Jump to content

MESH_POINTS with Geometry Shader


Go to solution Solved by Josh,

Recommended Posts

Posted

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

  • Solution
Posted

Question: Do you have a matching depth pass shader you are using for the depth pre-pass? You can disable camera depth pre-pass to test this.

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

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":
						{
						}
					}
				}		
			}
		}
	}
}

 

Posted

I have found it. ^_^

"OPAQUE":
{
	"default":
	{
		"base":
		{
			"geometry": "Materials/Point.geom.spv",
			"fragment": "Materials/Point.frag.spv"
		},
		"depthPass":
		{
			"geometry": "Materials/Point.geom.spv"
		}
	}
}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...