mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
The final step (barring any overlooked missing bits, requested refactors, and of course, rolling in dependencies already submitted as PRs) consists of:
renderPrePassMgr.cpp related: A) shifting .addFeature( MFT_XYZ); calls from ProcessedShaderMaterial::_determineFeatures to ProcessedPrePassMaterial::_determineFeatures B) mimicking the "// set the XXX if different" entries from RenderMeshMgr::render in RenderPrePassMgr::render C) fleshing out ProcessedPrePassMaterial::getNumStages() so that it shares a 1:1 correlation with ProcessedShaderMaterial::getNumStages() D) causing inline void Swizzle<T, mapLength>::ToBuffer( void *destination, const void *source, const dsize_t size ) to silently fail rather than fatally assert if a source or destination buffer is not yet ready to be filled. (support for #customTarget scripted render targets) Reflections: A) removing reflectRenderState.disableAdvancedLightingBins(true); entries. this would otherwise early out from prepass and provide no color data whatsoever. B) removing the fd.features.addFeature( MFT_ForwardShading ); entry forcing all materials to be forward lit when reflected. C) 2 things best described bluntly as working hacks: C1) when reflected, a scattersky is rotated PI along it's z then x axis in order to draw properly. C2) along similar lines, in terraincellmaterial, we shut off culling if it's a prepass material. Skies: scattersky is given a pair of rotations for reflection purposes, all sky objects are given a z value for depth testing.
This commit is contained in:
parent
5ed06fff9d
commit
8c5810adad
58 changed files with 353 additions and 117 deletions
|
|
@ -47,9 +47,16 @@ bool NamedTexTarget::registerWithName( const String &name )
|
|||
}
|
||||
|
||||
// Make sure the target name isn't empty or already taken.
|
||||
if ( name.isEmpty() || smTargets.contains( name ) )
|
||||
if ( name.isEmpty())
|
||||
{
|
||||
Con::errorf("NamedTexTarget::registerWithName( const String &name ) No name given!");
|
||||
return false;
|
||||
}
|
||||
if (smTargets.contains( name ) )
|
||||
{
|
||||
Con::errorf("NamedTexTarget::registerWithName( %s ) Already used!", name.c_str());
|
||||
return false;
|
||||
|
||||
}
|
||||
mName = name;
|
||||
mIsRegistered = true;
|
||||
smTargets.insert( mName, this );
|
||||
|
|
|
|||
|
|
@ -162,6 +162,9 @@ Material::Material()
|
|||
|
||||
mSeqFramePerSec[i] = 0.0f;
|
||||
mSeqSegSize[i] = 0.0f;
|
||||
|
||||
// Deferred Shading
|
||||
mMatInfoFlags[i] = 0.0f;
|
||||
}
|
||||
|
||||
dMemset(mCellIndex, 0, sizeof(mCellIndex));
|
||||
|
|
@ -170,6 +173,9 @@ Material::Material()
|
|||
dMemset(mNormalMapAtlas, 0, sizeof(mNormalMapAtlas));
|
||||
dMemset(mUseAnisotropic, 0, sizeof(mUseAnisotropic));
|
||||
|
||||
// Deferred Shading : Metalness
|
||||
dMemset(mUseMetalness, 0, sizeof(mUseMetalness));
|
||||
|
||||
mImposterLimits = Point4F::Zero;
|
||||
|
||||
mDoubleSided = false;
|
||||
|
|
@ -204,6 +210,9 @@ Material::Material()
|
|||
|
||||
mDirectSoundOcclusion = 1.f;
|
||||
mReverbSoundOcclusion = 1.0;
|
||||
|
||||
// Deferred Shading
|
||||
mIsSky = false;
|
||||
}
|
||||
|
||||
void Material::initPersistFields()
|
||||
|
|
@ -289,10 +298,7 @@ void Material::initPersistFields()
|
|||
|
||||
addField( "useAnisotropic", TypeBool, Offset(mUseAnisotropic, Material), MAX_STAGES,
|
||||
"Use anisotropic filtering for the textures of this stage." );
|
||||
|
||||
addField("envMap", TypeImageFilename, Offset(mEnvMapFilename, Material), MAX_STAGES,
|
||||
"The name of an environment map cube map to apply to this material." );
|
||||
|
||||
|
||||
addField("vertLit", TypeBool, Offset(mVertLit, Material), MAX_STAGES,
|
||||
"If true the vertex color is used for lighting." );
|
||||
|
||||
|
|
@ -379,9 +385,6 @@ void Material::initPersistFields()
|
|||
addProtectedField("bumpTex", TypeImageFilename, Offset(mNormalMapFilename, Material),
|
||||
defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
|
||||
"For backwards compatibility.\n@see normalMap\n");
|
||||
addProtectedField("envTex", TypeImageFilename, Offset(mEnvMapFilename, Material),
|
||||
defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
|
||||
"For backwards compatibility.\n@see envMap\n");
|
||||
addProtectedField("colorMultiply", TypeColorF, Offset(mDiffuse, Material),
|
||||
defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
|
||||
"For backwards compatibility.\n@see diffuseColor\n");
|
||||
|
|
@ -417,6 +420,9 @@ void Material::initPersistFields()
|
|||
addField("dynamicCubemap", TypeBool, Offset(mDynamicCubemap, Material),
|
||||
"Enables the material to use the dynamic cubemap from the ShapeBase object its applied to." );
|
||||
|
||||
addField("isSky", TypeBool, Offset(mIsSky, Material),
|
||||
"Sky support. Alters draw dimensions." );
|
||||
|
||||
addGroup( "Behavioral" );
|
||||
|
||||
addField( "showFootprints", TypeBool, Offset( mShowFootprints, Material ),
|
||||
|
|
|
|||
|
|
@ -221,8 +221,6 @@ public:
|
|||
/// The strength scalar for the detail normal map.
|
||||
F32 mDetailNormalMapStrength[MAX_STAGES];
|
||||
|
||||
FileName mEnvMapFilename[MAX_STAGES];
|
||||
|
||||
/// This color is the diffuse color of the material
|
||||
/// or if it has a texture it is multiplied against
|
||||
/// the diffuse texture color.
|
||||
|
|
@ -287,12 +285,18 @@ public:
|
|||
/// If the stage should use anisotropic filtering.
|
||||
bool mUseAnisotropic[MAX_STAGES];
|
||||
|
||||
// Deferred Shading: Metalness
|
||||
bool mUseMetalness[MAX_STAGES];
|
||||
|
||||
bool mDoubleSided;
|
||||
|
||||
String mCubemapName;
|
||||
CubemapData* mCubemapData;
|
||||
bool mDynamicCubemap;
|
||||
|
||||
// Deferred Shading
|
||||
bool mIsSky;
|
||||
F32 mMatInfoFlags[MAX_STAGES];
|
||||
bool mTranslucent;
|
||||
BlendOp mTranslucentBlendOp;
|
||||
bool mTranslucentZWrite;
|
||||
|
|
|
|||
|
|
@ -455,14 +455,6 @@ void ProcessedMaterial::_setStageData()
|
|||
if(!mStages[i].getTex( MFT_SpecularMap ))
|
||||
mMaterial->logError("Failed to load specular map %s for stage %i", _getTexturePath(mMaterial->mSpecularMapFilename[i]).c_str(), i);
|
||||
}
|
||||
|
||||
// EnironmentMap
|
||||
if( mMaterial->mEnvMapFilename[i].isNotEmpty() )
|
||||
{
|
||||
mStages[i].setTex( MFT_EnvMap, _createTexture( mMaterial->mEnvMapFilename[i], &GFXDefaultStaticDiffuseProfile ) );
|
||||
if(!mStages[i].getTex( MFT_EnvMap ))
|
||||
mMaterial->logError("Failed to load environment map %s for stage %i", _getTexturePath(mMaterial->mEnvMapFilename[i]).c_str(), i);
|
||||
}
|
||||
}
|
||||
|
||||
mMaterial->mCubemapData = dynamic_cast<CubemapData*>(Sim::findObject( mMaterial->mCubemapName ));
|
||||
|
|
|
|||
|
|
@ -106,6 +106,9 @@ void ShaderConstHandles::init( GFXShader *shader, CustomMaterial* mat /*=NULL*/
|
|||
for (S32 i = 0; i < Material::MAX_TEX_PER_PASS; ++i)
|
||||
mTexHandlesSC[i] = shader->getShaderConstHandle(mat->mSamplerNames[i]);
|
||||
}
|
||||
|
||||
// Deferred Shading
|
||||
mMatInfoFlagsSC = shader->getShaderConstHandle(ShaderGenVars::matInfoFlags);
|
||||
}
|
||||
|
||||
///
|
||||
|
|
@ -208,28 +211,6 @@ bool ProcessedShaderMaterial::init( const FeatureSet &features,
|
|||
mInstancingState = new InstancingState();
|
||||
mInstancingState->setFormat( &_getRPD( 0 )->shader->mInstancingFormat, mVertexFormat );
|
||||
}
|
||||
|
||||
// Check for a RenderTexTargetBin assignment
|
||||
// *IMPORTANT NOTE*
|
||||
// This is a temporary solution for getting diffuse mapping working with tex targets for standard materials
|
||||
// It should be removed once this is done properly, at that time the sAllowTextureTargetAssignment should also be removed
|
||||
// from Material (it is necessary for catching shadow maps/post effect this shouldn't be applied to)
|
||||
if (Material::sAllowTextureTargetAssignment)
|
||||
if (mMaterial && mMaterial->mDiffuseMapFilename[0].isNotEmpty() && mMaterial->mDiffuseMapFilename[0].substr( 0, 1 ).equal("#"))
|
||||
{
|
||||
String texTargetBufferName = mMaterial->mDiffuseMapFilename[0].substr(1, mMaterial->mDiffuseMapFilename[0].length() - 1);
|
||||
NamedTexTarget *texTarget = NamedTexTarget::find( texTargetBufferName );
|
||||
|
||||
RenderPassData* rpd = getPass(0);
|
||||
|
||||
if (rpd)
|
||||
{
|
||||
rpd->mTexSlot[0].texTarget = texTarget;
|
||||
rpd->mTexType[0] = Material::TexTarget;
|
||||
rpd->mSamplerNames[0] = "diffuseMap";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -353,11 +334,18 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
|||
fd.features.addFeature( MFT_VertLit );
|
||||
|
||||
// cubemaps only available on stage 0 for now - bramage
|
||||
if ( stageNum < 1 &&
|
||||
if ( stageNum < 1 && mMaterial->isTranslucent() &&
|
||||
( ( mMaterial->mCubemapData && mMaterial->mCubemapData->mCubemap ) ||
|
||||
mMaterial->mDynamicCubemap ) )
|
||||
fd.features.addFeature( MFT_CubeMap );
|
||||
{
|
||||
fd.features.addFeature( MFT_CubeMap );
|
||||
}
|
||||
|
||||
if (mMaterial->mIsSky)
|
||||
{
|
||||
fd.features.addFeature(MFT_CubeMap);
|
||||
fd.features.addFeature(MFT_SkyBox);
|
||||
}
|
||||
fd.features.addFeature( MFT_Visibility );
|
||||
|
||||
if ( lastStage &&
|
||||
|
|
@ -428,7 +416,6 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
|||
|
||||
if ( mMaterial->mAccuEnabled[stageNum] )
|
||||
{
|
||||
fd.features.addFeature( MFT_AccuMap );
|
||||
mHasAccumulation = true;
|
||||
}
|
||||
|
||||
|
|
@ -441,19 +428,7 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
|||
fd.features.removeFeature( MFT_AccuMap );
|
||||
mHasAccumulation = false;
|
||||
}
|
||||
|
||||
// if we still have the AccuMap feature, we add all accu constant features
|
||||
if ( fd.features[ MFT_AccuMap ] ) {
|
||||
// add the dependencies of the accu map
|
||||
fd.features.addFeature( MFT_AccuScale );
|
||||
fd.features.addFeature( MFT_AccuDirection );
|
||||
fd.features.addFeature( MFT_AccuStrength );
|
||||
fd.features.addFeature( MFT_AccuCoverage );
|
||||
fd.features.addFeature( MFT_AccuSpecular );
|
||||
// now remove some features that are not compatible with this
|
||||
fd.features.removeFeature( MFT_UseInstancing );
|
||||
}
|
||||
|
||||
|
||||
// Without a base texture use the diffuse color
|
||||
// feature to ensure some sort of output.
|
||||
if (!fd.features[MFT_DiffuseMap])
|
||||
|
|
@ -1175,7 +1150,12 @@ void ProcessedShaderMaterial::_setShaderConstants(SceneRenderState * state, cons
|
|||
0.0f, 0.0f ); // TODO: Wrap mode flags?
|
||||
shaderConsts->setSafe(handles->mBumpAtlasTileSC, atlasTileParams);
|
||||
}
|
||||
|
||||
|
||||
// Deferred Shading: Determine Material Info Flags
|
||||
S32 matInfoFlags =
|
||||
(mMaterial->mEmissive[stageNum] ? 1 : 0);
|
||||
mMaterial->mMatInfoFlags[stageNum] = matInfoFlags / 255.0f;
|
||||
shaderConsts->setSafe(handles->mMatInfoFlagsSC, mMaterial->mMatInfoFlags[stageNum]);
|
||||
if( handles->mAccuScaleSC->isValid() )
|
||||
shaderConsts->set( handles->mAccuScaleSC, mMaterial->mAccuScale[stageNum] );
|
||||
if( handles->mAccuDirectionSC->isValid() )
|
||||
|
|
|
|||
|
|
@ -87,6 +87,9 @@ public:
|
|||
GFXShaderConstHandle *mImposterUVs;
|
||||
GFXShaderConstHandle *mImposterLimits;
|
||||
|
||||
// Deferred Shading : Material Info Flags
|
||||
GFXShaderConstHandle* mMatInfoFlagsSC;
|
||||
|
||||
GFXShaderConstHandle* mTexHandlesSC[Material::MAX_TEX_PER_PASS];
|
||||
GFXShaderConstHandle* mRTParamsSC[TEXTURE_STAGE_COUNT];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue