In Unity I'm planning on using a geometry shader for processing points into quads and can't quite figure out why I'm not getting output from my geometry shader. I've edited it down to a minimum working example, as seen here:

Shader "foo/bar"
        Cull Off
        Lighting Off
        ZWrite Off

                #pragma vertex vert
                #pragma fragment frag
                #pragma geometry geom

                struct appdata {
                    float4 vertex : POSITION;
                struct v2g {
                    float4 vertex : POSITION;
                struct g2f {
                    float4 vertex : POSITION;

                v2g vert(appdata v) {
                    v2g o = (v2g)0;
                    o.vertex = v.vertex;
                    return o;

                void geom(point v2g p[1], inout TriangleStream<g2f> tristream)
                    g2f o = (g2f)0;
                    o.vertex = float4(0.1, 0.1, 0, 0);
                    o.vertex = float4(0.1, 0.9, 0, 0);
                    o.vertex = float4(0.9, 0.9, 0, 0);

                fixed4 frag(g2f i) : COLOR
                    return fixed4(1,1,1,1);

I'd expect that to draw a white triangle covering just under half the texture I'm rendering to. Instead it displays all black, just as it was before the shader.

So far I've:

  • Removed every possible source of culling I can think of
  • Made absolute sure my setup works when rendering a mesh in a similar fashion
  • Checked that this is getting input and running
  • and scoured the very limited amount of documentation available

I'm out of ideas. If anyone has even a minor clue as to what I'm doing wrong please let me know. Thanks.


  • \$\begingroup\$ Although it's inefficient a workaround I've found is to set the mesh's triangle[] to be something like {...5,0,0,6,0,0,7,0,0,8...} and to change void geom(point v2g p[1], ... to void geom(triangle v2g p[3], ... and to only ever use p[0]. \$\endgroup\$ – Fraser Jan 19 '19 at 7:01
  • \$\begingroup\$ if this solved your problem, you can post it as an Answer so it's easier to find. You can continue to invite additional answers with other alternatives if you're not satisfied with that solution. \$\endgroup\$ – DMGregory Jan 19 '19 at 14:59
  • \$\begingroup\$ I've posted it as a comment and not an answer because it's a highly inefficient workaround and doesn't actually get to the route of the problem, but if no one can find a real solution or explanation it'd still be useful to have available to others in this situation. \$\endgroup\$ – Fraser Jan 20 '19 at 1:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.