Advertisement
Guest User

ChromaKey Shader for Unity

a guest
Nov 22nd, 2013
7,707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. Shader "Custom/ChromaKey" {
  2.     Properties {
  3.         _MainTex ("Base (RGB)", 2D) = "white" {}
  4.     }
  5.     SubShader {
  6.         Tags { "Queue"="Transparent" "RenderType"="Transparent" }
  7.         LOD 200
  8.        
  9.         CGPROGRAM
  10.         #pragma surface surf Lambert alpha
  11.  
  12.         sampler2D _MainTex;
  13.  
  14.         struct Input {
  15.             float2 uv_MainTex;
  16.         };
  17.  
  18.         void surf (Input IN, inout SurfaceOutput o) {
  19.             half4 c = tex2D (_MainTex, IN.uv_MainTex);
  20.             o.Albedo = c.rgb;
  21.            
  22.             // #################################
  23.             //
  24.             // CHANGE THESE VALUES DEPENDING ON WHAT SHOULD BE TRANSPARENT
  25.             //
  26.             // #################################
  27.             if (c.g > 200.0/255.0 && c.r < 200.0/255.0 && c.b < 200.0/255.0)
  28.             {
  29.                 o.Alpha = 0.0; 
  30.             }
  31.             else
  32.             {
  33.                 o.Alpha = c.a;
  34.             }              
  35.         }
  36.         ENDCG
  37.     }
  38.     FallBack "Diffuse"
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement