GradientSkybox.shader 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. Shader "FlatKit/GradientSkybox" {
  2. Properties {
  3. _Color2 ("Top Color", Color) = (0.97, 0.67, 0.51, 0)
  4. _Color1 ("Bottom Color", Color) = (0, 0.7, 0.74, 0)
  5. [Space]
  6. _Intensity ("Intensity", Range (0, 2)) = 1.0
  7. _Exponent ("Exponent", Range (0, 3)) = 1.0
  8. [Space]
  9. _DirectionYaw ("Direction X angle", Range (0, 180)) = 0
  10. _DirectionPitch ("Direction Y angle", Range (0, 180)) = 0
  11. [Space]
  12. _NoiseIntensity ("Noise Intensity", Range (0, 0.25)) = 0.0
  13. [HideInInspector]
  14. _Direction ("Direction", Vector) = (0, 1, 0, 0)
  15. }
  16. CGINCLUDE
  17. #include "UnityCG.cginc"
  18. struct appdata {
  19. float4 position : POSITION;
  20. float3 texcoord : TEXCOORD0;
  21. UNITY_VERTEX_INPUT_INSTANCE_ID
  22. };
  23. struct v2f {
  24. float4 position : SV_POSITION;
  25. float3 texcoord : TEXCOORD0;
  26. UNITY_VERTEX_OUTPUT_STEREO
  27. };
  28. half4 _Color1;
  29. half4 _Color2;
  30. half3 _Direction;
  31. half _Intensity;
  32. half _Exponent;
  33. half _NoiseIntensity;
  34. v2f vert (appdata v) {
  35. v2f o;
  36. UNITY_SETUP_INSTANCE_ID(v);
  37. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  38. o.position = UnityObjectToClipPos(v.position);
  39. o.texcoord = v.texcoord;
  40. return o;
  41. }
  42. fixed4 frag (v2f i) : COLOR {
  43. const half d = dot(normalize(i.texcoord), _Direction) * 0.5f + 0.5f;
  44. float t = pow(d, _Exponent);
  45. t += frac(sin(dot(t, float4(12.9898, 78.233, 45.164, 94.673))) * 43758.5453) * _NoiseIntensity;
  46. return lerp(_Color1, _Color2, t) * _Intensity;
  47. }
  48. ENDCG
  49. SubShader {
  50. Tags { "RenderType"="Background" "Queue"="Background" }
  51. Pass {
  52. ZWrite Off
  53. Cull Off
  54. Fog { Mode Off }
  55. CGPROGRAM
  56. #pragma fragmentoption ARB_precision_hint_fastest
  57. #pragma vertex vert
  58. #pragma fragment frag
  59. ENDCG
  60. }
  61. }
  62. CustomEditor "GradientSkyboxEditor"
  63. }