Skip to content

Commit

Permalink
Merge pull request #93107 from clayjohn/GLES-sky-ambient
Browse files Browse the repository at this point in the history
Ensure sky reflection is updated when ambient mode is set to background
  • Loading branch information
akien-mga committed Jun 14, 2024
2 parents 75eb8ad + b758658 commit c58c508
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down

0 comments on commit c58c508

Please sign in to comment.