FnUsdAbstractionLib 15.1.6
|
#include <ShaderDesc.h>
Public Member Functions | |
ShaderDesc () | |
Default ctor builds an empty (invalid) ShaderDesc. | |
ShaderDesc (ShaderDesc &&) | |
Move constructor. | |
ShaderDesc (const SchemaDescription *schema) | |
~ShaderDesc () | |
Must have a destructor in implementation otherwise std::unique_ptr fails. | |
bool | isValid () const |
True if ShaderDescHandle is valid (has a valid object binding.) | |
operator bool () const | |
const std::string & | schemaName () const |
Returns the name of the underlying ShaderSchema. | |
const std::string & | getIdentifier () const |
void | setMaterialRelativeName (const std::string &prim_name) |
const std::string & | getMaterialRelativeName () const |
const std::string & | getSourceType () const |
const std::string & | getSourceCode () const |
const std::string & | getResolvedImplementationURI () const |
const std::string & | getResolvedDefinitionURI () const |
ShaderSchema * | createShaderSchema () const |
size_t | getInputNames (fdk::StringPtrList &names) const |
Retrieve the list of input property names. | |
bool | hasInput (const std::string &input_name) const |
Returns true if named input exists. | |
ShaderProperty | getInput (const std::string &input_name) const |
Value | getInputValue (const std::string &input_name) const |
Return the value of the input property with override (if any) applied. | |
Value | getInputDefaultValue (const std::string &input_name) const |
Return the default value (non-overriden) of the input property. | |
TokenValueMapSorted | getInputValues () const |
Retrieve a list of inputs and their default values. | |
ShaderProperty * | overrideInput (const std::string &input_name, const Value &override_value, const fdk::TimeValue &override_time=fdk::defaultTimeValue()) |
bool | overrideInputs (const ShaderPropertyMap &overrides) |
bool | clearInputOverride (const std::string &input_name) |
Remove a named input override, returning true if successful. | |
ShaderProperty * | getInputOverride (const std::string &input_name) const |
const ShaderPropertyMap & | getInputOverrides () const |
Returns the list of all input overrides currently assigned. | |
TokenValueMapSorted | getInputOverrideValues () const |
Retrieve a list of overriden inputs and their values. | |
ShaderConnectionList * | connectInput (const ShaderProperty &input_property, const ShaderDesc *source_shader, const std::string &source_shader_output_name) |
ShaderConnectionList * | connectInput (const std::string &input_name, const ShaderDesc *source_shader, const std::string &source_shader_output_name) |
ShaderConnectionList * | connectInput (const ShaderProperty &input_property, const std::string &connection_path) |
ShaderConnectionList * | connectInput (const std::string &input_name, const std::string &connection_path) |
bool | connectInputs (const ShaderConnectionMap &connections) |
const ShaderConnectionMap & | getInputConnections () const |
Returns the list of all input connections currently assigned. | |
const ShaderConnectionList * | getInputConnection (const std::string &input_name) const |
Return a list of connections if any have been assigned to the named input, otherwise null. | |
size_t | getLocalPropertyNames (fdk::StringPtrList &names) const |
Retrieve the list of local property names. | |
bool | hasLocalProperty (const std::string &prop_name) const |
Returns true if named local property exists. | |
ShaderProperty | getLocalProperty (const std::string &prop_name) const |
ShaderProperty * | overrideLocalProperty (const std::string &prop_name, const Value &override_value, const fdk::TimeValue &override_time=fdk::defaultTimeValue()) |
size_t | getOutputNames (fdk::StringPtrList &names) const |
Retrieve the list of output property names. | |
bool | hasOutput (const std::string &output_name) const |
Returns true if named output exists. | |
ShaderProperty | getOutput (const std::string &output_name) const |
void | print (const char *prefix, std::ostream &o, bool print_contents=false) const |
ShaderDescHandle * | impl () |
const ShaderDescHandle * | impl () const |
Static Public Member Functions | |
static std::string | buildName (const std::string &target_renderer, const std::string &prim_name) |
static ShaderDesc * | createFromSchema (const char *schema_name) |
static ShaderDesc * | createFromSchema (const char *schema_name, const std::string &prim_name) |
static ShaderDesc | createFromIdentifier (const std::string &identifier) |
Protected Attributes | |
std::unique_ptr< ShaderDescHandle, void(*)(ShaderDescHandle *)> | _pImpl |
Friends | |
std::ostream & | operator<< (std::ostream &o, const ShaderDesc &b) |
Describes a single shader as an abstract representation with local property overrides and connections.
It contains a reference to the ShaderSchema default configuration with the default values of all properties and a separate list of property overrides.
A ShaderDesc copy of a ShaderSchema is not directly modifiable, that is you cannot change the input or output properties directy. Modify it by assigning property overrides and connections.
This should be as abstract as possible to help translation to various shader targets.
usg::ShaderDesc::ShaderDesc | ( | const SchemaDescription * | schema | ) |
Construct from a ShaderSchema registry description. Direct copying ShaderDesc is disabled, use the ShaderDesc::createFromSchema() method instead to create additional copies.
const std::string & usg::ShaderDesc::getIdentifier | ( | ) | const |
Return the unique identifier of the ShaderSchema which may or may not contain the schemaName() string. ie don't use it to extract the shader class or type name, use schemaName() instead.
The ShaderSchema id is used to retrieve the singleton description from the registry and MUST BE THE SAME for shader define/declaration code, shader editing code (ie changing property values,) and any shader consumers like renderers or viewers.
|
static |
Convenience method prefixes the prim_name with the target renderer name, if not empty, separated with an underscore '_'.
void usg::ShaderDesc::setMaterialRelativeName | ( | const std::string & | prim_name | ) |
Set the local name of the shader node within the material graph. This is the prim name, not a path, so should not include a leading '.' or '/'.
const std::string & usg::ShaderDesc::getMaterialRelativeName | ( | ) | const |
Return the local name of the shader node within the material graph. This does not include the Material parent or anything above it.
If the local name mistakenly has a leading '/' it should be interpreted as '<material-path>/'. ie the '/' is replaced by the material parent path.
|
static |
Returns a newly-allocated ShaderDesc copied from a ShaderSchema registry entry matching the schema_name. Calling code takes ownership of allocation.
If there isn't one currently registered the schema_name is used to construct a plugin filename and the plugin path searched for a match, loading it if found.
Modify it by assigning property overrides and connections. The ShaderSchema copy is not directly modifiable, ie you can't change the input or output properties directy.
For example: if (ShaderDesc* shader = ShaderDesc::createFromSchema("MyShader")) { shader->overrideInput("diffuseColor", Value(Vec3f(0.1f, 0.2f, 0.3f))); shader->connectInput("opacity", "./MyOpacityTexture.outputs:r"); }
|
static |
Same as createFromSchema(schema_name) but sets the prim node name after creation, for convenience.
The resulting ShaderDesc's material-relative name is assigned via setMaterialRelativeName(), see that method for naming info.
|
static |
Returns a ShaderDesc copied from a ShaderSchema registry entry matching the unique identifier string.
This is a wrapped registry ShaderDesc and not editable.
ShaderSchema * usg::ShaderDesc::createShaderSchema | ( | ) | const |
Returns a constructed ShaderSchema from this ShaderDesc. Basically the reverse of createFromSchema(). Calling code takes ownership of returned allocation.
ShaderProperty usg::ShaderDesc::getInput | ( | const std::string & | input_name | ) | const |
Get a wrapped shader input property by name. Returned property is invalid if an input with the given name does not exist.
ShaderProperty * usg::ShaderDesc::overrideInput | ( | const std::string & | input_name, |
const Value & | override_value, | ||
const fdk::TimeValue & | override_time = fdk::defaultTimeValue() |
||
) |
Set an override value on a named input property, if the property exists.
If the property exists it will be returned with the override applied if the provided value type matches the property. ie if the property is a Value::Color and the provided value is a string the override is ignored and the returned property is unchanged.
bool usg::ShaderDesc::overrideInputs | ( | const ShaderPropertyMap & | overrides | ) |
Set a series of overrides at once. Returns false if any failed.
ShaderProperty * usg::ShaderDesc::getInputOverride | ( | const std::string & | input_name | ) | const |
Get a shader input override property override by name, otherwise null.
ShaderConnectionList * usg::ShaderDesc::connectInput | ( | const ShaderProperty & | input_property, |
const ShaderDesc * | source_shader, | ||
const std::string & | source_shader_output_name | ||
) |
Disconnect the input by passing a null or invalid source_shader or an empty source_shader_output string.
ShaderConnectionList * usg::ShaderDesc::connectInput | ( | const std::string & | input_name, |
const ShaderDesc * | source_shader, | ||
const std::string & | source_shader_output_name | ||
) |
Disconnect the input by passing a null or invalid source_shader or an empty source_shader_output string.
ShaderProperty usg::ShaderDesc::getLocalProperty | ( | const std::string & | prop_name | ) | const |
Get a wrapped shader local property by name. Returned property is invalid if a local with the given name does not exist.
ShaderProperty * usg::ShaderDesc::overrideLocalProperty | ( | const std::string & | prop_name, |
const Value & | override_value, | ||
const fdk::TimeValue & | override_time = fdk::defaultTimeValue() |
||
) |
Set an override value on a named local property, if the property exists.
If the property exists it will be returned with the override applied if the provided value type matches the property. ie if the property is a Value::Color and the provided value is a string the override is ignored and the returned property is unchanged.
ShaderProperty usg::ShaderDesc::getOutput | ( | const std::string & | output_name | ) | const |
Get a wrapped shader output property by name. Returned property is invalid if an output with the given name does not exist.
©2025 The Foundry Visionmongers, Ltd. All Rights Reserved. |