2012-09-19 11:15:01 -04: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 _SHADERGENVARS_H_
|
|
|
|
|
#define _SHADERGENVARS_H_
|
|
|
|
|
|
|
|
|
|
#ifndef _TORQUE_STRING_H_
|
|
|
|
|
#include "core/util/str.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// ShaderGenVars, predefined string names for variables that shadergen based shaders use, this avoids
|
|
|
|
|
/// misspelling and string creation issues
|
|
|
|
|
///
|
|
|
|
|
struct ShaderGenVars
|
|
|
|
|
{
|
|
|
|
|
const static String modelview;
|
|
|
|
|
const static String worldViewOnly;
|
|
|
|
|
const static String worldToCamera;
|
2018-10-28 20:42:26 +10:00
|
|
|
const static String cameraToWorld;
|
2012-09-19 11:15:01 -04:00
|
|
|
const static String worldToObj;
|
|
|
|
|
const static String viewToObj;
|
|
|
|
|
const static String cubeTrans;
|
2017-06-23 11:36:20 -05:00
|
|
|
const static String cubeMips;
|
2012-09-19 11:15:01 -04:00
|
|
|
const static String objTrans;
|
|
|
|
|
const static String cubeEyePos;
|
|
|
|
|
const static String eyePos;
|
|
|
|
|
const static String eyePosWorld;
|
|
|
|
|
const static String vEye;
|
|
|
|
|
const static String eyeMat;
|
|
|
|
|
const static String oneOverFarplane;
|
|
|
|
|
const static String nearPlaneWorld;
|
|
|
|
|
const static String fogData;
|
|
|
|
|
const static String fogColor;
|
|
|
|
|
const static String detailScale;
|
|
|
|
|
const static String visibility;
|
|
|
|
|
const static String colorMultiply;
|
|
|
|
|
const static String alphaTestValue;
|
|
|
|
|
const static String texMat;
|
|
|
|
|
const static String accumTime;
|
|
|
|
|
const static String minnaertConstant;
|
|
|
|
|
const static String subSurfaceParams;
|
|
|
|
|
|
|
|
|
|
// Texture atlasing parameters
|
|
|
|
|
const static String diffuseAtlasParams;
|
|
|
|
|
const static String diffuseAtlasTileParams;
|
|
|
|
|
const static String bumpAtlasParams;
|
|
|
|
|
const static String bumpAtlasTileParams;
|
|
|
|
|
|
|
|
|
|
// Render target parameters
|
|
|
|
|
const static String targetSize;
|
|
|
|
|
const static String oneOverTargetSize;
|
|
|
|
|
|
|
|
|
|
// Lighting parameters used by the default
|
|
|
|
|
// RTLighting shader feature.
|
|
|
|
|
const static String lightPosition;
|
|
|
|
|
const static String lightDiffuse;
|
|
|
|
|
const static String lightAmbient;
|
|
|
|
|
const static String lightInvRadiusSq;
|
|
|
|
|
const static String lightSpotDir;
|
|
|
|
|
const static String lightSpotAngle;
|
|
|
|
|
const static String lightSpotFalloff;
|
|
|
|
|
const static String specularColor;
|
2018-09-15 20:19:57 -05:00
|
|
|
const static String smoothness;
|
|
|
|
|
const static String metalness;
|
2018-09-16 22:15:07 -05:00
|
|
|
|
|
|
|
|
//Reflection Probes
|
|
|
|
|
const static String probePosition;
|
|
|
|
|
const static String probeRadius;
|
|
|
|
|
const static String probeBoxMin;
|
|
|
|
|
const static String probeBoxMax;
|
|
|
|
|
const static String probeLocalPos;
|
|
|
|
|
const static String probeIsSphere;
|
|
|
|
|
const static String probeCubemap;
|
2019-01-07 20:34:19 -06:00
|
|
|
const static String probeCount;
|
2012-09-19 11:15:01 -04:00
|
|
|
|
|
|
|
|
// Textures
|
|
|
|
|
const static String fogMap;
|
|
|
|
|
const static String dlightMap;
|
|
|
|
|
const static String dlightMask;
|
|
|
|
|
const static String dlightMapSec;
|
|
|
|
|
const static String blackfogMap;
|
|
|
|
|
const static String bumpMap;
|
|
|
|
|
const static String lightMap;
|
|
|
|
|
const static String lightNormMap;
|
|
|
|
|
const static String cubeMap;
|
|
|
|
|
const static String dLightMap;
|
|
|
|
|
const static String dLightMapSec;
|
|
|
|
|
const static String dLightMask;
|
|
|
|
|
const static String toneMap;
|
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 02:23:23 -06:00
|
|
|
|
|
|
|
|
// Deferred Shading
|
|
|
|
|
const static String matInfoFlags;
|
2012-09-19 11:15:01 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|