You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.0 KiB

  1. Shader "SkyboxPlus/Cubemap"
  2. {
  3. Properties
  4. {
  5. [NoScaleOffset] _Tex("-", Cube) = "grey"{}
  6. _Tint("-", Color) = (.5, .5, .5)
  7. _Euler("-", Vector) = (0, 0, 0)
  8. [HideInInspector] _Rotation1("-", Vector) = (1, 0, 0)
  9. [HideInInspector] _Rotation2("-", Vector) = (0, 1, 0)
  10. [HideInInspector] _Rotation3("-", Vector) = (0, 0, 1)
  11. [Gamma] _Exposure("-", Range(0, 8)) = 1
  12. _Saturation("-", Range(0, 2)) = 1
  13. [Toggle] _Lod("-", Float) = 0
  14. _LodLevel("-", Range(0, 10)) = 0
  15. }
  16. CGINCLUDE
  17. #pragma shader_feature _LOD_ON
  18. #include "UnityCG.cginc"
  19. samplerCUBE _Tex;
  20. half4 _Tex_HDR;
  21. half4 _Tint;
  22. half _Exposure;
  23. half _Saturation;
  24. float _LodLevel;
  25. float4 _Rotation1;
  26. float4 _Rotation2;
  27. float4 _Rotation3;
  28. struct appdata_t {
  29. float4 vertex : POSITION;
  30. };
  31. struct v2f {
  32. float4 vertex : SV_POSITION;
  33. float3 texcoord : TEXCOORD0;
  34. };
  35. v2f vert(appdata_t v)
  36. {
  37. v2f o;
  38. float3x3 m = float3x3(_Rotation1.xyz, _Rotation2.xyz, _Rotation3.xyz);
  39. float4 vp = float4(mul(m, v.vertex.xyz), v.vertex.w);
  40. o.vertex = UnityObjectToClipPos(vp);
  41. o.texcoord = v.vertex.xyz;
  42. return o;
  43. }
  44. fixed4 frag(v2f i) : SV_Target
  45. {
  46. #ifdef _LOD_ON
  47. half4 tex = texCUBElod(_Tex, float4(i.texcoord, _LodLevel));
  48. #else
  49. half4 tex = texCUBE(_Tex, i.texcoord);
  50. #endif
  51. half3 c = DecodeHDR(tex, _Tex_HDR);
  52. c *= _Tint.rgb * unity_ColorSpaceDouble.rgb * _Exposure;
  53. c = lerp((half3)Luminance(c), c, _Saturation);
  54. return half4(c, 1);
  55. }
  56. ENDCG
  57. SubShader
  58. {
  59. Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
  60. Cull Off ZWrite Off
  61. Pass
  62. {
  63. CGPROGRAM
  64. #pragma vertex vert
  65. #pragma fragment frag
  66. ENDCG
  67. }
  68. }
  69. Fallback Off
  70. CustomEditor "SkyboxPlus.CubemapMaterialEditor"
  71. }