mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 23:54:35 +00:00
Merge branch 'GarageGames/master' into ueberengine-dev
Conflicts: Engine/source/T3D/fps/guiCrossHairHud.cpp
This commit is contained in:
commit
81750f3deb
2827 changed files with 315755 additions and 121398 deletions
|
|
@ -26,6 +26,7 @@
|
|||
#include "terrain/terrFeatureTypes.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "materials/materialFeatureData.h"
|
||||
#include "materials/processedMaterial.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
#include "shaderGen/langElement.h"
|
||||
#include "shaderGen/shaderOp.h"
|
||||
|
|
@ -48,6 +49,10 @@ namespace
|
|||
FEATUREMGR->registerFeature( MFT_TerrainLightMap, new TerrainLightMapFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainSideProject, new NamedFeatureGLSL( "Terrain Side Projection" ) );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainBaseMap, new TerrainBaseMapFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainMacroMap, new TerrainMacroMapFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainDetailMap, new TerrainDetailMapFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainBlankInfoMap, new TerrainBlankInfoMapFeatGLSL );
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -64,6 +69,12 @@ MODULE_BEGIN( TerrainFeatGLSL )
|
|||
MODULE_END;
|
||||
|
||||
|
||||
TerrainFeatGLSL::TerrainFeatGLSL()
|
||||
: mTorqueDep( "shaders/common/gl/torque.glsl" )
|
||||
{
|
||||
addDependency( &mTorqueDep );
|
||||
}
|
||||
|
||||
Var* TerrainFeatGLSL::_getUniformVar( const char *name, const char *type, ConstantSortPosition csp )
|
||||
{
|
||||
Var *theVar = (Var*)LangElement::find( name );
|
||||
|
|
@ -244,10 +255,6 @@ void TerrainBaseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
// grab connector texcoord register
|
||||
Var *texCoord = getInTexCoord( "texCoord", "vec3", true, componentList );
|
||||
|
||||
// We do nothing more if this is a prepass.
|
||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
return;
|
||||
|
||||
// create texture var
|
||||
Var *diffuseMap = new Var;
|
||||
diffuseMap->setType( "sampler2D" );
|
||||
|
|
@ -262,7 +269,15 @@ void TerrainBaseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
baseColor->setType( "vec4" );
|
||||
baseColor->setName( "baseColor" );
|
||||
meta->addStatement( new GenOp( " @ = tex2D( @, @.xy );\r\n", new DecOp( baseColor ), diffuseMap, texCoord ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul ) ) );
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", baseColor, baseColor));
|
||||
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
|
||||
if(fd.features.hasFeature(MFT_isDeferred))
|
||||
{
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
}
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul,NULL,target ) ) );
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
@ -271,14 +286,16 @@ ShaderFeature::Resources TerrainBaseMapFeatGLSL::getResources( const MaterialFea
|
|||
{
|
||||
Resources res;
|
||||
res.numTexReg = 1;
|
||||
|
||||
// We only sample from the base map during a diffuse pass.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
res.numTex = 1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
U32 TerrainBaseMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
TerrainDetailMapFeatGLSL::TerrainDetailMapFeatGLSL()
|
||||
: mTorqueDep( "shaders/common/gl/torque.glsl" ),
|
||||
mTerrainDep( "shaders/common/terrain/terrain.glsl" )
|
||||
|
|
@ -291,7 +308,7 @@ TerrainDetailMapFeatGLSL::TerrainDetailMapFeatGLSL()
|
|||
void TerrainDetailMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
const U32 detailIndex = getProcessIndex();
|
||||
const S32 detailIndex = getProcessIndex();
|
||||
|
||||
// Grab incoming texture coords... the base map feature
|
||||
// made sure this was created.
|
||||
|
|
@ -376,7 +393,7 @@ void TerrainDetailMapFeatGLSL::processVert( Vector<ShaderComponent*> &component
|
|||
void TerrainDetailMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
const U32 detailIndex = getProcessIndex();
|
||||
const S32 detailIndex = getProcessIndex();
|
||||
Var *inTex = getVertTexCoord( "texCoord" );
|
||||
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
|
@ -447,6 +464,99 @@ void TerrainDetailMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
meta->addStatement( new GenOp( " @ = calcBlend( @.x, @.xy, @, @ );\r\n",
|
||||
new DecOp( detailBlend ), detailInfo, inTex, layerSize, layerSample ) );
|
||||
|
||||
// New terrain
|
||||
|
||||
Var *lerpBlend = (Var*)LangElement::find("lerpBlend");
|
||||
if (!lerpBlend)
|
||||
{
|
||||
lerpBlend = new Var;
|
||||
lerpBlend->setType("float");
|
||||
lerpBlend->setName("lerpBlend");
|
||||
lerpBlend->uniform = true;
|
||||
lerpBlend->constSortPos = cspPrimitive;
|
||||
}
|
||||
|
||||
|
||||
Var *blendDepth = (Var*)LangElement::find(String::ToString("blendDepth%d", detailIndex));
|
||||
if (!blendDepth)
|
||||
{
|
||||
blendDepth = new Var;
|
||||
blendDepth->setType("float");
|
||||
blendDepth->setName(String::ToString("blendDepth%d", detailIndex));
|
||||
blendDepth->uniform = true;
|
||||
blendDepth->constSortPos = cspPrimitive;
|
||||
}
|
||||
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
|
||||
if(fd.features.hasFeature( MFT_DeferredTerrainDetailMap ))
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
|
||||
Var *outColor = (Var*)LangElement::find( getOutputTargetVarName(target) );
|
||||
|
||||
if (!outColor)
|
||||
{
|
||||
// create color var
|
||||
outColor = new Var;
|
||||
outColor->setType("float4");
|
||||
outColor->setName("col");
|
||||
outColor->setStructName("OUT");
|
||||
meta->addStatement(new GenOp(" @;\r\n", outColor));
|
||||
}
|
||||
|
||||
Var *detailColor = (Var*)LangElement::find("detailColor");
|
||||
if (!detailColor)
|
||||
{
|
||||
detailColor = new Var;
|
||||
detailColor->setType("float4");
|
||||
detailColor->setName("detailColor");
|
||||
meta->addStatement(new GenOp(" @;\r\n", new DecOp(detailColor)));
|
||||
}
|
||||
|
||||
// Get the detail texture.
|
||||
Var *detailMap = new Var;
|
||||
detailMap->setType("sampler2D");
|
||||
detailMap->setName(String::ToString("detailMap%d", detailIndex));
|
||||
detailMap->uniform = true;
|
||||
detailMap->sampler = true;
|
||||
detailMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
// Get the normal map texture.
|
||||
Var *normalMap = _getNormalMapTex();
|
||||
|
||||
// Issue happens somewhere here -----
|
||||
|
||||
// Sample the normal map.
|
||||
//
|
||||
// We take two normal samples and lerp between them for
|
||||
// side projection layers... else a single sample.
|
||||
LangElement *texOp;
|
||||
|
||||
// Note that we're doing the standard greyscale detail
|
||||
// map technique here which can darken and lighten the
|
||||
// diffuse texture.
|
||||
//
|
||||
// We take two color samples and lerp between them for
|
||||
// side projection layers... else a single sample.
|
||||
//
|
||||
if (fd.features.hasFeature(MFT_TerrainSideProject, detailIndex))
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = ( lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet, detailMap, inDet, inTex));
|
||||
|
||||
texOp = new GenOp("lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z )",
|
||||
normalMap, inDet, normalMap, inDet, inTex);
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = ( tex2D( @, @.xy ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet));
|
||||
|
||||
texOp = new GenOp("tex2D(@, @.xy)", normalMap, inDet);
|
||||
}
|
||||
|
||||
// New terrain
|
||||
|
||||
// Get a var and accumulate the blend amount.
|
||||
Var *blendTotal = (Var*)LangElement::find( "blendTotal" );
|
||||
if ( !blendTotal )
|
||||
|
|
@ -480,46 +590,6 @@ void TerrainDetailMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
}
|
||||
}
|
||||
|
||||
// If this is a prepass then we skip color.
|
||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
{
|
||||
// Check to see if we have a gbuffer normal.
|
||||
Var *gbNormal = (Var*)LangElement::find( "gbNormal" );
|
||||
|
||||
// If we have a gbuffer normal and we don't have a
|
||||
// normal map feature then we need to lerp in a
|
||||
// default normal else the normals below this layer
|
||||
// will show thru.
|
||||
if ( gbNormal &&
|
||||
!fd.features.hasFeature( MFT_TerrainNormalMap, detailIndex ) )
|
||||
{
|
||||
Var *viewToTangent = getInViewToTangent( componentList );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, tGetMatrix3Row(@, 2), min( @, @.w ) );\r\n",
|
||||
gbNormal, gbNormal, viewToTangent, detailBlend, inDet ) );
|
||||
}
|
||||
|
||||
output = meta;
|
||||
return;
|
||||
}
|
||||
|
||||
Var *detailColor = (Var*)LangElement::find( "detailColor" );
|
||||
if ( !detailColor )
|
||||
{
|
||||
detailColor = new Var;
|
||||
detailColor->setType( "vec4" );
|
||||
detailColor->setName( "detailColor" );
|
||||
meta->addStatement( new GenOp( " @;\r\n", new DecOp( detailColor ) ) );
|
||||
}
|
||||
|
||||
// Get the detail texture.
|
||||
Var *detailMap = new Var;
|
||||
detailMap->setType( "sampler2D" );
|
||||
detailMap->setName( String::ToString( "detailMap%d", detailIndex ) );
|
||||
detailMap->uniform = true;
|
||||
detailMap->sampler = true;
|
||||
detailMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
// If we're using SM 3.0 then take advantage of
|
||||
// dynamic branching to skip layers per-pixel.
|
||||
|
||||
|
|
@ -550,11 +620,8 @@ void TerrainDetailMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
meta->addStatement( new GenOp( " @ *= @.y * @.w;\r\n",
|
||||
detailColor, detailInfo, inDet ) );
|
||||
|
||||
Var *baseColor = (Var*)LangElement::find( "baseColor" );
|
||||
Var *outColor = (Var*)LangElement::find( "col" );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, @ + @, @ );\r\n",
|
||||
outColor, outColor, baseColor, detailColor, detailBlend ) );
|
||||
meta->addStatement( new GenOp( " @ += @ * @;\r\n",
|
||||
outColor, detailColor, detailBlend));
|
||||
|
||||
meta->addStatement( new GenOp( " }\r\n" ) );
|
||||
|
||||
|
|
@ -578,9 +645,7 @@ ShaderFeature::Resources TerrainDetailMapFeatGLSL::getResources( const MaterialF
|
|||
res.numTexReg += 4;
|
||||
}
|
||||
|
||||
// If this isn't the prepass then we sample
|
||||
// from the detail texture for diffuse coloring.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
// sample from the detail texture for diffuse coloring.
|
||||
res.numTex += 1;
|
||||
|
||||
// If we have parallax for this layer then we'll also
|
||||
|
|
@ -595,6 +660,11 @@ ShaderFeature::Resources TerrainDetailMapFeatGLSL::getResources( const MaterialF
|
|||
return res;
|
||||
}
|
||||
|
||||
U32 TerrainDetailMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_DeferredTerrainDetailMap] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
|
||||
TerrainMacroMapFeatGLSL::TerrainMacroMapFeatGLSL()
|
||||
: mTorqueDep( "shaders/common/gl/torque.glsl" ),
|
||||
|
|
@ -609,7 +679,7 @@ TerrainMacroMapFeatGLSL::TerrainMacroMapFeatGLSL()
|
|||
void TerrainMacroMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
const U32 detailIndex = getProcessIndex();
|
||||
const S32 detailIndex = getProcessIndex();
|
||||
|
||||
// Grab incoming texture coords... the base map feature
|
||||
// made sure this was created.
|
||||
|
|
@ -667,7 +737,7 @@ void TerrainMacroMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentL
|
|||
void TerrainMacroMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
const U32 detailIndex = getProcessIndex();
|
||||
const S32 detailIndex = getProcessIndex();
|
||||
Var *inTex = getVertTexCoord( "texCoord" );
|
||||
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
|
@ -750,30 +820,7 @@ void TerrainMacroMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
}
|
||||
|
||||
// Add to the blend total.
|
||||
meta->addStatement( new GenOp( " @ = max( @, @ );\r\n", blendTotal, blendTotal, detailBlend ) );
|
||||
|
||||
// If this is a prepass then we skip color.
|
||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
{
|
||||
// Check to see if we have a gbuffer normal.
|
||||
Var *gbNormal = (Var*)LangElement::find( "gbNormal" );
|
||||
|
||||
// If we have a gbuffer normal and we don't have a
|
||||
// normal map feature then we need to lerp in a
|
||||
// default normal else the normals below this layer
|
||||
// will show thru.
|
||||
if ( gbNormal &&
|
||||
!fd.features.hasFeature( MFT_TerrainNormalMap, detailIndex ) )
|
||||
{
|
||||
Var *viewToTangent = getInViewToTangent( componentList );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, tGetMatrix3Row(@, 2), min( @, @.w ) );\r\n",
|
||||
gbNormal, gbNormal, viewToTangent, detailBlend, inDet ) );
|
||||
}
|
||||
|
||||
output = meta;
|
||||
return;
|
||||
}
|
||||
meta->addStatement( new GenOp( " @ += @;\r\n", blendTotal, detailBlend ) );
|
||||
|
||||
Var *detailColor = (Var*)LangElement::find( "macroColor" );
|
||||
if ( !detailColor )
|
||||
|
|
@ -819,11 +866,15 @@ void TerrainMacroMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
|
||||
meta->addStatement( new GenOp( " @ *= @.y * @.w;\r\n",
|
||||
detailColor, detailInfo, inDet ) );
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
|
||||
Var *outColor = (Var*)LangElement::find( "col" );
|
||||
if(fd.features.hasFeature(MFT_DeferredTerrainMacroMap))
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, @ + @, @ );\r\n",
|
||||
outColor, outColor, outColor, detailColor, detailBlend ) );
|
||||
Var *outColor = (Var*)LangElement::find( getOutputTargetVarName(target) );
|
||||
|
||||
meta->addStatement(new GenOp(" @ += @ * @;\r\n",
|
||||
outColor, detailColor, detailBlend));
|
||||
|
||||
meta->addStatement( new GenOp( " }\r\n" ) );
|
||||
|
||||
|
|
@ -843,9 +894,6 @@ ShaderFeature::Resources TerrainMacroMapFeatGLSL::getResources( const MaterialFe
|
|||
res.numTex += 1;
|
||||
}
|
||||
|
||||
// If this isn't the prepass then we sample
|
||||
// from the detail texture for diffuse coloring.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
res.numTex += 1;
|
||||
|
||||
// Finally we always send the detail texture
|
||||
|
|
@ -855,6 +903,11 @@ ShaderFeature::Resources TerrainMacroMapFeatGLSL::getResources( const MaterialFe
|
|||
return res;
|
||||
}
|
||||
|
||||
U32 TerrainMacroMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_DeferredTerrainMacroMap] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void TerrainNormalMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
|
|
@ -874,9 +927,6 @@ void TerrainNormalMapFeatGLSL::processVert( Vector<ShaderComponent*> &component
|
|||
void TerrainNormalMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
// We only need to process normals during the prepass.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
return;
|
||||
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
||||
|
|
@ -893,7 +943,7 @@ void TerrainNormalMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
meta->addStatement( new GenOp( " @ = tGetMatrix3Row(@, 2);\r\n", new DecOp( gbNormal ), viewToTangent ) );
|
||||
}
|
||||
|
||||
const U32 normalIndex = getProcessIndex();
|
||||
const S32 normalIndex = getProcessIndex();
|
||||
|
||||
Var *detailBlend = (Var*)LangElement::find( String::ToString( "detailBlend%d", normalIndex ) );
|
||||
AssertFatal( detailBlend, "The detail blend is missing!" );
|
||||
|
|
@ -1016,7 +1066,12 @@ ShaderFeature::Resources TerrainLightMapFeatGLSL::getResources( const MaterialFe
|
|||
void TerrainAdditiveFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
Var *color = (Var*) LangElement::find( "col" );
|
||||
Var *color = NULL;
|
||||
if (fd.features[MFT_DeferredTerrainDetailMap])
|
||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) );
|
||||
else
|
||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) );
|
||||
|
||||
Var *blendTotal = (Var*)LangElement::find( "blendTotal" );
|
||||
if ( !color || !blendTotal )
|
||||
return;
|
||||
|
|
@ -1028,3 +1083,40 @@ void TerrainAdditiveFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
//standard matInfo map contains data of the form .r = bitflags, .g = (will contain AO),
|
||||
//.b = specular strength, a= spec power.
|
||||
//here, it's merely a cutout for now, so that lightmapping (target3) doesn't get mangled.
|
||||
//we'll most likely revisit that later. possibly several ways...
|
||||
|
||||
U32 TerrainBlankInfoMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1;
|
||||
}
|
||||
|
||||
void TerrainBlankInfoMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
{
|
||||
// search for material var
|
||||
Var *material;
|
||||
OutputTarget targ = RenderTarget1;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = RenderTarget2;
|
||||
}
|
||||
material = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
if (!material)
|
||||
{
|
||||
// create color var
|
||||
material = new Var;
|
||||
material->setType("vec4");
|
||||
material->setName(getOutputTargetVarName(targ));
|
||||
material->setStructName("OUT");
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0,0.0,0.0,0.0001);\r\n", material));
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@
|
|||
class TerrainFeatGLSL : public ShaderFeatureGLSL
|
||||
{
|
||||
protected:
|
||||
ShaderIncludeDependency mTorqueDep;
|
||||
|
||||
public:
|
||||
TerrainFeatGLSL();
|
||||
Var* _getInDetailCoord(Vector<ShaderComponent*> &componentList );
|
||||
|
||||
Var* _getInMacroCoord(Vector<ShaderComponent*> &componentList );
|
||||
|
|
@ -64,6 +67,8 @@ public:
|
|||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
virtual String getName() { return "Terrain Base Texture"; }
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -87,6 +92,8 @@ public:
|
|||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
virtual String getName() { return "Terrain Detail Texture"; }
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -110,6 +117,8 @@ public:
|
|||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
virtual String getName() { return "Terrain Macro Texture"; }
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -151,4 +160,15 @@ public:
|
|||
virtual String getName() { return "Terrain Additive"; }
|
||||
};
|
||||
|
||||
class TerrainBlankInfoMapFeatGLSL : public ShaderFeatureGLSL
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd);
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
virtual String getName() { return "Blank Matinfo map"; }
|
||||
};
|
||||
|
||||
#endif // _TERRFEATUREGLSL_H_
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "terrain/terrFeatureTypes.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "materials/materialFeatureData.h"
|
||||
#include "materials/processedMaterial.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
#include "shaderGen/langElement.h"
|
||||
#include "shaderGen/shaderOp.h"
|
||||
|
|
@ -37,7 +38,7 @@ namespace
|
|||
{
|
||||
void register_hlsl_shader_features_for_terrain(GFXAdapterType type)
|
||||
{
|
||||
if(type != Direct3D9 && type != Direct3D9_360)
|
||||
if (type != Direct3D9 && type != Direct3D9_360 && type != Direct3D11)
|
||||
return;
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_TerrainBaseMap, new TerrainBaseMapFeatHLSL );
|
||||
|
|
@ -47,9 +48,12 @@ namespace
|
|||
FEATUREMGR->registerFeature( MFT_TerrainMacroMap, new TerrainMacroMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainLightMap, new TerrainLightMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainSideProject, new NamedFeatureHLSL( "Terrain Side Projection" ) );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainBaseMap, new TerrainBaseMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainMacroMap, new TerrainMacroMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainDetailMap, new TerrainDetailMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainBlankInfoMap, new TerrainBlankInfoMapFeatHLSL );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
MODULE_BEGIN( TerrainFeatHLSL )
|
||||
|
|
@ -64,6 +68,12 @@ MODULE_BEGIN( TerrainFeatHLSL )
|
|||
MODULE_END;
|
||||
|
||||
|
||||
TerrainFeatHLSL::TerrainFeatHLSL()
|
||||
: mTorqueDep( "shaders/common/torque.hlsl" )
|
||||
{
|
||||
addDependency( &mTorqueDep );
|
||||
}
|
||||
|
||||
Var* TerrainFeatHLSL::_getUniformVar( const char *name, const char *type, ConstantSortPosition csp )
|
||||
{
|
||||
Var *theVar = (Var*)LangElement::find( name );
|
||||
|
|
@ -119,14 +129,18 @@ Var* TerrainFeatHLSL::_getInMacroCoord( Vector<ShaderComponent*> &componentList
|
|||
|
||||
Var* TerrainFeatHLSL::_getNormalMapTex()
|
||||
{
|
||||
String name( String::ToString( "normalMap%d", getProcessIndex() ) );
|
||||
Var *normalMap = (Var*)LangElement::find( name );
|
||||
String name(String::ToString("normalMap%d", getProcessIndex()));
|
||||
Var *normalMap = (Var*)LangElement::find(name);
|
||||
|
||||
if ( !normalMap )
|
||||
if (!normalMap)
|
||||
{
|
||||
normalMap = new Var;
|
||||
normalMap->setType( "sampler2D" );
|
||||
normalMap->setName( name );
|
||||
if (mIsDirect3D11)
|
||||
normalMap->setType("SamplerState");
|
||||
else
|
||||
normalMap->setType("sampler2D");
|
||||
|
||||
normalMap->setName(name);
|
||||
normalMap->uniform = true;
|
||||
normalMap->sampler = true;
|
||||
normalMap->constNum = Var::getTexUnitNum();
|
||||
|
|
@ -244,10 +258,6 @@ void TerrainBaseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
// grab connector texcoord register
|
||||
Var *texCoord = getInTexCoord( "texCoord", "float3", true, componentList );
|
||||
|
||||
// We do nothing more if this is a prepass.
|
||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
return;
|
||||
|
||||
// create texture var
|
||||
Var *diffuseMap = new Var;
|
||||
diffuseMap->setType( "sampler2D" );
|
||||
|
|
@ -261,9 +271,32 @@ void TerrainBaseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
Var *baseColor = new Var;
|
||||
baseColor->setType( "float4" );
|
||||
baseColor->setName( "baseColor" );
|
||||
meta->addStatement( new GenOp( " @ = tex2D( @, @.xy );\r\n", new DecOp( baseColor ), diffuseMap, texCoord ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul ) ) );
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
diffuseMap->setType("SamplerState");
|
||||
Var *diffuseTex = new Var;
|
||||
diffuseTex->setType("Texture2D");
|
||||
diffuseTex->setName("baseTexture");
|
||||
diffuseTex->uniform = true;
|
||||
diffuseTex->texture = true;
|
||||
diffuseTex->constNum = diffuseMap->constNum;
|
||||
meta->addStatement(new GenOp(" @ = @.Sample( @, @.xy );\r\n", new DecOp(baseColor), diffuseTex, diffuseMap, texCoord));
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = tex2D( @, @.xy );\r\n", new DecOp(baseColor), diffuseMap, texCoord));
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", baseColor, baseColor));
|
||||
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
|
||||
if (fd.features.hasFeature(MFT_isDeferred))
|
||||
{
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul,NULL,target ) ) );
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -271,14 +304,16 @@ ShaderFeature::Resources TerrainBaseMapFeatHLSL::getResources( const MaterialFea
|
|||
{
|
||||
Resources res;
|
||||
res.numTexReg = 1;
|
||||
|
||||
// We only sample from the base map during a diffuse pass.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
res.numTex = 1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
U32 TerrainBaseMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_DeferredTerrainBaseMap] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
TerrainDetailMapFeatHLSL::TerrainDetailMapFeatHLSL()
|
||||
: mTorqueDep( "shaders/common/torque.hlsl" ),
|
||||
mTerrainDep( "shaders/common/terrain/terrain.hlsl" )
|
||||
|
|
@ -291,7 +326,7 @@ TerrainDetailMapFeatHLSL::TerrainDetailMapFeatHLSL()
|
|||
void TerrainDetailMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
const U32 detailIndex = getProcessIndex();
|
||||
const S32 detailIndex = getProcessIndex();
|
||||
|
||||
// Grab incoming texture coords... the base map feature
|
||||
// made sure this was created.
|
||||
|
|
@ -376,7 +411,7 @@ void TerrainDetailMapFeatHLSL::processVert( Vector<ShaderComponent*> &component
|
|||
void TerrainDetailMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
const U32 detailIndex = getProcessIndex();
|
||||
const S32 detailIndex = getProcessIndex();
|
||||
Var *inTex = getVertTexCoord( "texCoord" );
|
||||
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
|
@ -417,9 +452,25 @@ void TerrainDetailMapFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
layerTex->sampler = true;
|
||||
layerTex->constNum = Var::getTexUnitNum();
|
||||
|
||||
// Read the layer texture to get the samples.
|
||||
meta->addStatement( new GenOp( " @ = round( tex2D( @, @.xy ) * 255.0f );\r\n",
|
||||
new DecOp( layerSample ), layerTex, inTex ) );
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
layerTex->setType("SamplerState");
|
||||
Var* layerTexObj = new Var;
|
||||
layerTexObj->setName("layerTexObj");
|
||||
layerTexObj->setType("Texture2D");
|
||||
layerTexObj->uniform = true;
|
||||
layerTexObj->texture = true;
|
||||
layerTexObj->constNum = layerTex->constNum;
|
||||
// Read the layer texture to get the samples.
|
||||
meta->addStatement(new GenOp(" @ = round( @.Sample( @, @.xy ) * 255.0f );\r\n",
|
||||
new DecOp(layerSample), layerTexObj, layerTex, inTex));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read the layer texture to get the samples.
|
||||
meta->addStatement(new GenOp(" @ = round( tex2D( @, @.xy ) * 255.0f );\r\n",
|
||||
new DecOp(layerSample), layerTex, inTex));
|
||||
}
|
||||
}
|
||||
|
||||
Var *layerSize = (Var*)LangElement::find( "layerSize" );
|
||||
|
|
@ -462,47 +513,55 @@ void TerrainDetailMapFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
|
||||
// If we had a parallax feature... then factor in the parallax
|
||||
// amount so that it fades out with the layer blending.
|
||||
if ( fd.features.hasFeature( MFT_TerrainParallaxMap, detailIndex ) )
|
||||
if (fd.features.hasFeature(MFT_TerrainParallaxMap, detailIndex))
|
||||
{
|
||||
// Get the rest of our inputs.
|
||||
Var *normalMap = _getNormalMapTex();
|
||||
|
||||
// Call the library function to do the rest.
|
||||
if(fd.features.hasFeature( MFT_IsDXTnm, detailIndex ) )
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
meta->addStatement( new GenOp( " @.xy += parallaxOffsetDxtnm( @, @.xy, @, @.z * @ );\r\n",
|
||||
inDet, normalMap, inDet, negViewTS, detailInfo, detailBlend ) );
|
||||
String name(String::ToString("normalMapTex%d", getProcessIndex()));
|
||||
Var *normalMapTex = (Var*)LangElement::find(name);
|
||||
|
||||
if (!normalMapTex)
|
||||
{
|
||||
normalMapTex = new Var;
|
||||
normalMapTex->setName(String::ToString("normalMapTex%d", getProcessIndex()));
|
||||
normalMapTex->setType("Texture2D");
|
||||
normalMapTex->uniform = true;
|
||||
normalMapTex->texture = true;
|
||||
normalMapTex->constNum = normalMap->constNum;
|
||||
}
|
||||
|
||||
// Call the library function to do the rest.
|
||||
if (fd.features.hasFeature(MFT_IsDXTnm, detailIndex))
|
||||
{
|
||||
meta->addStatement(new GenOp(" @.xy += parallaxOffsetDxtnm( @, @, @.xy, @, @.z * @ );\r\n",
|
||||
inDet, normalMapTex, normalMap, inDet, negViewTS, detailInfo, detailBlend));
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp(" @.xy += parallaxOffset( @, @, @.xy, @, @.z * @ );\r\n",
|
||||
inDet, normalMapTex, normalMap, inDet, negViewTS, detailInfo, detailBlend));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement( new GenOp( " @.xy += parallaxOffset( @, @.xy, @, @.z * @ );\r\n",
|
||||
inDet, normalMap, inDet, negViewTS, detailInfo, detailBlend ) );
|
||||
// Call the library function to do the rest.
|
||||
if (fd.features.hasFeature(MFT_IsDXTnm, detailIndex))
|
||||
{
|
||||
meta->addStatement(new GenOp(" @.xy += parallaxOffsetDxtnm( @, @.xy, @, @.z * @ );\r\n",
|
||||
inDet, normalMap, inDet, negViewTS, detailInfo, detailBlend));
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp(" @.xy += parallaxOffset( @, @.xy, @, @.z * @ );\r\n",
|
||||
inDet, normalMap, inDet, negViewTS, detailInfo, detailBlend));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this is a prepass then we skip color.
|
||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
{
|
||||
// Check to see if we have a gbuffer normal.
|
||||
Var *gbNormal = (Var*)LangElement::find( "gbNormal" );
|
||||
|
||||
// If we have a gbuffer normal and we don't have a
|
||||
// normal map feature then we need to lerp in a
|
||||
// default normal else the normals below this layer
|
||||
// will show thru.
|
||||
if ( gbNormal &&
|
||||
!fd.features.hasFeature( MFT_TerrainNormalMap, detailIndex ) )
|
||||
{
|
||||
Var *viewToTangent = getInViewToTangent( componentList );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, @[2], min( @, @.w ) );\r\n",
|
||||
gbNormal, gbNormal, viewToTangent, detailBlend, inDet ) );
|
||||
}
|
||||
|
||||
output = meta;
|
||||
return;
|
||||
}
|
||||
|
||||
Var *detailColor = (Var*)LangElement::find( "detailColor" );
|
||||
if ( !detailColor )
|
||||
{
|
||||
|
|
@ -536,21 +595,54 @@ void TerrainDetailMapFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
// We take two color samples and lerp between them for
|
||||
// side projection layers... else a single sample.
|
||||
//
|
||||
if ( fd.features.hasFeature( MFT_TerrainSideProject, detailIndex ) )
|
||||
|
||||
//Sampled detail texture that is not expanded
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
meta->addStatement( new GenOp( " @ = ( lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet, detailMap, inDet, inTex ) );
|
||||
detailMap->setType("SamplerState");
|
||||
Var* detailTex = new Var;
|
||||
detailTex->setName(String::ToString("detailTex%d", detailIndex));
|
||||
detailTex->setType("Texture2D");
|
||||
detailTex->uniform = true;
|
||||
detailTex->texture = true;
|
||||
detailTex->constNum = detailMap->constNum;
|
||||
|
||||
if (fd.features.hasFeature(MFT_TerrainSideProject, detailIndex))
|
||||
{
|
||||
|
||||
meta->addStatement(new GenOp(" @ = ( lerp( @.Sample( @, @.yz ), @.Sample( @, @.xz ), @.z ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailTex, detailMap, inDet, detailTex, detailMap, inDet, inTex));
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = ( @.Sample( @, @.xy ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailTex, detailMap, inDet));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement( new GenOp( " @ = ( tex2D( @, @.xy ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet ) );
|
||||
if (fd.features.hasFeature(MFT_TerrainSideProject, detailIndex))
|
||||
{
|
||||
|
||||
meta->addStatement(new GenOp(" @ = ( lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet, detailMap, inDet, inTex));
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = ( tex2D( @, @.xy ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet));
|
||||
}
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @ *= @.y * @.w;\r\n",
|
||||
detailColor, detailInfo, inDet ) );
|
||||
|
||||
Var *outColor = (Var*)LangElement::find( "col" );
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
|
||||
if(fd.features.hasFeature( MFT_DeferredTerrainDetailMap ))
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
|
||||
Var *outColor = (Var*)LangElement::find( getOutputTargetVarName(target) );
|
||||
|
||||
meta->addStatement( new GenOp( " @ += @ * @;\r\n",
|
||||
outColor, detailColor, detailBlend));
|
||||
|
|
@ -577,9 +669,7 @@ ShaderFeature::Resources TerrainDetailMapFeatHLSL::getResources( const MaterialF
|
|||
res.numTexReg += 4;
|
||||
}
|
||||
|
||||
// If this isn't the prepass then we sample
|
||||
// from the detail texture for diffuse coloring.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
// sample from the detail texture for diffuse coloring.
|
||||
res.numTex += 1;
|
||||
|
||||
// If we have parallax for this layer then we'll also
|
||||
|
|
@ -594,6 +684,11 @@ ShaderFeature::Resources TerrainDetailMapFeatHLSL::getResources( const MaterialF
|
|||
return res;
|
||||
}
|
||||
|
||||
U32 TerrainDetailMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_DeferredTerrainDetailMap] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
|
||||
TerrainMacroMapFeatHLSL::TerrainMacroMapFeatHLSL()
|
||||
: mTorqueDep( "shaders/common/torque.hlsl" ),
|
||||
|
|
@ -608,7 +703,7 @@ TerrainMacroMapFeatHLSL::TerrainMacroMapFeatHLSL()
|
|||
void TerrainMacroMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
const U32 detailIndex = getProcessIndex();
|
||||
const S32 detailIndex = getProcessIndex();
|
||||
|
||||
// Grab incoming texture coords... the base map feature
|
||||
// made sure this was created.
|
||||
|
|
@ -666,7 +761,7 @@ void TerrainMacroMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentL
|
|||
void TerrainMacroMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
const U32 detailIndex = getProcessIndex();
|
||||
const S32 detailIndex = getProcessIndex();
|
||||
Var *inTex = getVertTexCoord( "texCoord" );
|
||||
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
|
@ -708,8 +803,21 @@ void TerrainMacroMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
layerTex->constNum = Var::getTexUnitNum();
|
||||
|
||||
// Read the layer texture to get the samples.
|
||||
meta->addStatement( new GenOp( " @ = round( tex2D( @, @.xy ) * 255.0f );\r\n",
|
||||
new DecOp( layerSample ), layerTex, inTex ) );
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
layerTex->setType("SamplerState");
|
||||
Var *layerTexObj = new Var;
|
||||
layerTexObj->setType("Texture2D");
|
||||
layerTexObj->setName("macroLayerTexObj");
|
||||
layerTexObj->uniform = true;
|
||||
layerTexObj->texture = true;
|
||||
layerTexObj->constNum = layerTex->constNum;
|
||||
meta->addStatement(new GenOp(" @ = round( @.Sample( @, @.xy ) * 255.0f );\r\n",
|
||||
new DecOp(layerSample), layerTexObj, layerTex, inTex));
|
||||
}
|
||||
else
|
||||
meta->addStatement(new GenOp(" @ = round( tex2D( @, @.xy ) * 255.0f );\r\n",
|
||||
new DecOp(layerSample), layerTex, inTex));
|
||||
}
|
||||
|
||||
Var *layerSize = (Var*)LangElement::find( "layerSize" );
|
||||
|
|
@ -742,7 +850,6 @@ void TerrainMacroMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
if ( !blendTotal )
|
||||
{
|
||||
blendTotal = new Var;
|
||||
//blendTotal->setName( "blendTotal" );
|
||||
blendTotal->setName( "blendTotal" );
|
||||
blendTotal->setType( "float" );
|
||||
meta->addStatement( new GenOp( " @ = 0;\r\n", new DecOp( blendTotal ) ) );
|
||||
|
|
@ -751,29 +858,6 @@ void TerrainMacroMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
// Add to the blend total.
|
||||
meta->addStatement( new GenOp( " @ += @;\r\n", blendTotal, detailBlend ) );
|
||||
|
||||
// If this is a prepass then we skip color.
|
||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
{
|
||||
// Check to see if we have a gbuffer normal.
|
||||
Var *gbNormal = (Var*)LangElement::find( "gbNormal" );
|
||||
|
||||
// If we have a gbuffer normal and we don't have a
|
||||
// normal map feature then we need to lerp in a
|
||||
// default normal else the normals below this layer
|
||||
// will show thru.
|
||||
if ( gbNormal &&
|
||||
!fd.features.hasFeature( MFT_TerrainNormalMap, detailIndex ) )
|
||||
{
|
||||
Var *viewToTangent = getInViewToTangent( componentList );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, @[2], min( @, @.w ) );\r\n",
|
||||
gbNormal, gbNormal, viewToTangent, detailBlend, inDet ) );
|
||||
}
|
||||
|
||||
output = meta;
|
||||
return;
|
||||
}
|
||||
|
||||
Var *detailColor = (Var*)LangElement::find( "macroColor" );
|
||||
if ( !detailColor )
|
||||
{
|
||||
|
|
@ -791,6 +875,20 @@ void TerrainMacroMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
detailMap->sampler = true;
|
||||
detailMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
//Create texture object for directx 11
|
||||
Var *detailTex = NULL;
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
detailMap->setType("SamplerState");
|
||||
detailTex = new Var;
|
||||
detailTex->setName(String::ToString("macroMapTex%d", detailIndex));
|
||||
detailTex->setType("Texture2D");
|
||||
detailTex->uniform = true;
|
||||
detailTex->texture = true;
|
||||
detailTex->constNum = detailMap->constNum;
|
||||
|
||||
}
|
||||
|
||||
// If we're using SM 3.0 then take advantage of
|
||||
// dynamic branching to skip layers per-pixel.
|
||||
if ( GFX->getPixelShaderVersion() >= 3.0f )
|
||||
|
|
@ -805,22 +903,36 @@ void TerrainMacroMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
// We take two color samples and lerp between them for
|
||||
// side projection layers... else a single sample.
|
||||
//
|
||||
if ( fd.features.hasFeature( MFT_TerrainSideProject, detailIndex ) )
|
||||
if (fd.features.hasFeature(MFT_TerrainSideProject, detailIndex))
|
||||
{
|
||||
meta->addStatement( new GenOp( " @ = ( lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet, detailMap, inDet, inTex ) );
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = ( lerp( @.Sample( @, @.yz ), @.Sample( @, @.xz ), @.z ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailTex, detailMap, inDet, detailTex, detailMap, inDet, inTex));
|
||||
}
|
||||
else
|
||||
meta->addStatement(new GenOp(" @ = ( lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet, detailMap, inDet, inTex));
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement( new GenOp( " @ = ( tex2D( @, @.xy ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet ) );
|
||||
if (mIsDirect3D11)
|
||||
meta->addStatement(new GenOp(" @ = ( @.Sample( @, @.xy ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailTex, detailMap, inDet));
|
||||
else
|
||||
meta->addStatement(new GenOp(" @ = ( tex2D( @, @.xy ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet));
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @ *= @.y * @.w;\r\n",
|
||||
detailColor, detailInfo, inDet ) );
|
||||
|
||||
//Var *baseColor = (Var*)LangElement::find( "baseColor" );
|
||||
Var *outColor = (Var*)LangElement::find( "col" );
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
|
||||
if(fd.features.hasFeature(MFT_DeferredTerrainMacroMap))
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
|
||||
Var *outColor = (Var*)LangElement::find( getOutputTargetVarName(target) );
|
||||
|
||||
meta->addStatement(new GenOp(" @ += @ * @;\r\n",
|
||||
outColor, detailColor, detailBlend));
|
||||
|
|
@ -830,8 +942,6 @@ void TerrainMacroMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
output = meta;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ShaderFeature::Resources TerrainMacroMapFeatHLSL::getResources( const MaterialFeatureData &fd )
|
||||
{
|
||||
Resources res;
|
||||
|
|
@ -843,9 +953,6 @@ ShaderFeature::Resources TerrainMacroMapFeatHLSL::getResources( const MaterialFe
|
|||
res.numTex += 1;
|
||||
}
|
||||
|
||||
// If this isn't the prepass then we sample
|
||||
// from the detail texture for diffuse coloring.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
res.numTex += 1;
|
||||
|
||||
// Finally we always send the detail texture
|
||||
|
|
@ -855,6 +962,11 @@ ShaderFeature::Resources TerrainMacroMapFeatHLSL::getResources( const MaterialFe
|
|||
return res;
|
||||
}
|
||||
|
||||
U32 TerrainMacroMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_DeferredTerrainMacroMap] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void TerrainNormalMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
|
|
@ -874,9 +986,6 @@ void TerrainNormalMapFeatHLSL::processVert( Vector<ShaderComponent*> &component
|
|||
void TerrainNormalMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
// We only need to process normals during the prepass.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
return;
|
||||
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
||||
|
|
@ -893,7 +1002,7 @@ void TerrainNormalMapFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
meta->addStatement( new GenOp( " @ = @[2];\r\n", new DecOp( gbNormal ), viewToTangent ) );
|
||||
}
|
||||
|
||||
const U32 normalIndex = getProcessIndex();
|
||||
const S32 normalIndex = getProcessIndex();
|
||||
|
||||
Var *detailBlend = (Var*)LangElement::find( String::ToString( "detailBlend%d", normalIndex ) );
|
||||
AssertFatal( detailBlend, "The detail blend is missing!" );
|
||||
|
|
@ -917,13 +1026,39 @@ void TerrainNormalMapFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
// We take two normal samples and lerp between them for
|
||||
// side projection layers... else a single sample.
|
||||
LangElement *texOp;
|
||||
if ( fd.features.hasFeature( MFT_TerrainSideProject, normalIndex ) )
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
texOp = new GenOp( "lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z )",
|
||||
normalMap, inDet, normalMap, inDet, inTex );
|
||||
String name(String::ToString("normalMapTex%d", getProcessIndex()));
|
||||
Var *normalMapTex = (Var*)LangElement::find(name);
|
||||
if (!normalMapTex)
|
||||
{
|
||||
normalMapTex = new Var;
|
||||
normalMapTex->setName(String::ToString("normalMapTex%d", getProcessIndex()));
|
||||
normalMapTex->setType("Texture2D");
|
||||
normalMapTex->uniform = true;
|
||||
normalMapTex->texture = true;
|
||||
normalMapTex->constNum = normalMap->constNum;
|
||||
}
|
||||
if (fd.features.hasFeature(MFT_TerrainSideProject, normalIndex))
|
||||
{
|
||||
texOp = new GenOp("lerp( @.Sample( @, @.yz ), @.Sample( @, @.xz ), @.z )",
|
||||
normalMapTex, normalMap, inDet, normalMapTex, normalMap, inDet, inTex);
|
||||
}
|
||||
else
|
||||
texOp = new GenOp("@.Sample(@, @.xy)", normalMapTex, normalMap, inDet);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
texOp = new GenOp( "tex2D(@, @.xy)", normalMap, inDet );
|
||||
{
|
||||
if (fd.features.hasFeature(MFT_TerrainSideProject, normalIndex))
|
||||
{
|
||||
texOp = new GenOp("lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z )",
|
||||
normalMap, inDet, normalMap, inDet, inTex);
|
||||
}
|
||||
else
|
||||
texOp = new GenOp("tex2D(@, @.xy)", normalMap, inDet);
|
||||
}
|
||||
|
||||
// create bump normal
|
||||
Var *bumpNorm = new Var;
|
||||
|
|
@ -1001,7 +1136,20 @@ void TerrainLightMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
meta->addStatement( new GenOp( " @ = 1;\r\n", new DecOp( lightMask ) ) );
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @[0] = tex2D( @, @.xy ).r;\r\n", lightMask, lightMap, inTex ) );
|
||||
if (mIsDirect3D11)
|
||||
{
|
||||
lightMap->setType("SamplerState");
|
||||
Var* lightMapTex = new Var;
|
||||
lightMapTex->setName("lightMapTexObj");
|
||||
lightMapTex->setType("Texture2D");
|
||||
lightMapTex->uniform = true;
|
||||
lightMapTex->texture = true;
|
||||
lightMapTex->constNum = lightMap->constNum;
|
||||
meta->addStatement(new GenOp(" @[0] = @.Sample( @, @.xy ).r;\r\n", lightMask, lightMapTex, lightMap, inTex));
|
||||
}
|
||||
else
|
||||
meta->addStatement(new GenOp(" @[0] = tex2D( @, @.xy ).r;\r\n", lightMask, lightMap, inTex));
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -1012,11 +1160,15 @@ ShaderFeature::Resources TerrainLightMapFeatHLSL::getResources( const MaterialFe
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
void TerrainAdditiveFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
Var *color = (Var*) LangElement::find( "col" );
|
||||
Var *color = NULL;
|
||||
if (fd.features[MFT_DeferredTerrainDetailMap])
|
||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) );
|
||||
else
|
||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) );
|
||||
|
||||
Var *blendTotal = (Var*)LangElement::find( "blendTotal" );
|
||||
if ( !color || !blendTotal )
|
||||
return;
|
||||
|
|
@ -1026,5 +1178,43 @@ void TerrainAdditiveFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
meta->addStatement( new GenOp( " clip( @ - 0.0001 );\r\n", blendTotal ) );
|
||||
meta->addStatement( new GenOp( " @.a = @;\r\n", color, blendTotal ) );
|
||||
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
//standard matInfo map contains data of the form .r = bitflags, .g = (will contain AO),
|
||||
//.b = specular strength, a= spec power.
|
||||
//here, it's merely a cutout for now, so that lightmapping (target3) doesn't get mangled.
|
||||
//we'll most likely revisit that later. possibly several ways...
|
||||
|
||||
U32 TerrainBlankInfoMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_DeferredTerrainBaseMap] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1;
|
||||
}
|
||||
|
||||
void TerrainBlankInfoMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
{
|
||||
// search for material var
|
||||
Var *material;
|
||||
OutputTarget targ = RenderTarget1;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = RenderTarget2;
|
||||
}
|
||||
material = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
if (!material)
|
||||
{
|
||||
// create color var
|
||||
material = new Var;
|
||||
material->setType("fragout");
|
||||
material->setName(getOutputTargetVarName(targ));
|
||||
material->setStructName("OUT");
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0,0.0,0.0,0.0001);\r\n", material));
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@ class TerrainFeatHLSL : public ShaderFeatureHLSL
|
|||
{
|
||||
protected:
|
||||
|
||||
ShaderIncludeDependency mTorqueDep;
|
||||
|
||||
public:
|
||||
TerrainFeatHLSL();
|
||||
Var* _getInDetailCoord(Vector<ShaderComponent*> &componentList );
|
||||
|
||||
Var* _getInMacroCoord(Vector<ShaderComponent*> &componentList );
|
||||
|
|
@ -64,6 +68,8 @@ public:
|
|||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
virtual String getName() { return "Terrain Base Texture"; }
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -87,6 +93,8 @@ public:
|
|||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
virtual String getName() { return "Terrain Detail Texture"; }
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -110,6 +118,8 @@ public:
|
|||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
virtual String getName() { return "Terrain Macro Texture"; }
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -151,4 +161,15 @@ public:
|
|||
virtual String getName() { return "Terrain Additive"; }
|
||||
};
|
||||
|
||||
class TerrainBlankInfoMapFeatHLSL : public TerrainFeatHLSL
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd);
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
virtual String getName() { return "Blank Matinfo map"; }
|
||||
};
|
||||
|
||||
#endif // _TERRFEATUREHLSL_H_
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "gfx/util/screenspace.h"
|
||||
#include "lighting/advanced/advancedLightBinManager.h"
|
||||
|
||||
S32 sgMaxTerrainMaterialsPerPass = 3;
|
||||
|
||||
AFTER_MODULE_INIT( MaterialManager )
|
||||
{
|
||||
|
|
@ -310,12 +311,12 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
if ( GFX->getPixelShaderVersion() < 3.0f )
|
||||
baseOnly = true;
|
||||
|
||||
// NOTE: At maximum we only try to combine 3 materials
|
||||
// NOTE: At maximum we only try to combine sgMaxTerrainMaterialsPerPass materials
|
||||
// into a single pass. This is sub-optimal for the simplest
|
||||
// cases, but the most common case results in much fewer
|
||||
// shader generation failures and permutations leading to
|
||||
// faster load time and less hiccups during gameplay.
|
||||
U32 matCount = getMin( 3, materials->size() );
|
||||
U32 matCount = getMin( sgMaxTerrainMaterialsPerPass, materials->size() );
|
||||
|
||||
Vector<GFXTexHandle> normalMaps;
|
||||
|
||||
|
|
@ -349,24 +350,27 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
{
|
||||
FeatureSet features;
|
||||
features.addFeature( MFT_VertTransform );
|
||||
features.addFeature( MFT_TerrainBaseMap );
|
||||
|
||||
if ( prePassMat )
|
||||
{
|
||||
features.addFeature( MFT_EyeSpaceDepthOut );
|
||||
features.addFeature( MFT_PrePassConditioner );
|
||||
features.addFeature( MFT_DeferredTerrainBaseMap );
|
||||
features.addFeature(MFT_isDeferred);
|
||||
|
||||
if ( advancedLightmapSupport )
|
||||
features.addFeature( MFT_RenderTarget1_Zero );
|
||||
features.addFeature( MFT_RenderTarget3_Zero );
|
||||
}
|
||||
else
|
||||
{
|
||||
features.addFeature( MFT_TerrainBaseMap );
|
||||
features.addFeature( MFT_RTLighting );
|
||||
|
||||
// The HDR feature is always added... it will compile out
|
||||
// if HDR is not enabled in the engine.
|
||||
features.addFeature( MFT_HDROut );
|
||||
}
|
||||
features.addFeature(MFT_DeferredTerrainBlankInfoMap);
|
||||
|
||||
// Enable lightmaps and fogging if we're in BL.
|
||||
if ( reflectMat || useBLM )
|
||||
|
|
@ -405,8 +409,16 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
|
||||
// check for macro detail texture
|
||||
if ( !(mat->getMacroSize() <= 0 || mat->getMacroDistance() <= 0 || mat->getMacroMap().isEmpty() ) )
|
||||
{
|
||||
if(prePassMat)
|
||||
features.addFeature( MFT_DeferredTerrainMacroMap, featureIndex );
|
||||
else
|
||||
features.addFeature( MFT_TerrainMacroMap, featureIndex );
|
||||
}
|
||||
|
||||
if(prePassMat)
|
||||
features.addFeature( MFT_DeferredTerrainDetailMap, featureIndex );
|
||||
else
|
||||
features.addFeature( MFT_TerrainDetailMap, featureIndex );
|
||||
|
||||
pass->materials.push_back( (*materials)[i] );
|
||||
|
|
@ -536,8 +548,8 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
// MFT_TerrainAdditive feature to lerp the
|
||||
// output normal with the previous pass.
|
||||
//
|
||||
if ( prePassMat )
|
||||
desc.setColorWrites( true, true, false, false );
|
||||
//if ( prePassMat )
|
||||
//desc.setColorWrites( true, true, false, false );
|
||||
}
|
||||
|
||||
// We write to the zbuffer if this is a prepass
|
||||
|
|
@ -656,9 +668,9 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
if ( prePassMat )
|
||||
desc.addDesc( RenderPrePassMgr::getOpaqueStenciWriteDesc( false ) );
|
||||
|
||||
// Flip the cull for reflection materials.
|
||||
if ( reflectMat )
|
||||
desc.setCullMode( GFXCullCW );
|
||||
// Shut off culling for prepass materials (reflection support).
|
||||
if ( prePassMat )
|
||||
desc.setCullMode( GFXCullNone );
|
||||
|
||||
pass->stateBlock = GFX->createStateBlock( desc );
|
||||
|
||||
|
|
|
|||
|
|
@ -150,9 +150,9 @@ DefineConsoleFunction( getTerrainUnderWorldPoint, S32, (const char* ptOrX, const
|
|||
"@hide")
|
||||
{
|
||||
Point3F pos;
|
||||
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y) && dStrIsEmpty(z))
|
||||
if(!String::isEmpty(ptOrX) && String::isEmpty(y) && String::isEmpty(z))
|
||||
dSscanf(ptOrX, "%f %f %f", &pos.x, &pos.y, &pos.z);
|
||||
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y) && !dStrIsEmpty(z))
|
||||
else if(!String::isEmpty(ptOrX) && !String::isEmpty(y) && !String::isEmpty(z))
|
||||
{
|
||||
pos.x = dAtof(ptOrX);
|
||||
pos.y = dAtof(y);
|
||||
|
|
@ -1340,9 +1340,9 @@ DefineConsoleFunction( getTerrainHeight, F32, (const char* ptOrX, const char* y)
|
|||
F32 height = 0.0f;
|
||||
|
||||
Point2F pos;
|
||||
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y))
|
||||
if(!String::isEmpty(ptOrX) && String::isEmpty(y))
|
||||
dSscanf(ptOrX, "%f %f", &pos.x, &pos.y);
|
||||
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y))
|
||||
else if(!String::isEmpty(ptOrX) && !String::isEmpty(y))
|
||||
{
|
||||
pos.x = dAtof(ptOrX);
|
||||
pos.y = dAtof(y);
|
||||
|
|
@ -1387,9 +1387,9 @@ DefineConsoleFunction( getTerrainHeightBelowPosition, F32, (const char* ptOrX, c
|
|||
F32 height = 0.0f;
|
||||
|
||||
Point3F pos;
|
||||
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y) && dStrIsEmpty(z))
|
||||
if(!String::isEmpty(ptOrX) && String::isEmpty(y) && String::isEmpty(z))
|
||||
dSscanf(ptOrX, "%f %f %f", &pos.x, &pos.y, &pos.z);
|
||||
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y) && !dStrIsEmpty(z))
|
||||
else if(!String::isEmpty(ptOrX) && !String::isEmpty(y) && !String::isEmpty(z))
|
||||
{
|
||||
pos.x = dAtof(ptOrX);
|
||||
pos.y = dAtof(y);
|
||||
|
|
|
|||
|
|
@ -34,4 +34,8 @@ ImplementFeatureType( MFT_TerrainMacroMap, MFG_Texture, 104.0f, false );
|
|||
ImplementFeatureType( MFT_TerrainLightMap, MFG_Texture, 105.0f, false );
|
||||
ImplementFeatureType( MFT_TerrainSideProject, MFG_Texture, 106.0f, false );
|
||||
ImplementFeatureType( MFT_TerrainAdditive, MFG_PostProcess, 999.0f, false );
|
||||
|
||||
//Deferred Shading
|
||||
ImplementFeatureType( MFT_DeferredTerrainBaseMap, MFG_Texture, 100.1f, false );
|
||||
ImplementFeatureType( MFT_DeferredTerrainDetailMap, MFG_Texture, 102.1f, false );
|
||||
ImplementFeatureType( MFT_DeferredTerrainMacroMap, MFG_Texture, 104.1f, false );
|
||||
ImplementFeatureType( MFT_DeferredTerrainBlankInfoMap, MFG_Texture, 104.1f, false);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ DeclareFeatureType( MFT_TerrainParallaxMap );
|
|||
DeclareFeatureType( MFT_TerrainLightMap );
|
||||
DeclareFeatureType( MFT_TerrainSideProject );
|
||||
DeclareFeatureType( MFT_TerrainAdditive );
|
||||
//Deferred Shading
|
||||
DeclareFeatureType( MFT_DeferredTerrainBaseMap );
|
||||
DeclareFeatureType( MFT_DeferredTerrainDetailMap );
|
||||
DeclareFeatureType( MFT_DeferredTerrainMacroMap );
|
||||
DeclareFeatureType( MFT_DeferredTerrainBlankInfoMap );
|
||||
|
||||
|
||||
#endif // _TERRFEATURETYPES_H_
|
||||
|
||||
|
|
|
|||
|
|
@ -208,14 +208,14 @@ void TerrainBlock::_updateBaseTexture(bool writeToCache)
|
|||
F32 copyOffsetY = 2.0f * GFX->getFillConventionOffset() / (F32)destSize.y;
|
||||
|
||||
GFXVertexPT points[4];
|
||||
points[0].point = Point3F( -1.0 - copyOffsetX, -1.0 + copyOffsetY, 0.0 );
|
||||
points[0].texCoord = Point2F( 0.0, 1.0f );
|
||||
points[1].point = Point3F( -1.0 - copyOffsetX, 1.0 + copyOffsetY, 0.0 );
|
||||
points[1].texCoord = Point2F( 0.0, 0.0f );
|
||||
points[2].point = Point3F( 1.0 - copyOffsetX, 1.0 + copyOffsetY, 0.0 );
|
||||
points[2].texCoord = Point2F( 1.0, 0.0f );
|
||||
points[3].point = Point3F( 1.0 - copyOffsetX, -1.0 + copyOffsetY, 0.0 );
|
||||
points[3].texCoord = Point2F( 1.0, 1.0f );
|
||||
points[0].point = Point3F(1.0 - copyOffsetX, -1.0 + copyOffsetY, 0.0);
|
||||
points[0].texCoord = Point2F(1.0, 1.0f);
|
||||
points[1].point = Point3F(1.0 - copyOffsetX, 1.0 + copyOffsetY, 0.0);
|
||||
points[1].texCoord = Point2F(1.0, 0.0f);
|
||||
points[2].point = Point3F(-1.0 - copyOffsetX, -1.0 + copyOffsetY, 0.0);
|
||||
points[2].texCoord = Point2F(0.0, 1.0f);
|
||||
points[3].point = Point3F(-1.0 - copyOffsetX, 1.0 + copyOffsetY, 0.0);
|
||||
points[3].texCoord = Point2F(0.0, 0.0f);
|
||||
|
||||
vb.set( GFX, 4, GFXBufferTypeVolatile );
|
||||
GFXVertexPT *ptr = vb.lock();
|
||||
|
|
@ -274,7 +274,7 @@ void TerrainBlock::_updateBaseTexture(bool writeToCache)
|
|||
mBaseShaderConsts->setSafe( mBaseTexScaleConst, Point2F( scale, -scale ) );
|
||||
mBaseShaderConsts->setSafe( mBaseTexIdConst, (F32)i );
|
||||
|
||||
GFX->drawPrimitive( GFXTriangleFan, 0, 2 );
|
||||
GFX->drawPrimitive( GFXTriangleStrip, 0, 2 );
|
||||
}
|
||||
|
||||
mBaseTarget->resolve();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue