I'm writing a simple geometry shader to create 3D "primitives" in place of a single point. I am performing all of the world-view-projection conversions within the geometry shader after creating the triangle strips to form the 3D primitive. Unfortunately, it seems to be creating the triangles in projection space, and giving me incorrect results. The following pictures demonstrate this problem. Any advice on how to work around this problem?
As can be seen here, the second top face seems to be rendered as if it was pulled off the top and splayed out.
Here is the geometry shader I am using, and a set of coordinates I use to generate these faces
static float3 cube_coords[8] =
{
float3(1, -1, 1),
float3(-1, -1, 1),
float3(1, 1, 1),
float3(-1, 1, 1),
float3(1, 1, 1),
float3(-1, 1, 1),
float3(1, 1, -1),
float3(-1, 1, -1),
};
[maxvertexcount(8)]
void GSMain(point GSInput input[1], inout TriangleStream< GSOutput > output)
{
GSOutput p;
for(unsigned int j = 0; j < 2; j++)
{
for(unsigned int i = 0; i < 4; i++)
{
p.Pos = input[0].Pos;
p.Pos += float4(cube_coords[i + (4*j)],1.0);
p.Pos = mul(p.Pos, worldViewProjection);
p.Color = input[0].Color;
p.Light = input[0].Light;
p.Norm = normals[j];
output.Append(p);
}
output.RestartStrip();
}
}