Transparent Single Color Shader

From Unify Community Wiki
Revision as of 09:14, 8 January 2013 by Markus Ewald (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This shader simply fills polygons rendered with it in solid color. It also honors that alpha value of the color, allows for meshes to be faded in and out via transparency.

This shader was written for and tested with Unity 4.0.

Shader Source

Shader "Custom/TransparentSingleColorShader" {
  Properties {
    _Color ("Color", Color) = (1.0, 1.0, 1.0, 1.0)
  }
  SubShader {
    Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
    Blend SrcAlpha OneMinusSrcAlpha
    Cull Off
    LOD 200
 
    CGPROGRAM
    #pragma surface surf Lambert
 
    fixed4 _Color;
 
    // Note: pointless texture coordinate. I couldn't get Unity (or Cg)
    //       to accept an empty Input structure or omit the inputs.
    struct Input {
      float2 uv_MainTex;
    };
 
    void surf (Input IN, inout SurfaceOutput o) {
      o.Albedo = _Color.rgb;
      o.Emission = _Color.rgb; // * _Color.a;
      o.Alpha = _Color.a;
    }
    ENDCG
  } 
  FallBack "Diffuse"
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox