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:
Azaezel 2016-02-16 02:50:49 -06:00
parent 5ed06fff9d
commit 8c5810adad
58 changed files with 353 additions and 117 deletions

View file

@ -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() )