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;
}
//[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!