MaterialX 1.39.1
Loading...
Searching...
No Matches
ClosureContext Class Reference

Class representing a context for closure evaluation. More...

#include <GenContext.h>

Public Types

using Argument = std::pair< TypeDesc, string >
 An extra argument for closure functions. More...
 
using Arguments = vector< Argument >
 An array of arguments.
 
using ClosureParams = std::unordered_map< string, const ShaderInput * >
 Extra parameters for closure evaluation.
 

Public Member Functions

 ClosureContext (int type=0)
 Constructor.
 
int getType () const
 Return the identifier for this context.
 
void addArgument (TypeDesc nodeType, const Argument &arg)
 For the given node type add an extra argument to be used for the function in this context.
 
void addArgument (const TypeDesc *nodeType, const Argument &arg)
 
const ArgumentsgetArguments (TypeDesc nodeType) const
 Return a list of extra argument to be used for the given node in this context.
 
const ArgumentsgetArguments (const TypeDesc *nodeType) const
 
void setSuffix (TypeDesc nodeType, const string &suffix)
 For the given node type set a function name suffix to be used for the function in this context.
 
void setSuffix (const TypeDesc *nodeType, const string &suffix)
 
const string & getSuffix (TypeDesc nodeType) const
 Return the function name suffix to be used for the given node in this context.
 
const string & getSuffix (const TypeDesc *nodeType) const
 
void setClosureParams (const ShaderNode *closure, const ClosureParams *params)
 Set extra parameters to use for evaluating a closure.
 
const ClosureParamsgetClosureParams (const ShaderNode *closure) const
 Return extra parameters to use for evaluating a closure. More...
 

Protected Attributes

const int _type
 
std::unordered_map< TypeDesc, Arguments, TypeDesc::Hasher_arguments
 
std::unordered_map< TypeDesc, string, TypeDesc::Hasher_suffix
 
std::unordered_map< const ShaderNode *, const ClosureParams * > _params
 

Static Protected Attributes

static const Arguments EMPTY_ARGUMENTS
 

Detailed Description

Class representing a context for closure evaluation.

On hardware BSDF closures are evaluated differently in reflection, transmission or environment/indirect contexts. This class represents the context we are in and if extra arguments and function decorators are needed for that context.

Member Typedef Documentation

◆ Argument

using Argument = std::pair<TypeDesc, string>

An extra argument for closure functions.

An argument is a pair of strings holding the 'type' and 'name' of the argument.

Member Function Documentation

◆ getClosureParams()

const ClosureParams * getClosureParams ( const ShaderNode closure) const
inline

Return extra parameters to use for evaluating a closure.

Or return nullptr if no parameters have been set for the given closure.


The documentation for this class was generated from the following file: