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("Light", Range(0.0, 1.0)) = 1.0
  10. _KeepColors("Show Mask Color", Range(0.0, 1.0)) = 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 lightCol = tex2D(_MainTex, i.uv);
  48. fixed4 mask = tex2D(_MaskTex, i.uv);
  49. float4 darkCol = mask * lerp(_MaskColor, lightCol, _KeepColors) + ((1 - mask) * _BackgroundColor);
  50. return lerp(darkCol, lightCol, _Apply);
  51. }
  52. ENDCG
  53. }
  54. }
  55. }