more conversionwork from specular entries to pbrconfig ones, adds backend glowmul and glowmap var tracking, as well as pbrconfigmap composite slip-in for the glowmap (sans shaderfeatures just yet). seems to have busted forward lit application though...

This commit is contained in:
AzaezelX 2019-10-22 15:11:39 -05:00
parent 7daf66cf9d
commit bfccfca0ce
21 changed files with 68 additions and 387 deletions

View file

@ -178,6 +178,9 @@ Material::Material()
mAOMapFilename[i].clear();
mMetalMapFilename[i].clear();
mMetalMapAsset[i] = StringTable->EmptyString();
mGlowMapFilename[i].clear();
mGlowMapAsset[i] = StringTable->EmptyString();
mGlowMul[i] = 0.0f;
}
dMemset(mCellIndex, 0, sizeof(mCellIndex));
@ -186,9 +189,6 @@ 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;
@ -277,6 +277,9 @@ void Material::initPersistFields()
addField("metalness", TypeF32, Offset(mMetalness, Material), MAX_STAGES,
"The degree of Metalness when not using a PBRConfigMap." );
addField("glowMul", TypeF32, Offset(mGlowMul, Material), MAX_STAGES,
"glow mask multiplier");
addProtectedField( "accuEnabled", TYPEID< bool >(), Offset( mAccuEnabled, Material ),
&_setAccuEnabled, &defaultProtectedGetFn, MAX_STAGES, "Accumulation texture." );
@ -320,6 +323,14 @@ void Material::initPersistFields()
addField("metalChan", TypeF32, Offset(mMetalChan, Material), MAX_STAGES,
"The input channel metalness maps use.");
addField("glowMap", TypeImageFilename, Offset(mGlowMapFilename, Material), MAX_STAGES,
"Metalness map. will be packed into the B channel of a packed 'specular' map");
addField("glowChan", TypeF32, Offset(mGlowChan, Material), MAX_STAGES,
"The input channel metalness maps use.");
addField("glowMul", TypeF32, Offset(mGlowMul, Material), MAX_STAGES,
"The input channel metalness maps use.");
addField("glow", TypeBool, Offset(mGlow, Material), MAX_STAGES,
"Enables rendering as glowing.");
addField( "parallaxScale", TypeF32, Offset(mParallaxScale, Material), MAX_STAGES,
"Enables parallax mapping and defines the scale factor for the parallax effect. Typically "
@ -346,9 +357,6 @@ void Material::initPersistFields()
addField("subSurfaceRolloff", TypeF32, Offset(mSubSurfaceRolloff, Material), MAX_STAGES,
"The 0 to 1 rolloff factor used in the subsurface scattering approximation." );
addField("glow", TypeBool, Offset(mGlow, Material), MAX_STAGES,
"Enables rendering this material to the glow buffer." );
addField("emissive", TypeBool, Offset(mEmissive, Material), MAX_STAGES,
"Enables emissive lighting for the material." );

View file

@ -253,6 +253,11 @@ public:
AssetPtr<ImageAsset> mMetalMapAsset[MAX_STAGES];
F32 mMetalChan[MAX_STAGES];
FileName mGlowMapFilename[MAX_STAGES];
StringTableEntry mGlowMapAssetId[MAX_STAGES];
AssetPtr<ImageAsset> mGlowMapAsset[MAX_STAGES];
F32 mGlowChan[MAX_STAGES];
F32 mGlowMul[MAX_STAGES];
/// A second normal map which repeats at the detail map
/// scale and blended with the base normal map.
FileName mDetailNormalMapFilename[MAX_STAGES];
@ -323,8 +328,6 @@ public:
/// If the stage should use anisotropic filtering.
bool mUseAnisotropic[MAX_STAGES];
// Deferred Shading: Metalness
bool mUseMetalness[MAX_STAGES];
bool mDoubleSided;

View file

@ -44,9 +44,9 @@ ImplementFeatureType( MFT_DiffuseColor, MFG_Texture, 5.0f, true );
ImplementFeatureType( MFT_DiffuseVertColor, MFG_Texture, 6.0f, true );
ImplementFeatureType( MFT_AlphaTest, MFG_Texture, 7.0f, true );
ImplementFeatureType(MFT_InvertSmoothness, U32(-1), -1, true);
ImplementFeatureType( MFT_PBRConfigMap, MFG_Texture, 8.0f, true );
ImplementFeatureType( MFT_NormalMap, MFG_Texture, 9.0f, true );
ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 10.0f, true );
ImplementFeatureType( MFT_GlowMap, MFG_Texture, 9.0f, true );
ImplementFeatureType( MFT_NormalMap, MFG_Texture, 10.0f, true );
ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 11.0f, true );
ImplementFeatureType( MFT_Imposter, U32(-1), -1, true );
ImplementFeatureType( MFT_AccuMap, MFG_PreLighting, 2.0f, true );
@ -74,7 +74,6 @@ ImplementFeatureType( MFT_IsBC5nm, U32(-1), -1, true);
ImplementFeatureType( MFT_IsTranslucent, U32(-1), -1, true );
ImplementFeatureType( MFT_IsTranslucentZWrite, U32(-1), -1, true );
ImplementFeatureType( MFT_IsEmissive, U32(-1), -1, true );
ImplementFeatureType( MFT_GlossMap, U32(-1), -1, true );
ImplementFeatureType( MFT_DiffuseMapAtlas, U32(-1), -1, true );
ImplementFeatureType( MFT_NormalMapAtlas, U32(-1), -1, true );
ImplementFeatureType( MFT_InterlacedDeferred, U32(-1), -1, true );
@ -102,8 +101,8 @@ ImplementFeatureType( MFT_ImposterVert, MFG_PreTransform, 1.0, false );
// Deferred Shading
ImplementFeatureType( MFT_isDeferred, U32(-1), -1, true );
ImplementFeatureType( MFT_SkyBox, MFG_Transform, 1.0f, false );
ImplementFeatureType( MFT_DeferredSpecMap, MFG_Texture, 8.2f, false );
ImplementFeatureType( MFT_DeferredSpecVars, MFG_Texture, 8.5f, false );
ImplementFeatureType( MFT_PBRConfigMap, MFG_Texture, 8.2f, false );
ImplementFeatureType( MFT_PBRConfigVars, MFG_Texture, 8.5f, false );
ImplementFeatureType( MFT_DeferredMatInfoFlags, MFG_Texture, 8.7f, false );
ImplementFeatureType( MFT_DeferredEmissive, MFG_Texture, 8.9f, false);

View file

@ -126,7 +126,9 @@ DeclareFeatureType( MFT_StaticCubemap );
DeclareFeatureType( MFT_CubeMap );
DeclareFeatureType( MFT_InvertSmoothness );
DeclareFeatureType( MFT_PBRConfigMap );
DeclareFeatureType( MFT_GlossMap );
DeclareFeatureType( MFT_PBRConfigVars );
DeclareFeatureType( MFT_GlowMap );
DeclareFeatureType( MFT_ReflectionProbes );
@ -189,8 +191,6 @@ DeclareFeatureType( MFT_HardwareSkinning );
// Deferred Shading
DeclareFeatureType( MFT_isDeferred );
DeclareFeatureType( MFT_SkyBox );
DeclareFeatureType( MFT_DeferredSpecMap );
DeclareFeatureType( MFT_DeferredSpecVars );
DeclareFeatureType( MFT_DeferredMatInfoFlags );
DeclareFeatureType( MFT_DeferredEmissive );
#endif // _MATERIALFEATURETYPES_H_

View file

@ -477,7 +477,7 @@ void ProcessedMaterial::_setStageData()
{
mStages[i].setTex(MFT_PBRConfigMap, _createTexture(mMaterial->mPBRConfigMapFilename[i], profile));
if (!mStages[i].getTex(MFT_PBRConfigMap))
mMaterial->logError("Failed to load specular map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i);
mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i);
}
else
{
@ -487,9 +487,9 @@ void ProcessedMaterial::_setStageData()
inputKey[0] = mMaterial->mSmoothnessChan[i];
inputKey[1] = mMaterial->mAOChan[i];
inputKey[2] = mMaterial->mMetalChan[i];
inputKey[3] = NULL;
inputKey[3] = mMaterial->mGlowChan[i];
mStages[i].setTex(MFT_PBRConfigMap, _createCompositeTexture(mMaterial->mRoughMapFilename[i], mMaterial->mAOMapFilename[i],
mMaterial->mMetalMapFilename[i], "",
mMaterial->mMetalMapFilename[i], mMaterial->mGlowMapFilename[i],
inputKey, profile));
if (!mStages[i].getTex(MFT_PBRConfigMap))
mMaterial->logError("Failed to load specular map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i);

View file

@ -439,21 +439,14 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
fd.features[ MFT_NormalMap ] )
fd.features.addFeature( MFT_Parallax );
}
// Without realtime lighting and on lower end
// shader models disable the specular map.
if ( !fd.features[ MFT_RTLighting ] || shaderVersion == 2.0 )
fd.features.removeFeature( MFT_PBRConfigMap );
// If we have a specular map then make sure we
// have per-pixel specular enabled.
if( fd.features[ MFT_PBRConfigMap ] )
{
// Check for an alpha channel on the specular map. If it has one (and it
// has values less than 255) than the artist has put the gloss map into
// Check for an alpha channel on the PBR Config map. If it has one (and it
// has values less than 255) than the artist has put the glow map into
// the alpha channel.
if( mStages[stageNum].getTex( MFT_PBRConfigMap )->mHasTransparency )
fd.features.addFeature( MFT_GlossMap );
fd.features.addFeature( MFT_GlowMap );
}
if ( mMaterial->mAccuEnabled[stageNum] )