Advertisement
Guest User

Untitled

a guest
May 26th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  2.  
  3. Shader "Skybox/SkyboxLerp" {
  4. Properties {
  5.     _Tint ("Tint Color", Color) = (.5, .5, .5, .5)
  6.     [Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0
  7.     _Rotation ("Rotation", Range(0, 360)) = 0
  8.     [NoScaleOffset] _Tex ("Cubemap   (HDR)", Cube) = "grey" {}
  9.     [NoScaleOffset] _Tex2 ("Cubemap 2 (HDR)", Cube) = "grey" {}
  10.     _lerpVal ("Lerp Value", Range(0, 1)) = 0.5
  11. }
  12.  
  13. SubShader {
  14.     Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
  15.     Cull Off ZWrite Off
  16.  
  17.     Pass {
  18.  
  19.         CGPROGRAM
  20.         #pragma vertex vert
  21.         #pragma fragment frag
  22.         #pragma target 2.0
  23.  
  24.         #include "UnityCG.cginc"
  25.  
  26.         samplerCUBE _Tex;
  27.         samplerCUBE _Tex2;
  28.         half4 _Tex_HDR;
  29.         half4 _Tint;
  30.         half _Exposure;
  31.         float _Rotation;
  32.         float _lerpVal;
  33.  
  34.         float3 RotateAroundYInDegrees (float3 vertex, float degrees)
  35.         {
  36.             float alpha = degrees * UNITY_PI / 180.0;
  37.             float sina, cosa;
  38.             sincos(alpha, sina, cosa);
  39.             float2x2 m = float2x2(cosa, -sina, sina, cosa);
  40.             return float3(mul(m, vertex.xz), vertex.y).xzy;
  41.         }
  42.  
  43.         struct appdata_t {
  44.             float4 vertex : POSITION;
  45.             UNITY_VERTEX_INPUT_INSTANCE_ID
  46.         };
  47.  
  48.         struct v2f {
  49.             float4 vertex : SV_POSITION;
  50.             float3 texcoord : TEXCOORD0;
  51.             UNITY_VERTEX_OUTPUT_STEREO
  52.         };
  53.  
  54.         v2f vert (appdata_t v)
  55.         {
  56.             v2f o;
  57.             UNITY_SETUP_INSTANCE_ID(v);
  58.             UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  59.             float3 rotated = RotateAroundYInDegrees(v.vertex, _Rotation);
  60.             o.vertex = UnityObjectToClipPos(rotated);
  61.             o.texcoord = v.vertex.xyz;
  62.             return o;
  63.         }
  64.  
  65.         fixed4 frag (v2f i) : SV_Target
  66.         {
  67.             half4 tex = texCUBE (_Tex, i.texcoord);
  68.             half4 tex2 = texCUBE (_Tex2, i.texcoord);
  69.  
  70.             half3 c = DecodeHDR (tex, _Tex_HDR);
  71.             half3 c2 = DecodeHDR (tex2, _Tex_HDR);
  72.  
  73.             c = lerp(c, c2, _lerpVal);
  74.  
  75.             c = c * _Tint.rgb * unity_ColorSpaceDouble.rgb;
  76.             c *= _Exposure;
  77.             return half4(c, 1);
  78.         }
  79.         ENDCG
  80.     }
  81. }
  82.  
  83.  
  84. Fallback Off
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement