• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

# Billboard WVP + rotation problem

2 replies to this topic

### #1me_12  Members   -  Reputation: 174

Like
0Likes
Like

Posted 26 October 2013 - 12:10 PM

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?

### #2me_12  Members   -  Reputation: 174

Like
0Likes
Like

Posted 27 October 2013 - 05:12 AM

To visualize this I made a simple test scene and a video:

This was done with the settings mentioned above. As you can see there are actually two problems:

1. The depth buffer problem

2. The billboards aren't rotated accordingly. The arrow should point to the right when I rotate the placement.

### #3me_12  Members   -  Reputation: 174

Like
0Likes
Like

Posted 27 October 2013 - 09:55 AM

A friend of mine found the solution.

Apparently I corrupted the w value of the vector.

And the second problem is actually no problem.

Anyways thank you!

PARTNERS