Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. Shader "Skybox/Cubemap" {
  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. [NoScaleOffset] _Tex ("Cubemap (HDR)", Cube) = "grey" {}
  7. }
  8.  
  9. SubShader {
  10. Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
  11. Cull Off ZWrite Off
  12.  
  13. Pass {
  14.  
  15. CGPROGRAM
  16. #pragma vertex vert
  17. #pragma fragment frag
  18. #pragma target 2.0
  19.  
  20. #include "UnityCG.cginc"
  21.  
  22. samplerCUBE _Tex;
  23. half4 _Tex_HDR;
  24. half4 _Tint;
  25. half _Exposure;
  26. float _Rotation;
  27.  
  28. float3 RotateAroundYInDegrees (float3 vertex, float degrees)
  29. {
  30. float alpha = degrees * UNITY_PI / 180.0;
  31. float sina, cosa;
  32. sincos(alpha, sina, cosa);
  33. float2x2 m = float2x2(cosa, -sina, sina, cosa);
  34. return float3(mul(m, vertex.xz), vertex.y).xzy;
  35. }
  36.  
  37. struct appdata_t {
  38. float4 vertex : POSITION;
  39. };
  40.  
  41. struct v2f {
  42. float4 vertex : SV_POSITION;
  43. float3 texcoord : TEXCOORD0;
  44. };
  45.  
  46. v2f vert (appdata_t v)
  47. {
  48. v2f o;
  49. float3 rotated = RotateAroundYInDegrees(v.vertex, _Rotation);
  50. o.vertex = UnityObjectToClipPos(rotated);
  51. o.texcoord = v.vertex.xyz;
  52. return o;
  53. }
  54.  
  55. fixed4 frag (v2f i) : SV_Target
  56. {
  57. half4 tex = texCUBE (_Tex, i.texcoord);
  58. half3 c = DecodeHDR (tex, _Tex_HDR);
  59. c = c * _Tint.rgb * unity_ColorSpaceDouble.rgb;
  60. c *= _Exposure;
  61. return half4(c, 1);
  62. }
  63. ENDCG
  64. }
  65. }
  66.  
  67.  
  68. Fallback Off
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement