diff --git a/crates/bevy_pbr/src/render/pbr_functions.wgsl b/crates/bevy_pbr/src/render/pbr_functions.wgsl index 84f7b95661..4af5f6abd7 100644 --- a/crates/bevy_pbr/src/render/pbr_functions.wgsl +++ b/crates/bevy_pbr/src/render/pbr_functions.wgsl @@ -604,21 +604,6 @@ fn apply_pbr_lighting( // Environment map light (indirect) #ifdef ENVIRONMENT_MAP - -#ifdef STANDARD_MATERIAL_ANISOTROPY - var bent_normal_lighting_input = lighting_input; - bend_normal_for_anisotropy(&bent_normal_lighting_input); - let environment_map_lighting_input = &bent_normal_lighting_input; -#else // STANDARD_MATERIAL_ANISOTROPY - let environment_map_lighting_input = &lighting_input; -#endif // STANDARD_MATERIAL_ANISOTROPY - - let environment_light = environment_map::environment_map_light( - environment_map_lighting_input, - &clusterable_object_index_ranges, - found_diffuse_indirect, - ); - // If screen space reflections are going to be used for this material, don't // accumulate environment map light yet. The SSR shader will do it. #ifdef SCREEN_SPACE_REFLECTIONS @@ -627,18 +612,25 @@ fn apply_pbr_lighting( #else // SCREEN_SPACE_REFLECTIONS let use_ssr = false; #endif // SCREEN_SPACE_REFLECTIONS - + if (!use_ssr) { +#ifdef STANDARD_MATERIAL_ANISOTROPY + var bent_normal_lighting_input = lighting_input; + bend_normal_for_anisotropy(&bent_normal_lighting_input); + let environment_map_lighting_input = &bent_normal_lighting_input; +#else // STANDARD_MATERIAL_ANISOTROPY + let environment_map_lighting_input = &lighting_input; +#endif // STANDARD_MATERIAL_ANISOTROPY + let environment_light = environment_map::environment_map_light( - &lighting_input, + environment_map_lighting_input, &clusterable_object_index_ranges, - found_diffuse_indirect + found_diffuse_indirect, ); indirect_light += environment_light.diffuse * diffuse_occlusion + environment_light.specular * specular_occlusion; } - #endif // ENVIRONMENT_MAP // Ambient light (indirect)