summaryrefslogtreecommitdiffstats
path: root/servers/rendering/renderer_rd
diff options
context:
space:
mode:
authorDario <dariosamo@gmail.com>2024-10-28 10:26:50 -0300
committerDario <dariosamo@gmail.com>2024-10-28 10:26:50 -0300
commit427ba09efc70b2ad836bfa2441a242bbda10ba36 (patch)
tree8626bb61528fa05ac4d031a2c929d5d2e56c7aab /servers/rendering/renderer_rd
parenta3080477ac0421aef24ca0916c40559abbf4846b (diff)
downloadredot-engine-427ba09efc70b2ad836bfa2441a242bbda10ba36.tar.gz
Fix soft shadows by increasing the bit count for specialization constants.
Diffstat (limited to 'servers/rendering/renderer_rd')
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h8
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp7
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h17
-rw-r--r--servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered_inc.glsl8
-rw-r--r--servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile_inc.glsl29
5 files changed, 42 insertions, 27 deletions
diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h
index 136514588a..8d79539b3d 100644
--- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h
+++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h
@@ -108,10 +108,10 @@ public:
uint32_t projector_use_mipmaps : 1;
uint32_t use_depth_fog : 1;
uint32_t use_lightmap_bicubic_filter : 1;
- uint32_t soft_shadow_samples : 4;
- uint32_t penumbra_shadow_samples : 4;
- uint32_t directional_soft_shadow_samples : 4;
- uint32_t directional_penumbra_shadow_samples : 4;
+ uint32_t soft_shadow_samples : 6;
+ uint32_t penumbra_shadow_samples : 6;
+ uint32_t directional_soft_shadow_samples : 6;
+ uint32_t directional_penumbra_shadow_samples : 6;
};
uint32_t packed_0;
diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
index 6dcaadddd3..6323d7dd6a 100644
--- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
@@ -322,7 +322,12 @@ void SceneShaderForwardMobile::ShaderData::_create_pipeline(PipelineKey p_pipeli
specialization_constants.push_back(sc);
sc.constant_id = 1;
- sc.float_value = p_pipeline_key.shader_specialization.packed_1;
+ sc.int_value = p_pipeline_key.shader_specialization.packed_1;
+ sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT;
+ specialization_constants.push_back(sc);
+
+ sc.constant_id = 2;
+ sc.float_value = p_pipeline_key.shader_specialization.packed_2;
sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_FLOAT;
specialization_constants.push_back(sc);
diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h
index c1095d29dc..a27da6c72d 100644
--- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h
+++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h
@@ -74,22 +74,23 @@ public:
uint32_t use_depth_fog : 1;
uint32_t is_multimesh : 1;
uint32_t use_lightmap_bicubic_filter : 1;
- uint32_t pad : 2;
- uint32_t soft_shadow_samples : 4;
- uint32_t penumbra_shadow_samples : 4;
- uint32_t directional_soft_shadow_samples : 4;
- uint32_t directional_penumbra_shadow_samples : 4;
+ uint32_t soft_shadow_samples : 6;
+ uint32_t penumbra_shadow_samples : 6;
+ uint32_t directional_soft_shadow_samples : 6;
};
uint32_t packed_0;
};
union {
- float luminance_multiplier;
- float packed_1;
+ uint32_t directional_penumbra_shadow_samples : 6;
+ uint32_t packed_1;
};
- uint32_t packed_2;
+ union {
+ float luminance_multiplier;
+ float packed_2;
+ };
};
struct UbershaderConstants {
diff --git a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered_inc.glsl b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered_inc.glsl
index 9f68d59be2..7bfcb2fb12 100644
--- a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered_inc.glsl
+++ b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered_inc.glsl
@@ -107,19 +107,19 @@ bool sc_use_lightmap_bicubic_filter() {
}
uint sc_soft_shadow_samples() {
- return (sc_packed_0() >> 8) & 15U;
+ return (sc_packed_0() >> 8) & 63U;
}
uint sc_penumbra_shadow_samples() {
- return (sc_packed_0() >> 12) & 15U;
+ return (sc_packed_0() >> 14) & 63U;
}
uint sc_directional_soft_shadow_samples() {
- return (sc_packed_0() >> 16) & 15U;
+ return (sc_packed_0() >> 20) & 63U;
}
uint sc_directional_penumbra_shadow_samples() {
- return (sc_packed_0() >> 20) & 15U;
+ return (sc_packed_0() >> 26) & 63U;
}
float sc_luminance_multiplier() {
diff --git a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile_inc.glsl b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile_inc.glsl
index 495e52a29e..df528973da 100644
--- a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile_inc.glsl
+++ b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile_inc.glsl
@@ -22,8 +22,8 @@ layout(push_constant, std430) uniform DrawCall {
uint pad;
#ifdef UBERSHADER
uint sc_packed_0;
- float sc_packed_1;
- uint sc_packed_2;
+ uint sc_packed_1;
+ float sc_packed_2;
uint uc_packed_0;
#endif
}
@@ -42,10 +42,14 @@ uint sc_packed_0() {
return draw_call.sc_packed_0;
}
-float sc_packed_1() {
+uint sc_packed_1() {
return draw_call.sc_packed_1;
}
+float sc_packed_2() {
+ return draw_call.sc_packed_2;
+}
+
uint uc_cull_mode() {
return (draw_call.uc_packed_0 >> 0) & 3U;
}
@@ -54,16 +58,21 @@ uint uc_cull_mode() {
// Pull the constants from the pipeline's specialization constants.
layout(constant_id = 0) const uint pso_sc_packed_0 = 0;
-layout(constant_id = 1) const float pso_sc_packed_1 = 2.0;
+layout(constant_id = 1) const uint pso_sc_packed_1 = 0;
+layout(constant_id = 2) const float pso_sc_packed_2 = 2.0;
uint sc_packed_0() {
return pso_sc_packed_0;
}
-float sc_packed_1() {
+uint sc_packed_1() {
return pso_sc_packed_1;
}
+float sc_packed_2() {
+ return pso_sc_packed_2;
+}
+
#endif
bool sc_use_light_projector() {
@@ -123,23 +132,23 @@ bool sc_use_lightmap_bicubic_filter() {
}
uint sc_soft_shadow_samples() {
- return (sc_packed_0() >> 16) & 15U;
+ return (sc_packed_0() >> 14) & 63U;
}
uint sc_penumbra_shadow_samples() {
- return (sc_packed_0() >> 20) & 15U;
+ return (sc_packed_0() >> 20) & 63U;
}
uint sc_directional_soft_shadow_samples() {
- return (sc_packed_0() >> 24) & 15U;
+ return (sc_packed_0() >> 26) & 63U;
}
uint sc_directional_penumbra_shadow_samples() {
- return (sc_packed_0() >> 28) & 15U;
+ return (sc_packed_1() >> 0) & 63U;
}
float sc_luminance_multiplier() {
- return sc_packed_1();
+ return sc_packed_2();
}
/* Set 0: Base Pass (never changes) */