101 lines
2.7 KiB
Plaintext
101 lines
2.7 KiB
Plaintext
|
Shader "Hidden/HDRP/Sky/GradientSky"
|
||
|
{
|
||
|
HLSLINCLUDE
|
||
|
|
||
|
#pragma vertex Vert
|
||
|
|
||
|
#pragma editor_sync_compilation
|
||
|
#pragma target 4.5
|
||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
|
||
|
|
||
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
||
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUtils.hlsl"
|
||
|
|
||
|
float4 _GradientBottom;
|
||
|
float4 _GradientMiddle;
|
||
|
float4 _GradientTop;
|
||
|
float _GradientDiffusion;
|
||
|
float _SkyIntensity;
|
||
|
|
||
|
struct Attributes
|
||
|
{
|
||
|
uint vertexID : SV_VertexID;
|
||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||
|
};
|
||
|
|
||
|
struct Varyings
|
||
|
{
|
||
|
float4 positionCS : SV_POSITION;
|
||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||
|
};
|
||
|
|
||
|
Varyings Vert(Attributes input)
|
||
|
{
|
||
|
Varyings output;
|
||
|
UNITY_SETUP_INSTANCE_ID(input);
|
||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||
|
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID, UNITY_RAW_FAR_CLIP_VALUE);
|
||
|
return output;
|
||
|
}
|
||
|
|
||
|
float4 RenderSky(Varyings input)
|
||
|
{
|
||
|
float3 viewDirWS = GetSkyViewDirWS(input.positionCS.xy);
|
||
|
float verticalGradient = viewDirWS.y * _GradientDiffusion;
|
||
|
float topLerpFactor = saturate(-verticalGradient);
|
||
|
float bottomLerpFactor = saturate(verticalGradient);
|
||
|
float3 color = lerp(_GradientMiddle.xyz, _GradientBottom.xyz, bottomLerpFactor);
|
||
|
color = lerp(color, _GradientTop.xyz, topLerpFactor);
|
||
|
return float4(color * _SkyIntensity, 1.0);
|
||
|
}
|
||
|
|
||
|
float4 FragBaking(Varyings input) : SV_Target
|
||
|
{
|
||
|
return RenderSky(input);
|
||
|
}
|
||
|
|
||
|
float4 FragRender(Varyings input) : SV_Target
|
||
|
{
|
||
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||
|
float4 color = RenderSky(input);
|
||
|
color.rgb *= GetCurrentExposureMultiplier();
|
||
|
return color;
|
||
|
}
|
||
|
|
||
|
ENDHLSL
|
||
|
|
||
|
SubShader
|
||
|
{
|
||
|
Tags{ "RenderPipeline" = "HDRenderPipeline" }
|
||
|
Pass
|
||
|
{
|
||
|
ZWrite Off
|
||
|
ZTest Always
|
||
|
Blend Off
|
||
|
Cull Off
|
||
|
|
||
|
HLSLPROGRAM
|
||
|
#pragma fragment FragBaking
|
||
|
ENDHLSL
|
||
|
|
||
|
}
|
||
|
|
||
|
Pass
|
||
|
{
|
||
|
ZWrite Off
|
||
|
ZTest LEqual
|
||
|
Blend Off
|
||
|
Cull Off
|
||
|
|
||
|
HLSLPROGRAM
|
||
|
#pragma fragment FragRender
|
||
|
ENDHLSL
|
||
|
}
|
||
|
|
||
|
}
|
||
|
Fallback Off
|
||
|
}
|