Global Game Jam 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.7 KiB

  1. Shader "ImageEffect/DarknessEffect"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _MaskTex ("Texture", 2D) = "white" {}
  7. _BackgroundColor("BackGround Color", Color) = (.25, .5, .5, 1)
  8. _MaskColor("Mask Color", Color) = (1, 1, 1, 1)
  9. _Apply("Darkness Effect Multiplier", Range(0.0, 1.0)) = 0.5
  10. _KeepColors("Show Mask Color", Int) = 1
  11. }
  12. SubShader
  13. {
  14. // No culling or depth
  15. Cull Off ZWrite Off ZTest Always
  16. Pass
  17. {
  18. CGPROGRAM
  19. #pragma vertex vert
  20. #pragma fragment frag
  21. #include "UnityCG.cginc"
  22. struct appdata
  23. {
  24. float4 vertex : POSITION;
  25. float2 uv : TEXCOORD0;
  26. };
  27. struct v2f
  28. {
  29. float2 uv : TEXCOORD0;
  30. float4 vertex : SV_POSITION;
  31. };
  32. v2f vert (appdata v)
  33. {
  34. v2f o;
  35. o.vertex = UnityObjectToClipPos(v.vertex);
  36. o.uv = v.uv;
  37. return o;
  38. }
  39. sampler2D _MainTex;
  40. sampler2D _MaskTex;
  41. float4 _BackgroundColor;
  42. float4 _MaskColor;
  43. float _Apply;
  44. float _KeepColors;
  45. fixed4 frag (v2f i) : SV_Target
  46. {
  47. fixed4 col = tex2D(_MainTex, i.uv);
  48. fixed4 mask = tex2D(_MaskTex, i.uv);
  49. // just invert the colors
  50. col.rgb = lerp(_MaskColor, col, clamp(_KeepColors,0,1));
  51. col.rgb = lerp(_BackgroundColor, col, clamp(mask.r + _Apply, 0, 1));
  52. return col;
  53. }
  54. ENDCG
  55. }
  56. }
  57. }