# Unity: Simple “pass through” geometry shader

I would like to implement a geometry shader that does nothing, just for the purpose of learning and to go ahead with that and do something useful with it.

I currently have:

• A compute shader creating "particles".
• A vertex shader doing the transformation

StructuredBuffer<float3> particles;

struct fsInput {
float4 pos : SV_POSITION;
};

fsInput vert(uint id : SV_VertexID)
{
fsInput fsIn;
float3 worldPos = particles[id];
fsIn.pos = mul(UNITY_MATRIX_VP, float4(worldPos, 1.0f));
return fsIn;
}

//[maxvertexcount(1)]
//void geom(point fsInput p[1], inout TriangleStream<fsInput> output)
//{
//  fsInput fsOut = (fsInput) 0;
//  fsOut.pos = p[0].pos;
//  output.Append(fsOut);
//}

float4 frag(fsInput fsIn) : COLOR
{
return float4(1.0, 0.2, 0.2, 1);
}


I'm drawing my particles with this call:

Graphics.DrawProcedural(MeshTopology.Points, NUM_PARTICLES);


In my understanding, which is quite limited due to the perfect documentation of geometry shaders, my geometry shader should do nothing. Just forward the points to the fragment shader. However, if I use that shader (comment in those lines), I wont see my particles anymore. Without the geometry shader, I can see every particle.

So the first question is, where is the error? The second question is: Can I, starting with points and using the geometry shader, go from points to a, for example, cube? Or should I do it in the compute shaders? But if so, which MeshTopology should I use to draw the data from the compute shader as Cube, Sphere, etc...?

Thank you for help!

• Why did you use the compute-shader? I don't see anything in the question about it. Commented Mar 31, 2017 at 10:04
• Hi, I'm sorry for that. I've marked my SO post as deleted. I've used it because I wanted to learn about it, so I've written a dummy compute shader that creates "particles" according the threads id. And, as I said, if the geometry shader is "out", I see them. Now i want to dive into the geometry shader and make, for example, quads out of the points given from the compute shader. And obviously something is wrong with my geometry shader, because otherwise, i would see something I guess. Commented Mar 31, 2017 at 10:20

• Thats it! Thanks a lot. One subsequent question please: If i now want to draw, e.g. pyramids, around my point: Is this possible? And if yes, do i call the draw with MeshTopology.Points or MeshTopology.Triangles? Is there a maximum of triangles i can generate out of one point? I've accepted your answer, but if you know the answer to this second question, any hints would be very nice. Tanks! Commented Apr 1, 2017 at 14:57