OpenUSDPreview
Open in TheBrain

UsdSchemaBase, UsdTyped, UsdShadeNodeGraph

A node-graph is a container for shading nodes, as well as other node-graphs.

The UsdShadeNodeGraph is a class in the USD (Universal Scene Description) API that represents a shading network or a collection of shading nodes. It is a part of the UsdShade module and provides a way to define and manage the relationships between different shading nodes in a scene.

The UsdShadeNodeGraph class inherits from two base classes, UsdSchemaBase and UsdTyped. UsdSchemaBase provides the basic functionality for creating and manipulating USD schema objects, while UsdTyped adds the ability to query and set the type of the object.

One of the key features of the UsdShadeNodeGraph is its ability to define input and output connections between shading nodes. Inputs represent values that are consumed by a shading node, while outputs represent values that are produced by a shading node. These connections allow for the flow of data between different nodes in the shading network.

The UsdShadeNodeGraph class provides methods to create, query, and manage input and output connections. Inputs can be added using the CreateInput method, which creates a new input on the node graph and returns a handle to it. The input can then be connected to an output of another shading node using the ConnectToSource method. Similarly, outputs can be added using the CreateOutput method, and their connections can be managed using the ConnectToSource and DisconnectSource methods.

In addition to managing connections, the UsdShadeNodeGraph also allows for the creation and management of shading nodes within the graph. Shading nodes represent individual operations or computations that are applied to the shading network. They can be created using the CreateShaderNode method, which takes the type of the node as an argument and returns a handle to the created node.

Once created, shading nodes can be added to the graph using the AddNode method. They can also be queried using the GetShaderNodeByName method, which returns a handle to the node with the specified name. Shading nodes can be removed from the graph using the RemoveNode method.

The UsdShadeNodeGraph class also provides methods for querying and setting the node type. The GetNodeTypeName method returns the type of the node as a string, while the SetNodeTypeName method allows for setting the type of the node.

In addition to the methods mentioned above, the UsdShadeNodeGraph class also provides various other methods for querying and manipulating the shading network. These include methods for querying the inputs and outputs of the graph, as well as methods for querying the connections between nodes.

In conclusion, the UsdShadeNodeGraph class is a powerful tool for defining and managing shading networks in USD. Its ability to create and manage input and output connections, as well as shading nodes, makes it a versatile class for working with shading networks. Whether you are creating complex shading networks or simply manipulating existing ones, the UsdShadeNodeGraph class provides the necessary functionality to get the job done.

Attachments