Sign in to follow this  

Third person cross-hair

This topic is 2318 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

Hello

I'm working on a third person (kind of) shooter and until now I've made the targeting with the cross-hair with a ray test. This works well for the map, but not so well for the enemies because for the map I do a correct triangle test, but for the enemies only a ray ellipsoid test (a triangle test would be far too slow).

Now I thought it would be much simpler and faster to just get the z-buffer data. Is there a problem with that? I only need the z-buffer data of one pixel (the one in the centre where the cross-hair is).

How can this be done best with DirectX9? Making the z-Buffer lockable is probably not the best idea as I also need the stencil buffer..? Could I maybe do it with a pixel shader? Or is it just no good idea?

Share this post


Link to post
Share on other sites
Reading data back from the GPU require locking the texture and that is seriously slow even with DirectX 11. When I read one pixel every render, PIX show that 50% of the time is used for waiting.

Share this post


Link to post
Share on other sites
[quote name='domok' timestamp='1312623444' post='4845368']
I'm working on a third person (kind of) shooter and until now I've made the targeting with the cross-hair with a ray test. This works well for the map, but not so well for the enemies because for the map I do a correct triangle test, but for the enemies only a ray ellipsoid test (a triangle test would be far too slow).[/quote]
What makes you say that? I think it could be the fastest solution. You could also use multiple primitives to represent an enemy and test against those.

Share this post


Link to post
Share on other sites
Ok so I will stay with the ray test.

But now I found another problem: When I cast a ray from the near clipping plane to the far clipping plane it can also occur that the intersection occurs behind the player so the bullet goes backwards. How can I solve this? Can I somehow find out the depth (z) value of where the player is so I don't cast from z=0 to z=1 but from like z = 0.5 to z=1..??

Thanks for the answers

Share this post


Link to post
Share on other sites

This topic is 2318 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