AlphaVertexLitZ
From Unify Community Wiki
(Difference between revisions)
m (Text replace - "</shaderlab>" to "</syntaxhighlight>") |
Matt maker (Talk | contribs) m (removing broken syntax highlight tag) |
||
Line 13: | Line 13: | ||
== Shader == | == Shader == | ||
− | < | + | <source lang="text"> |
Shader "Transparent/VertexLit with Z" { | Shader "Transparent/VertexLit with Z" { | ||
Properties { | Properties { | ||
Line 42: | Line 42: | ||
} | } | ||
} | } | ||
− | </ | + | </source> |
Revision as of 19:19, 2 November 2012
Author: Aras Pranckevicius.
Description
Built-in Transparent shaders do not write to depth buffer, hence an object is x-ray like transparent - you can see object's parts which are behind other parts. If you want to fade the object as a whole, this shader can help. See the image on the right.
The shader should work about everywhere (probably even on iPhone). It does render object in two passes though, so it's twice as expensive as regular VertexLit.
Shader
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"} // Render into depth buffer only Pass { ColorMask 0 } // 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 } } } }