mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 00:05:40 +00:00
shift pbrconfig to ORM
This commit is contained in:
parent
22b0785c73
commit
0c7811bd1a
54 changed files with 879 additions and 680 deletions
|
|
@ -118,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;
|
||||
|
||||
|
|
@ -265,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");
|
||||
|
|
@ -295,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.");
|
||||
|
|
|
|||
|
|
@ -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