Lux URP Toon Gradient Sky.shader 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //https://github.com/keijiro/UnitySkyboxShaders/
  2. Shader "Lux URP/Gradient Sky"
  3. {
  4. Properties
  5. {
  6. [Header(Surface Inputs)]
  7. [Space(8)]
  8. [HDR] _GroundColor ("Base Color", Color) = (1,1,1,1)
  9. [HDR] _TopColor ("Top Color", Color) = (1,1,1,1)
  10. _Intensity ("Intensity", Range (0, 1)) = 1
  11. [Space(5)]
  12. _FallOff ("Fall Off", Range (0, 16)) = 1.0
  13. _Yaw ("Yaw", Range (-3.14159, 3.14159)) = 0
  14. _Pitch ("Pitch", Range (-3.14159, 3.14159)) = 0
  15. }
  16. SubShader
  17. {
  18. Tags
  19. {
  20. "RenderPipeline" = "UniversalPipeline"
  21. "RenderType" = "Background"
  22. "Queue" = "Background"
  23. }
  24. Pass
  25. {
  26. Name "Unlit"
  27. //Tags{"LightMode" = "UniversalForward"}
  28. //Blend SrcAlpha OneMinusSrcAlpha
  29. Cull Back
  30. ZWrite Off
  31. HLSLPROGRAM
  32. // Required to compile gles 2.0 with standard srp library
  33. #pragma prefer_hlslcc gles
  34. #pragma exclude_renderers d3d11_9x
  35. #pragma target 2.0
  36. #pragma vertex vert
  37. #pragma fragment frag
  38. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  39. CBUFFER_START(UnityPerMaterial)
  40. half4 _GroundColor;
  41. half4 _TopColor;
  42. half _FallOff;
  43. half _Yaw;
  44. half _Pitch;
  45. half _Intensity;
  46. CBUFFER_END
  47. struct VertexInput
  48. {
  49. float4 vertex : POSITION;
  50. float3 uv : TEXCOORD0;
  51. };
  52. struct VertexOutput
  53. {
  54. float4 positionCS : SV_POSITION;
  55. UNITY_VERTEX_OUTPUT_STEREO
  56. float3 uv : TEXCOORD0;
  57. float3 dir : TEXCOORD1;
  58. };
  59. VertexOutput vert (VertexInput v)
  60. {
  61. VertexOutput output = (VertexOutput)0;
  62. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  63. output.positionCS = TransformObjectToHClip(v.vertex.xyz);
  64. output.uv = v.uv;
  65. half sinPitch, cosPitch, sinYaw, cosYaw;
  66. sincos (_Pitch, sinPitch, cosPitch);
  67. sincos (_Yaw, sinYaw, cosYaw);
  68. output.dir = half3(sinPitch * sinYaw, cosPitch, sinPitch * cosYaw);
  69. return output;
  70. }
  71. half4 frag (VertexOutput input ) : SV_Target
  72. {
  73. half gradient = dot( normalize(float3(input.uv.xyz)), input.dir) * 0.5h + 0.5h;
  74. half4 col = lerp(_GroundColor, _TopColor, pow(abs(gradient), _FallOff)) * _Intensity;
  75. return half4(col.xyz, 1.0h);
  76. }
  77. ENDHLSL
  78. }
  79. }
  80. FallBack "Hidden/InternalErrorShader"
  81. CustomEditor "LuxURPUniversalCustomShaderGUI"
  82. }