diff options
Diffstat (limited to 'doc/CONTRIBUTING.md')
| -rw-r--r-- | doc/CONTRIBUTING.md | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md index 7fbfd64..c077342 100644 --- a/doc/CONTRIBUTING.md +++ b/doc/CONTRIBUTING.md @@ -66,22 +66,30 @@ See `doc/CODING_STYLE.md` for detailed examples. ### Adding Visual Effect -**For SDF/raymarching effects:** Use `SDFEffect` base class (see `doc/SDF_EFFECT_GUIDE.md`). +**Full workflow:** See `doc/EFFECT_WORKFLOW.md`. -**For standard effects:** -1. Create effect class files (each effect should have its own `.h` and `.cc` file, e.g., `src/effects/my_effect.h` and `src/effects/my_effect.cc`). Use `tools/shadertoy/convert_shadertoy.py` or templates. -2. Add shader to `workspaces/main/assets.txt` -3. Add effect `.cc` file to `CMakeLists.txt` GPU_SOURCES (both sections) -4. Include header in `src/gpu/demo_effects.h` (which now serves as a central include for all individual effect headers) -5. Add to workspace `timeline.seq` (e.g., `workspaces/main/timeline.seq`) -6. **Update `src/tests/gpu/test_demo_effects.cc`**: - - Add to `post_process_effects` list (lines 80-93) or `scene_effects` list (lines 125-137) - - Example: `{"MyEffect", std::make_shared<MyEffect>(fixture.ctx())},` -7. Verify: +**Simple post-process (shader only) — WgslEffect path:** +1. Write `src/effects/<name>.wgsl` +2. Add to `workspaces/main/assets.txt` +3. Create `src/effects/<name>_effect.h` as a thin wrapper (no `.cc`, no CMake entry): + ```cpp + struct MyEffect : public WgslEffect { + MyEffect(const GpuContext& ctx, const std::vector<std::string>& inputs, + const std::vector<std::string>& outputs, float s, float e) + : WgslEffect(ctx, inputs, outputs, s, e, my_shader_wgsl) {} + }; + ``` +4. Add `extern const char* my_shader_wgsl;` to `shaders.h`, definition to `shaders.cc` +5. Include in `src/gpu/demo_effects.h`, add test entry in `test_demo_effects.cc` +6. Add to `workspaces/main/timeline.seq` + +**Complex effects (custom uniforms / 3D / compute):** follow all 7 steps in `doc/EFFECT_WORKFLOW.md`. + +**For SDF/raymarching effects:** See `doc/SDF_EFFECT_GUIDE.md`. + +Verify: ```bash -cmake -S . -B build -DDEMO_BUILD_TESTS=ON -cmake --build build -j4 --target test_demo_effects -cd build && ./test_demo_effects +cmake --build build -j4 && cd build && ./test_demo_effects ``` ### Audio Initialization |
