You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Fix shadow disabling settings
Fixes the SHADOW_CASTING_SETTING_OFF setting in GeometryInstance3D and the "shadows_disabled" render mode in spatial materials, which were not working before.
This commit is contained in:
@@ -1251,6 +1251,7 @@ void main() {
|
|||||||
|
|
||||||
{ //directional light
|
{ //directional light
|
||||||
|
|
||||||
|
#ifndef SHADOWS_DISABLED
|
||||||
// Do shadow and lighting in two passes to reduce register pressure
|
// Do shadow and lighting in two passes to reduce register pressure
|
||||||
uint shadow0 = 0;
|
uint shadow0 = 0;
|
||||||
uint shadow1 = 0;
|
uint shadow1 = 0;
|
||||||
@@ -1449,6 +1450,7 @@ void main() {
|
|||||||
shadow1 |= uint(clamp(shadow * 255.0, 0.0, 255.0)) << ((i - 4) * 8);
|
shadow1 |= uint(clamp(shadow * 255.0, 0.0, 255.0)) << ((i - 4) * 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // SHADOWS_DISABLED
|
||||||
|
|
||||||
for (uint i = 0; i < 8; i++) {
|
for (uint i = 0; i < 8; i++) {
|
||||||
if (i >= scene_data.directional_light_count) {
|
if (i >= scene_data.directional_light_count) {
|
||||||
@@ -1511,12 +1513,13 @@ void main() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
float shadow = 1.0;
|
float shadow = 1.0;
|
||||||
|
#ifndef SHADOWS_DISABLED
|
||||||
if (i < 4) {
|
if (i < 4) {
|
||||||
shadow = float(shadow0 >> (i * 8) & 0xFF) / 255.0;
|
shadow = float(shadow0 >> (i * 8) & 0xFF) / 255.0;
|
||||||
} else {
|
} else {
|
||||||
shadow = float(shadow1 >> ((i - 4) * 8) & 0xFF) / 255.0;
|
shadow = float(shadow1 >> ((i - 4) * 8) & 0xFF) / 255.0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
blur_shadow(shadow);
|
blur_shadow(shadow);
|
||||||
|
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, float atte
|
|||||||
#endif //defined(LIGHT_CODE_USED)
|
#endif //defined(LIGHT_CODE_USED)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_NO_SHADOWS
|
#ifndef SHADOWS_DISABLED
|
||||||
|
|
||||||
// Interleaved Gradient Noise
|
// Interleaved Gradient Noise
|
||||||
// https://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
|
// https://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
|
||||||
@@ -433,7 +433,7 @@ float sample_directional_soft_shadow(texture2D shadow, vec3 pssm_coord, vec2 tex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //USE_NO_SHADOWS
|
#endif // SHADOWS_DISABLED
|
||||||
|
|
||||||
float get_omni_attenuation(float distance, float inv_range, float decay) {
|
float get_omni_attenuation(float distance, float inv_range, float decay) {
|
||||||
float nd = distance * inv_range;
|
float nd = distance * inv_range;
|
||||||
@@ -445,7 +445,7 @@ float get_omni_attenuation(float distance, float inv_range, float decay) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float light_process_omni_shadow(uint idx, vec3 vertex, vec3 normal) {
|
float light_process_omni_shadow(uint idx, vec3 vertex, vec3 normal) {
|
||||||
#ifndef USE_NO_SHADOWS
|
#ifndef SHADOWS_DISABLED
|
||||||
if (omni_lights.data[idx].shadow_enabled) {
|
if (omni_lights.data[idx].shadow_enabled) {
|
||||||
// there is a shadowmap
|
// there is a shadowmap
|
||||||
vec2 texel_size = scene_data.shadow_atlas_pixel_size;
|
vec2 texel_size = scene_data.shadow_atlas_pixel_size;
|
||||||
@@ -730,7 +730,7 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 v
|
|||||||
}
|
}
|
||||||
|
|
||||||
float light_process_spot_shadow(uint idx, vec3 vertex, vec3 normal) {
|
float light_process_spot_shadow(uint idx, vec3 vertex, vec3 normal) {
|
||||||
#ifndef USE_NO_SHADOWS
|
#ifndef SHADOWS_DISABLED
|
||||||
if (spot_lights.data[idx].shadow_enabled) {
|
if (spot_lights.data[idx].shadow_enabled) {
|
||||||
vec3 light_rel_vec = spot_lights.data[idx].position - vertex;
|
vec3 light_rel_vec = spot_lights.data[idx].position - vertex;
|
||||||
float light_length = length(light_rel_vec);
|
float light_length = length(light_rel_vec);
|
||||||
@@ -806,7 +806,7 @@ float light_process_spot_shadow(uint idx, vec3 vertex, vec3 normal) {
|
|||||||
return shadow;
|
return shadow;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //USE_NO_SHADOWS
|
#endif // SHADOWS_DISABLED
|
||||||
|
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1139,7 +1139,7 @@ void RendererSceneCull::instance_geometry_set_cast_shadows_setting(RID p_instanc
|
|||||||
if (instance->scenario && instance->array_index >= 0) {
|
if (instance->scenario && instance->array_index >= 0) {
|
||||||
InstanceData &idata = instance->scenario->instance_data[instance->array_index];
|
InstanceData &idata = instance->scenario->instance_data[instance->array_index];
|
||||||
|
|
||||||
if (instance->cast_shadows != RS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
|
if (instance->cast_shadows != RS::SHADOW_CASTING_SETTING_OFF) {
|
||||||
idata.flags |= InstanceData::FLAG_CAST_SHADOWS;
|
idata.flags |= InstanceData::FLAG_CAST_SHADOWS;
|
||||||
} else {
|
} else {
|
||||||
idata.flags &= ~uint32_t(InstanceData::FLAG_CAST_SHADOWS);
|
idata.flags &= ~uint32_t(InstanceData::FLAG_CAST_SHADOWS);
|
||||||
@@ -1603,7 +1603,7 @@ void RendererSceneCull::_update_instance(Instance *p_instance) {
|
|||||||
//always dirty when added
|
//always dirty when added
|
||||||
idata.flags |= InstanceData::FLAG_REFLECTION_PROBE_DIRTY;
|
idata.flags |= InstanceData::FLAG_REFLECTION_PROBE_DIRTY;
|
||||||
}
|
}
|
||||||
if (p_instance->cast_shadows != RS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
|
if (p_instance->cast_shadows != RS::SHADOW_CASTING_SETTING_OFF) {
|
||||||
idata.flags |= InstanceData::FLAG_CAST_SHADOWS;
|
idata.flags |= InstanceData::FLAG_CAST_SHADOWS;
|
||||||
}
|
}
|
||||||
if (p_instance->cast_shadows == RS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
|
if (p_instance->cast_shadows == RS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
|
||||||
|
|||||||
Reference in New Issue
Block a user