diff options
| author | skal <pascal.massimino@gmail.com> | 2026-03-10 21:47:56 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-03-10 21:47:56 +0100 |
| commit | 58112b4fbc95d188ce2c001f84a810b2c57fe3c2 (patch) | |
| tree | c2486e67e077100a7415bf6257e59d94c6115f5a | |
| parent | 3e9c66284b7a0f09a747c52cf9334c39c14b71de (diff) | |
change dither_c64() signature to take 'dimension' directly
| -rw-r--r-- | src/effects/rotating_cube.wgsl | 5 | ||||
| -rw-r--r-- | src/shaders/math/color_c64.wgsl | 8 | ||||
| -rw-r--r-- | workspaces/main/timeline.seq | 15 |
3 files changed, 12 insertions, 16 deletions
diff --git a/src/effects/rotating_cube.wgsl b/src/effects/rotating_cube.wgsl index abd584c..fcb4774 100644 --- a/src/effects/rotating_cube.wgsl +++ b/src/effects/rotating_cube.wgsl @@ -89,6 +89,7 @@ fn get_cube_normal(vid: u32) -> vec3f { let ambient = 0.3; let lighting = ambient + diffuse * 0.7; - let color = object.color.rgb * lighting; - return rgba_to_luma_chroma_phase(vec4f(color, 1.0), screen_uv.y, 264.); + var color = object.color * lighting; + color = dither_c64(color, screen_uv, uniforms.resolution / 2.); + return rgba_to_luma_chroma_phase(color, screen_uv.y, 264.); } diff --git a/src/shaders/math/color_c64.wgsl b/src/shaders/math/color_c64.wgsl index 60fde28..2a86919 100644 --- a/src/shaders/math/color_c64.wgsl +++ b/src/shaders/math/color_c64.wgsl @@ -44,10 +44,10 @@ fn colorDistance(color: vec4f, c1: vec4f, c2: vec4f, frac: f32) -> f32 { } // Quantize col to the nearest C64 color pair using 8x8 Bayer dithering. -// xsize/ysize: virtual pixel grid dimensions (e.g. 54.*8., 33.*8.). -fn dither_c64(col: vec4f, uv: vec2f, xsize: f32, ysize: f32) -> vec4f { - let ix = u32(floor(uv.x * xsize / 2.)) % 8; - let iy = u32(floor(uv.y * ysize / 2.)) % 8; +// dimension: virtual pixel grid dimensions (e.g. {54.*8., 33.*8.}). +fn dither_c64(col: vec4f, uv: vec2f, dimension: vec2f) -> vec4f { + let ix = u32(floor(uv.x * dimension.x)) % 8; + let iy = u32(floor(uv.y * dimension.y)) % 8; let thresh = f32(BAYER_8X8[ix + 8 * iy]) / 64.; var color = min(col, vec4f(1.)); diff --git a/workspaces/main/timeline.seq b/workspaces/main/timeline.seq index a054a42..ee7e1e7 100644 --- a/workspaces/main/timeline.seq +++ b/workspaces/main/timeline.seq @@ -1,14 +1,9 @@ # Demo Timeline v2 # BPM 90 -SEQUENCE 0.00 0 "intro" - EFFECT + RotatingCube source -> temp1 0.00 4.00 - EFFECT + GaussianBlur temp1 -> temp2 0.00 4.00 - EFFECT + Scratch temp2 -> sink 0.00 4.00 - -SEQUENCE 4.00 0 "rotating_cube" - EFFECT + RotatingCube source -> temp1 0.00 4.00 - EFFECT + Ntsc temp1 -> sink 0.00 4.00 +SEQUENCE 0.00 0 "rotating_cube" + EFFECT + RotatingCube source -> temp1 0.00 8.00 + EFFECT + NtscYiq temp1 -> sink 0.00 8.00 SEQUENCE 8.00 0 "scene 2" # Scene2 test @@ -32,9 +27,9 @@ SEQUENCE 20.00 0 "heptagon_scene" EFFECT + Ntsc temp1 -> sink 0.00 8.00 SEQUENCE 28.00 0 "fade_test" - # Heptagon -> Fade (placeholder) -> sink + # Heptagon -> Ntsc -> sink EFFECT + Heptagon source -> temp1 0.00 2.00 - EFFECT + Placeholder temp1 -> sink 0.00 2.00 + EFFECT + Ntsc temp1 -> sink 0.00 2.00 SEQUENCE 30.00 3 "complex_chain" # Theme (placeholder) -> Heptagon -> Blur -> ChromaAberration (placeholder) -> Solarize (placeholder) -> sink |
