Advertisement
tonynogo

Demo 31 - Sepia with final color

Jul 6th, 2017
3,004
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/FinalColorSepia"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex ("Texture", 2D) = "white" {}
  6.         _SepiaIntensity ("SepiaIntensity", Range(0, 1)) = 0
  7.     }
  8.  
  9.     SubShader
  10.     {
  11.         Tags {"Queue"="Geometry" "RenderType"="Opaque"}
  12.  
  13.         CGPROGRAM
  14.         #pragma surface surf Lambert finalcolor:SepiaColor
  15.  
  16.         struct Input {
  17.             float2 uv_MainTex;
  18.         };
  19.  
  20.         fixed _SepiaIntensity;
  21.  
  22.         void SepiaColor(Input IN, SurfaceOutput s, inout fixed4 col) {
  23.             fixed3 c = col;
  24.             c.r = dot(col.rgb, half3(0.393, 0.769, 0.189));
  25.             c.g = dot(col.rgb, half3(0.349, 0.686, 0.168));
  26.             c.b = dot(col.rgb, half3(0.272, 0.534, 0.131));
  27.             col.rgb = lerp(col, c, _SepiaIntensity);
  28.         }
  29.        
  30.         sampler2D _MainTex;
  31.  
  32.         void surf(Input IN, inout SurfaceOutput o) {
  33.             o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
  34.             o.Alpha = 1.0;
  35.         }
  36.  
  37.         ENDCG
  38.     }
  39.  
  40.     FallBack "Diffuse"
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement