MaterialX 1.39.5
Loading...
Searching...
No Matches
SlangShaderGenerator Class Reference

Base class for Slang code generation. More...

#include <SlangShaderGenerator.h>

Inheritance diagram for SlangShaderGenerator:

Public Member Functions

 SlangShaderGenerator (TypeSystemPtr typeSystem)
 Constructor.
 
ShaderPtr generate (const string &name, ElementPtr element, GenContext &context) const override
 Generate a shader starting from the given element, translating the element and all dependencies upstream into shader code.
 
const string & getTarget () const override
 Return a unique identifier for the target this generator is for.
 
virtual const string & getVersion () const
 Return the version string for the Slang version this generator is for.
 
void emitVariableDeclaration (const ShaderPort *variable, const string &qualifier, GenContext &context, ShaderStage &stage, bool assignValue=true) const override
 Emit a shader variable.
 
string getVertexDataPrefix (const VariableBlock &vertexData) const override
 Determine the prefix of vertex data variables.
 

Static Public Member Functions

static ShaderGeneratorPtr create (TypeSystemPtr typeSystem=nullptr)
 Creator function.
 

Static Public Attributes

static const string TARGET
 Unique identifier for this generator target.
 
static const string VERSION
 Version string for the generator target.
 

Protected Member Functions

virtual void emitVertexStage (const ShaderGraph &graph, GenContext &context, ShaderStage &stage) const
 
virtual void emitPixelStage (const ShaderGraph &graph, GenContext &context, ShaderStage &stage) const
 
virtual void emitDirectives (GenContext &context, ShaderStage &stage) const
 
virtual void emitConstants (GenContext &context, ShaderStage &stage) const
 
virtual void emitUniforms (GenContext &context, ShaderStage &stage, bool emitLighting) const
 
virtual void emitInputs (GenContext &context, ShaderStage &stage) const
 
virtual void emitOutputs (GenContext &context, ShaderStage &stage) const
 
virtual bool requiresLighting (const ShaderGraph &graph) const override
 Logic to indicate whether code to support direct lighting should be emitted.
 
virtual void emitSpecularEnvironment (GenContext &context, ShaderStage &stage) const
 Emit specular environment lookup code.
 
virtual void emitTransmissionRender (GenContext &context, ShaderStage &stage) const
 Emit transmission rendering code.
 
virtual void emitLightFunctionDefinitions (const ShaderGraph &graph, GenContext &context, ShaderStage &stage) const
 Emit function definitions for lighting code.
 
void SlangSyntaxFromGlsl (ShaderStage &shaderStage) const
 

Static Protected Member Functions

static void toVec4 (TypeDesc type, string &variable)
 
static void toVec4 (const TypeDesc *type, string &variable)
 

Protected Attributes

vector< ShaderNodePtr_lightSamplingNodes
 Nodes used internally for light sampling.
 

Detailed Description

Base class for Slang code generation.

A generator for a specific Slang target should be derived from this class.

Member Function Documentation

◆ create()

static ShaderGeneratorPtr create ( TypeSystemPtr typeSystem = nullptr)
inlinestatic

Creator function.

If a TypeSystem is not provided it will be created internally. Optionally pass in an externally created TypeSystem here, if you want to keep type descriptions alive after the lifetime of the shader generator.

◆ requiresLighting()

virtual bool requiresLighting ( const ShaderGraph & graph) const
overrideprotectedvirtual

Logic to indicate whether code to support direct lighting should be emitted.

By default if the graph is classified as a shader, or BSDF node then lighting is assumed to be required. Derived classes can override this logic.


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