HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HioGlslfx Class Reference

#include <glslfx.h>

Public Member Functions

HIO_API HioGlslfx ()
 Create an invalid glslfx object. More...
 
HIO_API HioGlslfx (std::string const &filePath, TfToken const &technique=HioGlslfxTokens->defVal)
 Create a glslfx object from a file. More...
 
HIO_API HioGlslfx (std::istream &is, TfToken const &technique=HioGlslfxTokens->defVal)
 Create a glslfx object from a stream. More...
 
HIO_API HioGlslfxConfig::Parameters GetParameters () const
 Return the parameters specified in the configuration. More...
 
HIO_API HioGlslfxConfig::Textures GetTextures () const
 Return the textures specified in the configuration. More...
 
HIO_API HioGlslfxConfig::Attributes GetAttributes () const
 Return the attributes specified in the configuration. More...
 
HIO_API
HioGlslfxConfig::MetadataDictionary 
GetMetadata () const
 Return the metadata specified in the configuration. More...
 
HIO_API bool IsValid (std::string *reason=NULL) const
 Returns true if this is a valid glslfx file. More...
 
HIO_API std::string GetSource (const TfToken &shaderStageKey) const
 Get the shader source associated with given key. More...
 
const std::stringGetFilePath () const
 Get the original file name passed to the constructor. More...
 
const std::set< std::string > & GetFiles () const
 
size_t GetHash () const
 Return the computed hash value based on the string. More...
 
Access to commonly used shader sources.
HIO_API std::string GetSurfaceSource () const
 Get the surface source string. More...
 
HIO_API std::string GetDisplacementSource () const
 Get the displacement source string. More...
 
HIO_API std::string GetVolumeSource () const
 Get the volume source string. More...
 

Static Public Member Functions

static HIO_API std::vector
< std::string
ExtractImports (const std::string &filename)
 

Detailed Description

A class representing the config and shader source of a glslfx file.

a HioGlslfx object is constructed by providing the path of a file whose contents look something like this:

-- glslfx version 0.1
-- configuration
{
'textures' : {
'texture_1':{
'documentation' : 'a useful texture.',
},
'texture_2':{
'documentation' : 'another useful texture.',
},
},
'parameters': {
'param_1' : {
'default' : 1.0,
'documentation' : 'the first parameter'
},
'param_2' : {
'default' : [1.0, 1.0, 1.0],
'documentation' : 'a vec3f parameter'
},
'param_3' : {
'default' : 2.0
},
'param_4' : {
'default' : True
},
'param_5' : {
'default' : [1.0, 1.0, 1.0],
'role' : 'color'
'documentation' : 'specifies a color for use in the shader'
},
},
'parameterOrder': ['param_1',
'param_2',
'param_3',
'param_4',
'param_5'],
'techniques': {
'default': {
'fragmentShader': {
'source': [ 'MyFragment' ]
}
},
'metal': {
'fragmentShader': {
'source': [ 'MyFragment.Metal' ]
}
}
}
}
-- glsl MyFragment
uniform float param_1;
uniform float param_2;
uniform float param_3;
uniform float param_4;
uniform float param_5;
void main()
{
// ...
// glsl code which consumes the various uniforms, and perhaps sets
// gl_FragColor = someOutputColor;
// ...
}

Definition at line 148 of file glslfx.h.

Constructor & Destructor Documentation

HIO_API HioGlslfx::HioGlslfx ( )

Create an invalid glslfx object.

HIO_API HioGlslfx::HioGlslfx ( std::string const filePath,
TfToken const technique = HioGlslfxTokens->defVal 
)

Create a glslfx object from a file.

HIO_API HioGlslfx::HioGlslfx ( std::istream &  is,
TfToken const technique = HioGlslfxTokens->defVal 
)

Create a glslfx object from a stream.

Member Function Documentation

static HIO_API std::vector<std::string> HioGlslfx::ExtractImports ( const std::string filename)
static

Extract imported files from the specified glslfx file. The returned paths are as-authored, in the order of declaration, with possible duplicates. This function is not recursive – it only extracts imports from the specified filename.

HIO_API HioGlslfxConfig::Attributes HioGlslfx::GetAttributes ( ) const

Return the attributes specified in the configuration.

HIO_API std::string HioGlslfx::GetDisplacementSource ( ) const

Get the displacement source string.

const std::string& HioGlslfx::GetFilePath ( ) const
inline

Get the original file name passed to the constructor.

Definition at line 209 of file glslfx.h.

const std::set<std::string>& HioGlslfx::GetFiles ( ) const
inline

Return set of all files processed for this glslfx object. This includes the original file given to the constructor as well as any other files that were imported. This set will only contain files that exist.

Definition at line 215 of file glslfx.h.

size_t HioGlslfx::GetHash ( ) const
inline

Return the computed hash value based on the string.

Definition at line 218 of file glslfx.h.

HIO_API HioGlslfxConfig::MetadataDictionary HioGlslfx::GetMetadata ( ) const

Return the metadata specified in the configuration.

HIO_API HioGlslfxConfig::Parameters HioGlslfx::GetParameters ( ) const

Return the parameters specified in the configuration.

HIO_API std::string HioGlslfx::GetSource ( const TfToken shaderStageKey) const

Get the shader source associated with given key.

HIO_API std::string HioGlslfx::GetSurfaceSource ( ) const

Get the surface source string.

HIO_API HioGlslfxConfig::Textures HioGlslfx::GetTextures ( ) const

Return the textures specified in the configuration.

HIO_API std::string HioGlslfx::GetVolumeSource ( ) const

Get the volume source string.

HIO_API bool HioGlslfx::IsValid ( std::string reason = NULL) const

Returns true if this is a valid glslfx file.


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