- Home /
Depth-only pass in Surface Shader
I have a shader that I used in Unity 2.x that utilizes transparency and has a depth-only pass that it renders first, so it won't render the faces behind the faces in front. I am now trying to upgrade this to a Unity3 surface shader but surface shaders don't seem to support render passes and as such I cannot make a depth-only pass.
How would I go about producing the same thing with a surface shader?
Answer by jonas-echterhoff · Mar 09, 2011 at 05:18 PM
In short, you can't. The idea with surface shaders is that you can have one shader which can be used for both forward and deferred rendering. However, the idea of transparency or multiple custom render passes do not quite translate to the deferred rendering model, so shaders like that should still be implemented using vertex and fragment programs, just like you used to do.
The problem there is unity tells me: "SubShader commented out; uses Unity 2.x per-pixel lighting. You should rewrite shader into a Surface Shader." Is there somewhere I can check up on how Unity wants me to implement said vertex/fragment shader, since it obviously doesn't like the old way?
Actually, I was not quite correct in my reply. Surface shaders do in fact support transparency (they will just always use forward rendering). But they still won't allow multiple passes. But you can still use normal vertex lighting in passes. Look at the "Alpha-VertexLit.shader" in our builtin shaders for an example.