ov-kit-doc / Sdr.md
larkZ's picture
Upload 253 files
d8ab1df verified
Sdr module — pxr-usd-api 105.1 documentation
pxr-usd-api
»
Modules »
Sdr module
 
# Sdr module
Summary: The Sdr (Shader Definition Registry) is a specialized version of Ndr for Shaders.
Python bindings for libSdr
Classes:
NodeContext
NodeMetadata
NodeRole
PropertyMetadata
PropertyRole
PropertyTypes
Registry
The shading-specialized version of NdrRegistry .
ShaderNode
A specialized version of NdrNode which holds shading information.
ShaderNodeList
ShaderProperty
A specialized version of NdrProperty which holds shading information.
class pxr.Sdr.NodeContext
Attributes:
Displacement
Light
LightFilter
Pattern
PixelFilter
SampleFilter
Surface
Volume
Displacement = 'displacement'
Light = 'light'
LightFilter = 'lightFilter'
Pattern = 'pattern'
PixelFilter = 'pixelFilter'
SampleFilter = 'sampleFilter'
Surface = 'surface'
Volume = 'volume'
class pxr.Sdr.NodeMetadata
Attributes:
Category
Departments
Help
ImplementationName
Label
Pages
Primvars
Role
SdrDefinitionNameFallbackPrefix
SdrUsdEncodingVersion
Target
Category = 'category'
Departments = 'departments'
Help = 'help'
ImplementationName = '__SDR__implementationName'
Label = 'label'
Pages = 'pages'
Primvars = 'primvars'
Role = 'role'
SdrDefinitionNameFallbackPrefix = 'sdrDefinitionNameFallbackPrefix'
SdrUsdEncodingVersion = 'sdrUsdEncodingVersion'
Target = '__SDR__target'
class pxr.Sdr.NodeRole
Attributes:
Field
Math
Primvar
Texture
Field = 'field'
Math = 'math'
Primvar = 'primvar'
Texture = 'texture'
class pxr.Sdr.PropertyMetadata
Attributes:
Colorspace
Connectable
DefaultInput
Help
Hints
ImplementationName
IsAssetIdentifier
IsDynamicArray
Label
Options
Page
RenderType
Role
SdrUsdDefinitionType
Target
ValidConnectionTypes
VstructConditionalExpr
VstructMemberName
VstructMemberOf
Widget
Colorspace = '__SDR__colorspace'
Connectable = 'connectable'
DefaultInput = '__SDR__defaultinput'
Help = 'help'
Hints = 'hints'
ImplementationName = '__SDR__implementationName'
IsAssetIdentifier = '__SDR__isAssetIdentifier'
IsDynamicArray = 'isDynamicArray'
Label = 'label'
Options = 'options'
Page = 'page'
RenderType = 'renderType'
Role = 'role'
SdrUsdDefinitionType = 'sdrUsdDefinitionType'
Target = '__SDR__target'
ValidConnectionTypes = 'validConnectionTypes'
VstructConditionalExpr = 'vstructConditionalExpr'
VstructMemberName = 'vstructMemberName'
VstructMemberOf = 'vstructMemberOf'
Widget = 'widget'
class pxr.Sdr.PropertyRole
Attributes:
None
None = 'none'
class pxr.Sdr.PropertyTypes
Attributes:
Color
Color4
Float
Int
Matrix
Normal
Point
String
Struct
Terminal
Unknown
Vector
Vstruct
Color = 'color'
Color4 = 'color4'
Float = 'float'
Int = 'int'
Matrix = 'matrix'
Normal = 'normal'
Point = 'point'
String = 'string'
Struct = 'struct'
Terminal = 'terminal'
Unknown = 'unknown'
Vector = 'vector'
Vstruct = 'vstruct'
class pxr.Sdr.Registry
The shading-specialized version of NdrRegistry .
Methods:
GetShaderNodeByIdentifier(identifier, ...)
Exactly like NdrRegistry::GetNodeByIdentifier() , but returns a SdrShaderNode pointer instead of a NdrNode pointer.
GetShaderNodeByIdentifierAndType(identifier, ...)
Exactly like NdrRegistry::GetNodeByIdentifierAndType() , but returns a SdrShaderNode pointer instead of a NdrNode pointer.
GetShaderNodeByName(name, typePriority, filter)
Exactly like NdrRegistry::GetNodeByName() , but returns a SdrShaderNode pointer instead of a NdrNode pointer.
GetShaderNodeByNameAndType(name, nodeType, ...)
Exactly like NdrRegistry::GetNodeByNameAndType() , but returns a SdrShaderNode pointer instead of a NdrNode pointer.
GetShaderNodeFromAsset(shaderAsset, ...)
Wrapper method for NdrRegistry::GetNodeFromAsset() .
GetShaderNodeFromSourceCode(sourceCode, ...)
Wrapper method for NdrRegistry::GetNodeFromSourceCode() .
GetShaderNodesByFamily(family, filter)
Exactly like NdrRegistry::GetNodesByFamily() , but returns a vector of SdrShaderNode pointers instead of a vector of NdrNode pointers.
GetShaderNodesByIdentifier(identifier)
Exactly like NdrRegistry::GetNodesByIdentifier() , but returns a vector of SdrShaderNode pointers instead of a vector of NdrNode pointers.
GetShaderNodesByName(name, filter)
Exactly like NdrRegistry::GetNodesByName() , but returns a vector of SdrShaderNode pointers instead of a vector of NdrNode pointers.
Attributes:
expired
True if this object has expired, False otherwise.
GetShaderNodeByIdentifier(identifier, typePriority) → ShaderNode
Exactly like NdrRegistry::GetNodeByIdentifier() , but returns a
SdrShaderNode pointer instead of a NdrNode pointer.
Parameters
identifier (NdrIdentifier) –
typePriority (NdrTokenVec) –
GetShaderNodeByIdentifierAndType(identifier, nodeType) → ShaderNode
Exactly like NdrRegistry::GetNodeByIdentifierAndType() , but
returns a SdrShaderNode pointer instead of a NdrNode pointer.
Parameters
identifier (NdrIdentifier) –
nodeType (str) –
GetShaderNodeByName(name, typePriority, filter) → ShaderNode
Exactly like NdrRegistry::GetNodeByName() , but returns a
SdrShaderNode pointer instead of a NdrNode pointer.
Parameters
name (str) –
typePriority (NdrTokenVec) –
filter (VersionFilter) –
GetShaderNodeByNameAndType(name, nodeType, filter) → ShaderNode
Exactly like NdrRegistry::GetNodeByNameAndType() , but returns a
SdrShaderNode pointer instead of a NdrNode pointer.
Parameters
name (str) –
nodeType (str) –
filter (VersionFilter) –
GetShaderNodeFromAsset(shaderAsset, metadata, subIdentifier, sourceType) → ShaderNode
Wrapper method for NdrRegistry::GetNodeFromAsset() .
Returns a valid SdrShaderNode pointer upon success.
Parameters
shaderAsset (AssetPath) –
metadata (NdrTokenMap) –
subIdentifier (str) –
sourceType (str) –
GetShaderNodeFromSourceCode(sourceCode, sourceType, metadata) → ShaderNode
Wrapper method for NdrRegistry::GetNodeFromSourceCode() .
Returns a valid SdrShaderNode pointer upon success.
Parameters
sourceCode (str) –
sourceType (str) –
metadata (NdrTokenMap) –
GetShaderNodesByFamily(family, filter) → SdrShaderNodePtrVec
Exactly like NdrRegistry::GetNodesByFamily() , but returns a
vector of SdrShaderNode pointers instead of a vector of
NdrNode pointers.
Parameters
family (str) –
filter (VersionFilter) –
GetShaderNodesByIdentifier(identifier) → SdrShaderNodePtrVec
Exactly like NdrRegistry::GetNodesByIdentifier() , but returns a
vector of SdrShaderNode pointers instead of a vector of
NdrNode pointers.
Parameters
identifier (NdrIdentifier) –
GetShaderNodesByName(name, filter) → SdrShaderNodePtrVec
Exactly like NdrRegistry::GetNodesByName() , but returns a vector
of SdrShaderNode pointers instead of a vector of NdrNode
pointers.
Parameters
name (str) –
filter (VersionFilter) –
property expired
True if this object has expired, False otherwise.
class pxr.Sdr.ShaderNode
A specialized version of NdrNode which holds shading information.
Methods:
GetAdditionalPrimvarProperties()
The list of string input properties whose values provide the names of additional primvars consumed by this node.
GetAllVstructNames()
Gets all vstructs that are present in the shader.
GetAssetIdentifierInputNames()
Returns the list of all inputs that are tagged as asset identifier inputs.
GetCategory()
The category assigned to this node, if any.
GetDefaultInput()
Returns the first shader input that is tagged as the default input.
GetDepartments()
The departments this node is associated with, if any.
GetHelp()
The help message assigned to this node, if any.
GetImplementationName()
Returns the implementation name of this node.
GetLabel()
The label assigned to this node, if any.
GetPages()
Gets the pages on which the node's properties reside (an aggregate of the unique SdrShaderProperty::GetPage() values for all of the node's properties).
GetPrimvars()
The list of primvars this node knows it requires / uses.
GetPropertyNamesForPage(pageName)
Gets the names of the properties on a certain page (one that was returned by GetPages() ).
GetRole()
Returns the role of this node.
GetShaderInput(inputName)
Get a shader input property by name.
GetShaderOutput(outputName)
Get a shader output property by name.
GetAdditionalPrimvarProperties() → NdrTokenVec
The list of string input properties whose values provide the names of
additional primvars consumed by this node.
For example, this may return a token named varname . This
indicates that the client should query the value of a (presumed to be
string-valued) input attribute named varname from its scene
description to determine the name of a primvar the node will consume.
See GetPrimvars() for additional information.
GetAllVstructNames() → NdrTokenVec
Gets all vstructs that are present in the shader.
GetAssetIdentifierInputNames() → NdrTokenVec
Returns the list of all inputs that are tagged as asset identifier
inputs.
GetCategory() → str
The category assigned to this node, if any.
Distinct from the family returned from GetFamily() .
GetDefaultInput() → ShaderProperty
Returns the first shader input that is tagged as the default input.
A default input and its value can be used to acquire a fallback value
for a node when the node is considered’disabled’or otherwise incapable
of producing an output value.
GetDepartments() → NdrTokenVec
The departments this node is associated with, if any.
GetHelp() → str
The help message assigned to this node, if any.
GetImplementationName() → str
Returns the implementation name of this node.
The name of the node is how to refer to the node in shader networks.
The label is how to present this node to users. The implementation
name is the name of the function (or something) this node represents
in the implementation. Any client using the implementation must
call this method to get the correct name; using getName() is not
correct.
GetLabel() → str
The label assigned to this node, if any.
Distinct from the name returned from GetName() . In the context of
a UI, the label value might be used as the display name for the node
instead of the name.
GetPages() → NdrTokenVec
Gets the pages on which the node’s properties reside (an aggregate of
the unique SdrShaderProperty::GetPage() values for all of the
node’s properties).
Nodes themselves do not reside on pages. In an example scenario,
properties might be divided into two pages,’Simple’and’Advanced’.
GetPrimvars() → NdrTokenVec
The list of primvars this node knows it requires / uses.
For example, a shader node may require the’normals’primvar to function
correctly. Additional, user specified primvars may have been authored
on the node. These can be queried via
GetAdditionalPrimvarProperties() . Together, GetPrimvars() and
GetAdditionalPrimvarProperties() , provide the complete list of
primvar requirements for the node.
GetPropertyNamesForPage(pageName) → NdrTokenVec
Gets the names of the properties on a certain page (one that was
returned by GetPages() ).
To get properties that are not assigned to a page, an empty string can
be used for pageName .
Parameters
pageName (str) –
GetRole() → str
Returns the role of this node.
This is used to annotate the role that the shader node plays inside a
shader network. We can tag certain shaders to indicate their role
within a shading network. We currently tag primvar reading nodes,
texture reading nodes and nodes that access volume fields (like
extinction or scattering). This is done to identify resources used by
a shading network.
GetShaderInput(inputName) → ShaderProperty
Get a shader input property by name.
nullptr is returned if an input with the given name does not
exist.
Parameters
inputName (str) –
GetShaderOutput(outputName) → ShaderProperty
Get a shader output property by name.
nullptr is returned if an output with the given name does not
exist.
Parameters
outputName (str) –
class pxr.Sdr.ShaderNodeList
Methods:
append
extend
append()
extend()
class pxr.Sdr.ShaderProperty
A specialized version of NdrProperty which holds shading
information.
Methods:
GetDefaultValueAsSdfType()
Accessor for default value corresponding to the SdfValueTypeName returned by GetTypeAsSdfType.
GetHelp()
The help message assigned to this property, if any.
GetHints()
Any UI"hints"that are associated with this property.
GetImplementationName()
Returns the implementation name of this property.
GetLabel()
The label assigned to this property, if any.
GetOptions()
If the property has a set of valid values that are pre-determined, this will return the valid option names and corresponding string values (if the option was specified with a value).
GetPage()
The page (group), eg"Advanced", this property appears on, if any.
GetVStructConditionalExpr()
If this field is part of a vstruct, this is the conditional expression.
GetVStructMemberName()
If this field is part of a vstruct, this is its name in the struct.
GetVStructMemberOf()
If this field is part of a vstruct, this is the name of the struct.
GetValidConnectionTypes()
Gets the list of valid connection types for this property.
GetWidget()
The widget"hint"that indicates the widget that can best display the type of data contained in this property, if any.
IsAssetIdentifier()
Determines if the value held by this property is an asset identifier (eg, a file path); the logic for this is left up to the parser.
IsDefaultInput()
Determines if the value held by this property is the default input for this node.
IsVStruct()
Returns true if the field is the head of a vstruct.
IsVStructMember()
Returns true if this field is part of a vstruct.
GetDefaultValueAsSdfType() → VtValue
Accessor for default value corresponding to the SdfValueTypeName
returned by GetTypeAsSdfType.
Note that this is different than GetDefaultValue which returns the
default value associated with the SdrPropertyType and may differ from
the SdfValueTypeName, example when sdrUsdDefinitionType metadata is
specified for a sdr property.
GetTypeAsSdfType
GetHelp() → str
The help message assigned to this property, if any.
GetHints() → NdrTokenMap
Any UI”hints”that are associated with this property.
“Hints”are simple key/value pairs.
GetImplementationName() → str
Returns the implementation name of this property.
The name of the property is how to refer to the property in shader
networks. The label is how to present this property to users. The
implementation name is the name of the parameter this property
represents in the implementation. Any client using the implementation
must call this method to get the correct name; using getName()
is not correct.
GetLabel() → str
The label assigned to this property, if any.
Distinct from the name returned from GetName() . In the context of
a UI, the label value might be used as the display name for the
property instead of the name.
GetOptions() → NdrOptionVec
If the property has a set of valid values that are pre-determined,
this will return the valid option names and corresponding string
values (if the option was specified with a value).
GetPage() → str
The page (group), eg”Advanced”, this property appears on, if any.
Note that the page for a shader property can be nested, delimited
by”:”, representing the hierarchy of sub-pages a property is defined
in.
GetVStructConditionalExpr() → str
If this field is part of a vstruct, this is the conditional
expression.
GetVStructMemberName() → str
If this field is part of a vstruct, this is its name in the struct.
GetVStructMemberOf() → str
If this field is part of a vstruct, this is the name of the struct.
GetValidConnectionTypes() → NdrTokenVec
Gets the list of valid connection types for this property.
This value comes from shader metadata, and may not be specified. The
value from NdrProperty::GetType() can be used as a fallback, or
you can use the connectability test in CanConnectTo() .
GetWidget() → str
The widget”hint”that indicates the widget that can best display the
type of data contained in this property, if any.
Examples of this value could include”number”,”slider”, etc.
IsAssetIdentifier() → bool
Determines if the value held by this property is an asset identifier
(eg, a file path); the logic for this is left up to the parser.
Note: The type returned from GetTypeAsSdfType() will be Asset
if this method returns true (even though its true underlying data
type is string).
IsDefaultInput() → bool
Determines if the value held by this property is the default input for
this node.
IsVStruct() → bool
Returns true if the field is the head of a vstruct.
IsVStructMember() → bool
Returns true if this field is part of a vstruct.
© Copyright 2019-2023, NVIDIA.
Last updated on Nov 14, 2023.