UnlitDarkenable.shader 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Shader "Unlit/UnlitDarkenable"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _Color ("Color", Color) = (0.5, 0.5, 0.5, 1)
  7. _Brightness ("Brightness Multiplier", Range(0,1)) = 1
  8. }
  9. SubShader
  10. {
  11. Tags { "RenderType"="Opaque" }
  12. LOD 100
  13. Pass
  14. {
  15. CGPROGRAM
  16. #pragma vertex vert
  17. #pragma fragment frag
  18. // make fog work
  19. #pragma multi_compile_fog
  20. #include "UnityCG.cginc"
  21. struct appdata
  22. {
  23. float4 vertex : POSITION;
  24. float2 uv : TEXCOORD0;
  25. };
  26. struct v2f
  27. {
  28. float2 uv : TEXCOORD0;
  29. UNITY_FOG_COORDS(1)
  30. float4 vertex : SV_POSITION;
  31. };
  32. sampler2D _MainTex;
  33. float4 _MainTex_ST;
  34. float4 _Color;
  35. float _Brightness;
  36. v2f vert (appdata v)
  37. {
  38. v2f o;
  39. o.vertex = UnityObjectToClipPos(v.vertex);
  40. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  41. UNITY_TRANSFER_FOG(o,o.vertex);
  42. return o;
  43. }
  44. fixed4 frag (v2f i) : SV_Target
  45. {
  46. // sample the texture
  47. fixed4 col = tex2D(_MainTex, i.uv);
  48. col *= _Color;
  49. col.rgb *= _Brightness;
  50. // apply fog
  51. UNITY_APPLY_FOG(i.fogCoord, col);
  52. return col;
  53. }
  54. ENDCG
  55. }
  56. }
  57. }