How to render some material over every thing else

Hi Guys
I’m working on an FPS Project now i have to make the weapons and the hands render over other things
I don’t want to use the 2 camera thing because it resists the shadow of the world objects to cast on the weapon + hands

Any Idea ??
Please help , thanks! :smiley:

There is a very easy way to get the exact effect desired, and that is to add a single line of code to the default Standard Shader in unity. You can download the latest built-in shaders from here: Download Archive

Grab the standard one, bring it over to your project, and around line 60 you should see

Blend [_SrcBlend] [_DstBlend] ZWrite [_ZWrite]

Directly underneath that, just add “Ztest Always”, and whatever object you use the material on will be rendered on top of everything else in the scene, with all the shadows and everything still on it.

The best new way to do this is to use the method suggested by 3agle in this forum post:

http://forum.unity3d.com/threads/weapon-clipping-methods.203824/

Scroll down a bit to find it. In short, there is a new option in Unity 5 to render shadows only, which means you can still use the two camera approach, and have the camera that renders the hands and weapon render the rest of the world with shadows only (to cast shadows onto the hands and weapon), and have the first camera (for the world) render the hands and weapon with shadows only, so they, too, cast shadows onto the world.

The other, older way to do it would be to edit the shader for your hands and weapon and directly modify the renderQueue number for them to ensure they always get rendered after everything else, i.e. putting “Queue” = “Overlay” in its Tags list, for example. See subshader tags in the docs:

If you’re not comfortable messing with shaders, the same number should be available on the material to be set from CPU-side code:

There is one final alternative to doing this: Eliminating the behaviour that causes geometry clipping in the first place. This means using colliders to actually physically bump the weapon out of the player’s hands, making him drop it, or raising the weapon so it’s vertical near walls. I can think of at least one FPS (Crysis) that did the latter option. :wink: