AlphaVertexLitZ

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Removing all content from page)
m (Reverted edits by Joseph05408 (Talk); changed back to last version by Ethan)
Line 1: Line 1:
 +
[[Category: Unity 2.x shaders]]
  
 +
Author: [[User:NeARAZ|Aras Pranckevicius]].
 +
 +
==Description==
 +
 +
[[Image:AlphaVertexLitZ.jpg|thumb]]
 +
 +
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 ==
 +
 +
<shaderlab>
 +
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
 +
        }
 +
    }
 +
}
 +
}
 +
</shaderlab>

Revision as of 19:29, 19 October 2009


Author: Aras Pranckevicius.

Description

AlphaVertexLitZ.jpg

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

<shaderlab> 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
       } 
   }

} } </shaderlab>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox