FnUsdAbstractionLib 0.6.0
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
usg::ShaderDescGroup Class Reference

#include <ShaderDesc.h>

Public Member Functions

 ShaderDescGroup (const std::string &_target_renderer=std::string())
 
size_t size () const
 
void reserve (size_t n)
 
bool addShaderDesc (ShaderDesc *shader)
 
bool addShaderDesc (ShaderDesc *shader, const std::string &prim_name)
 
void setOutput (ShaderDesc *shader)
 Assign the primary output shader (sub type doesn't matter - ie surface, volume, light, etc)
 
void setDisplacementOutput (ShaderDesc *shader)
 
void deleteShaders ()
 
ShaderDescgetShaderNode (const std::string &shader_node_name) const
 Return the shader matching the name, or null if not in group.
 
fdk::Hash getTopologyHash ()
 Computes and returns the topology hash for the shader group.
 

Public Attributes

std::string target_renderer
 If not empty (ie universalRenderContext) the shaders are associated with a named renderer.
 
std::string material_base_name
 Base name for the material (may not be the final MaterialPrim name)
 
Path material_prim_path
 Prim path of MaterialPrim owner.
 
ShaderDescPtrMap shaders
 Map of ShaderDesc pointers keyed by shader material-relative names.
 
ShaderDescoutput
 The output shader for the group.
 
ShaderDescdisplacement_output
 The output displacement shader for the group (may be the same as surface output)
 
fdk::Hash topology_hash
 Does the shader graph need to be rebuilt?
 
fdk::Hash property_hash
 Do the shaders need parameter updating?
 

Detailed Description

A list of ShaderDesc pointers usually organized into a shader graph. The group's output shader(s) are also noted as well as the name (if any) of a renderer to target.

Added ShaderDesc allocations are owned by this class and deleted in the destructor.

Member Function Documentation

◆ addShaderDesc() [1/2]

bool usg::ShaderDescGroup::addShaderDesc ( ShaderDesc shader)

Add a ShaderDesc to the group, taking ownership of the allocation.

Important - this requires that the ShaderDesc already have a unique name assigned as getMaterialRelativeName() is called on the ShaderDesc to map the storage of the pointer. If the name is not assigned or is not unique then the ShaderDesc will NOT be added to the group and false returned.

The ShaderDesc pointer will be deleted when the group is destroyed.

Returns true is ShaderDesc was added to group.

◆ addShaderDesc() [2/2]

bool usg::ShaderDescGroup::addShaderDesc ( ShaderDesc shader,
const std::string &  prim_name 
)

Add a ShaderDesc to the group, taking ownership of the allocation and setting the shader's name at the same time. If the name is empty or is not unique then the ShaderDesc will NOT be added to the group and false returned.

The ShaderDesc pointer will be deleted when the group is destroyed.

Returns true is ShaderDesc was added to group.

◆ setDisplacementOutput()

void usg::ShaderDescGroup::setDisplacementOutput ( ShaderDesc shader)
inline

Assign the primary displacement output shader.

◆ deleteShaders()

void usg::ShaderDescGroup::deleteShaders ( )

Delete the ShaderDesc pointers and empty the group. Leaves the material_prim_path and target_renderer intact.



©2025 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.thefoundry.co.uk