Jump to content
  • Advertisement
Sign in to follow this  

Billboard WVP + rotation problem

This topic is 2093 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?


Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites

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!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!