mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-24 22:05:40 +00:00
Merge pull request #323 from Azaezel/alpha40_smoothToRough_clean
shift pbrconfig to ORM in keeping with the prepoderance of industry standards
This commit is contained in:
commit
681dbe108c
55 changed files with 970 additions and 767 deletions
|
|
@ -97,9 +97,6 @@ ImplementEnumType( MaterialWaveType,
|
|||
{ Material::Square, "Square", "Warps the material along a wave which transitions between two oppposite states. As a Square Wave, the transition is quick and sudden." },
|
||||
EndImplementEnumType;
|
||||
|
||||
#define initMapSlot(name,id) m##name##Filename[id] = String::EmptyString; m##name##AssetId[id] = StringTable->EmptyString(); m##name##Asset[id] = NULL;
|
||||
#define bindMapSlot(name,id) if (m##name##AssetId[id] != String::EmptyString) m##name##Asset[id] = m##name##AssetId[id];
|
||||
|
||||
bool Material::sAllowTextureTargetAssignment = false;
|
||||
|
||||
GFXCubemap * Material::GetNormalizeCube()
|
||||
|
|
@ -121,13 +118,13 @@ Material::Material()
|
|||
mDiffuse[i].set( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
mDiffuseMapSRGB[i] = true;
|
||||
|
||||
mSmoothness[i] = 0.0f;
|
||||
mRoughness[i] = 1.0f;
|
||||
mMetalness[i] = 0.0f;
|
||||
|
||||
mIsSRGb[i] = true;
|
||||
mInvertSmoothness[i] = false;
|
||||
mInvertRoughness[i] = false;
|
||||
|
||||
mSmoothnessChan[i] = 0;
|
||||
mRoughnessChan[i] = 0;
|
||||
mAOChan[i] = 1;
|
||||
mMetalChan[i] = 2;
|
||||
|
||||
|
|
@ -138,18 +135,18 @@ Material::Material()
|
|||
mAccuCoverage[i] = 0.9f;
|
||||
mAccuSpecular[i] = 16.0f;
|
||||
|
||||
initMapSlot(DiffuseMap, i);
|
||||
initMapSlot(OverlayMap, i);
|
||||
initMapSlot(LightMap, i);
|
||||
initMapSlot(ToneMap, i);
|
||||
initMapSlot(DetailMap, i);
|
||||
initMapSlot(NormalMap, i);
|
||||
initMapSlot(PBRConfigMap, i);
|
||||
initMapSlot(RoughMap, i);
|
||||
initMapSlot(AOMap, i);
|
||||
initMapSlot(MetalMap, i);
|
||||
initMapSlot(GlowMap, i);
|
||||
initMapSlot(DetailNormalMap, i);
|
||||
initMapArraySlot(DiffuseMap, i);
|
||||
initMapArraySlot(OverlayMap, i);
|
||||
initMapArraySlot(LightMap, i);
|
||||
initMapArraySlot(ToneMap, i);
|
||||
initMapArraySlot(DetailMap, i);
|
||||
initMapArraySlot(NormalMap, i);
|
||||
initMapArraySlot(ORMConfigMap, i);
|
||||
initMapArraySlot(RoughMap, i);
|
||||
initMapArraySlot(AOMap, i);
|
||||
initMapArraySlot(MetalMap, i);
|
||||
initMapArraySlot(GlowMap, i);
|
||||
initMapArraySlot(DetailNormalMap, i);
|
||||
|
||||
mParallaxScale[i] = 0.0f;
|
||||
|
||||
|
|
@ -246,18 +243,18 @@ void Material::initPersistFields()
|
|||
"This color is multiplied against the diffuse texture color. If no diffuse texture "
|
||||
"is present this is the material color." );
|
||||
|
||||
scriptBindMapArraySlot(DiffuseMap, MAX_STAGES, Material);
|
||||
scriptBindMapArraySlot(OverlayMap, MAX_STAGES, Material);
|
||||
scriptBindMapArraySlot(LightMap, MAX_STAGES, Material);
|
||||
scriptBindMapArraySlot(ToneMap, MAX_STAGES, Material);
|
||||
scriptBindMapArraySlot(DetailMap, MAX_STAGES, Material);
|
||||
scriptBindMapArraySlot(NormalMap, MAX_STAGES, Material);
|
||||
scriptBindMapArraySlot(PBRConfigMap, MAX_STAGES, Material);
|
||||
scriptBindMapArraySlot(RoughMap, MAX_STAGES, Material);
|
||||
scriptBindMapArraySlot(AOMap, MAX_STAGES, Material);
|
||||
scriptBindMapArraySlot(MetalMap, MAX_STAGES, Material);
|
||||
scriptBindMapArraySlot(GlowMap, MAX_STAGES, Material);
|
||||
scriptBindMapArraySlot(DetailNormalMap, MAX_STAGES, Material);
|
||||
scriptBindMapArraySlot(DiffuseMap, MAX_STAGES, Material, "Albedo");
|
||||
scriptBindMapArraySlot(OverlayMap, MAX_STAGES, Material, "Overlay");
|
||||
scriptBindMapArraySlot(LightMap, MAX_STAGES, Material, "LightMap");
|
||||
scriptBindMapArraySlot(ToneMap, MAX_STAGES, Material, "ToneMap");
|
||||
scriptBindMapArraySlot(DetailMap, MAX_STAGES, Material, "DetailMap");
|
||||
scriptBindMapArraySlot(NormalMap, MAX_STAGES, Material, "NormalMap");
|
||||
scriptBindMapArraySlot(ORMConfigMap, MAX_STAGES, Material, "AO|Roughness|metalness map");
|
||||
scriptBindMapArraySlot(RoughMap, MAX_STAGES, Material, "RoughMap (also needs MetalMap)");
|
||||
scriptBindMapArraySlot(AOMap, MAX_STAGES, Material, "AOMap");
|
||||
scriptBindMapArraySlot(MetalMap, MAX_STAGES, Material, "MetalMap (also needs RoughMap)");
|
||||
scriptBindMapArraySlot(GlowMap, MAX_STAGES, Material, "GlowMap (needs Albedo)");
|
||||
scriptBindMapArraySlot(DetailNormalMap, MAX_STAGES, Material, "DetailNormalMap");
|
||||
|
||||
addField("diffuseMapSRGB", TypeBool, Offset(mDiffuseMapSRGB, Material), MAX_STAGES,
|
||||
"Enable sRGB for the diffuse color texture map.");
|
||||
|
|
@ -268,11 +265,11 @@ void Material::initPersistFields()
|
|||
addField( "detailNormalMapStrength", TypeF32, Offset(mDetailNormalMapStrength, Material), MAX_STAGES,
|
||||
"Used to scale the strength of the detail normal map when blended with the base normal map." );
|
||||
|
||||
addField("smoothness", TypeF32, Offset(mSmoothness, Material), MAX_STAGES,
|
||||
"The degree of smoothness when not using a PBRConfigMap." );
|
||||
addField("roughness", TypeF32, Offset(mRoughness, Material), MAX_STAGES,
|
||||
"The degree of roughness when not using a ORMConfigMap." );
|
||||
|
||||
addField("metalness", TypeF32, Offset(mMetalness, Material), MAX_STAGES,
|
||||
"The degree of Metalness when not using a PBRConfigMap." );
|
||||
"The degree of Metalness when not using a ORMConfigMap." );
|
||||
|
||||
addField("glowMul", TypeF32, Offset(mGlowMul, Material), MAX_STAGES,
|
||||
"glow mask multiplier");
|
||||
|
|
@ -298,11 +295,11 @@ void Material::initPersistFields()
|
|||
addField("isSRGb", TypeBool, Offset(mIsSRGb, Material), MAX_STAGES,
|
||||
"Substance Designer Workaround.");
|
||||
|
||||
addField("invertSmoothness", TypeBool, Offset(mInvertSmoothness, Material), MAX_STAGES,
|
||||
"Treat Smoothness as Roughness");
|
||||
addField("invertRoughness", TypeBool, Offset(mInvertRoughness, Material), MAX_STAGES,
|
||||
"Treat Roughness as Roughness");
|
||||
|
||||
addField("smoothnessChan", TypeF32, Offset(mSmoothnessChan, Material), MAX_STAGES,
|
||||
"The input channel smoothness maps use.");
|
||||
addField("roughnessChan", TypeF32, Offset(mRoughnessChan, Material), MAX_STAGES,
|
||||
"The input channel roughness maps use.");
|
||||
|
||||
addField("AOChan", TypeF32, Offset(mAOChan, Material), MAX_STAGES,
|
||||
"The input channel AO maps use.");
|
||||
|
|
@ -543,29 +540,20 @@ bool Material::onAdd()
|
|||
if ( slash != String::NPos )
|
||||
mPath = scriptFile.substr( 0, slash + 1 );
|
||||
|
||||
/*
|
||||
//bind any assets we have
|
||||
for (U32 i = 0; i < MAX_STAGES; i++)
|
||||
{
|
||||
if (mDiffuseMapAssetId[i] != StringTable->EmptyString())
|
||||
{
|
||||
mDiffuseMapAsset[0] = mDiffuseMapAssetId[0];
|
||||
}
|
||||
}
|
||||
*/
|
||||
for (U32 i = 0; i < MAX_STAGES; i++)
|
||||
{
|
||||
bindMapSlot(DiffuseMap, i);
|
||||
bindMapSlot(OverlayMap, i);
|
||||
bindMapSlot(LightMap, i);
|
||||
bindMapSlot(ToneMap, i);
|
||||
bindMapSlot(DetailMap, i);
|
||||
bindMapSlot(PBRConfigMap, i);
|
||||
bindMapSlot(RoughMap, i);
|
||||
bindMapSlot(AOMap, i);
|
||||
bindMapSlot(MetalMap, i);
|
||||
bindMapSlot(GlowMap, i);
|
||||
bindMapSlot(DetailNormalMap, i);
|
||||
bindMapArraySlot(DiffuseMap, i);
|
||||
bindMapArraySlot(OverlayMap, i);
|
||||
bindMapArraySlot(LightMap, i);
|
||||
bindMapArraySlot(ToneMap, i);
|
||||
bindMapArraySlot(DetailMap, i);
|
||||
bindMapArraySlot(ORMConfigMap, i);
|
||||
bindMapArraySlot(RoughMap, i);
|
||||
bindMapArraySlot(AOMap, i);
|
||||
bindMapArraySlot(MetalMap, i);
|
||||
bindMapArraySlot(GlowMap, i);
|
||||
bindMapArraySlot(DetailNormalMap, i);
|
||||
}
|
||||
|
||||
_mapMaterial();
|
||||
|
|
|
|||
|
|
@ -211,11 +211,11 @@ public:
|
|||
DECLARE_TEXTUREARRAY(ToneMap, MAX_STAGES);
|
||||
DECLARE_TEXTUREARRAY(DetailMap, MAX_STAGES);;
|
||||
DECLARE_TEXTUREARRAY(NormalMap, MAX_STAGES);
|
||||
DECLARE_TEXTUREARRAY(PBRConfigMap, MAX_STAGES);
|
||||
DECLARE_TEXTUREARRAY(ORMConfigMap, MAX_STAGES);
|
||||
bool mIsSRGb[MAX_STAGES];
|
||||
DECLARE_TEXTUREARRAY(RoughMap, MAX_STAGES);
|
||||
bool mInvertSmoothness[MAX_STAGES];
|
||||
F32 mSmoothnessChan[MAX_STAGES];
|
||||
bool mInvertRoughness[MAX_STAGES];
|
||||
F32 mRoughnessChan[MAX_STAGES];
|
||||
DECLARE_TEXTUREARRAY(AOMap, MAX_STAGES);
|
||||
F32 mAOChan[MAX_STAGES];
|
||||
DECLARE_TEXTUREARRAY(MetalMap, MAX_STAGES);
|
||||
|
|
@ -240,7 +240,7 @@ public:
|
|||
/// the diffuse texture color.
|
||||
LinearColorF mDiffuse[MAX_STAGES];
|
||||
|
||||
F32 mSmoothness[MAX_STAGES];
|
||||
F32 mRoughness[MAX_STAGES];
|
||||
F32 mMetalness[MAX_STAGES];
|
||||
|
||||
bool mVertLit[MAX_STAGES];
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ ImplementFeatureType( MFT_DetailMap, MFG_Texture, 4.0f, true );
|
|||
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_PBRConfigVars, MFG_Texture, 8.0f, true);
|
||||
ImplementFeatureType( MFT_InvertRoughness, U32(-1), -1, true);
|
||||
ImplementFeatureType( MFT_OrmMap, MFG_Texture, 8.0f, true);
|
||||
ImplementFeatureType( MFT_ORMConfigVars, MFG_Texture, 8.0f, true);
|
||||
ImplementFeatureType( MFT_MatInfoFlags, MFG_Texture, 9.0f, true);
|
||||
ImplementFeatureType( MFT_NormalMap, MFG_Texture, 11.0f, true );
|
||||
ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 12.0f, true );
|
||||
|
|
|
|||
|
|
@ -124,9 +124,9 @@ DeclareFeatureType( MFT_VertLitTone );
|
|||
|
||||
DeclareFeatureType( MFT_StaticCubemap );
|
||||
DeclareFeatureType( MFT_CubeMap );
|
||||
DeclareFeatureType( MFT_InvertSmoothness );
|
||||
DeclareFeatureType( MFT_PBRConfigMap );
|
||||
DeclareFeatureType( MFT_PBRConfigVars );
|
||||
DeclareFeatureType( MFT_InvertRoughness );
|
||||
DeclareFeatureType( MFT_OrmMap );
|
||||
DeclareFeatureType( MFT_ORMConfigVars );
|
||||
|
||||
DeclareFeatureType( MFT_GlowMap );
|
||||
|
||||
|
|
|
|||
|
|
@ -485,27 +485,27 @@ void ProcessedMaterial::_setStageData()
|
|||
if (mMaterial->mIsSRGb[i])
|
||||
profile = &GFXStaticTextureSRGBProfile;
|
||||
|
||||
// PBRConfig
|
||||
if (mMaterial->mPBRConfigMapFilename[i].isNotEmpty())
|
||||
// ORMConfig
|
||||
if (mMaterial->mORMConfigMapFilename[i].isNotEmpty())
|
||||
{
|
||||
mStages[i].setTex(MFT_PBRConfigMap, _createTexture(mMaterial->mPBRConfigMapFilename[i], profile));
|
||||
if (!mStages[i].getTex(MFT_PBRConfigMap))
|
||||
mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i);
|
||||
mStages[i].setTex(MFT_OrmMap, _createTexture(mMaterial->mORMConfigMapFilename[i], profile));
|
||||
if (!mStages[i].getTex(MFT_OrmMap))
|
||||
mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mORMConfigMapFilename[i]).c_str(), i);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mMaterial->mRoughMapFilename[i].isNotEmpty() && mMaterial->mMetalMapFilename[i].isNotEmpty())
|
||||
{
|
||||
U32 inputKey[4];
|
||||
inputKey[0] = mMaterial->mSmoothnessChan[i];
|
||||
inputKey[1] = mMaterial->mAOChan[i];
|
||||
inputKey[0] = mMaterial->mAOChan[i];
|
||||
inputKey[1] = mMaterial->mRoughnessChan[i];
|
||||
inputKey[2] = mMaterial->mMetalChan[i];
|
||||
inputKey[3] = 0;
|
||||
mStages[i].setTex(MFT_PBRConfigMap, _createCompositeTexture(mMaterial->mRoughMapFilename[i], mMaterial->mAOMapFilename[i],
|
||||
mStages[i].setTex(MFT_OrmMap, _createCompositeTexture( mMaterial->mAOMapFilename[i], mMaterial->mRoughMapFilename[i],
|
||||
mMaterial->mMetalMapFilename[i], "",
|
||||
inputKey, profile));
|
||||
if (!mStages[i].getTex(MFT_PBRConfigMap))
|
||||
mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i);
|
||||
if (!mStages[i].getTex(MFT_OrmMap))
|
||||
mMaterial->logError("Failed to load PBR Config map %s for stage %i", _getTexturePath(mMaterial->mORMConfigMapFilename[i]).c_str(), i);
|
||||
}
|
||||
}
|
||||
if (mMaterial->mGlowMapFilename[i].isNotEmpty())
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ void ShaderConstHandles::init( GFXShader *shader, CustomMaterial* mat /*=NULL*/)
|
|||
mDiffuseColorSC = shader->getShaderConstHandle("$diffuseMaterialColor");
|
||||
mTexMatSC = shader->getShaderConstHandle(ShaderGenVars::texMat);
|
||||
mToneMapTexSC = shader->getShaderConstHandle(ShaderGenVars::toneMap);
|
||||
mPBRConfigSC = shader->getShaderConstHandle(ShaderGenVars::pbrConfig);
|
||||
mSmoothnessSC = shader->getShaderConstHandle(ShaderGenVars::smoothness);
|
||||
mORMConfigSC = shader->getShaderConstHandle(ShaderGenVars::ormConfig);
|
||||
mRoughnessSC = shader->getShaderConstHandle(ShaderGenVars::roughness);
|
||||
mMetalnessSC = shader->getShaderConstHandle(ShaderGenVars::metalness);
|
||||
mGlowMulSC = shader->getShaderConstHandle(ShaderGenVars::glowMul);
|
||||
mAccuScaleSC = shader->getShaderConstHandle("$accuScale");
|
||||
|
|
@ -304,8 +304,8 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
|||
|
||||
// First we add all the features which the
|
||||
// material has defined.
|
||||
if (mMaterial->mInvertSmoothness[stageNum])
|
||||
fd.features.addFeature(MFT_InvertSmoothness);
|
||||
if (mMaterial->mInvertRoughness[stageNum])
|
||||
fd.features.addFeature(MFT_InvertRoughness);
|
||||
|
||||
if ( mMaterial->isTranslucent() )
|
||||
{
|
||||
|
|
@ -429,12 +429,12 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
|||
}
|
||||
|
||||
// Deferred Shading : PBR Config
|
||||
if (mStages[stageNum].getTex(MFT_PBRConfigMap))
|
||||
if (mStages[stageNum].getTex(MFT_OrmMap))
|
||||
{
|
||||
fd.features.addFeature(MFT_PBRConfigMap);
|
||||
fd.features.addFeature(MFT_OrmMap);
|
||||
}
|
||||
else
|
||||
fd.features.addFeature(MFT_PBRConfigVars);
|
||||
fd.features.addFeature(MFT_ORMConfigVars);
|
||||
|
||||
// Deferred Shading : Material Info Flags
|
||||
fd.features.addFeature(MFT_MatInfoFlags);
|
||||
|
|
@ -450,7 +450,7 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
|||
fd.features.addFeature(MFT_SkyBox);
|
||||
|
||||
fd.features.removeFeature(MFT_ReflectionProbes);
|
||||
fd.features.removeFeature(MFT_PBRConfigVars);
|
||||
fd.features.removeFeature(MFT_ORMConfigVars);
|
||||
fd.features.removeFeature(MFT_MatInfoFlags);
|
||||
}
|
||||
|
||||
|
|
@ -1109,7 +1109,7 @@ void ProcessedShaderMaterial::_setShaderConstants(SceneRenderState * state, cons
|
|||
if ( !shaderConsts->wasLost() )
|
||||
return;
|
||||
|
||||
shaderConsts->setSafe(handles->mSmoothnessSC, mMaterial->mSmoothness[stageNum]);
|
||||
shaderConsts->setSafe(handles->mRoughnessSC, mMaterial->mRoughness[stageNum]);
|
||||
shaderConsts->setSafe(handles->mMetalnessSC, mMaterial->mMetalness[stageNum]);
|
||||
shaderConsts->setSafe(handles->mGlowMulSC, mMaterial->mGlowMul[stageNum]);
|
||||
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ public:
|
|||
GFXShaderConstHandle* mDiffuseColorSC;
|
||||
GFXShaderConstHandle* mToneMapTexSC;
|
||||
GFXShaderConstHandle* mTexMatSC;
|
||||
GFXShaderConstHandle* mPBRConfigSC;
|
||||
GFXShaderConstHandle* mSmoothnessSC;
|
||||
GFXShaderConstHandle* mORMConfigSC;
|
||||
GFXShaderConstHandle* mRoughnessSC;
|
||||
GFXShaderConstHandle* mMetalnessSC;
|
||||
GFXShaderConstHandle* mGlowMulSC;
|
||||
GFXShaderConstHandle* mParallaxInfoSC;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue