Merge pull request #93107 from clayjohn/GLES-sky-ambient

Ensure sky reflection is updated when ambient mode is set to background
This commit is contained in:
Rémi Verschelde 2024-06-14 17:13:35 +02:00
commit c58c50831b
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 8 additions and 2 deletions

View File

@ -2398,6 +2398,7 @@ void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &p_render_
float bg_energy_multiplier = environment_get_bg_energy_multiplier(render_data.environment);
bg_energy_multiplier *= environment_get_bg_intensity(render_data.environment);
RS::EnvironmentReflectionSource reflection_source = environment_get_reflection_source(render_data.environment);
RS::EnvironmentAmbientSource ambient_source = environment_get_ambient_source(render_data.environment);
if (render_data.camera_attributes.is_valid()) {
bg_energy_multiplier *= RSG::camera_attributes->camera_attributes_get_exposure_normalization_factor(render_data.camera_attributes);
@ -2438,8 +2439,13 @@ void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &p_render_
}
}
bool sky_reflections = reflection_source == RS::ENV_REFLECTION_SOURCE_SKY;
sky_reflections |= reflection_source == RS::ENV_REFLECTION_SOURCE_BG && bg_mode == RS::ENV_BG_SKY;
bool sky_ambient = ambient_source == RS::ENV_AMBIENT_SOURCE_SKY;
sky_ambient |= ambient_source == RS::ENV_AMBIENT_SOURCE_BG && bg_mode == RS::ENV_BG_SKY;
// setup sky if used for ambient, reflections, or background
if (draw_sky || draw_sky_fog_only || (reflection_source == RS::ENV_REFLECTION_SOURCE_BG && bg_mode == RS::ENV_BG_SKY) || reflection_source == RS::ENV_REFLECTION_SOURCE_SKY || environment_get_ambient_source(render_data.environment) == RS::ENV_AMBIENT_SOURCE_SKY) {
if (draw_sky || draw_sky_fog_only || sky_reflections || sky_ambient) {
RENDER_TIMESTAMP("Setup Sky");
Projection projection = render_data.cam_projection;
if (is_reflection_probe) {
@ -2453,7 +2459,7 @@ void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &p_render_
_setup_sky(&render_data, *render_data.lights, projection, render_data.cam_transform, screen_size);
if (environment_get_sky(render_data.environment).is_valid()) {
if (environment_get_reflection_source(render_data.environment) == RS::ENV_REFLECTION_SOURCE_SKY || environment_get_ambient_source(render_data.environment) == RS::ENV_AMBIENT_SOURCE_SKY || (environment_get_reflection_source(render_data.environment) == RS::ENV_REFLECTION_SOURCE_BG && environment_get_background(render_data.environment) == RS::ENV_BG_SKY)) {
if (sky_reflections || sky_ambient) {
_update_sky_radiance(render_data.environment, projection, render_data.cam_transform, sky_energy_multiplier);
}
} else {