Game Development Community

Shouldn't the first-person weapon be rendered last?

by 7nMs23fF · in Torque 3D Professional · 10/01/2010 (3:28 pm) · 5 replies

While playing around with the engine, I've noticed that the first-person weapon usually clips through solid geometry, but sometimes it pushes itself back to prevent this.

I'm not certain of the engine's internal workings, but couldn't this be solved easily if it just was rendered after everything else? This would effectively make it always show on top of everything, and it would never clip through solid geometry. I believe that this is what they do in the Source Engine as well.

I'm not sure if this qualifies itself as a bug or if it's even possible to fix so I just posted it here.

#1
10/01/2010 (4:02 pm)

... see Pat Wilson's post below ...
#2
10/01/2010 (4:03 pm)
Quote:Ben Garney
"Some games draw "view models" like guns in a separate pass to avoid this issue. Depth information isn't shared, so they can't clip against the scene, and they can have their own near/far planes. You might consider adding this to your rendering to achieve the effect you want."

This was in response to me messing around with nearClip.

edit: doh, Rene got there first.
#3
10/02/2010 (4:05 am)
yes it should be rendered last after clearing the depth buffer.
#4
10/02/2010 (4:48 am)
Disappointing.

When something obscures a significant portion of the screen, draw it *first* to prevent guaranteed overdraw. To achieve the functionality you are all describing, draw the weapon first during pre-pass, and flip a stencil bit. The rest of the scene tests against that bit. Nothing will draw in front of the weapon, and you will have prevented a few thousand pixels of overdraw which would have been incurred had it been rendered last, while retaining proper lighting information.
#5
10/02/2010 (6:53 am)
@Pat

there's two problems with that approach. first, it would be impossible to render a weapon which is transparent, or a weapon in which part of it is transparent because nothing could ever render behind it. secondly, it's not a good idea to require an arbitrary stencil test for every object in the scene. what if an object requires use of the stencil buffer for rendering? what if one is using stencil buffer shadows?

@Assassini

The torque way of handling this problem is to set the size of the player's bounding box big enough so that the weapon never gets close enough to the wall to penetrate it.