Jump to content
  • Advertisement
Sign in to follow this  
domok

Third person cross-hair

This topic is 2540 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
Advertisement
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

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).

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
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!