SepiaToneEffect.shader 738 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. Shader "Hidden/Sepiatone Effect" {
  2. Properties {
  3. _MainTex ("Base (RGB)", 2D) = "white" {}
  4. }
  5. SubShader {
  6. Pass {
  7. ZTest Always Cull Off ZWrite Off
  8. Fog { Mode off }
  9. CGPROGRAM
  10. #pragma vertex vert_img
  11. #pragma fragment frag
  12. #pragma fragmentoption ARB_precision_hint_fastest
  13. #include "UnityCG.cginc"
  14. uniform sampler2D _MainTex;
  15. fixed4 frag (v2f_img i) : COLOR
  16. {
  17. fixed4 original = tex2D(_MainTex, i.uv);
  18. // get intensity value (Y part of YIQ color space)
  19. fixed Y = dot (fixed3(0.299, 0.587, 0.114), original.rgb);
  20. // Convert to Sepia Tone by adding constant
  21. fixed4 sepiaConvert = float4 (0.191, -0.054, -0.221, 0.0);
  22. fixed4 output = sepiaConvert + Y;
  23. output.a = original.a;
  24. return output;
  25. }
  26. ENDCG
  27. }
  28. }
  29. Fallback off
  30. }