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.

109 lines
3.0 KiB

  1. Shader "SkyboxPlus/Gradients"
  2. {
  3. Properties
  4. {
  5. [HDR] _BaseColor("Base Color", Color) = (0.1, 0.1, 0.1)
  6. [Gamma] _Exposure("Exposure", Range(0, 8)) = 1
  7. [Toggle] _Switch2("Gradient 2", Float) = 1
  8. [Toggle] _Switch3("Gradient 3", Float) = 1
  9. [Toggle] _Switch4("Gradient 4", Float) = 1
  10. _Direction1("Direction 1", Vector) = (0, 1, 0)
  11. _Direction2("Direction 2", Vector) = (0.5, 1, 0)
  12. _Direction3("Direction 3", Vector) = (-0.3, -1, -0.2)
  13. _Direction4("Direction 4", Vector) = (0, 1, 0)
  14. [HDR] _Color1("Color 1", Color) = (0.16, 0.18, 0.19)
  15. [HDR] _Color2("Color 2", Color) = (0.26, 0.28, 0.21)
  16. [HDR] _Color3("Color 3", Color) = (0.15, 0.15, 0.12)
  17. [HDR] _Color4("Color 4", Color) = (1.00, 0.99, 0.95)
  18. _Exponent1("Exponent 1", Range(1, 20)) = 1
  19. _Exponent2("Exponent 2", Range(1, 20)) = 1
  20. _Exponent3("Exponent 3", Range(1, 20)) = 1
  21. _Exponent4("Exponent 4", Range(1, 20)) = 20
  22. [HideInInspector] _NormalizedVector1("-", Vector) = (0, 1, 0)
  23. [HideInInspector] _NormalizedVector2("-", Vector) = (0, 1, 0)
  24. [HideInInspector] _NormalizedVector3("-", Vector) = (0, 1, 0)
  25. [HideInInspector] _NormalizedVector4("-", Vector) = (0, 1, 0)
  26. }
  27. CGINCLUDE
  28. #pragma shader_feature _SWITCH2_ON
  29. #pragma shader_feature _SWITCH3_ON
  30. #pragma shader_feature _SWITCH4_ON
  31. #include "UnityCG.cginc"
  32. half3 _BaseColor;
  33. half _Exposure;
  34. half3 _NormalizedVector1;
  35. half3 _NormalizedVector2;
  36. half3 _NormalizedVector3;
  37. half3 _NormalizedVector4;
  38. half3 _Color1;
  39. half3 _Color2;
  40. half3 _Color3;
  41. half3 _Color4;
  42. half _Exponent1;
  43. half _Exponent2;
  44. half _Exponent3;
  45. half _Exponent4;
  46. struct appdata_t {
  47. float4 vertex : POSITION;
  48. };
  49. struct v2f {
  50. float4 vertex : SV_POSITION;
  51. float3 texcoord : TEXCOORD0;
  52. };
  53. v2f vert(appdata_t v)
  54. {
  55. v2f o;
  56. o.vertex = UnityObjectToClipPos(v.vertex);
  57. o.texcoord = v.vertex.xyz;
  58. return o;
  59. }
  60. half4 frag(v2f i) : SV_Target
  61. {
  62. half3 d = normalize(i.texcoord.xyz);
  63. half3 c = _BaseColor;
  64. c += _Color1 * pow((dot(d, _NormalizedVector1) + 1) * 0.5, _Exponent1);
  65. #ifdef _SWITCH2_ON
  66. c += _Color2 * pow((dot(d, _NormalizedVector2) + 1) * 0.5, _Exponent2);
  67. #endif
  68. #ifdef _SWITCH3_ON
  69. c += _Color3 * pow((dot(d, _NormalizedVector3) + 1) * 0.5, _Exponent3);
  70. #endif
  71. #ifdef _SWITCH4_ON
  72. c += _Color4 * pow((dot(d, _NormalizedVector4) + 1) * 0.5, _Exponent4);
  73. #endif
  74. return half4(c * _Exposure, 1);
  75. }
  76. ENDCG
  77. SubShader
  78. {
  79. Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
  80. Cull Off ZWrite Off
  81. Pass
  82. {
  83. CGPROGRAM
  84. #pragma vertex vert
  85. #pragma fragment frag
  86. ENDCG
  87. }
  88. }
  89. Fallback Off
  90. CustomEditor "SkyboxPlus.GradientsMaterialEditor"
  91. }