EDIT: shadow on/off

This commit is contained in:
2025-12-08 17:38:13 +09:00
parent 33fc35ab6c
commit f62ce93695
9 changed files with 56 additions and 17 deletions

View File

@@ -189,6 +189,12 @@ float sampleCascadeShadow(uint ci, vec3 worldPos, vec3 N, vec3 L)
float calcShadowVisibility(vec3 worldPos, vec3 N, vec3 L)
{
// Early out when shadows are globally disabled.
if (sceneData.rtParams.y <= 0.0)
{
return 1.0;
}
vec3 wp = worldPos + N * SHADOW_NORMAL_OFFSET * (0.5 + 0.5 * (1.0 - max(dot(N, L), 0.0)));
// RT-only mode: cast a ray and skip clipmap sampling entirely
@@ -301,7 +307,7 @@ void main(){
// Optional RT shadow for the first few point lights (hybrid mode)
#ifdef GL_EXT_ray_query
if (sceneData.rtOptions.x == 1u && i < 4u)
if (sceneData.rtOptions.x == 1u && sceneData.rtParams.y > 0.0 && i < 4u)
{
vec3 toL = sceneData.punctualLights[i].position_radius.xyz - pos;
float maxT = length(toL);

View File

@@ -181,6 +181,12 @@ float sampleCascadeShadow(uint ci, vec3 worldPos, vec3 N, vec3 L)
float calcShadowVisibility(vec3 worldPos, vec3 N, vec3 L)
{
// Early out when shadows are globally disabled.
if (sceneData.rtParams.y <= 0.0)
{
return 1.0;
}
vec3 wp = worldPos + N * SHADOW_NORMAL_OFFSET * (0.5 + 0.5 * (1.0 - max(dot(N, L), 0.0)));
CascadeMix cm = computeCascadeMix(wp);

View File

@@ -23,11 +23,12 @@ layout(set = 0, binding = 0) uniform SceneData{
mat4 lightViewProjCascades[4];
// View-space split distances for selecting cascades (x,y,z,w)
vec4 cascadeSplitsView;
// Ray-query settings (packed)
// rtOptions.x = enabled (1/0)
// Ray-query & reflection settings (packed)
// rtOptions.x = RT shadows enabled (1/0)
// rtOptions.y = cascade bitmask (bit i => cascade i assisted)
uvec4 rtOptions;
// rtParams.x = N·L threshold; others reserved
// rtParams.x = N·L threshold for hybrid shadows
// rtParams.y = shadows enabled flag (1.0 = on, 0.0 = off)
vec4 rtParams;
GPUPunctualLight punctualLights[MAX_PUNCTUAL_LIGHTS];