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"
{
SubShader{
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