Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Third person cross-hair


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 domok   Members   -  Reputation: 184

Like
0Likes
Like

Posted 06 August 2011 - 03:37 AM

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?

Sponsor:

#2 Dawoodoz   Members   -  Reputation: 280

Like
0Likes
Like

Posted 06 August 2011 - 11:28 AM

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.

My open source DirectX 10/11 graphics engine. https://sites.google.com/site/dawoodoz

"My design pattern is the simplest to understand. Everyone else is just too stupid to understand it."


#3 Mussi   Crossbones+   -  Reputation: 967

Like
0Likes
Like

Posted 06 August 2011 - 11:52 AM

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.

#4 domok   Members   -  Reputation: 184

Like
0Likes
Like

Posted 06 August 2011 - 02:22 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS