diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index eba43e1c0ba..f2cbb88d5f2 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -3728,7 +3728,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ // find an appropriate cubemap to render to for (int i = shadow_cubemaps.size() - 1; i >= 0; i--) { - if (shadow_cubemaps[i].size > shadow_size * 2) { + if (shadow_cubemaps[i].size > shadow_size) { break; } @@ -4006,7 +4006,7 @@ void RasterizerSceneGLES2::initialize() { // cubemaps for shadows if (storage->config.support_shadow_cubemaps) { //not going to be used - int max_shadow_cubemap_sampler_size = 512; + int max_shadow_cubemap_sampler_size = CLAMP(int(next_power_of_2(GLOBAL_GET("rendering/quality/shadow_atlas/size")) >> 1), 256, storage->config.max_cubemap_texture_size); int cube_size = max_shadow_cubemap_sampler_size; diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 42c9702b984..4f8af2b0e71 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -6218,6 +6218,7 @@ void RasterizerStorageGLES2::initialize() { glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &config.max_vertex_texture_image_units); glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &config.max_texture_image_units); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &config.max_texture_size); + glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &config.max_cubemap_texture_size); glGetIntegerv(GL_MAX_VIEWPORT_DIMS, config.max_viewport_dimensions); // the use skeleton software path should be used if either float texture is not supported, diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h index 264d0e65849..d6add5d54a9 100644 --- a/drivers/gles2/rasterizer_storage_gles2.h +++ b/drivers/gles2/rasterizer_storage_gles2.h @@ -63,6 +63,7 @@ public: int max_vertex_texture_image_units; int max_texture_image_units; int max_texture_size; + int max_cubemap_texture_size; int max_viewport_dimensions[2]; // TODO implement wireframe in GLES2 diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 80ac85c1e91..41e3165eb62 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -4811,7 +4811,7 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_ for (int i = shadow_cubemaps.size() - 1; i >= 0; i--) { //find appropriate cubemap to render to - if (shadow_cubemaps[i].size > shadow_size * 2) + if (shadow_cubemaps[i].size > shadow_size) break; cubemap_index = i; @@ -5110,7 +5110,7 @@ void RasterizerSceneGLES3::initialize() { shadow_atlas_realloc_tolerance_msec = 500; - int max_shadow_cubemap_sampler_size = 512; + int max_shadow_cubemap_sampler_size = CLAMP(int(next_power_of_2(GLOBAL_GET("rendering/quality/shadow_atlas/size")) >> 1), 256, storage->config.max_cubemap_texture_size); int cube_size = max_shadow_cubemap_sampler_size; diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 6736ad1ba75..31ccaac4e6b 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -8499,6 +8499,7 @@ void RasterizerStorageGLES3::initialize() { glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &config.max_texture_image_units); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &config.max_texture_size); + glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &config.max_cubemap_texture_size); config.use_rgba_2d_shadows = !config.framebuffer_float_supported; diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 77c368e90ea..928caa5b3b4 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -97,6 +97,7 @@ public: int max_texture_image_units; int max_texture_size; + int max_cubemap_texture_size; bool generate_wireframes; diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index b873aebabb2..99392fdcc63 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -2403,10 +2403,10 @@ VisualServer::VisualServer() { GLOBAL_DEF("rendering/limits/time/time_rollover_secs", 3600); ProjectSettings::get_singleton()->set_custom_property_info("rendering/limits/time/time_rollover_secs", PropertyInfo(Variant::REAL, "rendering/limits/time/time_rollover_secs", PROPERTY_HINT_RANGE, "0,10000,1,or_greater")); - GLOBAL_DEF("rendering/quality/directional_shadow/size", 4096); + GLOBAL_DEF_RST("rendering/quality/directional_shadow/size", 4096); GLOBAL_DEF("rendering/quality/directional_shadow/size.mobile", 2048); ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/directional_shadow/size", PropertyInfo(Variant::INT, "rendering/quality/directional_shadow/size", PROPERTY_HINT_RANGE, "256,16384")); - GLOBAL_DEF("rendering/quality/shadow_atlas/size", 4096); + GLOBAL_DEF_RST("rendering/quality/shadow_atlas/size", 4096); GLOBAL_DEF("rendering/quality/shadow_atlas/size.mobile", 2048); ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/size", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/size", PROPERTY_HINT_RANGE, "256,16384")); GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_0_subdiv", 1);