Refactor and improve brush

This commit is contained in:
Andras Schmelczer 2023-04-29 20:20:57 +01:00
parent 9e582110ea
commit d8a3ae7528
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
19 changed files with 368 additions and 93 deletions

View file

@ -5,8 +5,6 @@ struct Settings {
diffusionRate : f32,
decayRate : f32,
swipeRadius : f32,
swipeBlur : f32,
};
@group(0) @binding(0) var<uniform> settings : Settings;
@ -24,9 +22,11 @@ fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
+ textureSample(trailMap, Sampler, uv + vec2<f32>(1, 0) / settings.size)
);
return mix(
let mixed = mix(
current,
neighbours / 4.0,
settings.diffusionRate
) * (1.0 - settings.decayRate);
return clamp(mixed, vec4(0), vec4(1));
}