I need a shader that will let me fade out objects from view to display objects behind them (with the same shader to allow multiple levels of alpha transitions) yet still respect the zbuffer. So I want to see the objects behind the transparent one, but have proper z-sorting. This has gotten me close, but causes weird clipping of full-alpha, but z-behind objects. Code (csharp): Shader "Transparent/VertexLit with Z" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} } SubShader { Tags {"RenderType"="Transparent" "Queue"="Transparent"} Pass { Cull Front Cull Back ColorMask 0 } // Render into depth buffer only Pass { ColorMask 0 AlphaTest Greater [_Cutoff] SetTexture [_MainTex] { combine texture * primary, texture } } // Render normally Pass { ZWrite Off Blend SrcAlpha OneMinusSrcAlpha ColorMask RGB Material { Diffuse [_Color] Ambient [_Color] } Lighting On SetTexture [_MainTex] { Combine texture * primary DOUBLE, texture * primary } } } } Here's an image of what I get: 1 points at an object with this shader at ~15% alpha 2 is an object with a standard diffuse shader 3 is an object with the above shader, but full 100% alpha. Note how the sides have been clipped by one of the objects in collection 1 (there would be more objects in this group, but due to the current scripting I have to turn on the renderer manually to see them, I'm trying to transition from a click -> visible/invisible to a click -> animated alpha tween shift).
I guess the important point is that you understand how difficult your problem is. Then we can talk further.
What shader do you use for group 1? Do you need the alpha component of the framebuffer for anything of may the shaders use it for temporary data?
The problem is, all that opaque geometry will at some point in its own lifetime also be transparent, thus I can only use one shader. Think Google Body and how you can turn layers on and off through a slider bar. Except I'm not building Google Body (I'm not, really, I swear, WHY DOES IT LOOK LIKE GOOGLE BODY!? D: Thank god I'm not responsible for the design or content. Or dropping $1000 on an anatomically correct 3D model, complete with individually modeled muscles and organs.) Hm. Might be able to swap shaders at runtime...will be kind of a bitch, but I think it might work.
It's the VertexLitWithZ that's over on the unitywiki, although slightly edited to get a slightly better result (I posted it in the first post). Que? I'm afraid I don't understand the question. I was never too good with materials and textures and 3D in general (I couldn't model a paper bag to save my life).
OK. I think you should consider using different shaders for different parts. In Unity, the framebuffer has color components (red, green, blue) and a depth for each pixel. Additionally, it has an alpha component. If you don't know about it, you are probably not using it. I thought I had an idea, but it probably is not as easy as I thought. I have to think more about it.
I'm going to see tomorrow about setting a diffuse shader when alpha = 1. I understand that, but I don't get how the shader...script finds/tracks/uses those values. And none of that made any sense to me at all. XD
Not the script and the shader can use them only by making "clever" use of the blending factors: "destination alpha" = "DstAlpha" refers to the alpha component of the framebuffer (see http://unity3d.com/support/documentation/Components/SL-Blend.html ). Neither to me.