ShaderFeature

Engine/source/shaderGen/shaderFeature.h

More...

Classes:

Public Types

enum
OutputTarget {
  DefaultTarget =   1 << 0
  RenderTarget1 =   1 << 1
  RenderTarget2 =   1 << 2
  RenderTarget3 =   1 << 3
  RenderTarget4 =   1 << 4
  RenderTarget5 =   1 << 5
}

Protected Attributes

The list of unique shader dependencies.

Public Functions

Adds a dependency to this shader feature.

Helper function for applying the color to shader output.

determineFeature(Material * material, const GFXVertexFormat * vertexFormat, U32 stageNum, const FeatureType & type, const FeatureSet & features, MaterialFeatureData * outFeatureData)
expandNormalMap(LangElement * sampleNormalOp, LangElement * normalDecl, LangElement * normalVar, const MaterialFeatureData & fd)

Expand and assign a normal map. This takes care of compressed normal maps as well.

Identifies what type of blending a feature uses.

Gets the dependency list for this shader feature.

Returns the name of this feature.

returns output from a processed vertex or pixel shader

Gets the render target this shader feature is assigning data to.

const char *

Returns the name of output targer var.

const char *

Returns the output variable name for this feature if it applies.

Returns the resource requirements of this feature based on what other features are present.

Var *

Get the incoming base texture coords - useful for bumpmap and detail maps.

Allows the feature to add macros to pixel shader compiles.

Allows the feature to add macros to vertex shader compiles.

Called after processing the vertex and processing the pixel to cleanup any temporary structures stored in the feature.

setTexData(Material::StageData & stageDat, const MaterialFeatureData & fd, RenderPassData & passData, U32 & texIndex)

Fills texture related info in RenderPassData for this feature.

setupTexSpaceMat(Vector< ShaderComponent * > & componentList, Var ** texSpaceMat)

Set up a texture space matrix - to pass into pixel shader.

Public Static Functions

Var *
findOrCreateLocal(const char * name, const char * type, MultiLine * multi)

A simpler helper function which either finds the existing local var or creates one.

Detailed Description

The ShaderFeature class is the base class for every procedurally generated feature. Each feature the engine recognizes is part of the MaterialFeatureType enum. That structure is used to indicate which features are present in a shader to be generated. This is useful as many ShaderFeatures will output different code depending on what other features are going to be in the shader.

Shaders are generated using the ShaderFeature interface, so all of the descendants interact pretty much the same way.

Public Types

OutputTarget

Enumerator

DefaultTarget = 1 << 0
RenderTarget1 = 1 << 1
RenderTarget2 = 1 << 2
RenderTarget3 = 1 << 3
RenderTarget4 = 1 << 4
RenderTarget5 = 1 << 5

Protected Attributes

Vector< const ShaderDependency * > mDependencies 

The list of unique shader dependencies.

S32 mProcessIndex 
LangElement * output 

Public Attributes

GFXVertexFormat * mInstancingFormat 
const GFXVertexFormat * mVertexFormat 

Public Functions

ShaderFeature()

~ShaderFeature()

addDependency(const ShaderDependency * depends)

Adds a dependency to this shader feature.

assignColor(LangElement * elem, Material::BlendOp blend, LangElement * lerpElem, ShaderFeature::OutputTarget outputTarget)

Helper function for applying the color to shader output.

Parameters:

elem

The rbg or rgba color to assign.

blend

The type of blending to perform.

lerpElem

The optional lerp parameter when doing a LerpAlpha blend, if not set then the elem is used.

Reimplemented by: ConditionerFeature, ShaderFeatureGLSL, ShaderFeatureHLSL

createConstHandles(GFXShader * shader, SimObject * userObject)

Reimplemented by: WindDeformationGLSL, WindDeformationHLSL, FoliageFeatureGLSL, FoliageFeatureHLSL

determineFeature(Material * material, const GFXVertexFormat * vertexFormat, U32 stageNum, const FeatureType & type, const FeatureSet & features, MaterialFeatureData * outFeatureData)

Reimplemented by: WindDeformationGLSL, WindDeformationHLSL, VertPositionGLSL, FoliageFeatureGLSL, ImposterVertFeatureGLSL, VertPositionHLSL, FoliageFeatureHLSL, ImposterVertFeatureHLSL

expandNormalMap(LangElement * sampleNormalOp, LangElement * normalDecl, LangElement * normalVar, const MaterialFeatureData & fd)

Expand and assign a normal map. This takes care of compressed normal maps as well.

Reimplemented by: ConditionerFeature, ShaderFeatureGLSL, ShaderFeatureHLSL

getBlendOp()

Identifies what type of blending a feature uses.

This is used to group features with the same blend operation together in a multipass situation.

Reimplemented by: DeferredRTLightingFeatGLSL, DeferredBumpFeatGLSL, DeferredRTLightingFeatHLSL, DeferredBumpFeatHLSL, ConditionerFeature, AccuTexFeatGLSL, BumpFeatGLSL, NormalsOutFeatGLSL, CustomFeatureGLSL, EyeSpaceDepthOutGLSL, DepthOutGLSL, ParaboloidVertTransformGLSL, RTLightingFeatGLSL, DiffuseMapFeatGLSL, OverlayTexFeatGLSL, DiffuseFeatureGLSL, DiffuseVertColorFeatureGLSL, LightmapFeatGLSL, TonemapFeatGLSL, VertLitGLSL, DetailFeatGLSL, FogFeatGLSL, TexAnimGLSL, VisibilityFeatGLSL, AlphaTestGLSL, GlowMaskGLSL, HDROutGLSL, AccuTexFeatHLSL, BumpFeatHLSL, NormalsOutFeatHLSL, CustomFeatureHLSL, EyeSpaceDepthOutHLSL, DepthOutHLSL, ParaboloidVertTransformHLSL, RTLightingFeatHLSL, DiffuseMapFeatHLSL, OverlayTexFeatHLSL, DiffuseFeatureHLSL, DiffuseVertColorFeatureHLSL, LightmapFeatHLSL, TonemapFeatHLSL, VertLitHLSL, DetailFeatHLSL, FogFeatHLSL, TexAnimHLSL, VisibilityFeatHLSL, AlphaTestHLSL, GlowMaskHLSL, HDROutHLSL

getDependencies()

Gets the dependency list for this shader feature.

getName()

Returns the name of this feature.

Reimplemented by: WindDeformationGLSL, WindDeformationHLSL, AdvancedLightBufferConditioner, DeferredRTLightingFeatGLSL, DeferredBumpFeatGLSL, DeferredMinnaertGLSL, DeferredSubSurfaceGLSL, DeferredOrmMapGLSL, MatInfoFlagsGLSL, ORMConfigVarsGLSL, GlowMapGLSL, GBufferConditionerGLSL, DeferredRTLightingFeatHLSL, DeferredBumpFeatHLSL, DeferredMinnaertHLSL, DeferredSubSurfaceHLSL, DeferredOrmMapHLSL, MatInfoFlagsHLSL, ORMConfigVarsHLSL, GlowMapHLSL, GBufferConditionerHLSL, LinearEyeDepthConditioner, AccuTexFeatGLSL, AccuScaleFeature, AccuDirectionFeature, AccuStrengthFeature, AccuCoverageFeature, AccuSpecularFeature, BumpFeatGLSL, ParallaxFeatGLSL, NormalsOutFeatGLSL, CustomFeatureGLSL, DebugVizGLSL, EyeSpaceDepthOutGLSL, DepthOutGLSL, ParaboloidVertTransformGLSL, NamedFeatureGLSL, RenderTargetZeroGLSL, VertPositionGLSL, RTLightingFeatGLSL, DiffuseMapFeatGLSL, OverlayTexFeatGLSL, DiffuseFeatureGLSL, DiffuseVertColorFeatureGLSL, LightmapFeatGLSL, TonemapFeatGLSL, VertLitGLSL, DetailFeatGLSL, ReflectCubeFeatGLSL, FogFeatGLSL, TexAnimGLSL, VisibilityFeatGLSL, AlphaTestGLSL, GlowMaskGLSL, HDROutGLSL, FoliageFeatureGLSL, ParticleNormalFeatureGLSL, ImposterVertFeatureGLSL, HardwareSkinningFeatureGLSL, ReflectionProbeFeatGLSL, AccuTexFeatHLSL, AccuScaleFeature, AccuDirectionFeature, AccuStrengthFeature, AccuCoverageFeature, AccuSpecularFeature, BumpFeatHLSL, ParallaxFeatHLSL, NormalsOutFeatHLSL, CustomFeatureHLSL, DebugVizHLSL, EyeSpaceDepthOutHLSL, DepthOutHLSL, ParaboloidVertTransformHLSL, NamedFeatureHLSL, RenderTargetZeroHLSL, VertPositionHLSL, RTLightingFeatHLSL, DiffuseMapFeatHLSL, OverlayTexFeatHLSL, DiffuseFeatureHLSL, DiffuseVertColorFeatureHLSL, LightmapFeatHLSL, TonemapFeatHLSL, VertLitHLSL, DetailFeatHLSL, ReflectCubeFeatHLSL, FogFeatHLSL, TexAnimHLSL, VisibilityFeatHLSL, AlphaTestHLSL, GlowMaskHLSL, HDROutHLSL, FoliageFeatureHLSL, ParticleNormalFeatureHLSL, ImposterVertFeatureHLSL, HardwareSkinningFeatureHLSL, ReflectionProbeFeatHLSL, TerrainBaseMapFeatGLSL, TerrainDetailMapFeatGLSL, TerrainMacroMapFeatGLSL, TerrainNormalMapFeatGLSL, TerrainLightMapFeatGLSL, TerrainORMMapFeatGLSL, TerrainBlankInfoMapFeatGLSL, TerrainHeightMapBlendGLSL, TerrainBaseMapFeatHLSL, TerrainDetailMapFeatHLSL, TerrainMacroMapFeatHLSL, TerrainNormalMapFeatHLSL, TerrainLightMapFeatHLSL, TerrainORMMapFeatHLSL, TerrainBlankInfoMapFeatHLSL, TerrainHeightMapBlendHLSL

getOutput()

returns output from a processed vertex or pixel shader

getOutputTargets(const MaterialFeatureData & fd)

Gets the render target this shader feature is assigning data to.

Reimplemented by: DeferredOrmMapGLSL, MatInfoFlagsGLSL, ORMConfigVarsGLSL, GlowMapGLSL, DeferredOrmMapHLSL, MatInfoFlagsHLSL, ORMConfigVarsHLSL, GlowMapHLSL, RenderTargetZeroGLSL, DiffuseMapFeatGLSL, DiffuseFeatureGLSL, LightmapFeatGLSL, TonemapFeatGLSL, VertLitGLSL, RenderTargetZeroHLSL, DiffuseMapFeatHLSL, DiffuseFeatureHLSL, LightmapFeatHLSL, TonemapFeatHLSL, VertLitHLSL, TerrainBaseMapFeatGLSL, TerrainDetailMapFeatGLSL, TerrainMacroMapFeatGLSL, TerrainORMMapFeatGLSL, TerrainBlankInfoMapFeatGLSL, TerrainBaseMapFeatHLSL, TerrainDetailMapFeatHLSL, TerrainMacroMapFeatHLSL, TerrainORMMapFeatHLSL, TerrainBlankInfoMapFeatHLSL

getOutputTargetVarName(OutputTarget target)

Returns the name of output targer var.

getOutputVarName()

Returns the output variable name for this feature if it applies.

Reimplemented by: EyeSpaceDepthOutGLSL, DepthOutGLSL, EyeSpaceDepthOutHLSL, DepthOutHLSL

getProcessIndex()

getResources(const MaterialFeatureData & fd)

Returns the resource requirements of this feature based on what other features are present.

The "resources" are things such as texture units, and texture registers of which there can be very limited numbers. The resources can vary depending on hardware and what other features are present.

Reimplemented by: DeferredRTLightingFeatGLSL, DeferredBumpFeatGLSL, DeferredMinnaertGLSL, DeferredOrmMapGLSL, GlowMapGLSL, GBufferConditionerGLSL, DeferredRTLightingFeatHLSL, DeferredBumpFeatHLSL, DeferredMinnaertHLSL, DeferredOrmMapHLSL, GlowMapHLSL, GBufferConditionerHLSL, AccuTexFeatGLSL, BumpFeatGLSL, ParallaxFeatGLSL, CustomFeatureGLSL, EyeSpaceDepthOutGLSL, DepthOutGLSL, ParaboloidVertTransformGLSL, RTLightingFeatGLSL, DiffuseMapFeatGLSL, OverlayTexFeatGLSL, LightmapFeatGLSL, TonemapFeatGLSL, DetailFeatGLSL, ReflectCubeFeatGLSL, FogFeatGLSL, VisibilityFeatGLSL, ReflectionProbeFeatGLSL, AccuTexFeatHLSL, BumpFeatHLSL, ParallaxFeatHLSL, CustomFeatureHLSL, EyeSpaceDepthOutHLSL, DepthOutHLSL, ParaboloidVertTransformHLSL, RTLightingFeatHLSL, DiffuseMapFeatHLSL, OverlayTexFeatHLSL, LightmapFeatHLSL, TonemapFeatHLSL, DetailFeatHLSL, ReflectCubeFeatHLSL, FogFeatHLSL, VisibilityFeatHLSL, ReflectionProbeFeatHLSL, TerrainBaseMapFeatGLSL, TerrainDetailMapFeatGLSL, TerrainMacroMapFeatGLSL, TerrainNormalMapFeatGLSL, TerrainLightMapFeatGLSL, TerrainORMMapFeatGLSL, TerrainBaseMapFeatHLSL, TerrainDetailMapFeatHLSL, TerrainMacroMapFeatHLSL, TerrainNormalMapFeatHLSL, TerrainLightMapFeatHLSL, TerrainORMMapFeatHLSL

getVertTexCoord(const String & name)

Get the incoming base texture coords - useful for bumpmap and detail maps.

Reimplemented by: ConditionerFeature, ShaderFeatureGLSL, ShaderFeatureHLSL

processPix(Vector< ShaderComponent * > & componentList, const MaterialFeatureData & fd)

Process pixel shader - This function is used by each feature to generate a list of LangElements that can be traversed and "printed" to generate the actual shader code. The 'output' member is the head of that list.

The componentList is used mostly for access to the "Connector" structure which is used to pass data from the vertex to the pixel shader.

The MaterialFeatureData parameter is used to determine what other features are present for the shader being generated.

Reimplemented by: DeferredRTLightingFeatGLSL, DeferredBumpFeatGLSL, DeferredMinnaertGLSL, DeferredSubSurfaceGLSL, DeferredOrmMapGLSL, MatInfoFlagsGLSL, ORMConfigVarsGLSL, GlowMapGLSL, GBufferConditionerGLSL, DeferredRTLightingFeatHLSL, DeferredBumpFeatHLSL, DeferredMinnaertHLSL, DeferredSubSurfaceHLSL, DeferredOrmMapHLSL, MatInfoFlagsHLSL, ORMConfigVarsHLSL, GlowMapHLSL, GBufferConditionerHLSL, LinearEyeDepthConditioner, AccuTexFeatGLSL, AccuScaleFeature, AccuDirectionFeature, AccuStrengthFeature, AccuCoverageFeature, AccuSpecularFeature, BumpFeatGLSL, ParallaxFeatGLSL, NormalsOutFeatGLSL, CustomFeatureGLSL, DebugVizGLSL, EyeSpaceDepthOutGLSL, DepthOutGLSL, ParaboloidVertTransformGLSL, RenderTargetZeroGLSL, RTLightingFeatGLSL, DiffuseMapFeatGLSL, OverlayTexFeatGLSL, DiffuseFeatureGLSL, DiffuseVertColorFeatureGLSL, LightmapFeatGLSL, TonemapFeatGLSL, VertLitGLSL, DetailFeatGLSL, ReflectCubeFeatGLSL, FogFeatGLSL, VisibilityFeatGLSL, AlphaTestGLSL, GlowMaskGLSL, HDROutGLSL, FoliageFeatureGLSL, ImposterVertFeatureGLSL, ReflectionProbeFeatGLSL, AccuTexFeatHLSL, AccuScaleFeature, AccuDirectionFeature, AccuStrengthFeature, AccuCoverageFeature, AccuSpecularFeature, BumpFeatHLSL, ParallaxFeatHLSL, NormalsOutFeatHLSL, CustomFeatureHLSL, DebugVizHLSL, EyeSpaceDepthOutHLSL, DepthOutHLSL, ParaboloidVertTransformHLSL, RenderTargetZeroHLSL, VertPositionHLSL, RTLightingFeatHLSL, DiffuseMapFeatHLSL, OverlayTexFeatHLSL, DiffuseFeatureHLSL, DiffuseVertColorFeatureHLSL, LightmapFeatHLSL, TonemapFeatHLSL, VertLitHLSL, DetailFeatHLSL, ReflectCubeFeatHLSL, FogFeatHLSL, VisibilityFeatHLSL, AlphaTestHLSL, GlowMaskHLSL, HDROutHLSL, FoliageFeatureHLSL, ImposterVertFeatureHLSL, ReflectionProbeFeatHLSL, TerrainBaseMapFeatGLSL, TerrainDetailMapFeatGLSL, TerrainMacroMapFeatGLSL, TerrainNormalMapFeatGLSL, TerrainLightMapFeatGLSL, TerrainORMMapFeatGLSL, TerrainBlankInfoMapFeatGLSL, TerrainHeightMapBlendGLSL, TerrainBaseMapFeatHLSL, TerrainDetailMapFeatHLSL, TerrainMacroMapFeatHLSL, TerrainNormalMapFeatHLSL, TerrainLightMapFeatHLSL, TerrainORMMapFeatHLSL, TerrainBlankInfoMapFeatHLSL, TerrainHeightMapBlendHLSL

processPixMacros(Vector< GFXShaderMacro > & macros, const MaterialFeatureData & fd)

Allows the feature to add macros to pixel shader compiles.

Reimplemented by: DeferredRTLightingFeatGLSL, DeferredMinnaertGLSL, DeferredRTLightingFeatHLSL, DeferredMinnaertHLSL

processVert(Vector< ShaderComponent * > & componentList, const MaterialFeatureData & fd)

Process vertex shader - This function is used by each feature to generate a list of LangElements that can be traversed and "printed" to generate the actual shader code. The 'output' member is the head of that list.

The componentList is used mostly for access to the "Connector" structure which is used to pass data from the vertex to the pixel shader.

The MaterialFeatureData parameter is used to determine what other features are present for the shader being generated.

Reimplemented by: WindDeformationGLSL, WindDeformationHLSL, DeferredRTLightingFeatGLSL, DeferredBumpFeatGLSL, DeferredMinnaertGLSL, DeferredOrmMapGLSL, GBufferConditionerGLSL, DeferredRTLightingFeatHLSL, DeferredBumpFeatHLSL, DeferredMinnaertHLSL, DeferredOrmMapHLSL, GBufferConditionerHLSL, AccuTexFeatGLSL, BumpFeatGLSL, ParallaxFeatGLSL, NormalsOutFeatGLSL, CustomFeatureGLSL, EyeSpaceDepthOutGLSL, DepthOutGLSL, ParaboloidVertTransformGLSL, VertPositionGLSL, RTLightingFeatGLSL, DiffuseMapFeatGLSL, OverlayTexFeatGLSL, DiffuseVertColorFeatureGLSL, LightmapFeatGLSL, TonemapFeatGLSL, VertLitGLSL, DetailFeatGLSL, ReflectCubeFeatGLSL, FogFeatGLSL, VisibilityFeatGLSL, FoliageFeatureGLSL, ParticleNormalFeatureGLSL, ImposterVertFeatureGLSL, HardwareSkinningFeatureGLSL, ReflectionProbeFeatGLSL, AccuTexFeatHLSL, BumpFeatHLSL, ParallaxFeatHLSL, NormalsOutFeatHLSL, CustomFeatureHLSL, EyeSpaceDepthOutHLSL, DepthOutHLSL, ParaboloidVertTransformHLSL, VertPositionHLSL, RTLightingFeatHLSL, DiffuseMapFeatHLSL, OverlayTexFeatHLSL, DiffuseVertColorFeatureHLSL, LightmapFeatHLSL, TonemapFeatHLSL, VertLitHLSL, DetailFeatHLSL, ReflectCubeFeatHLSL, FogFeatHLSL, VisibilityFeatHLSL, FoliageFeatureHLSL, ParticleNormalFeatureHLSL, ImposterVertFeatureHLSL, HardwareSkinningFeatureHLSL, ReflectionProbeFeatHLSL, TerrainBaseMapFeatGLSL, TerrainDetailMapFeatGLSL, TerrainMacroMapFeatGLSL, TerrainNormalMapFeatGLSL, TerrainORMMapFeatGLSL, TerrainHeightMapBlendGLSL, TerrainBaseMapFeatHLSL, TerrainDetailMapFeatHLSL, TerrainMacroMapFeatHLSL, TerrainNormalMapFeatHLSL, TerrainORMMapFeatHLSL, TerrainHeightMapBlendHLSL

processVertMacros(Vector< GFXShaderMacro > & macros, const MaterialFeatureData & fd)

Allows the feature to add macros to vertex shader compiles.

reset()

Called after processing the vertex and processing the pixel to cleanup any temporary structures stored in the feature.

setInstancingFormat(GFXVertexFormat * format)

setProcessIndex(S32 index)

setTexData(Material::StageData & stageDat, const MaterialFeatureData & fd, RenderPassData & passData, U32 & texIndex)

Fills texture related info in RenderPassData for this feature.

It takes into account the current pass (passData) as well as what other data is available to the material stage (stageDat).

For instance, ReflectCubeFeatHLSL would like to modulate its output by the alpha channel of another texture. If the current pass does not contain a diffuse or bump texture, but the Material does, then this function allows it to use one of those textures in the current pass.

Reimplemented by: DeferredRTLightingFeatGLSL, DeferredBumpFeatGLSL, DeferredMinnaertGLSL, DeferredOrmMapGLSL, GlowMapGLSL, DeferredRTLightingFeatHLSL, DeferredBumpFeatHLSL, DeferredMinnaertHLSL, DeferredOrmMapHLSL, GlowMapHLSL, AccuTexFeatGLSL, BumpFeatGLSL, ParallaxFeatGLSL, CustomFeatureGLSL, DiffuseMapFeatGLSL, OverlayTexFeatGLSL, LightmapFeatGLSL, TonemapFeatGLSL, DetailFeatGLSL, ReflectCubeFeatGLSL, ReflectionProbeFeatGLSL, AccuTexFeatHLSL, BumpFeatHLSL, ParallaxFeatHLSL, CustomFeatureHLSL, DiffuseMapFeatHLSL, OverlayTexFeatHLSL, LightmapFeatHLSL, TonemapFeatHLSL, DetailFeatHLSL, ReflectCubeFeatHLSL, ReflectionProbeFeatHLSL

setupTexSpaceMat(Vector< ShaderComponent * > & componentList, Var ** texSpaceMat)

Set up a texture space matrix - to pass into pixel shader.

Reimplemented by: ConditionerFeature, ShaderFeatureGLSL, ShaderFeatureHLSL

Public Static Functions

findOrCreateLocal(const char * name, const char * type, MultiLine * multi)

A simpler helper function which either finds the existing local var or creates one.