diff options
| -rw-r--r-- | src/effects/ntsc_rgb.wgsl | 4 | ||||
| -rw-r--r-- | src/effects/ntsc_yiq.wgsl | 7 | ||||
| -rw-r--r-- | src/shaders/render/ntsc_common.wgsl | 13 |
3 files changed, 14 insertions, 10 deletions
diff --git a/src/effects/ntsc_rgb.wgsl b/src/effects/ntsc_rgb.wgsl index 09adbf1..c377d47 100644 --- a/src/effects/ntsc_rgb.wgsl +++ b/src/effects/ntsc_rgb.wgsl @@ -18,3 +18,7 @@ fn sample_ntsc_signal(uv: vec2f) -> vec4f { } #include "render/ntsc_common" + +@fragment fn fs_main(in: VertexOutput) -> @location(0) vec4f { + return render_ntsc(in.st); +} diff --git a/src/effects/ntsc_yiq.wgsl b/src/effects/ntsc_yiq.wgsl index 8ab36d3..854620b 100644 --- a/src/effects/ntsc_yiq.wgsl +++ b/src/effects/ntsc_yiq.wgsl @@ -17,3 +17,10 @@ fn sample_ntsc_signal(uv: vec2f) -> vec4f { } #include "render/ntsc_common" + +@fragment fn fs_main(in: VertexOutput) -> @location(0) vec4f { + var col = render_ntsc(in.st); + col = debug_f32(col, in.position.xy / 2., vec2f(100., 75.), uniforms.beat_time); + col = debug_str(col, in.position.xy / 2., vec2f(100., 150.), vec4u(0x48656C6Cu, 0x6F000000u, 0u, 0u), 5u); + return col; +} diff --git a/src/shaders/render/ntsc_common.wgsl b/src/shaders/render/ntsc_common.wgsl index 61ea254..2f0d247 100644 --- a/src/shaders/render/ntsc_common.wgsl +++ b/src/shaders/render/ntsc_common.wgsl @@ -1,5 +1,6 @@ // Shared NTSC post-process constants and functions. // Requires sample_ntsc_signal(uv: vec2f) -> vec4f to be defined by the includer. +// Provides render_ntsc(). const PI = 3.14159265; const TAU = 6.28318530718; @@ -79,12 +80,12 @@ fn randomized_f32(p: vec2f, t: f32) -> f32 { return hash_2f_alt(vec2f(p * 0.152 + t * 1500. + 50.0)); } -@fragment fn fs_main(in: VertexOutput) -> @location(0) vec4f { +fn render_ntsc(st: vec2f) -> vec4f { let t = uniforms.time; let bt = uniforms.beat_phase; // Fisheye/barrel distortion - var uv = fisheye(in.st, 0.18); + var uv = fisheye(st, 0.18); let mframe = sin(bt * 32.) * 1.2; uv.y += mframe * SCAN_FLICKER / uniforms.resolution.y; // flicker at target resolution @@ -131,13 +132,5 @@ fn randomized_f32(p: vec2f, t: f32) -> f32 { let scanl = 0.82 + 0.5 * sin(PI * uv.y * uniforms.resolution.y / 2.); col = scanl * mix(border_col, col, v_strength); col = clamp(col, vec4f(0.), vec4f(1.0)); - - // Black outside screen edges - if (uv.x <= 0.0 || uv.x >= 1.0 || uv.y <= 0.0 || uv.y >= 1.0) { - // discard; - } - - col = debug_f32(col, in.position.xy / 2., vec2f(100., 75.), uniforms.beat_time); - col = debug_str(col, in.position.xy / 2., vec2f(100., 150.), vec4u(0x48656C6Cu, 0x6F000000u, 0u, 0u), 5u); return col; } |
