Advertisement
Makak

Skybox.shader

Sep 7th, 2015
1,080
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 KB | None | 0 0
  1. Shader "Unknown Studios/Skybox"
  2. {
  3.     Properties
  4.     {
  5.         _SkyColor1("Top Color", Color) = (0.37, 0.52, 0.73, 0)
  6.         _SkyExponent1("Top Exponent", Float) = 2
  7.  
  8.         _SkyColor2("Horizon Color", Color) = (0.89, 0.96, 1, 0)
  9.  
  10.         _SkyIntensity("Sky Intensity", Float) = 1.75
  11.  
  12.         _SunColor("Sun Color", Color) = (1, 0.99, 0.87, 1)
  13.         _SunIntensity("Sun Intensity", Range(0.0,20.0)) = 10.0
  14.     }
  15.  
  16.         CGINCLUDE
  17.  
  18. #include "UnityCG.cginc"
  19.  
  20.     struct appdata
  21.     {
  22.         float4 position : POSITION;
  23.         float3 texcoord : TEXCOORD0;
  24.     };
  25.  
  26.     struct v2f
  27.     {
  28.         float4 position : SV_POSITION;
  29.         float3 texcoord : TEXCOORD0;
  30.     };
  31.  
  32.     half3 _SkyColor1;
  33.     half _SkyExponent1;
  34.  
  35.     half3 _SkyColor2;
  36.     half _SkyIntensity;
  37.  
  38.     half3 _SunColor;
  39.     half _SunIntensity;
  40.  
  41.     v2f vert(appdata v)
  42.     {
  43.         v2f o;
  44.         o.position = mul(UNITY_MATRIX_MVP, v.position);
  45.         o.texcoord = v.texcoord;
  46.         return o;
  47.     }
  48.  
  49.     half4 frag(v2f i) : COLOR
  50.     {
  51.         float3 v = normalize(i.texcoord);
  52.  
  53.         float p = v.y;
  54.         float p1 = 1 - pow(min(1, 1 - p), _SkyExponent1);
  55.         float p2 = 1 - p1;
  56.  
  57.         half3 c_sky = _SkyColor1 * p1 + _SkyColor2 * p2;
  58.         half3 c_sun = _SunColor * min(pow(max(0, dot(v, _WorldSpaceLightPos0.xyz)), 550), 1);
  59.  
  60.         return half4(c_sky * _SkyIntensity + c_sun * _SunIntensity, 0);
  61.     }
  62.  
  63.         ENDCG
  64.  
  65.         SubShader
  66.     {
  67.         Tags{ "RenderType" = "Skybox" "Queue" = "Background" }
  68.             Pass
  69.         {
  70.             ZWrite Off
  71.             Cull Off
  72.             Fog { Mode Off }
  73.             CGPROGRAM
  74.             #pragma fragmentoption ARB_precision_hint_fastest
  75.             #pragma vertex vert
  76.             #pragma fragment frag
  77.             ENDCG
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement