Sign in to follow this  

Billboard WVP + rotation problem

This topic is 1507 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:

 

particle_WVP1.jpgparticle_WVP2.jpg

 

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:

 

http://www.youtube.com/watch?v=QXFxU8nsAuI

 

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

This topic is 1507 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this