Changes to GLES2 renderer to not use cube shadows if not available, fixes #25132
This commit is contained in:
parent
6ab16512eb
commit
46af4b0a4b
@ -2877,7 +2877,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
|
||||
|
||||
if (light->type == VS::LIGHT_OMNI) {
|
||||
// cubemap only
|
||||
if (light->omni_shadow_mode == VS::LIGHT_OMNI_SHADOW_CUBE) {
|
||||
if (light->omni_shadow_mode == VS::LIGHT_OMNI_SHADOW_CUBE && storage->config.support_write_depth) {
|
||||
int cubemap_index = shadow_cubemaps.size() - 1;
|
||||
|
||||
// find an appropriate cubemap to render to
|
||||
@ -2973,7 +2973,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_
|
||||
state.scene_shader.set_conditional(SceneShaderGLES2::RENDER_DEPTH_DUAL_PARABOLOID, false);
|
||||
|
||||
// convert cubemap to dual paraboloid if needed
|
||||
if (light->type == VS::LIGHT_OMNI && light->omni_shadow_mode == VS::LIGHT_OMNI_SHADOW_CUBE && p_pass == 5) {
|
||||
if (light->type == VS::LIGHT_OMNI && (light->omni_shadow_mode == VS::LIGHT_OMNI_SHADOW_CUBE && storage->config.support_write_depth) && p_pass == 5) {
|
||||
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, shadow_atlas->fbo);
|
||||
|
@ -473,6 +473,7 @@ public:
|
||||
virtual void light_instance_set_transform(RID p_light_instance, const Transform &p_transform);
|
||||
virtual void light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform &p_transform, float p_far, float p_split, int p_pass, float p_bias_scale = 1.0);
|
||||
virtual void light_instance_mark_visible(RID p_light_instance);
|
||||
virtual bool light_instances_can_render_shadow_cube() const { return storage->config.support_write_depth; }
|
||||
|
||||
LightInstance **render_light_instances;
|
||||
int render_directional_lights;
|
||||
|
@ -4673,6 +4673,13 @@ void RasterizerStorageGLES2::initialize() {
|
||||
config.support_32_bits_indices = config.extensions.has("GL_OES_element_index_uint");
|
||||
#endif
|
||||
|
||||
#ifdef GLES_OVER_GL
|
||||
config.support_write_depth = true;
|
||||
#else
|
||||
config.support_write_depth = config.extensions.has("GL_EXT_frag_depth");
|
||||
#endif
|
||||
|
||||
|
||||
frame.count = 0;
|
||||
frame.delta = 0;
|
||||
frame.current_rt = NULL;
|
||||
|
@ -80,6 +80,7 @@ public:
|
||||
bool use_rgba_2d_shadows;
|
||||
|
||||
bool support_32_bits_indices;
|
||||
bool support_write_depth;
|
||||
} config;
|
||||
|
||||
struct Resources {
|
||||
|
@ -1832,6 +1832,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
|
||||
storage->info.render.vertices_count += s->index_array_len * amount;
|
||||
} else
|
||||
#endif
|
||||
|
||||
if (s->index_array_len > 0) {
|
||||
|
||||
glDrawElementsInstanced(gl_primitive[s->primitive], s->index_array_len, (s->array_len >= (1 << 16)) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, 0, amount);
|
||||
|
@ -141,6 +141,7 @@ public:
|
||||
virtual void light_instance_set_transform(RID p_light_instance, const Transform &p_transform) = 0;
|
||||
virtual void light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform &p_transform, float p_far, float p_split, int p_pass, float p_bias_scale = 1.0) = 0;
|
||||
virtual void light_instance_mark_visible(RID p_light_instance) = 0;
|
||||
virtual bool light_instances_can_render_shadow_cube() const { return true; }
|
||||
|
||||
virtual RID reflection_atlas_create() = 0;
|
||||
virtual void reflection_atlas_set_size(RID p_ref_atlas, int p_size) = 0;
|
||||
|
@ -1535,8 +1535,7 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
|
||||
|
||||
VS::LightOmniShadowMode shadow_mode = VSG::storage->light_omni_get_shadow_mode(p_instance->base);
|
||||
|
||||
switch (shadow_mode) {
|
||||
case VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID: {
|
||||
if (shadow_mode == VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID || !VSG::scene_render->light_instances_can_render_shadow_cube()) {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
@ -1576,8 +1575,7 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
|
||||
VSG::scene_render->light_instance_set_shadow_transform(light->instance, CameraMatrix(), light_transform, radius, 0, i);
|
||||
VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count);
|
||||
}
|
||||
} break;
|
||||
case VS::LIGHT_OMNI_SHADOW_CUBE: {
|
||||
} else { //shadow cube
|
||||
|
||||
float radius = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_RANGE);
|
||||
CameraMatrix cm;
|
||||
@ -1633,8 +1631,6 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
|
||||
|
||||
//restore the regular DP matrix
|
||||
VSG::scene_render->light_instance_set_shadow_transform(light->instance, CameraMatrix(), light_transform, radius, 0, 0);
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
} break;
|
||||
|
Loading…
Reference in New Issue
Block a user