LWJGL Forum

Please login or register.

Login with username, password and session length

Author Topic: Preventing weapon from going through walls?  (Read 167 times)

cellis

  • Newbie
  • *
  • Offline Offline
  • Posts: 2
Preventing weapon from going through walls?
« on: January 22, 2018, 03:00:54 »

Does anyone know how can i prevent my FPS weapon from going through walls? Is a there a layered rendering system that i can put in place?
Logged

orange451

  • Newbie
  • *
  • Offline Offline
  • Posts: 33
Re: Preventing weapon from going through walls?
« Reply #1 on: January 24, 2018, 04:33:32 »

Look into stencils :)
Logged

CoDi

  • Newbie
  • *
  • Offline Offline
  • Posts: 43
Re: Preventing weapon from going through walls?
« Reply #2 on: January 25, 2018, 01:40:34 »

a) Render the scene first, then clear the depth buffer, then render the weapon model. Clearing the depth buffer should be fairly cheap nowadays.

b) You may be able to divide the depth buffer range, at the cost of precision. For example, map the weapon model to use the first 10% of the depth buffer, and let the scene use the remaining 90%. Might need careful tweaking to minimize Z fighting.
Logged