I have particles which are processed to a billboard in the geometry shader.
These particles emit from a source point. This source point is attached to a placement. One can position, rotate and scale this placement.
What I would like to have is, that if I rotate the placement (which rotates the emitter) the emission direction is also rotated. So i.e. if my particles follow the y-axsis and I rotate it by 90° it would then follow the x-axis. Sounds more complicated than it is. Check these images to imagine it:
Basicly I am getting the WVP matrix from that placement(emitter). So all I need to do is project my particle with that matrix.
Here is what I tried:
float3 g_positions[4] =
{
float3( fHalfBillboardSizeX, fHalfBillboardSizeY, 0 ),
float3( -fHalfBillboardSizeX, fHalfBillboardSizeY, 0 ),
float3( fHalfBillboardSizeX, -fHalfBillboardSizeY, 0 ),
float3( -fHalfBillboardSizeX, -fHalfBillboardSizeY, 0 ),
};
// for all 4 billboard edge points (g_positions[4] ) do:
float3 position = g_positions[i];
float3 vInputPos = input[0].position; // that is the center point of the billboard. the actual particle position.
output.position = float4(vInputPos, 1.0);
output.position = mul(output.position, World);
output.position = mul(float4(position, 1.0f), (float4x4)ViewInv ) + output.position;
output.position = mul(output.position, View);
output.position = mul(output.position, Projection);
This does nearly work. It's just that my depth buffer seems to be broken with this. I see my particles through other objects for example. Any ideas why that is and how I could fix it?