Jump to content

SpiderPig

Members
  • Posts

    2,346
  • Joined

  • Last visited

Posts posted by SpiderPig

  1. Thought I'd show off my node editor for Ultra Engine Shaders.  Currently I'm developing it as I develop my game, so features get added as I need them.  But I'd love to hear your feedback and if you'd like me to add something I'm sure I can oblige. :)

    Discord for ShaderMaster

    ShaderMaster_v1.3.zip

    Before use, you need to set the path to UltraEngine like this so it can find the tools and shaders.  You will also need to copy 'FragmentCustom.glsl' to 'UltraEngine\Templates\Common\Source\Shaders\PBR' in order to use the fragment shader nodes.

    Preferences.thumb.png.e08bba9906a0d6df9e7fa866dd1d0d7d.png

    Then to create a new project go to File->New Project and enter in a name.  PBR is the only available at the moment and you can choose PostEffect from the right drop down - but this has not been tested in some time!  Feel free to explore it though.

    NewProject.png.96af94df3b2ce90a0dbd3df73404a3cf.png

    Add a file to the project by clicking the file icon with the '+'.  Below are the files associated with one of my projects.  Macros are also visible when the checkbox is checked.  Macros are functions that can be used between projects.  Create a function, right click the function file and choose 'Convert to Macro'.  The function will be removed the current project and added to the macro folder.

    AddButton.png.0f6ea291557ca9466a6ef03625fede52.png

     

    Choose a file type, this is either a shader stage or a function or definition.  I've used the fragment shader extensively.  I have used the vertex and geometry shaders though there may be bugs here.  Please let me know.  Tessellation and Compute stages aren't working yet.

    NewShader.png.13710f6c4515f5653a9a6ff5fdb8f321.png

     

    Select a file from the list on the right to open it and right click in the node area to get a menu of all the available nodes.

    I'll make in depth tutorials on this later if any one is interested as there's a lot more to cover.  Right now it's there to play with. :)

    An example of the fragment shader for my voxel terrain.

    Example.thumb.png.3f3ff2b460b2d18e09be738d9e76b02f.png

    • Like 6
  2. I wanted to try and compile some shaders in a location away from the validator and the .glsl files.  It compiles fine so long as I don't try to include anything in the shader.

    The BAT file;

    C:\UltraEngine\Tools\glslangValidator.exe "C:\_output\Test.frag" -V -o "C:\_output\Test.frag.spv"

    The Shader;

    #version 450
    #extension GL_GOOGLE_include_directive : enable
    #extension GL_ARB_separate_shader_objects : enable
    #extension GL_EXT_multiview : enable
    
    //Compiles if this line is commented out
    #include "C:\UltraEngine\Templates\Common\Shaders\Base\Materials.glsl"
    
    layout(location = 0) out vec4 outColor;
    
    void main()
    {
    	outColor = vec4(0.0f, 1.0f, 1.0f, 1.0f);
    }

    Does the validator only use relative paths somhow?

  3. Ah yes that is the problem.  Where does that go in the shader family JSON?

    {
    	"shaderFamily":
    	{
    		"root": "Shaders/PBR.json",
    		"static":
    		{
    			"float":
    			{
    				"OPAQUE":
    				{
    					"default":
    					{
    						"base":
    						{
    							"geometry": "Materials/Point.geom.spv",
    							"fragment": "Materials/Point.frag.spv"
    						}
    					}
    				},
    				"MASK":
    				{
    					"default":
    					{
    						"base":
    						{
    						}
    					}
    				}
    			},
    			"double":
    			{
    				"OPAQUE":
    				{
    					"default":
    					{
    						"base":
    						{
    						}
    					}
    				},
    				"MASK":
    				{
    					"default":
    					{
    						"base":
    						{
    						}
    					}
    				}		
    			}
    		}
    	}
    }

     

  4. I've had no luck with this.  When I add a geometry stage to the material family, it's fragment shader no longer works.  The points seem to be showing the background color.   I've got a simplified example here, it should move the verts a bit and they should be green.

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1440, 900, displays[0]);
        auto framebuffer = CreateFramebuffer(window);
        auto world = CreateWorld();
    
        auto camera = CreateCamera(world);
        camera->Move(0, 2, 0);
        camera->SetClearColor(1, 0, 0);
    
        auto light = CreateDirectionalLight(world);
        light->SetColor(5.0f);
        light->SetRotation(35, 35, 35);
    
        auto floor = CreateBox(world, 100.0f, 0.5f, 100.0f);
    
    
        auto model = CreateModel(world);
        auto mesh = model->AddMesh(MESH_POINTS);
    
        for (int z = 0; z < 100; z++) {
            for (int x = 0; x < 100; x++) {
                mesh->AddVertex((float)x / 10.0f - 5.0f, 1.0f, (float)z / 10.0f);
            }
        }
    
        model->UpdateBounds();
        model->SetMaterial(LoadMaterial("Materials\\Point.mat"));
    
    
        while (window->KeyHit(KEY_ESCAPE) == false && window->Closed() == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

    Materials.zip

  5. I noticed this a while ago just briefly.  Text area works but text field is not visible.  The project is up to date.

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1440, 900, displays[0]);
        auto framebuffer = CreateFramebuffer(window);
        auto world = CreateWorld();
    
        auto camera = CreateCamera(world);
        camera->Move(0, 2, -3);
        camera->SetClearColor(1, 0, 0);
    
        auto light = CreateDirectionalLight(world);
        light->SetRotation(35, 35, 35);
    
        auto floor = CreateBox(world, 100.0f, 0.5f, 100.0f);
    
        auto default_font = LoadFont("Fonts\\arial.ttf");
        auto ui = CreateInterface(world, default_font, framebuffer->size);
        ui->SetRenderLayers(2);
        ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f);
    
        auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0);
        ui_camera->SetRenderLayers(2);
        ui_camera->SetClearMode(CLEAR_DEPTH);
    
        //auto text = CreateTextArea(0, 0, 512, 30, ui->root);
        auto text = CreateTextField(0, 0, 512, 30, ui->root);
        text->SetText("Hello Ultra");
    
        while (window->KeyHit(KEY_ESCAPE) == false && window->Closed() == false)
        {
            while (PeekEvent()) {
                ui->ProcessEvent(WaitEvent());
            }
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  6. I saw here I might need to do a better job at averaging the normals of shared vertices.  It says to use the angle to determine the weight that each face's normal will effect the vertex.  I tried with the dot product and seemed to get slightly better results but I'm unsure on exactly what the value of "Angle" in this answers code should be.  Degrees maybe?  or just 0 to 1? <_<

    Is there a "proper" method of average normals for shared vertices?  Usually I just add all the faces normals up that share the vertex and divided by total number of faces that share it.  Might be half my problem.

  7. I agree, its a bit messy.  I could merge vertices in a 2nd pass but I think it'll be a bit slow - or maybe it could be done in one pass as I create the vertices... <_< but Surface Nets should make better geometry because the vertices should be relative evenly spaced, and there will be less triangles too.  I'm working on it now so should have some results soon.

  8. Love the Model::Save() method.  ;)

    In blender I confirmed there is no double up on verts, all triangles are sharing what they should be.  These are the exported normals.  Using blender to recalculate smooth shading gave no visual difference.  I thought they should look better than this?  Maybe this is another pitfall of marching cubes.  Too many small thin triangles!

    BlenderComponent.thumb.png.b4f6a8408f4e1ff9a866c95795632a75.png

    BlenderComponentWireframe.thumb.png.c6bd426831ad12ebab2d407ee4046a88.png

  9. I've decided I will write a method that saves a voxel terrains component as a mesh so I can do some more testing on it in a separate program.  I'll upload some results and hopefully find what I'm doing wrong.

  10. Getting some mixed results with this.  There are no double vertices in the mesh any more (99.9% sure <_<) and this is with model->UpdateNormals().

    This is the result.

    SmoothNormals.thumb.png.2afd1c218107774644b78d1942e9f0e1.png

    I've outlined the wireframe with red.

    SmoothNormals_2.thumb.png.cb9f94114d0fe34b1ef4bae4ce2c12c3.png

    It seems that if the triangles are really small it gives sharp results.

    • Like 1
    • Confused 1
  11. I wonder if it's too much to ask for a temporary solution for this?  Just the ability to get the index the material is stored in the shader is enough, I can do the rest and send it to my shader.  I'd like to get a nice material up and running for the voxel terrain.  I'm just guessing at what the material index is in the shader.  It changes though as the game grows though. :)

×
×
  • Create New...