diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-16 10:03:18 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-16 10:03:18 +0100 |
| commit | 2e33a435d6f1efee5a6c88cbfc99b97241fe2ad3 (patch) | |
| tree | 6eb1890a738ff9050835cd88bc4cadebeeb390c8 /workspaces/main | |
| parent | a126caf9e52b8f7c5be8e09b303e741aa9a410cb (diff) | |
feat(sequence): port rotating_cube_effect to v2
- Add RotatingCubeEffectV2 with 3D rendering + depth buffer
- Create rotating_cube_v2.wgsl (hardcoded cube geometry)
- Simplified: no auxiliary mask texture dependency
- Declare depth node via NodeRegistry
- Update timeline_v2.seq rotating_cube sequence
- Add shader exports to shaders.{h,cc}
- All 36 tests passing
handoff(Claude): RotatingCube v2 complete, hybrid_3d next
Diffstat (limited to 'workspaces/main')
| -rw-r--r-- | workspaces/main/assets.txt | 1 | ||||
| -rw-r--r-- | workspaces/main/shaders/rotating_cube_v2.wgsl | 89 | ||||
| -rw-r--r-- | workspaces/main/timeline_v2.seq | 7 |
3 files changed, 93 insertions, 4 deletions
diff --git a/workspaces/main/assets.txt b/workspaces/main/assets.txt index fe15cdf..9d15213 100644 --- a/workspaces/main/assets.txt +++ b/workspaces/main/assets.txt @@ -35,6 +35,7 @@ SHADER_PARTICLE_COMPUTE, NONE, shaders/particle_compute.wgsl, "Particle Compute SHADER_PARTICLE_RENDER, NONE, shaders/particle_render.wgsl, "Particle Render Shader" SHADER_PARTICLE_COMPUTE_V2, NONE, shaders/particle_compute_v2.wgsl, "Particle Compute Shader V2" SHADER_PARTICLE_RENDER_V2, NONE, shaders/particle_render_v2.wgsl, "Particle Render Shader V2" +SHADER_ROTATING_CUBE_V2, NONE, shaders/rotating_cube_v2.wgsl, "Rotating Cube Shader V2" SHADER_PASSTHROUGH, NONE, ../../common/shaders/passthrough.wgsl, "Passthrough Shader" SHADER_ELLIPSE, NONE, shaders/ellipse.wgsl, "Ellipse Shader" SHADER_PARTICLE_SPRAY_COMPUTE, NONE, shaders/particle_spray_compute.wgsl, "Particle Spray Compute" diff --git a/workspaces/main/shaders/rotating_cube_v2.wgsl b/workspaces/main/shaders/rotating_cube_v2.wgsl new file mode 100644 index 0000000..d7e4cae --- /dev/null +++ b/workspaces/main/shaders/rotating_cube_v2.wgsl @@ -0,0 +1,89 @@ +// Rotating cube shader v2 (simplified, no masking) + +struct Uniforms { + view_proj: mat4x4<f32>, + inv_view_proj: mat4x4<f32>, + camera_pos_time: vec4<f32>, + params: vec4<f32>, + resolution: vec2<f32>, + aspect_ratio: f32, + _pad: f32, +}; + +struct ObjectData { + model: mat4x4<f32>, + inv_model: mat4x4<f32>, + color: vec4<f32>, + params: vec4<f32>, +}; + +@group(0) @binding(0) var<uniform> uniforms: Uniforms; +@group(0) @binding(1) var<storage, read> object: ObjectData; + +struct VSOut { + @builtin(position) pos: vec4<f32>, + @location(0) world_pos: vec3<f32>, + @location(1) normal: vec3<f32>, +}; + +// Cube vertices (hardcoded) +fn get_cube_vertex(vid: u32) -> vec3<f32> { + let positions = array<vec3<f32>, 36>( + // Front face + vec3<f32>(-1, -1, 1), vec3<f32>( 1, -1, 1), vec3<f32>( 1, 1, 1), + vec3<f32>(-1, -1, 1), vec3<f32>( 1, 1, 1), vec3<f32>(-1, 1, 1), + // Back face + vec3<f32>( 1, -1, -1), vec3<f32>(-1, -1, -1), vec3<f32>(-1, 1, -1), + vec3<f32>( 1, -1, -1), vec3<f32>(-1, 1, -1), vec3<f32>( 1, 1, -1), + // Right face + vec3<f32>( 1, -1, 1), vec3<f32>( 1, -1, -1), vec3<f32>( 1, 1, -1), + vec3<f32>( 1, -1, 1), vec3<f32>( 1, 1, -1), vec3<f32>( 1, 1, 1), + // Left face + vec3<f32>(-1, -1, -1), vec3<f32>(-1, -1, 1), vec3<f32>(-1, 1, 1), + vec3<f32>(-1, -1, -1), vec3<f32>(-1, 1, 1), vec3<f32>(-1, 1, -1), + // Top face + vec3<f32>(-1, 1, 1), vec3<f32>( 1, 1, 1), vec3<f32>( 1, 1, -1), + vec3<f32>(-1, 1, 1), vec3<f32>( 1, 1, -1), vec3<f32>(-1, 1, -1), + // Bottom face + vec3<f32>(-1, -1, -1), vec3<f32>( 1, -1, -1), vec3<f32>( 1, -1, 1), + vec3<f32>(-1, -1, -1), vec3<f32>( 1, -1, 1), vec3<f32>(-1, -1, 1) + ); + return positions[vid]; +} + +fn get_cube_normal(vid: u32) -> vec3<f32> { + let face_id = vid / 6u; + let normals = array<vec3<f32>, 6>( + vec3<f32>( 0, 0, 1), // Front + vec3<f32>( 0, 0, -1), // Back + vec3<f32>( 1, 0, 0), // Right + vec3<f32>(-1, 0, 0), // Left + vec3<f32>( 0, 1, 0), // Top + vec3<f32>( 0, -1, 0) // Bottom + ); + return normals[face_id]; +} + +@vertex fn vs_main(@builtin(vertex_index) vid: u32) -> VSOut { + let local_pos = get_cube_vertex(vid); + let local_normal = get_cube_normal(vid); + + let world_pos = object.model * vec4<f32>(local_pos, 1.0); + let world_normal = normalize((object.model * vec4<f32>(local_normal, 0.0)).xyz); + + let clip_pos = uniforms.view_proj * world_pos; + + return VSOut(clip_pos, world_pos.xyz, world_normal); +} + +@fragment fn fs_main(@location(0) world_pos: vec3<f32>, @location(1) normal: vec3<f32>) -> @location(0) vec4<f32> { + let N = normalize(normal); + let light_dir = normalize(vec3<f32>(1.0, 1.0, 1.0)); + let diffuse = max(dot(N, light_dir), 0.0); + + let ambient = 0.3; + let lighting = ambient + diffuse * 0.7; + + let color = object.color.rgb * lighting; + return vec4<f32>(color, 1.0); +} diff --git a/workspaces/main/timeline_v2.seq b/workspaces/main/timeline_v2.seq index 2dc1720..3c97f7b 100644 --- a/workspaces/main/timeline_v2.seq +++ b/workspaces/main/timeline_v2.seq @@ -7,10 +7,9 @@ SEQUENCE 0.00 0 "intro" EFFECT + PlaceholderEffect temp1 -> sink 0.00 4.00 SEQUENCE 4.00 0 "rotating_cube" - # CircleMask (placeholder) -> RotatingCube (placeholder) -> Blur -> sink - EFFECT + PlaceholderEffect source -> temp1 0.00 4.00 - EFFECT + PlaceholderEffect temp1 -> temp2 0.00 4.00 - EFFECT + GaussianBlurEffect temp2 -> sink 1.00 4.00 + # RotatingCube -> Blur -> sink + EFFECT + RotatingCubeEffectV2 source -> temp1 0.00 4.00 + EFFECT + GaussianBlurEffect temp1 -> sink 1.00 4.00 SEQUENCE 8.00 0 "flash_cube" # FlashCube (placeholder) -> Flash (placeholder) -> sink |
