您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
81 行
1.8 KiB
81 行
1.8 KiB
Shader "Hidden/HDRenderPipeline/Sky/GradientSky"
|
|
{
|
|
HLSLINCLUDE
|
|
|
|
#pragma vertex Vert
|
|
#pragma fragment Frag
|
|
|
|
#pragma target 4.5
|
|
#pragma only_renderers d3d11 ps4 xboxone vulkan metal
|
|
|
|
#include "CoreRP/ShaderLibrary/Common.hlsl"
|
|
#include "CoreRP/ShaderLibrary/Color.hlsl"
|
|
#include "CoreRP/ShaderLibrary/CommonLighting.hlsl"
|
|
#include "HDRP/ShaderVariables.hlsl"
|
|
|
|
float4x4 _PixelCoordToViewDirWS; // Actually just 3x3, but Unity can only set 4x4
|
|
|
|
float4 _GradientBottom;
|
|
float4 _GradientMiddle;
|
|
float4 _GradientTop;
|
|
float _GradientDiffusion;
|
|
|
|
struct Attributes
|
|
{
|
|
uint vertexID : SV_VertexID;
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
float4 positionCS : SV_POSITION;
|
|
};
|
|
|
|
Varyings Vert(Attributes input)
|
|
{
|
|
Varyings output;
|
|
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID, UNITY_RAW_FAR_CLIP_VALUE);
|
|
return output;
|
|
}
|
|
|
|
float4 Frag(Varyings input) : SV_Target
|
|
{
|
|
float3 viewDirWS = normalize(mul(float3(input.positionCS.xy, 1.0), (float3x3)_PixelCoordToViewDirWS));
|
|
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, 1.0);
|
|
}
|
|
|
|
|
|
ENDHLSL
|
|
|
|
SubShader
|
|
{
|
|
Pass
|
|
{
|
|
ZWrite Off
|
|
ZTest Always
|
|
Blend Off
|
|
Cull Off
|
|
|
|
HLSLPROGRAM
|
|
ENDHLSL
|
|
|
|
}
|
|
|
|
Pass
|
|
{
|
|
ZWrite Off
|
|
ZTest LEqual
|
|
Blend Off
|
|
Cull Off
|
|
|
|
HLSLPROGRAM
|
|
ENDHLSL
|
|
}
|
|
|
|
}
|
|
Fallback Off
|
|
}
|