Skip to content

Commit baa88b9

Browse files
authored
fix variable-termination loop gradients by sampling specific lod (#19988)
# Objective - Calculating gradients in variable-termination loop is bad, and we dont need to here ## Solution - Sample mip 0 always ## Testing - volumetric_fog example
1 parent 1579256 commit baa88b9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/bevy_pbr/src/volumetric_fog/volumetric_fog.wgsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ fn fragment(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f32> {
251251
// case.
252252
let P_uvw = Ro_uvw + Rd_step_uvw * f32(step);
253253
if (all(P_uvw >= vec3(0.0)) && all(P_uvw <= vec3(1.0))) {
254-
density *= textureSample(density_texture, density_sampler, P_uvw + density_texture_offset).r;
254+
density *= textureSampleLevel(density_texture, density_sampler, P_uvw + density_texture_offset, 0.0).r;
255255
} else {
256256
density = 0.0;
257257
}

0 commit comments

Comments
 (0)