summaryrefslogtreecommitdiff
path: root/workspaces/main/shaders
AgeCommit message (Collapse)Author
18 hoursfix: Support variable kernel sizes in CNN layer generationskal
Training script was hardcoded to generate cnn_conv3x3_* calls regardless of actual kernel size, causing shader validation errors when layer 1 used 5×5 kernel (100 weights) but called 3×3 function (expected 36). Changes: - train_cnn.py: Generate correct conv function based on kernel_sizes[i] - cnn_conv5x5.wgsl: Add cnn_conv5x5_7to4 and cnn_conv5x5_7to1 variants - Regenerate cnn_layer.wgsl with correct function calls for [3,5,3] - Document kernel size→function mapping in HOWTO.md Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
18 hoursfeat: CNN RGBD→grayscale with 7-channel augmented inputskal
Upgrade CNN architecture to process RGBD input, output grayscale, with 7-channel layer inputs (RGBD + UV coords + grayscale). Architecture changes: - Inner layers: Conv2d(7→4) output RGBD - Final layer: Conv2d(7→1) output grayscale - All inputs normalized to [-1,1] for tanh activation - Removed CoordConv2d in favor of unified 7-channel input Training (train_cnn.py): - SimpleCNN: 7→4 (inner), 7→1 (final) architecture - Forward: Normalize RGBD/coords/gray to [-1,1] - Weight export: array<array<f32, 8>, 36> (inner), array<f32, 8>, 9> (final) - Dataset: Load RGBA (RGBD) input Shaders (cnn_conv3x3.wgsl): - Added cnn_conv3x3_7to4: 7-channel input → RGBD output - Added cnn_conv3x3_7to1: 7-channel input → grayscale output - Both normalize inputs and use flattened weight arrays Documentation: - CNN_EFFECT.md: Updated architecture, training, weight format - CNN_RGBD_GRAYSCALE_SUMMARY.md: Implementation summary - HOWTO.md: Added training command example Next: Train with RGBD input data Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
19 hoursfix: Resolve CNN effect black screen bug (framebuffer capture + uniforms)skal
Two bugs causing black screen when CNN post-processing activated: 1. Framebuffer capture timing: Capture ran inside post-effect loop after ping-pong swaps, causing layers 1+ to capture wrong buffer. Moved capture before loop to copy framebuffer_a once before post-chain starts. 2. Missing uniforms update: CNNEffect never updated uniforms_ buffer, leaving uniforms.resolution uninitialized (0,0). UV calculation p.xy/uniforms.resolution produced NaN, causing all texture samples to return black. Added uniforms update in update_bind_group(). Files modified: - src/gpu/effect.cc: Capture before post-chain (lines 308-346) - src/gpu/effects/cnn_effect.cc: Add uniforms update (lines 132-142) - workspaces/main/shaders/cnn/cnn_layer.wgsl: Remove obsolete comment - doc/CNN_DEBUG.md: Historical debugging doc - CLAUDE.md: Reference CNN_DEBUG.md in historical section Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
22 hoursfeat: Add multi-layer CNN support with framebuffer capture and blend controlskal
Implements automatic layer chaining and generic framebuffer capture API for multi-layer neural network effects with proper original input preservation. Key changes: - Effect::needs_framebuffer_capture() - generic API for pre-render capture - MainSequence: auto-capture to "captured_frame" auxiliary texture - CNNEffect: multi-layer support via layer_index/total_layers params - seq_compiler: expands "layers=N" to N chained effect instances - Shader: @binding(4) original_input available to all layers - Training: generates layer switches and original input binding - Blend: mix(original, result, blend_amount) uses layer 0 input Timeline syntax: CNNEffect layers=3 blend=0.7 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
25 hoursfeat: Add coordinate-aware CNN layer 0 for position-dependent stylizationskal
- Implement CoordConv2d custom layer accepting (x,y) patch center - Split layer 0 weights: rgba_weights (9x mat4x4) + coord_weights (mat2x4) - Add *_with_coord() functions to 3x3/5x5/7x7 convolution shaders - Update training script to generate coordinate grid and export split weights - Regenerate placeholder weights with new format Size impact: +32B coord weights + ~100B shader code = +132B total All 36 tests passing (100%) handoff(Claude): CNN coordinate awareness implemented, ready for training Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
27 hoursfeat: Add CNN post-processing effect with modular WGSL architectureskal
Implements multi-layer convolutional neural network shader for stylized post-processing of 3D rendered scenes: **Core Components:** - CNNEffect: C++ effect class with single-layer rendering (expandable to multi-pass) - Modular WGSL snippets: cnn_activation, cnn_conv3x3/5x5/7x7, cnn_weights_generated - Placeholder identity-like weights for initial testing (to be replaced by trained weights) **Architecture:** - Flexible kernel sizes (3×3, 5×5, 7×7) via separate snippet files - ShaderComposer integration (#include resolution) - Residual connections (input + processed output) - Supports parallel convolutions (design ready, single conv implemented) **Size Impact:** - ~3-4 KB shader code (snippets + main shader) - ~2-4 KB weights (depends on network architecture when trained) - Total: ~5-8 KB (acceptable for 64k demo) **Testing:** - CNNEffect added to test_demo_effects.cc - 36/36 tests passing (100%) **Next Steps:** - Training script (scripts/train_cnn.py) to generate real weights - Multi-layer rendering with ping-pong textures - Weight quantization for size optimization handoff(Claude): CNN effect foundation complete, ready for training integration
40 hoursfeat: Implement workspace system (Task #77)skal
Self-contained workspaces for parallel demo development. Structure: - workspaces/main,test - Demo-specific resources - assets/common - Shared resources - workspace.cfg - Configuration per workspace CMake integration: - DEMO_WORKSPACE option (defaults to main) - cmake/ParseWorkspace.cmake - Config parser - Workspace-relative asset/timeline/music paths Migration: - Main demo: demo.seq to workspaces/main/timeline.seq - Test demo: test_demo.seq to workspaces/test/timeline.seq - Common shaders: assets/common/shaders - Workspace shaders: workspaces/*/shaders Build: cmake -B build -DDEMO_WORKSPACE=main cmake -B build_test -DDEMO_WORKSPACE=test All tests passing (36/36). handoff(Claude): Task #77 workspace system complete. Both main and test workspaces build and pass all tests. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>