Sign in to follow this  
littlekid

FPS Weapon Clipping

Recommended Posts

After searching about the forums on position the weapon for a FPS game, I have manager to sucessfully do it. However how do I prevent the weapon from getting clipped by the near plane? my near-z is at 0.1f, should I go about reducing the near-z value?

Share this post


Link to post
Share on other sites
When you say to treat it as a HUD element, did you mean to draw it in orthographic projection too? I am already rendering my gun last with a clear to the z-buffer and stencil buffer, but the gun still gets clip by the near plane.

Example, when I draw the gun, the stock of the gun disappear due to the clipping plane.

Here is my current steps in rendering the scene

1. Setup 3D perspective view projection from camera class.
2. Draw world scene to g-buffer
3. For each light
if needs shadow mapping
- Draw world scene to 128x128 shadow map
- Apply Gaussian Blur to shadow map
- Draw light volume to do lighting calculations and shadow mapping
else
- Draw light volume to do lighting calculations
4. Draw Transparent Objects/ Particles etc.
5. Clear z-buffer and stencil buffer
6. Draw Weapon
7. Draw HUD


Is something amiss? because my weapon still gets clipped. I will try and have a screenshot up.

Share this post


Link to post
Share on other sites
Quote:
Original post by littlekid
However how do I prevent the weapon from getting clipped by the near plane? my near-z is at 0.1f, should I go about reducing the near-z value?

Sure, why not? Render the scene with one far/near value, clear the depth buffer, change the projection to have the same FOV but different near/far, and render the gun. Much easier than mucking with depth tests and stencils and whatnot. (don't forget to clear the depth buffer before rendering the gun.)

Share this post


Link to post
Share on other sites

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