TexeL

Untitled

Feb 5th, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/DepthHighlighter"
  2. {
  3.         Properties {
  4.                 _MainTex ("Base (RGB)", 2D) = "white" {}
  5.                 _trgDepth ("target depth", float) = 1
  6.                 _replacingColor ("replacting color", Color) = (0,1,0,0)
  7.         }
  8.         SubShader {
  9.                 Tags { "RenderType"="Opaque" }
  10.                 LOD 200
  11.                
  12.                 CGPROGRAM
  13.                 #pragma exclude_renderers gles
  14.                 #pragma surface surf Lambert
  15.  
  16.                 sampler2D _MainTex;
  17.                 sampler2D _CameraDepthTexture;
  18.                 float _trgDepth;
  19.                 float4 _replacingColor;
  20.  
  21.                 struct Input
  22.                 {
  23.                         float2 uv_MainTex;
  24.                         float4 screenPos;
  25.                 };
  26.                
  27.                 void surf (Input IN, inout SurfaceOutput o)
  28.                 {
  29.                         half4 c = tex2D (_MainTex, IN.uv_MainTex);
  30.                         float aa = tex2D (_CameraDepthTexture, IN.uv_MainTex).g;
  31.                        
  32.                         if(aa > _trgDepth)
  33.                         {
  34.                             o.Albedo = c.rgb;
  35.                         }
  36.                         else
  37.                         {
  38.                             o.Albedo = _replacingColor.rgb;
  39.                         }
  40.                        
  41.                        
  42.                         //o.Alpha = c.a;
  43.                 }
  44.                 ENDCG
  45.         }
  46.         FallBack "Diffuse"
  47. }
Advertisement
Add Comment
Please, Sign In to add comment