Skip to content

Commit 7948308

Browse files
committed
flux: implement blend between line noises
This is used to conceal the noise offset reset. The offset is reset to 1. avoid overflow 2. reduce floating-point precision issues.
1 parent d6eef85 commit 7948308

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

flux/shader/place_lines.comp.wgsl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,15 @@ fn main(
125125
let basepoint = basepoints[index];
126126
let line = lines[index];
127127
let velocity = textureSampleLevel(velocity_texture, linear_sampler, basepoint, 0.0).xy;
128-
let noise = snoise(vec3(uniforms.line_noise_scale * basepoint, uniforms.line_noise_offset_1));
128+
129+
// Blend the two noises when reaching the limit of the offset
130+
let scaled_pos = uniforms.line_noise_scale * basepoint;
131+
let noise1 = snoise(vec3(scaled_pos, uniforms.line_noise_offset_1));
132+
var noise = noise1;
133+
if (uniforms.line_noise_blend_factor > 0.0) {
134+
let noise2 = snoise(vec3(scaled_pos, uniforms.line_noise_offset_2));
135+
noise = mix(noise1, noise2, uniforms.line_noise_blend_factor);
136+
}
129137

130138
let variance = mix(1.0 - uniforms.line_variance, 1.0, 0.5 + 0.5 * noise);
131139
let velocity_delta_boost = mix(3.0, 25.0, 1.0 - variance);

0 commit comments

Comments
 (0)