Python: SPG Pipeline#

Two SPG shaders chained into a pipeline: LdrColor → grayscale → invert → LdrInverted. Shaders are chained by connecting one shader’s output directly to the next shader’s input, so the intermediate grayscale result stays internal to the chain and only the final image is published as an AOV. SPG runs the shaders in topological order of the connection graph.

“Chain two SPG shaders so the renderer’s color output is converted to grayscale and then inverted in a single RenderProduct, reading back only the final result.”

SPG two-shader pipeline example output

Prerequisites#

  • Python 3.10-3.13

  • uv

  • An NVIDIA RTX-capable GPU and a supported driver

Running#

uv run main.py                                    # CUDA
uv run main.py --scene pipeline_scene_slang.usda  # Slang

The first step compiles both kernels. A successful run writes _output/input.png and _output/inverted_grayscale.png, the input turned grey by the first node and inverted by the second. See Chain Nodes for the chaining and intermediate-AOV patterns.