What You Can Author in USD#
Everything SPG reads from a scene.
Ports#
A node is one unit of GPU work with named ports. Ports are declared in the USD shader definition and come in three kinds.
Kind |
Declared as |
Carries |
|---|---|---|
Resource-input |
|
An AOV or a buffer another node produced. |
Value-input |
a typed attribute, such as |
A number, vector, matrix or token authored in USD. |
Resource-output |
|
What this node writes. |
The port name is the contract. It is what the scene connects to, and what the launch script keys on. Position only matters inside a launch script, where the GPU code’s parameters or declarations are matched in order.
The Shader Prim#
Attribute |
Meaning |
|---|---|
|
|
|
The GPU source. The extension selects the language. May be a path, a file inside a package, or a URI; refer to Where Assets May Live. |
|
The entry point to invoke, and the Lua function that launches it. The GPU source must
export an entry point of that name for the node’s stage; a |
|
The built-in node, as |
|
A resource-input: an AOV, a buffer, or a sensor composite. |
|
A resource-output the node writes. |
a typed attribute, such as |
A value-input. The types are below. |
Shader prims must not be nested under a Material prim, and a shader under an instance
prototype is ignored.
Ports and Values an API Schema Declares#
A shader prim may apply a single-apply API schema that declares ports and value-inputs with their
defaults. The node has every port and value-input such a schema declares, as if the prim authored
it. A value-input takes inputs:X when it holds a value or a connection to a source the prim
authors in any layer, else a legacy params:X that holds one, else the schema’s default of
inputs:X. An empty connection list, which disconnecting through UsdShade leaves, connects nothing.
Authoring, changing, connecting or removing a value while the stage runs reaches the node on the step
after the edit is applied, and the same rule picks the value then: removing an authored inputs:X
gives the node params:X when the prim authors one, else the schema’s default.
Register the schema before the stage is populated, with
ovstage.population.register_usd_schemas; a stage populated before that sees only what the
prims author.
Value-Input Types#
A value-input is any attribute under inputs: that is not opaque. Its USD type decides what
the launch script is handed and what the GPU code has to declare.
USD type |
Arrives as |
Notes |
|---|---|---|
|
|
|
|
the matching integer |
The 64-bit forms bind on CUDA and not on Slang. Refer to The slang Lua Table. |
|
the matching float |
|
|
|
|
|
the matching vector |
|
|
|
USD has no float matrix type, so a shader’s |
|
|
Four components. The text order is not the memory order: USDA writes |
|
a null-terminated |
Bound with |
|
the file’s raw bytes, read as the dtype you name |
SPG resolves the path and uploads the contents. It may be a path, a file inside a package, or a URI; refer to Where Assets May Live and Upload Your Own Data. |
an array, such as |
a buffer |
Read on Slang as a |
Types that share a base type behave alike, so color3f, point3f, normal3f and
texCoord3f all arrive as a three-component float, exactly as float3 does. A type whose base
type is none of the above is not read, and the log says so by name.
Where Assets May Live#
Two things a shader prim can name are files: info:spg:sourceAsset, the GPU source, and any
asset value-input, which is data to upload. Both are resolved the same way, and either may
come from any of three places.
Written as |
Reads from |
|---|---|
|
A path, resolved relative to the file that names it. |
|
A file inside a USD package, alongside the scene that references it. |
|
A URI. |
The launch script follows its source. It is found by appending .lua to whatever
info:spg:sourceAsset says, so a kernel loaded from a server takes its script from that same
server. Inside a package the suffix goes within the brackets, so pkg.usdz[Kernel.cu] pairs
with pkg.usdz[Kernel.cu.lua].
The RenderVar Prim#
Attribute |
Meaning |
|---|---|
|
The AOV name. Required, both to publish a new AOV and to name an existing one. |
|
Exposes a renderer AOV as connectable, for a node to read. |
|
Connects a node output to this RenderVar, publishing it. |
|
For a sensor composite, which channels it carries. Refer to Read a Sensor Composite. |
The RenderProduct Prim#
Attribute |
Meaning |
|---|---|
|
The camera, or the sensor, this product renders from. |
|
Which RenderVars the product produces. Every RenderVar a graph consumes or publishes belongs here; intermediates do not. |
|
The product’s resolution. |
Connections#
The pattern a graph is wired with, in order:
RenderVar.omni:rtx:aov -> Shader.inputs:X
Shader.outputs:Y -> Shader.inputs:Z (chaining, stays internal)
Shader.outputs:Y -> RenderVar.omni:rtx:aov.connect (publishing)
A shader-to-shader connection groups both prims into one graph. A node output can be bound to
one RenderVar at a time. An input, inputs:X or params:X, a resource port or a value, takes
one source: an input connected to two or more is an error that names the shader, the input and the
sources, and no node of that shader’s graph runs until the input has one source again.