Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bevy_pbr: Make choosing of diffuse indirect lighting explicit. #15093

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions crates/bevy_pbr/src/render/pbr_functions.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -545,19 +545,20 @@ fn apply_pbr_lighting(
// example, both lightmaps and irradiance volumes are present.

var indirect_light = vec3(0.0f);
var found_diffuse_indirect = false;

#ifdef LIGHTMAP
if (all(indirect_light == vec3(0.0f))) {
indirect_light += in.lightmap_light * diffuse_color;
}
indirect_light += in.lightmap_light * diffuse_color;
found_diffuse_indirect = true;
#endif

#ifdef IRRADIANCE_VOLUME {
#ifdef IRRADIANCE_VOLUME
// Irradiance volume light (indirect)
if (all(indirect_light == vec3(0.0f))) {
if (!found_diffuse_indirect) {
let irradiance_volume_light = irradiance_volume::irradiance_volume_light(
in.world_position.xyz, in.N);
indirect_light += irradiance_volume_light * diffuse_color * diffuse_occlusion;
found_diffuse_indirect = true;
}
#endif

Expand All @@ -574,7 +575,7 @@ fn apply_pbr_lighting(

let environment_light = environment_map::environment_map_light(
environment_map_lighting_input,
any(indirect_light != vec3(0.0f))
found_diffuse_indirect
);

// If screen space reflections are going to be used for this material, don't
Expand All @@ -589,7 +590,7 @@ fn apply_pbr_lighting(
if (!use_ssr) {
let environment_light = environment_map::environment_map_light(
&lighting_input,
any(indirect_light != vec3(0.0f))
found_diffuse_indirect
);

indirect_light += environment_light.diffuse * diffuse_occlusion +
Expand Down