struct VSIn
{
float3 position : POSITION;
float3 speed : SPEED;
};
struct PSIn
{
float4 position : SV_POSITION;
};
////////////////////////////////////////
//ADVANCE RAIN
////////////////////////////////////////
VSIn PassThroughVS(VSIn vertex)
{
return vertex;
}
VSIn AdvanceRainVS(VSIn vertex)
{
vertex.position.y -= 0.1f;
if(vertex.position.y <= 0)
{
vertex.position.y = 20;
}
return vertex;
}
[maxvertexcount(1)]
void AdvanceRainGS(point VSIn input[1], inout PointStream<VSIn> OutputStream)
{
VSIn output = (VSIn)0;
output = input[0];
output.position += output.speed * 0.001f;
if(output.position.y < 0)
{
output.position.y = 20;
}
OutputStream.Append(output);
};
VertexShader vsShader = CompileShader(vs_5_0, AdvanceRainVS());
GeometryShader gsShader = CompileShader(gs_5_0, AdvanceRainGS());
GeometryShader gsStreamOut = ConstructGSWithSO( gsShader, "0:POSITION.xyz; 0:SPEED.xyz" );
technique11 AdvanceRain
{
pass p0
{
SetVertexShader(CompileShader(vs_5_0, PassThroughVS()));
SetGeometryShader(gsStreamOut);
SetPixelShader(NULL);
SetDepthStencilState(DisableDepth, 0);
}
}
Now if i try ConstructGSWithSO with AdvanceRainVS function rain particles doesn't move but i get no error and it draws rain particles. And if i try with AdvanceRainGS it works correctly. I couldn't find the reason for this problem.
My second question is when i try to debug my code with pix i get error about ConstructGSWithSO. I've added screenshot of the problem. I've searched for this problem and found there are also some other people having the same problem but they couldn't manage to solve it. I tried to debug nvidia rain demo to see if i get the same error but i didn't get any errors. So i think i did something wrong but since it works correctly i couldn't find what.
And my last question is about geometry shaders. For vertex shaders matrices need to be transposed before multiplication. But in the geometry shader they need to be sent without transpose. I don't understand reasoning behind this. So if anyone have knowledge about this i really appreciate. Here is the code where i use matrices in geometry shader.
[maxvertexcount(4)]
void RenderRainGS(point VSIn input[1], inout TriangleStream<PSIn> SpriteStream)
{
PSIn output = (PSIn)0;
float3 pos[4];
GenBillboardSpriteVertices(input[0].position, float3(0, -1, 0), cameraPosition, pos);
matrix viewProjection = mul(viewMatrix, projectionMatrix);
output.position = mul( float4(pos[0],1.0), viewProjection );
SpriteStream.Append(output);
output.position = mul( float4(pos[1],1.0), viewProjection );
SpriteStream.Append(output);
output.position = mul( float4(pos[2],1.0), viewProjection );
SpriteStream.Append(output);
output.position = mul( float4(pos[3],1.0), viewProjection );
SpriteStream.Append(output);
SpriteStream.RestartStrip();
}
Thanks.