summaryrefslogtreecommitdiff
path: root/tools/shadertoy
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-10 18:53:17 +0100
committerskal <pascal.massimino@gmail.com>2026-02-10 18:53:17 +0100
commitdfe33c099d36dad6d2a62ff583e7354df0a73cca (patch)
treef63dfd5e24943f2233eba9ccde915dd9dc6400bd /tools/shadertoy
parentebceca338c902ffaa650f931a356c28a0659ebb1 (diff)
feat: Add --shader-only option to convert_shadertoy.py
Allows regenerating just the .wgsl shader file without touching .h/.cc files when iterating on shader code. Usage: ./tools/shadertoy/convert_shadertoy.py shader.txt EffectName --shader-only Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'tools/shadertoy')
-rw-r--r--tools/shadertoy/README.md3
-rwxr-xr-xtools/shadertoy/convert_shadertoy.py13
2 files changed, 15 insertions, 1 deletions
diff --git a/tools/shadertoy/README.md b/tools/shadertoy/README.md
index d12865f..283a65f 100644
--- a/tools/shadertoy/README.md
+++ b/tools/shadertoy/README.md
@@ -19,6 +19,9 @@ EOF
# Generate effect files
./tools/shadertoy/convert_shadertoy.py tunnel.txt Tunnel
+# Regenerate only shader (if .h/.cc already exist)
+./tools/shadertoy/convert_shadertoy.py tunnel.txt Tunnel --shader-only
+
# Follow printed instructions to integrate
```
diff --git a/tools/shadertoy/convert_shadertoy.py b/tools/shadertoy/convert_shadertoy.py
index 2f402cc..e85f384 100755
--- a/tools/shadertoy/convert_shadertoy.py
+++ b/tools/shadertoy/convert_shadertoy.py
@@ -296,15 +296,17 @@ def generate_shader(effect_name, shadertoy_code, is_post_process=False):
def main():
if len(sys.argv) < 3:
- print("Usage: convert_shadertoy.py <shader.txt> <EffectName> [--post-process]")
+ print("Usage: convert_shadertoy.py <shader.txt> <EffectName> [--post-process] [--shader-only]")
print()
print("Examples:")
print(" ./tools/shadertoy/convert_shadertoy.py tunnel.txt Tunnel")
print(" ./tools/shadertoy/convert_shadertoy.py blur.txt Blur --post-process")
+ print(" ./tools/shadertoy/convert_shadertoy.py tunnel.txt Tunnel --shader-only")
print()
print("Options:")
print(" --post-process Generate post-process effect (operates on previous frame)")
print(" Default: scene effect (renders geometry)")
+ print(" --shader-only Only regenerate .wgsl shader (skip .h/.cc files)")
print()
print("This will generate:")
print(" src/gpu/effects/<effect>_effect.h")
@@ -315,6 +317,7 @@ def main():
shader_file = sys.argv[1]
effect_name = sys.argv[2]
is_post_process = '--post-process' in sys.argv
+ shader_only = '--shader-only' in sys.argv
# Ensure effect name is CamelCase
if '_' in effect_name:
@@ -339,6 +342,14 @@ def main():
shader_path = repo_root / "workspaces" / "main" / "shaders" / f"{snake_name}.wgsl"
# Generate files
+ if shader_only:
+ print(f"Regenerating shader only: {effect_name}")
+ print(f" Shader: {shader_path}")
+ print()
+ shader_path.write_text(generate_shader(effect_name, shadertoy_code, is_post_process))
+ print(f"✓ Shader regenerated")
+ return
+
print(f"Generating effect: {effect_name}")
print(f" Header: {header_path}")
print(f" Impl: {impl_path}")