hShadertoy

Experimental Shadertoy.com importer for Houdini 21 Copernicus

https://youtu.be/3tn9HGVOtD8

What is this?

“You know what would be cool, if you could import a Shadertoy shader to Houdini COPs, do you think it’s possible?”

It is. hShadertoy fetches a shader straight from Shadertoy.com and rebuilds it as a native Copernicus network - including multi-pass buffers, cubemaps and textures. The GLSL is translated to OpenCL on the fly. Madness!

How it works

  1. Editor - a Shadertoy mini-IDE on the hShadertoy shelf. Browse, fetch by URL/ID, import (Shadertoy API JSON in/out).
  2. Builder - creates the hShadertoy HDA and wires every renderpass up.
  3. Transpiler - translates each GLSL pass to OpenCL for Copernicus.

The hShadertoy Editor

The generated HDA exposes every Shadertoy renderpass as parameters, backed by a Copernicus subnet:

hShadertoy HDA parameters

hShadertoy HDA subnet

Shadertoy → Houdini mapping:

Requirements

Installation

  1. Download and unpack (or clone) to a local directory, e.g. C:/dev/hShadertoy

  2. Install the Python deps into Houdini’s Python (plain pip may target the wrong interpreter):

    "C:/Program Files/Side Effects Software/Houdini 21.0.XXX/python311/python.exe" -m pip install --user tree-sitter tree-sitter-glsl curl-cffi
    
  3. Copy houdini/packages/hShadertoy.json to your packages directory, e.g. $HOUDINI_USER_PREF_DIR/packages

  4. Edit it - fill in the first three values and set "enable": true:

    { "HSHADERTOY_ROOT": "C:/dev/hShadertoy" },
    { "HSHADERTOY_HOUDINI": "C:/dev/hShadertoy/houdini" },
    { "SHADERTOY_API_KEY": "YOUR_API_KEY" },
    ...
    "enable": true
    
  5. Start Houdini → hShadertoy shelf → Editor → paste a shader URL → import → build. That’s it

Limitations

Development

New contributors: start with .claude/skills/onboarding/SKILL.md

Pipeline

  1. houdini/toolbar/hShadertoy.shelf
  2. houdini/scripts/python/hshadertoy/gui/editor.py
  3. houdini/scripts/python/hshadertoy/builder/builder.py
  4. houdini/scripts/python/hshadertoy/transpiler/transpile_glsl.py
  5. src/glsl_to_opencl
  6. houdini/otls/hShadertoy.hda - hShadertoy::shadertoy
  7. magic!

Transpiler spec

Testing

pip install -r requirements.txt              # dev deps (pytest, pyopencl, ...)
python -m pytest tests/unit/ -q              # unit suite - the regression gate
python tests/transpile.py <file>.glsl        # transpile one shader -> .header.cl/.kernel.cl
python tests/compilecl.py --header <file>.header.cl <file>.kernel.cl   # compile it

Compile options live in tests/build_options.json; extract the ones for your machine by setting HOUDINI_OCL_REPORT_BUILD_LOGS = 2 in houdini.env and reading the HDA’s OpenCL build log.