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.

This example uses the deprecated renderer scene-loading API so it can remain focused on SPG authoring. Use the 0.3-to-0.4 migration skill when moving scene management to ovstage.

“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

The first step compiles both CUDA kernels with NVRTC. A successful run writes _output/input.png and _output/inverted_grayscale.png. See Overview for the chaining and intermediate-AOV patterns.