rendering: thread global shader keywords into builtin variants
This commit is contained in:
@@ -43,6 +43,9 @@ in vec3 vPositionWS;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
float ComputeShadowAttenuation(vec3 positionWS) {
|
||||
#ifndef XC_MAIN_LIGHT_SHADOWS
|
||||
return 1.0;
|
||||
#else
|
||||
if (gShadowOptions.x < 0.5) {
|
||||
return 1.0;
|
||||
}
|
||||
@@ -66,6 +69,7 @@ float ComputeShadowAttenuation(vec3 positionWS) {
|
||||
float receiverDepth = shadowNdc.z * 0.5 + 0.5 - gShadowBiasAndTexelSize.x;
|
||||
float shadowStrength = clamp(gShadowBiasAndTexelSize.w, 0.0, 1.0);
|
||||
return receiverDepth <= shadowDepth ? 1.0 : (1.0 - shadowStrength);
|
||||
#endif
|
||||
}
|
||||
|
||||
float ComputeRangeAttenuation(float distanceSq, float range) {
|
||||
|
||||
@@ -45,6 +45,9 @@ layout(location = 2) in vec3 vPositionWS;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
float ComputeShadowAttenuation(vec3 positionWS) {
|
||||
#ifndef XC_MAIN_LIGHT_SHADOWS
|
||||
return 1.0;
|
||||
#else
|
||||
if (gShadowOptions.x < 0.5) {
|
||||
return 1.0;
|
||||
}
|
||||
@@ -68,6 +71,7 @@ float ComputeShadowAttenuation(vec3 positionWS) {
|
||||
float receiverDepth = shadowNdc.z - gShadowBiasAndTexelSize.x;
|
||||
float shadowStrength = clamp(gShadowBiasAndTexelSize.w, 0.0, 1.0);
|
||||
return receiverDepth <= shadowDepth ? 1.0 : (1.0 - shadowStrength);
|
||||
#endif
|
||||
}
|
||||
|
||||
float ComputeRangeAttenuation(float distanceSq, float range) {
|
||||
|
||||
@@ -45,6 +45,9 @@ struct PSInput {
|
||||
};
|
||||
|
||||
float ComputeShadowAttenuation(float3 positionWS) {
|
||||
#ifndef XC_MAIN_LIGHT_SHADOWS
|
||||
return 1.0f;
|
||||
#else
|
||||
if (gShadowOptions.x < 0.5f) {
|
||||
return 1.0f;
|
||||
}
|
||||
@@ -68,6 +71,7 @@ float ComputeShadowAttenuation(float3 positionWS) {
|
||||
const float receiverDepth = shadowNdc.z - gShadowBiasAndTexelSize.x;
|
||||
const float shadowStrength = saturate(gShadowBiasAndTexelSize.w);
|
||||
return receiverDepth <= shadowDepth ? 1.0f : (1.0f - shadowStrength);
|
||||
#endif
|
||||
}
|
||||
|
||||
float ComputeRangeAttenuation(float distanceSq, float range) {
|
||||
|
||||
@@ -25,6 +25,7 @@ Shader "Builtin Forward Lit"
|
||||
HLSLPROGRAM
|
||||
#pragma vertex MainVS
|
||||
#pragma fragment MainPS
|
||||
#pragma multi_compile _ XC_MAIN_LIGHT_SHADOWS
|
||||
#pragma backend D3D12 HLSL "forward-lit.vs.hlsl" "forward-lit.ps.hlsl" vs_5_0 ps_5_0
|
||||
#pragma backend OpenGL GLSL "forward-lit.vert.glsl" "forward-lit.frag.glsl"
|
||||
#pragma backend Vulkan GLSL "forward-lit.vert.vk.glsl" "forward-lit.frag.vk.glsl"
|
||||
|
||||
Reference in New Issue
Block a user