Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.40 KB | None | 0 0
  1. Shader "Custom/SkyBox6sided-simple" {
  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.  
  24. SubShader {
  25. Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
  26. Cull Off ZWrite Off
  27.  
  28. CGINCLUDE
  29. #include "UnityCG.cginc"
  30.  
  31. half4 _Tint;
  32. half _Exposure;
  33. float _Rotation;
  34. //float _SkyBlend;
  35.  
  36. float4 RotateAroundYInDegrees (float4 vertex, float degrees)
  37. {
  38. float alpha = degrees * UNITY_PI / 180.0;
  39. float sina, cosa;
  40. sincos(alpha, sina, cosa);
  41. float2x2 m = float2x2(cosa, -sina, sina, cosa);
  42. return float4(mul(m, vertex.xz), vertex.yw).xzyw;
  43. }
  44.  
  45. struct appdata_t {
  46. float4 vertex : POSITION;
  47. float2 texcoord : TEXCOORD0;
  48. };
  49. struct v2f {
  50. float4 vertex : SV_POSITION;
  51. float2 texcoord : TEXCOORD0;
  52. };
  53. v2f vert (appdata_t v)
  54. {
  55. v2f o;
  56. o.vertex = mul(UNITY_MATRIX_MVP, RotateAroundYInDegrees(v.vertex, _Rotation));
  57. o.texcoord = v.texcoord;
  58. return o;
  59. }
  60. /*
  61. half4 skybox_frag (v2f i, sampler2D smp1, half4 smpDecode1, sampler2D smp2, half4 smpDecode2)
  62. {
  63. half4 tex1 = tex2D (smp1, i.texcoord);
  64. half4 tex2 = tex2D (smp2, i.texcoord);
  65.  
  66. half3 c1 = DecodeHDR (tex1, smpDecode1);
  67. half3 c2 = DecodeHDR (tex2, smpDecode2);
  68.  
  69. half3 c = lerp(c1, c2, _SkyBlend);
  70.  
  71. c = c * _Tint.rgb * unity_ColorSpaceDouble;
  72. c *= _Exposure;
  73. return half4(c, 1);
  74. }
  75. */
  76. //half4 skybox_frag_simple(v2f i, sampler2D smp1, half4 smpDecode1, sampler2D smp2, half4 smpDecode2)
  77. half4 skybox_frag_simple(v2f i, sampler2D smp1, half4 smpDecode1)
  78. {
  79. half4 tex1 = tex2D(smp1, i.texcoord);
  80. //half4 tex2 = tex2D(smp2, i.texcoord);
  81.  
  82. half3 c1 = DecodeHDR(tex1, smpDecode1);
  83. //half3 c2 = DecodeHDR(tex2, smpDecode2);
  84.  
  85. //half3 c = lerp(c1, c2, _SkyBlend)
  86.  
  87. half3 c = c1;
  88.  
  89. c = c * _Tint.rgb * unity_ColorSpaceDouble;
  90. c *= _Exposure;
  91. return half4(c, 1);
  92. }
  93.  
  94.  
  95. ENDCG
  96.  
  97. Pass {
  98. CGPROGRAM
  99. #pragma vertex vert
  100. #pragma fragment frag
  101. sampler2D _FrontTex_01;
  102. //sampler2D _FrontTex_02;
  103. half4 _FrontTex_01_HDR;
  104. //half4 _FrontTex_02_HDR;
  105. half4 frag (v2f i) : SV_Target {
  106. return skybox_frag_simple(i,_FrontTex_01, _FrontTex_01_HDR);
  107. }
  108. ENDCG
  109. }
  110. Pass{
  111. CGPROGRAM
  112. #pragma vertex vert
  113. #pragma fragment frag
  114. sampler2D _BackTex_01;
  115. //sampler2D _BackTex_02;
  116. half4 _BackTex_01_HDR;
  117. //half4 _BackTex_02_HDR;
  118. half4 frag (v2f i) : SV_Target {
  119. return skybox_frag_simple(i,_BackTex_01, _BackTex_01_HDR);
  120. }
  121. ENDCG
  122. }
  123. Pass{
  124. CGPROGRAM
  125. #pragma vertex vert
  126. #pragma fragment frag
  127. sampler2D _LeftTex_01;
  128. //sampler2D _LeftTex_02;
  129. half4 _LeftTex_01_HDR;
  130. //half4 _LeftTex_02_HDR;
  131. half4 frag (v2f i) : SV_Target {
  132. return skybox_frag_simple(i,_LeftTex_01, _LeftTex_01_HDR);
  133. }
  134. ENDCG
  135. }
  136. Pass{
  137. CGPROGRAM
  138. #pragma vertex vert
  139. #pragma fragment frag
  140. sampler2D _RightTex_01;
  141. //sampler2D _RightTex_02;
  142. half4 _RightTex_01_HDR;
  143. //half4 _RightTex_02_HDR;
  144. half4 frag (v2f i) : SV_Target {
  145. return skybox_frag_simple(i,_RightTex_01, _RightTex_01_HDR);
  146. }
  147. ENDCG
  148. }
  149. Pass{
  150. CGPROGRAM
  151. #pragma vertex vert
  152. #pragma fragment frag
  153. sampler2D _UpTex_01;
  154. //sampler2D _UpTex_02;
  155. half4 _UpTex_01_HDR;
  156. //half4 _UpTex_02_HDR;
  157. half4 frag (v2f i) : SV_Target {
  158. return skybox_frag_simple(i,_UpTex_01, _UpTex_01_HDR);
  159. }
  160. ENDCG
  161. }
  162. Pass{
  163. CGPROGRAM
  164. #pragma vertex vert
  165. #pragma fragment frag
  166. sampler2D _DownTex_01;
  167. //sampler2D _DownTex_02;
  168. half4 _DownTex_01_HDR;
  169. //half4 _DownTex_02_HDR;
  170. half4 frag (v2f i) : SV_Target {
  171. return skybox_frag_simple(i,_DownTex_01, _DownTex_01_HDR);
  172. }
  173. ENDCG
  174. }
  175. }
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement