Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 18th, 2012  |  syntax: None  |  size: 1.10 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Shader "Custom/MobileMatte(Diffuse)" {
  2.         Properties {
  3.                 _MainTex ("Base (RGB)", 2D) = "white" {}
  4.                 _Color ("Color (RGB)", Color) = (1,1,1,1)
  5.         }
  6.         SubShader {
  7.                 Tags { "RenderType"="Opaque" }
  8.                 LOD 200
  9.                
  10.         pass {
  11.                 CGPROGRAM
  12.                 #include "UnityCG.cginc"       
  13.                 #pragma vertex vert
  14.                 #pragma fragment frag
  15.                 #pragma fragmentoption ARB_precision_hint_fastest
  16.                 #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  17.                
  18.                
  19.                 sampler2D _MainTex;    
  20.                 half4 _MainTex_ST;
  21.                 fixed3 _Color;
  22.                 half4 unity_LightmapST;
  23.                 sampler2D unity_Lightmap;
  24.                
  25.                 struct v2f
  26.                 {
  27.                         half4 pos : SV_POSITION;
  28.                         half2 uv : TEXCOORD0;
  29.                         half2 uvLM : TEXCOORD1;
  30.                 };
  31.                
  32.                 v2f vert (appdata_full v)
  33.                 {
  34.                         v2f o;
  35.                         o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
  36.                         o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
  37.                         o.uvLM = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
  38.                         return o;
  39.                 }      
  40.                
  41.                 fixed4 frag (v2f i) : COLOR0
  42.                 {
  43.                         fixed4 tex = tex2D (_MainTex, i.uv);
  44.                        
  45.                         tex.rgb *= _Color;
  46.                         #ifdef LIGHTMAP_ON
  47.                         fixed3 lm = DecodeLightmap (tex2D (unity_Lightmap, i.uvLM));
  48.                         tex.rgb *= lm;                 
  49.                         #endif
  50.                        
  51.                         return tex;            
  52.                 }                              
  53.        
  54.                 ENDCG
  55.         }
  56. }
  57. }