ShaderGen
Engine/source/shaderGen/shaderGen.h
Public Types
Protected Types
Map< String, GFXShaderRef >
ShaderMap
Map of cache string -> shaders.
Public Static Attributes
Public Friends
Protected Attributes
Public Functions
generateShader(const MaterialFeatureData & featureData, char * vertFile, char * pixFile, F32 * pixVersion, const GFXVertexFormat * vertexFormat, const char * cacheName, Vector< GFXShaderMacro > & macros)
vertFile and pixFile are filled in by this function.
Returns the signal used to notify systems to register features.
getShader(const MaterialFeatureData & dat, const GFXVertexFormat * vertexFormat, const Vector< GFXShaderMacro > * macros, const Vector< String > & samplers)
registerInitDelegate(GFXAdapterType adapterType, ShaderGenInitDelegate & initDelegate)
Register an initialization delegate for adapterType.
setComponentFactory(ShaderGenComponentFactory * factory)
setFileEnding(String ending)
setPrinter(ShaderGenPrinter * printer)
Protected Functions
Creates all the various shader components that will be filled in when the shader features are processed.
bool
_printDependencies(Stream & stream)
_printFeatureList(Stream & stream)
_printFeatures(Stream & stream)
print out the processed features to the file stream
_printPixShader(Stream & stream)
_printVertShader(Stream & stream)
_processPixFeatures(Vector< GFXShaderMacro > & macros, bool macrosOnly)
_processVertFeatures(Vector< GFXShaderMacro > & macros, bool macrosOnly)
Causes the init delegate to be called.
Protected Static Functions
const char *
Detailed Description
The ShaderGen class takes shader feature data (usually created by MatInstance) and creates a vertex/pixel shader pair in text files to be later compiled by a shader manager.
It accomplishes this task by creating a group of shader "components" and "features" that output bits of high level shader code. Shader components translate to structures in HLSL that indicate incoming vertex data, data that is output from the vertex shader to the pixel shader, and data such as constants and textures that are passed directly to the shader from the app.
Shader features are separable shader functions that can be turned on or off. Examples would be bumpmapping and specular highlights. See MaterialFeatureData for the current list of features supported.
ShaderGen processes all of the features that are present for a desired shader, and then prints them out to the respective vertex or pixel shader file.
For more information on shader features and components see the ShaderFeature and ShaderComponent classes.
Public Types
typedef Signal< void(GFXAdapterType type)> FeatureInitSignal
Signal used to notify systems to register features.
typedef Delegate< void(ShaderGen *)> ShaderGenInitDelegate
Parameter 1 is the ShaderGen instance to initialize.
Protected Types
typedef Map< String, GFXShaderRef > ShaderMap
Map of cache string -> shaders.
Public Static Attributes
String smCommonShaderPath
Public Friends
Protected Attributes
AutoPtr< ShaderGenComponentFactory > mComponentFactory
Vector< ShaderComponent * > mComponents
MaterialFeatureData mFeatureData
FeatureInitSignal mFeatureInitSignal
String mFileEnding
bool mInit
Init.
ShaderGenInitDelegate mInitDelegates [GFXAdapterType_Count]
GFXVertexFormat mInstancingFormat
Torque::FS::FileSystemRef mMemFS
MultiLine * mOutput
The currently processing output.
AutoPtr< ShaderGenPrinter > mPrinter
ShaderMap mProcShaders
bool mRegisteredWithGFX
const GFXVertexFormat * mVertexFormat
Public Functions
~ShaderGen()
flushProceduralShaders()
generateShader(const MaterialFeatureData & featureData, char * vertFile, char * pixFile, F32 * pixVersion, const GFXVertexFormat * vertexFormat, const char * cacheName, Vector< GFXShaderMacro > & macros)
vertFile and pixFile are filled in by this function.
They point to the vertex and pixel shader files. pixVersion is also filled in by this function. Parameters:
assignNum | used to assign a specific number as the filename |
getFeatureInitSignal()
Returns the signal used to notify systems to register features.
getShader(const MaterialFeatureData & dat, const GFXVertexFormat * vertexFormat, const Vector< GFXShaderMacro > * macros, const Vector< String > & samplers)
registerInitDelegate(GFXAdapterType adapterType, ShaderGenInitDelegate & initDelegate)
Register an initialization delegate for adapterType.
This should setPrinter/ComponentFactory/etc, and register shader features.
setComponentFactory(ShaderGenComponentFactory * factory)
setFileEnding(String ending)
setPrinter(ShaderGenPrinter * printer)
Protected Functions
ShaderGen()
_createComponents()
Creates all the various shader components that will be filled in when the shader features are processed.
_handleGFXEvent(GFXDevice::GFXDeviceEventType event)
_init()
_printDependencies(Stream & stream)
_printFeatureList(Stream & stream)
_printFeatures(Stream & stream)
print out the processed features to the file stream
_printPixShader(Stream & stream)
_printVertShader(Stream & stream)
_processPixFeatures(Vector< GFXShaderMacro > & macros, bool macrosOnly)
_processVertFeatures(Vector< GFXShaderMacro > & macros, bool macrosOnly)
_uninit()
initShaderGen()
Causes the init delegate to be called.