diff options
Diffstat (limited to 'src/effects/rotating_cube.wgsl')
| -rw-r--r-- | src/effects/rotating_cube.wgsl | 11 |
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.); } |
