# Hard coded triangle in HLSL geometry shader doesn't show on screen

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

Pass{
CGPROGRAM
#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;
}

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

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


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 i getting input and running
• and scoured the very limited amount of documentation available

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

-Fraser

• 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]. – Fraser Jan 19 at 7:01
• 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. – DMGregory Jan 19 at 14:59
• 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. – Fraser Jan 20 at 1:08