summaryrefslogtreecommitdiff
path: root/src/effects/rotating_cube.wgsl
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-03-10 09:33:41 +0100
committerskal <pascal.massimino@gmail.com>2026-03-10 09:33:41 +0100
commit7ca40818e3d0401f97efae6fe876038df4f5bd00 (patch)
tree455d124beba7b08ffbb482bff49963ad5cdbdcbd /src/effects/rotating_cube.wgsl
parentef205b6eda78f1dcf65aa696dedf1f8c0707ff30 (diff)
rotating_cube: use VSOut, and store to yiq
Diffstat (limited to 'src/effects/rotating_cube.wgsl')
-rw-r--r--src/effects/rotating_cube.wgsl11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/effects/rotating_cube.wgsl b/src/effects/rotating_cube.wgsl
index 0c75a13..abd584c 100644
--- a/src/effects/rotating_cube.wgsl
+++ b/src/effects/rotating_cube.wgsl
@@ -1,4 +1,8 @@
// Rotating cube shader v2 (simplified, no masking)
+// output to YIQ color space
+
+#include "math/color"
+#include "math/color_c64"
struct Uniforms {
view_proj: mat4x4f,
@@ -76,8 +80,9 @@ fn get_cube_normal(vid: u32) -> vec3f {
return VSOut(clip_pos, world_pos.xyz, world_normal);
}
-@fragment fn fs_main(@location(0) world_pos: vec3f, @location(1) normal: vec3f) -> @location(0) vec4f {
- let N = normalize(normal);
+@fragment fn fs_main(in: VSOut) -> @location(0) vec4f {
+ let screen_uv = in.pos.xy / uniforms.resolution;
+ let N = in.normal; // not re-normalized: cube faces are flat, no drift
let light_dir = normalize(vec3f(1.0, 1.0, 1.0));
let diffuse = max(dot(N, light_dir), 0.0);
@@ -85,5 +90,5 @@ fn get_cube_normal(vid: u32) -> vec3f {
let lighting = ambient + diffuse * 0.7;
let color = object.color.rgb * lighting;
- return vec4f(color, 1.0);
+ return rgba_to_luma_chroma_phase(vec4f(color, 1.0), screen_uv.y, 264.);
}