Refactor & improve
This commit is contained in:
parent
b51cba28ad
commit
b3d9229af5
22 changed files with 713 additions and 334 deletions
|
|
@ -1,14 +1,9 @@
|
|||
struct Settings {
|
||||
size: vec2<f32>,
|
||||
deltaTime: f32,
|
||||
time: f32,
|
||||
brushWidth: f32,
|
||||
brushWidthRandomness: f32
|
||||
};
|
||||
|
||||
@group(0) @binding(0) var<uniform> settings: Settings;
|
||||
@group(0) @binding(1) var Sampler: sampler;
|
||||
@group(0) @binding(2) var noise: texture_2d<f32>;
|
||||
@group(1) @binding(0) var<uniform> settings: Settings;
|
||||
|
||||
struct VertexOutput {
|
||||
@builtin(position) position: vec4<f32>,
|
||||
|
|
@ -23,7 +18,7 @@ fn vertex(
|
|||
@location(1) @interpolate(flat) start: vec2<f32>,
|
||||
@location(2) @interpolate(flat) end: vec2<f32>
|
||||
) -> VertexOutput {
|
||||
let uv = screenPosition / settings.size;
|
||||
let uv = screenPosition / state.size;
|
||||
let position = uv * 2.0 - 1.0;
|
||||
return VertexOutput(vec4(position, 0.0, 1.0), screenPosition, start, end);
|
||||
}
|
||||
|
|
@ -35,7 +30,7 @@ fn fragment(
|
|||
@location(2) end: vec2<f32>
|
||||
) -> @location(0) vec4<f32> {
|
||||
var distance = distanceFromLine(screenPosition, start, end);
|
||||
let noise = textureSample(noise, Sampler, screenPosition / settings.size);
|
||||
let noise = textureSample(noise, noiseSampler, screenPosition / state.size / 50);
|
||||
distance += noise.r * settings.brushWidthRandomness;
|
||||
|
||||
if(distance > settings.brushWidth) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue