From cbafe430ef2fe3b26f048e8ba44b8d32c72133f0 Mon Sep 17 00:00:00 2001 From: Marco Buono Date: Tue, 18 Jul 2023 00:33:04 -0300 Subject: [PATCH] Add note about average being calculated to scale thickness --- crates/bevy_pbr/src/render/pbr.wgsl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/bevy_pbr/src/render/pbr.wgsl b/crates/bevy_pbr/src/render/pbr.wgsl index 3578db8dcb..6096dc8b8f 100644 --- a/crates/bevy_pbr/src/render/pbr.wgsl +++ b/crates/bevy_pbr/src/render/pbr.wgsl @@ -109,6 +109,8 @@ fn fragment( thickness *= textureSample(pbr_bindings::thickness_texture, pbr_bindings::thickness_sampler, uv).g; } #endif + // scale the thickness by the average length of basis vectors for the transform matrix + // this is a rough way to approximate the average “scale” applied to the mesh as a single scalar thickness *= (length(mesh.model[0].xyz) + length(mesh.model[1].xyz) + length(mesh.model[2].xyz)) / 3.0; pbr_input.material.thickness = thickness;