Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 KB | None | 0 0
  1. Shader "Custom/SkyBoxBlend" {
  2. Properties {
  3. _Tint ("Tint Color", Color) = (.5, .5, .5, .5)
  4. [Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0
  5. _Rotation ("Rotation", Range(0, 360)) = 0
  6. _SkyBlend ("Blend", Range(0.0, 1.0)) = 0.0
  7.  
  8. [NoScaleOffset] _FrontTex_01 ("Front_01 [+Z] (HDR)", 2D) = "grey" {}
  9. [NoScaleOffset] _BackTex_01 ("Back_01 [-Z] (HDR)", 2D) = "grey" {}
  10. [NoScaleOffset] _LeftTex_01 ("Left_01 [+X] (HDR)", 2D) = "grey" {}
  11. [NoScaleOffset] _RightTex_01 ("Right_01 [-X] (HDR)", 2D) = "grey" {}
  12. [NoScaleOffset] _UpTex_01 ("Up_01 [+Y] (HDR)", 2D) = "grey" {}
  13. [NoScaleOffset] _DownTex_01 ("Down_01 [-Y] (HDR)", 2D) = "grey" {}
  14.  
  15. [NoScaleOffset] _FrontTex_02 ("Front_02 [+Z] (HDR)", 2D) = "grey" {}
  16. [NoScaleOffset] _BackTex_02 ("Back_02 [-Z] (HDR)", 2D) = "grey" {}
  17. [NoScaleOffset] _LeftTex_02 ("Left_02 [+X] (HDR)", 2D) = "grey" {}
  18. [NoScaleOffset] _RightTex_02 ("Right_02 [-X] (HDR)", 2D) = "grey" {}
  19. [NoScaleOffset] _UpTex_02 ("Up_02 [+Y] (HDR)", 2D) = "grey" {}
  20. [NoScaleOffset] _DownTex_02 ("Down_02 [-Y] (HDR)", 2D) = "grey" {}
  21. }
  22.  
  23. SubShader {
  24. Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
  25. Cull Off ZWrite Off
  26.  
  27. CGINCLUDE
  28. #include "UnityCG.cginc"
  29.  
  30. half4 _Tint;
  31. half _Exposure;
  32. float _Rotation;
  33. float _SkyBlend;
  34.  
  35. float4 RotateAroundYInDegrees (float4 vertex, float degrees)
  36. {
  37. float alpha = degrees * UNITY_PI / 180.0;
  38. float sina, cosa;
  39. sincos(alpha, sina, cosa);
  40. float2x2 m = float2x2(cosa, -sina, sina, cosa);
  41. return float4(mul(m, vertex.xz), vertex.yw).xzyw;
  42. }
  43.  
  44. struct appdata_t {
  45. float4 vertex : POSITION;
  46. float2 texcoord : TEXCOORD0;
  47. };
  48. struct v2f {
  49. float4 vertex : SV_POSITION;
  50. float2 texcoord : TEXCOORD0;
  51. };
  52. v2f vert (appdata_t v)
  53. {
  54. v2f o;
  55. o.vertex = mul(UNITY_MATRIX_MVP, RotateAroundYInDegrees(v.vertex, _Rotation));
  56. o.texcoord = v.texcoord;
  57. return o;
  58. }
  59.  
  60. half4 skybox_frag (v2f i, sampler2D smp1, half4 smpDecode1, sampler2D smp2, half4 smpDecode2)
  61. {
  62. half4 tex1 = tex2D (smp1, i.texcoord);
  63. half4 tex2 = tex2D (smp2, i.texcoord);
  64.  
  65. half3 c1 = DecodeHDR (tex1, smpDecode1);
  66. half3 c2 = DecodeHDR (tex2, smpDecode2);
  67.  
  68. half3 c = lerp(c1, c2, _SkyBlend);
  69.  
  70. c = c * _Tint.rgb * unity_ColorSpaceDouble;
  71. c *= _Exposure;
  72. return half4(c, 1);
  73. }
  74. ENDCG
  75.  
  76. Pass {
  77. CGPROGRAM
  78. #pragma vertex vert
  79. #pragma fragment frag
  80. sampler2D _FrontTex_01;
  81. sampler2D _FrontTex_02;
  82. half4 _FrontTex_01_HDR;
  83. half4 _FrontTex_02_HDR;
  84. half4 frag (v2f i) : SV_Target { return skybox_frag(i,_FrontTex_01, _FrontTex_01_HDR, _FrontTex_02, _FrontTex_02_HDR); }
  85. ENDCG
  86. }
  87. Pass{
  88. CGPROGRAM
  89. #pragma vertex vert
  90. #pragma fragment frag
  91. sampler2D _BackTex_01;
  92. sampler2D _BackTex_02;
  93. half4 _BackTex_01_HDR;
  94. half4 _BackTex_02_HDR;
  95. half4 frag (v2f i) : SV_Target { return skybox_frag(i,_BackTex_01, _BackTex_01_HDR, _BackTex_02, _BackTex_02_HDR); }
  96. ENDCG
  97. }
  98. Pass{
  99. CGPROGRAM
  100. #pragma vertex vert
  101. #pragma fragment frag
  102. sampler2D _LeftTex_01;
  103. sampler2D _LeftTex_02;
  104. half4 _LeftTex_01_HDR;
  105. half4 _LeftTex_02_HDR;
  106. half4 frag (v2f i) : SV_Target { return skybox_frag(i,_LeftTex_01, _LeftTex_01_HDR, _LeftTex_02, _LeftTex_02_HDR); }
  107. ENDCG
  108. }
  109. Pass{
  110. CGPROGRAM
  111. #pragma vertex vert
  112. #pragma fragment frag
  113. sampler2D _RightTex_01;
  114. sampler2D _RightTex_02;
  115. half4 _RightTex_01_HDR;
  116. half4 _RightTex_02_HDR;
  117. half4 frag (v2f i) : SV_Target { return skybox_frag(i,_RightTex_01, _RightTex_01_HDR, _RightTex_02, _RightTex_02_HDR); }
  118. ENDCG
  119. }
  120. Pass{
  121. CGPROGRAM
  122. #pragma vertex vert
  123. #pragma fragment frag
  124. sampler2D _UpTex_01;
  125. sampler2D _UpTex_02;
  126. half4 _UpTex_01_HDR;
  127. half4 _UpTex_02_HDR;
  128. half4 frag (v2f i) : SV_Target { return skybox_frag(i,_UpTex_01, _UpTex_01_HDR, _UpTex_02, _UpTex_02_HDR); }
  129. ENDCG
  130. }
  131. Pass{
  132. CGPROGRAM
  133. #pragma vertex vert
  134. #pragma fragment frag
  135. sampler2D _DownTex_01;
  136. sampler2D _DownTex_02;
  137. half4 _DownTex_01_HDR;
  138. half4 _DownTex_02_HDR;
  139. half4 frag (v2f i) : SV_Target { return skybox_frag(i,_DownTex_01, _DownTex_01_HDR, _DownTex_02, _DownTex_02_HDR); }
  140. ENDCG
  141. }
  142. }
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement