UnlitAlpha

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
 
m (Made the tabs less humungulous.)
Line 11: Line 11:
 
<shaderlab>Shader "UnlitAlpha"
 
<shaderlab>Shader "UnlitAlpha"
 
{
 
{
Properties
+
    Properties
{
+
    {
_Color ("Main Color", Color) = (1,1,1,1)
+
        _Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans. (Alpha)", 2D) = "white" { }
+
        _MainTex ("Base (RGB) Trans. (Alpha)", 2D) = "white" { }
}
+
    }
  
Category
+
    Category
{
+
    {
ZWrite On
+
        ZWrite On
Alphatest Greater 0.5
+
        Alphatest Greater 0.5
Cull Off
+
        Cull Off
SubShader
+
        SubShader
{
+
        {
Pass
+
            Pass
{
+
            {
Lighting Off
+
                Lighting Off
SetTexture [_MainTex]
+
                SetTexture [_MainTex]
{
+
                {
constantColor [_Color]
+
                    constantColor [_Color]
Combine texture * constant, texture * constant  
+
                    Combine texture * constant, texture * constant  
}  
+
                }  
}
+
            }
}  
+
        }  
}
+
    }
 
}</shaderlab>
 
}</shaderlab>

Revision as of 20:41, 29 December 2005

Author: Neil Carter (NCarter)

Description

This shader is useful for sprites and other billboards that shouldn't be affected by lighting and should be visible from both sides. Note that alpha testing is used instead of blending, which means partial transparency is not possible - texels are either completely opaque or completely transparent. On the other hand, it's much faster than blending.

Usage

Place this shader somewhere in your Assets folder hierarchy, create a material which uses it and apply it to the relevant objects.

ShaderLab - UnlitAlpha.shader

<shaderlab>Shader "UnlitAlpha" {

   Properties
   {
       _Color ("Main Color", Color) = (1,1,1,1)
       _MainTex ("Base (RGB) Trans. (Alpha)", 2D) = "white" { }
   }
   Category
   {
       ZWrite On
       Alphatest Greater 0.5
       Cull Off
       SubShader
       {
           Pass
           {
               Lighting Off
               SetTexture [_MainTex]
               {
                   constantColor [_Color]
                   Combine texture * constant, texture * constant 
               } 
           }
       } 
   }

}</shaderlab>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox