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
  • A fragment shader...

This is the shader file:

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;

//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!

  • \$\begingroup\$ Why did you use the compute-shader? I don't see anything in the question about it. \$\endgroup\$
    – Vaillancourt
    Commented Mar 31, 2017 at 10:04
  • \$\begingroup\$ 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. \$\endgroup\$
    – Christoph
    Commented Mar 31, 2017 at 10:20

1 Answer 1


It looks like the problem is that you're using a TriangleStream. You've marked it as maxvertexcount(1) which means that you can't actually draw anything, because a triangle with one vertex isn't a triangle. Try using a PointStream as your output type.

A GeometryShader with a TriangleStream can be used to output two triangles that are facing the screen in order to draw billboards for particles, but if you really want an identity geometry shader, the output type must be the same as the input type.

  • \$\begingroup\$ 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! \$\endgroup\$
    – Christoph
    Commented Apr 1, 2017 at 14:57
  • 1
    \$\begingroup\$ If you wanted to draw triangles with points as inputs, you'd use MeshTopology.Points, and then use a TriangleStream to output triangles that form the shape of the pyramids you want. As far as the number of output triangles. I've seen a few different answers, but 256 vertices seems to be the maximum output for each input primitive. \$\endgroup\$
    – jharger
    Commented Apr 4, 2017 at 15:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .