diff --git a/crates/bevy_pbr/src/render/pbr_fragment.wgsl b/crates/bevy_pbr/src/render/pbr_fragment.wgsl index 47d4f6f6d883b..d783d3bca5d15 100644 --- a/crates/bevy_pbr/src/render/pbr_fragment.wgsl +++ b/crates/bevy_pbr/src/render/pbr_fragment.wgsl @@ -148,6 +148,8 @@ fn pbr_input_from_standard_material( pbr_input.N = pbr_functions::apply_normal_mapping( pbr_bindings::material.flags, pbr_input.world_normal, + double_sided, + is_front, #ifdef VERTEX_TANGENTS #ifdef STANDARDMATERIAL_NORMAL_MAP in.world_tangent, diff --git a/crates/bevy_pbr/src/render/pbr_functions.wgsl b/crates/bevy_pbr/src/render/pbr_functions.wgsl index 9979f75be0d3a..6b8c65459d338 100644 --- a/crates/bevy_pbr/src/render/pbr_functions.wgsl +++ b/crates/bevy_pbr/src/render/pbr_functions.wgsl @@ -61,6 +61,8 @@ fn prepare_world_normal( fn apply_normal_mapping( standard_material_flags: u32, world_normal: vec3, + double_sided: bool, + is_front: bool, #ifdef VERTEX_TANGENTS #ifdef STANDARDMATERIAL_NORMAL_MAP world_tangent: vec4, @@ -106,6 +108,11 @@ fn apply_normal_mapping( if (standard_material_flags & pbr_types::STANDARD_MATERIAL_FLAGS_FLIP_NORMAL_MAP_Y) != 0u { Nt.y = -Nt.y; } + + if double_sided && !is_front { + Nt = -Nt; + } + // NOTE: The mikktspace method of normal mapping applies maps the tangent-space normal from // the normal map texture in this way to be an EXACT inverse of how the normal map baker // calculates the normal maps so there is no error introduced. Do not change this code