Skip to content

Commit 91894fe

Browse files
author
Dahmen issam
committed
Fix volume attenuation
1 parent 7517c61 commit 91894fe

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

crates/bevy_pbr/src/render/pbr_functions.wgsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,8 @@ fn apply_pbr_lighting(
857857
// and will allow us to eventually hook up subsurface scattering more easily
858858
var attenuation_fog: mesh_view_types::Fog;
859859
attenuation_fog.base_color.a = 1.0;
860-
attenuation_fog.be = pow(1.0 - in.material.attenuation_color.rgb, vec3<f32>(E)) / in.material.attenuation_distance;
860+
let attenuation_color = max(in.material.attenuation_color.rgb, vec3<f32>(1e-6));
861+
attenuation_fog.be = -log(attenuation_color) / in.material.attenuation_distance;
861862
// TODO: Add the subsurface scattering factor below
862863
// attenuation_fog.bi = /* ... */
863864
transmitted_light = bevy_pbr::fog::atmospheric_fog(

0 commit comments

Comments
 (0)