2012-09-19 15:15:01 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// Copyright (c) 2012 GarageGames, LLC
|
|
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to
|
|
|
|
|
// deal in the Software without restriction, including without limitation the
|
|
|
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
// IN THE SOFTWARE.
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
#ifndef _SHADERGEN_HLSL_SHADERFEATUREHLSL_H_
|
|
|
|
|
#define _SHADERGEN_HLSL_SHADERFEATUREHLSL_H_
|
|
|
|
|
|
|
|
|
|
#ifndef _SHADERFEATURE_H_
|
|
|
|
|
#include "shaderGen/shaderFeature.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
struct LangElement;
|
|
|
|
|
struct MaterialFeatureData;
|
|
|
|
|
struct RenderPassData;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ShaderFeatureHLSL : public ShaderFeature
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ShaderFeatureHLSL();
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
Var* getOutTexCoord( const char *name,
|
|
|
|
|
const char *type,
|
|
|
|
|
bool useTexAnim,
|
|
|
|
|
MultiLine *meta,
|
|
|
|
|
Vector<ShaderComponent*> &componentList );
|
|
|
|
|
|
|
|
|
|
/// Returns an input texture coord by name adding it
|
|
|
|
|
/// to the input connector if it doesn't exist.
|
|
|
|
|
static Var* getInTexCoord( const char *name,
|
|
|
|
|
const char *type,
|
|
|
|
|
Vector<ShaderComponent*> &componentList );
|
|
|
|
|
|
|
|
|
|
static Var* getInColor( const char *name,
|
|
|
|
|
const char *type,
|
|
|
|
|
Vector<ShaderComponent*> &componentList );
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
static Var* addOutVpos( MultiLine *meta,
|
|
|
|
|
Vector<ShaderComponent*> &componentList );
|
|
|
|
|
|
|
|
|
|
/// Returns the VPOS input register for the pixel shader.
|
|
|
|
|
static Var* getInVpos( MultiLine *meta,
|
|
|
|
|
Vector<ShaderComponent*> &componentList );
|
|
|
|
|
|
|
|
|
|
/// Returns the "objToTangentSpace" transform or creates one if this
|
|
|
|
|
/// is the first feature to need it.
|
|
|
|
|
Var* getOutObjToTangentSpace( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
MultiLine *meta,
|
|
|
|
|
const MaterialFeatureData &fd );
|
|
|
|
|
|
|
|
|
|
/// Returns the existing output "outWorldToTangent" transform or
|
|
|
|
|
/// creates one if this is the first feature to need it.
|
|
|
|
|
Var* getOutWorldToTangent( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
MultiLine *meta,
|
|
|
|
|
const MaterialFeatureData &fd );
|
|
|
|
|
|
|
|
|
|
/// Returns the input "worldToTanget" space transform
|
|
|
|
|
/// adding it to the input connector if it doesn't exist.
|
|
|
|
|
static Var* getInWorldToTangent( Vector<ShaderComponent*> &componentList );
|
|
|
|
|
|
|
|
|
|
/// Returns the existing output "outViewToTangent" transform or
|
|
|
|
|
/// creates one if this is the first feature to need it.
|
|
|
|
|
Var* getOutViewToTangent( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
MultiLine *meta,
|
|
|
|
|
const MaterialFeatureData &fd );
|
|
|
|
|
|
|
|
|
|
/// Returns the input "viewToTangent" space transform
|
|
|
|
|
/// adding it to the input connector if it doesn't exist.
|
|
|
|
|
static Var* getInViewToTangent( Vector<ShaderComponent*> &componentList );
|
|
|
|
|
|
|
|
|
|
/// Calculates the world space position in the vertex shader and
|
|
|
|
|
/// assigns it to the passed language element. It does not pass
|
|
|
|
|
/// it across the connector to the pixel shader.
|
|
|
|
|
/// @see addOutWsPosition
|
|
|
|
|
void getWsPosition( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
bool useInstancing,
|
|
|
|
|
MultiLine *meta,
|
|
|
|
|
LangElement *wsPosition );
|
|
|
|
|
|
|
|
|
|
/// Adds the "wsPosition" to the input connector if it doesn't exist.
|
|
|
|
|
Var* addOutWsPosition( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
bool useInstancing,
|
|
|
|
|
MultiLine *meta );
|
|
|
|
|
|
|
|
|
|
/// Returns the input world space position from the connector.
|
|
|
|
|
static Var* getInWsPosition( Vector<ShaderComponent*> &componentList );
|
|
|
|
|
|
|
|
|
|
/// Returns the world space view vector from the wsPosition.
|
|
|
|
|
static Var* getWsView( Var *wsPosition, MultiLine *meta );
|
|
|
|
|
|
|
|
|
|
/// Returns the input normal map texture.
|
|
|
|
|
static Var* getNormalMapTex();
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
Var* addOutDetailTexCoord( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
MultiLine *meta,
|
2019-10-04 04:46:53 +00:00
|
|
|
bool useTexAnim,
|
|
|
|
|
bool useFoliageTexCoord);
|
2012-09-19 15:15:01 +00:00
|
|
|
|
|
|
|
|
///
|
|
|
|
|
Var* getObjTrans( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
bool useInstancing,
|
|
|
|
|
MultiLine *meta );
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
Var* getModelView( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
bool useInstancing,
|
|
|
|
|
MultiLine *meta );
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
Var* getWorldView( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
bool useInstancing,
|
|
|
|
|
MultiLine *meta );
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
Var* getInvWorldView( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
bool useInstancing,
|
|
|
|
|
MultiLine *meta );
|
|
|
|
|
|
2019-07-03 00:26:20 +00:00
|
|
|
Var* getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta, const MaterialFeatureData& fd);
|
2019-07-01 04:04:16 +00:00
|
|
|
|
2019-11-20 07:39:12 +00:00
|
|
|
Var* getInWorldNormal(Vector<ShaderComponent*>& componentList);
|
|
|
|
|
|
2012-09-19 15:15:01 +00:00
|
|
|
// ShaderFeature
|
2024-03-18 18:40:22 +00:00
|
|
|
Var* getVertTexCoord( const String &name ) override;
|
|
|
|
|
LangElement* setupTexSpaceMat( Vector<ShaderComponent*> &componentList, Var **texSpaceMat ) override;
|
|
|
|
|
LangElement* assignColor( LangElement *elem, Material::BlendOp blend, LangElement *lerpElem = NULL, ShaderFeature::OutputTarget outputTarget = ShaderFeature::DefaultTarget ) override;
|
|
|
|
|
LangElement* expandNormalMap( LangElement *sampleNormalOp, LangElement *normalDecl, LangElement *normalVar, const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NamedFeatureHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
String mName;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
NamedFeatureHLSL( const String &name )
|
|
|
|
|
: mName( name )
|
|
|
|
|
{}
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override { return mName; }
|
2012-09-19 15:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class RenderTargetZeroHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
ShaderFeature::OutputTarget mOutputTargetMask;
|
|
|
|
|
String mFeatureName;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
RenderTargetZeroHLSL( const ShaderFeature::OutputTarget target )
|
|
|
|
|
: mOutputTargetMask( target )
|
|
|
|
|
{
|
|
|
|
|
char buffer[256];
|
|
|
|
|
dSprintf(buffer, sizeof(buffer), "Render Target Output = 0.0, output mask %04b", mOutputTargetMask);
|
|
|
|
|
mFeatureName = buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override { return mFeatureName; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 getOutputTargets( const MaterialFeatureData &fd ) const override { return mOutputTargetMask; }
|
2012-09-19 15:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Vertex position
|
|
|
|
|
class VertPositionHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2016-03-20 11:52:11 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Vert Position";
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void determineFeature( Material *material,
|
2012-09-19 15:15:01 +00:00
|
|
|
const GFXVertexFormat *vertexFormat,
|
|
|
|
|
U32 stageNum,
|
|
|
|
|
const FeatureType &type,
|
|
|
|
|
const FeatureSet &features,
|
2024-03-18 18:40:22 +00:00
|
|
|
MaterialFeatureData *outFeatureData ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Vertex lighting based on the normal and the light
|
|
|
|
|
/// direction passed through the vertex color.
|
|
|
|
|
class RTLightingFeatHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
ShaderIncludeDependency mDep;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
RTLightingFeatHLSL();
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override{ return Material::None; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Resources getResources( const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "RT Lighting";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Base texture
|
|
|
|
|
class DiffuseMapFeatHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
2015-11-11 19:52:46 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
ShaderIncludeDependency mTorqueDep;
|
|
|
|
|
|
2012-09-19 15:15:01 +00:00
|
|
|
public:
|
2015-11-11 19:52:46 +00:00
|
|
|
DiffuseMapFeatHLSL();
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 getOutputTargets(const MaterialFeatureData &fd) const override;
|
engine:
defines and alters a series of material features for deferred shading in order to define a fully fleshed out multiple render target gbuffer patterned after the general principles outlined http://www.catalinzima.com/xna/tutorials/deferred-rendering-in-xna/creating-the-g-buffer/ (though I cannot stress enough *not* using the identical layout)
script:
removes dead material features (ie: those that never functioned to begin with)
shader:
bool getFlag(float flags, int num) definition for retreiving data from the 3rd (matinfo) gbuffer slot's red channel (more on that shortly)
purpose:
_A)_ Small primer on how material features function:
When a https://github.com/GarageGames/Torque3D/search?utf8=%E2%9C%93&q=_determineFeatures call is executed, certain conditions trigger a given .addFeature(MFT_SOMEFEATURE) call based upon material definition entries, be it a value, a texture reference, or even the presence or lack thereof for another feature. In general terms, the first to be executed is ProcessedShaderMaterial::_determineFeatures followed by ProcessedPrePassMaterial::_determineFeatures. The next commit will provide the bindings there. For now it's enough to understand that one of those two will trigger the shadergen subsystem, when rendering a material, to check it's associated list of features and spit out a shader if one is not already defined, or reference a pre-existing one that includes codelines determined by that list of features.
Relevant execution of this is as follows:
DeclareFeatureType( MFT_DeferredDiffuseMap ); - Name
ImplementFeatureType( MFT_DeferredDiffuseMap, MFG_Texture, 2.0f, false ); - Codeline Insertion Order
FEATUREMGR->registerFeature( MFT_DeferredDiffuseMap, new DeferredDiffuseMapHLSL ); - Hook to class which actually generates code
alternately FEATUREMGR->registerFeature( MFT_Imposter, new NamedFeatureHLSL( "Imposter" ) ); - a simple feature that serves no purpose further than as a test of it's existence (to modify other features for instance)
class DeferredDiffuseMapHLSL : public ShaderFeatureHLSL - Class definition
{
getName -embeded in the proceedural shader as a remline both up top and before actual code insertions
processPix - pixel shader codeline insertions
getOutputTargets - used to determine which buffer is written to (assumes only one. depending on branched logic, older features that may be run for either forward or deferred rendering depending on circumstance may have a logical switch based on additional feature flags. as an example: TerrainBaseMapFeatHLSL::getOutputTargets)
getResources - associated with the Resources struct, closely aligned with the hardware regestry
getBlendOp - used to determine what blend operation to use if a material requires a second pass (defaults to overwriting)
setTexData - ???
processVert - vertex shader codeline insertions
};
_B)_
The resultant Gbuffer layout defined by the previous commit therefore is as follows:
defaultrendertarget (referred to in shaders as out.col or col depending on GFX plugin) contains either lighting and normal data, or color data depending on if it is used in a deferred or forward lit manner (note for forward lit, this data is replaced as a second step with color. why custommaterials have traditionally had problems with lighting)
color1 (referred to in shaders as out.col1 or col1 depending on GFX plugin) RGB color data and an A for blending operations (including transparency)
color2 (referred to in shaders as out.col2 or col2 depending on GFX plugin) contains:
red channel comprising material flags such as metalness, emissive, ect,
green channel for translucency (light shining through, as oposed to see-through transparency), blue for
blue for specular strength (how much light influences net color)
alpha for specular power (generally how reflective/glossy an object is)
long term purpose:
further down the line, these will be used to condition data for use with a PBR subsystem, with further corrections to the underlying mathematics, strength being replaced by roughness, and power by metalness
2016-02-16 08:23:23 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override{ return Material::LerpAlpha; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Resources getResources( const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
|
|
|
|
// Sets textures and texture flags for current pass
|
2024-03-18 18:40:22 +00:00
|
|
|
void setTexData( Material::StageData &stageDat,
|
2012-09-19 15:15:01 +00:00
|
|
|
const MaterialFeatureData &fd,
|
|
|
|
|
RenderPassData &passData,
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 &texIndex ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Base Texture";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Overlay texture
|
|
|
|
|
class OverlayTexFeatHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override{ return Material::LerpAlpha; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Resources getResources( const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
|
|
|
|
// Sets textures and texture flags for current pass
|
2024-03-18 18:40:22 +00:00
|
|
|
void setTexData( Material::StageData &stageDat,
|
2012-09-19 15:15:01 +00:00
|
|
|
const MaterialFeatureData &fd,
|
|
|
|
|
RenderPassData &passData,
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 &texIndex ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Overlay Texture";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Diffuse color
|
|
|
|
|
class DiffuseFeatureHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override{ return Material::None; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 getOutputTargets(const MaterialFeatureData &fd) const override;
|
|
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Diffuse Color";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// Diffuse vertex color
|
|
|
|
|
class DiffuseVertColorFeatureHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector< ShaderComponent* >& componentList,
|
|
|
|
|
const MaterialFeatureData& fd ) override;
|
|
|
|
|
void processPix( Vector< ShaderComponent* >&componentList,
|
|
|
|
|
const MaterialFeatureData& fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override{ return Material::None; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Diffuse Vertex Color";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// Lightmap
|
|
|
|
|
class LightmapFeatHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override{ return Material::LerpAlpha; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Resources getResources( const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
|
|
|
|
// Sets textures and texture flags for current pass
|
2024-03-18 18:40:22 +00:00
|
|
|
void setTexData( Material::StageData &stageDat,
|
2012-09-19 15:15:01 +00:00
|
|
|
const MaterialFeatureData &fd,
|
|
|
|
|
RenderPassData &passData,
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 &texIndex ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Lightmap";
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 getOutputTargets( const MaterialFeatureData &fd ) const override;
|
2012-09-19 15:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Tonemap
|
|
|
|
|
class TonemapFeatHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override{ return Material::LerpAlpha; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Resources getResources( const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
|
|
|
|
// Sets textures and texture flags for current pass
|
2024-03-18 18:40:22 +00:00
|
|
|
void setTexData( Material::StageData &stageDat,
|
2012-09-19 15:15:01 +00:00
|
|
|
const MaterialFeatureData &fd,
|
|
|
|
|
RenderPassData &passData,
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 &texIndex ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Tonemap";
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 getOutputTargets( const MaterialFeatureData &fd ) const override;
|
2012-09-19 15:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Baked lighting stored on the vertex color
|
|
|
|
|
class VertLitHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override{ return Material::None; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Vert Lit";
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 getOutputTargets( const MaterialFeatureData &fd ) const override;
|
2012-09-19 15:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Detail map
|
|
|
|
|
class DetailFeatHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Resources getResources( const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override{ return Material::Mul; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
|
|
|
|
// Sets textures and texture flags for current pass
|
2024-03-18 18:40:22 +00:00
|
|
|
void setTexData( Material::StageData &stageDat,
|
2012-09-19 15:15:01 +00:00
|
|
|
const MaterialFeatureData &fd,
|
|
|
|
|
RenderPassData &passData,
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 &texIndex ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Detail";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Reflect Cubemap
|
|
|
|
|
class ReflectCubeFeatHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Resources getResources( const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
|
|
|
|
// Sets textures and texture flags for current pass
|
2024-03-18 18:40:22 +00:00
|
|
|
void setTexData( Material::StageData &stageDat,
|
2012-09-19 15:15:01 +00:00
|
|
|
const MaterialFeatureData &fd,
|
|
|
|
|
RenderPassData &passData,
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 &texIndex ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Reflect Cube";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Fog
|
|
|
|
|
class FogFeatHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
ShaderIncludeDependency mFogDep;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
FogFeatHLSL();
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Resources getResources( const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override { return Material::LerpAlpha; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Fog";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Tex Anim
|
|
|
|
|
class TexAnimHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override { return Material::None; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Texture Animation";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Visibility
|
|
|
|
|
class VisibilityFeatHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
ShaderIncludeDependency mTorqueDep;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
VisibilityFeatHLSL();
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Resources getResources( const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override { return Material::None; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Visibility";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
class AlphaTestHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override { return Material::None; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Alpha Test";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Special feature used to mask out the RGB color for
|
|
|
|
|
/// non-glow passes of glow materials.
|
|
|
|
|
/// @see RenderGlowMgr
|
|
|
|
|
class GlowMaskHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
2024-05-30 22:29:42 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
|
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Glow Mask";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// This should be the final feature on most pixel shaders which
|
|
|
|
|
/// encodes the color for the current HDR target format.
|
|
|
|
|
/// @see HDRPostFx
|
|
|
|
|
/// @see LightManager
|
|
|
|
|
/// @see torque.hlsl
|
|
|
|
|
class HDROutHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
ShaderIncludeDependency mTorqueDep;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
HDROutHLSL();
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Material::BlendOp getBlendOp() override { return Material::None; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override { return "HDR Output"; }
|
2012-09-19 15:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
class FoliageFeatureHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
ShaderIncludeDependency mDep;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
FoliageFeatureHLSL();
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Foliage Feature";
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void determineFeature( Material *material,
|
2012-09-19 15:15:01 +00:00
|
|
|
const GFXVertexFormat *vertexFormat,
|
|
|
|
|
U32 stageNum,
|
|
|
|
|
const FeatureType &type,
|
|
|
|
|
const FeatureSet &features,
|
2024-03-18 18:40:22 +00:00
|
|
|
MaterialFeatureData *outFeatureData ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
ShaderFeatureConstHandles* createConstHandles( GFXShader *shader, SimObject *userObject ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ParticleNormalFeatureHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2012-09-19 15:15:01 +00:00
|
|
|
{
|
|
|
|
|
return "Particle Normal Generation Feature";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Special feature for unpacking imposter verts.
|
|
|
|
|
/// @see RenderImposterMgr
|
|
|
|
|
class ImposterVertFeatureHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
ShaderIncludeDependency mDep;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
ImposterVertFeatureHLSL();
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override { return "Imposter Vert"; }
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void determineFeature( Material *material,
|
2012-09-19 15:15:01 +00:00
|
|
|
const GFXVertexFormat *vertexFormat,
|
|
|
|
|
U32 stageNum,
|
|
|
|
|
const FeatureType &type,
|
|
|
|
|
const FeatureSet &features,
|
2024-03-18 18:40:22 +00:00
|
|
|
MaterialFeatureData *outFeatureData ) override;
|
2012-09-19 15:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
2015-01-10 19:41:25 +00:00
|
|
|
/// Hardware Skinning
|
|
|
|
|
class HardwareSkinningFeatureHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd ) override;
|
2015-01-10 19:41:25 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override { return "Hardware Skinning"; }
|
2015-01-10 19:41:25 +00:00
|
|
|
};
|
|
|
|
|
|
2018-09-17 03:15:07 +00:00
|
|
|
/// Reflection Probes
|
|
|
|
|
class ReflectionProbeFeatHLSL : public ShaderFeatureHLSL
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
ShaderIncludeDependency mDep;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
ReflectionProbeFeatHLSL();
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processVert(Vector<ShaderComponent*>& componentList,
|
|
|
|
|
const MaterialFeatureData& fd) override;
|
2019-04-29 22:39:47 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
void processPix(Vector<ShaderComponent*> &componentList,
|
|
|
|
|
const MaterialFeatureData &fd) override;
|
2018-09-17 03:15:07 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
Resources getResources(const MaterialFeatureData &fd) override;
|
2018-09-17 03:15:07 +00:00
|
|
|
|
|
|
|
|
// Sets textures and texture flags for current pass
|
2024-03-18 18:40:22 +00:00
|
|
|
void setTexData(Material::StageData &stageDat,
|
2018-09-17 03:15:07 +00:00
|
|
|
const MaterialFeatureData &fd,
|
|
|
|
|
RenderPassData &passData,
|
2024-03-18 18:40:22 +00:00
|
|
|
U32 &texIndex) override;
|
2018-09-17 03:15:07 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
String getName() override
|
2018-09-17 03:15:07 +00:00
|
|
|
{
|
|
|
|
|
return "Reflection Probes";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2012-09-19 15:15:01 +00:00
|
|
|
#endif // _SHADERGEN_HLSL_SHADERFEATUREHLSL_H_
|