Horizontal Skybox.shader 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Skybox/Horizontal Skybox"
  3. {
  4. Properties
  5. {
  6. _Color1 ("Top Color", Color) = (1, 1, 1, 0)
  7. _Color2 ("Horizon Color", Color) = (1, 1, 1, 0)
  8. _Color3 ("Bottom Color", Color) = (1, 1, 1, 0)
  9. _Exponent1 ("Exponent Factor for Top Half", Float) = 1.0
  10. _Exponent2 ("Exponent Factor for Bottom Half", Float) = 1.0
  11. _Intensity ("Intensity Amplifier", Float) = 1.0
  12. }
  13. CGINCLUDE
  14. #include "UnityCG.cginc"
  15. struct appdata
  16. {
  17. float4 position : POSITION;
  18. float3 texcoord : TEXCOORD0;
  19. UNITY_VERTEX_INPUT_INSTANCE_ID
  20. };
  21. struct v2f
  22. {
  23. float4 position : SV_POSITION;
  24. float3 texcoord : TEXCOORD0;
  25. UNITY_VERTEX_OUTPUT_STEREO
  26. };
  27. half4 _Color1;
  28. half4 _Color2;
  29. half4 _Color3;
  30. half _Intensity;
  31. half _Exponent1;
  32. half _Exponent2;
  33. half4 _MainTex_ST;
  34. v2f vert (appdata v)
  35. {
  36. v2f o;
  37. UNITY_SETUP_INSTANCE_ID(v);
  38. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  39. o.position = UnityObjectToClipPos (v.position);
  40. o.texcoord = v.texcoord;
  41. return o;
  42. }
  43. half4 frag (v2f i) : COLOR
  44. {
  45. float p = normalize (i.texcoord).y;
  46. float p1 = 1.0f - pow (min (1.0f, 1.0f - p), _Exponent1);
  47. float p3 = 1.0f - pow (min (1.0f, 1.0f + p), _Exponent2);
  48. float p2 = 1.0f - p1 - p3;
  49. return (_Color1 * p1 + _Color2 * p2 + _Color3 * p3) * _Intensity;
  50. }
  51. ENDCG
  52. SubShader
  53. {
  54. Tags { "RenderType"="Background" "Queue"="Background" }
  55. Pass
  56. {
  57. ZWrite Off
  58. Cull Off
  59. Fog { Mode Off }
  60. CGPROGRAM
  61. #pragma fragmentoption ARB_precision_hint_fastest
  62. #pragma vertex vert
  63. #pragma fragment frag
  64. ENDCG
  65. }
  66. }
  67. }