mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
backend specularMap to PBRConfigMap alts.
left:
addField( "specularMap", TypeImageFilename, Offset(mPBRConfigMapFilename, Material), MAX_STAGES,
scripthook till last since that *will* break all current materials.
This commit is contained in:
parent
e621e362f4
commit
65cbf49c4a
24 changed files with 95 additions and 100 deletions
|
|
@ -390,7 +390,7 @@ void DeferredBumpFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
Parent::processPix( componentList, fd );
|
Parent::processPix( componentList, fd );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!fd.features[MFT_SpecularMap] )
|
else if (!fd.features[MFT_PBRConfigMap] )
|
||||||
{
|
{
|
||||||
Var *bumpSample = (Var *)LangElement::find( "bumpSample" );
|
Var *bumpSample = (Var *)LangElement::find( "bumpSample" );
|
||||||
if( bumpSample == NULL )
|
if( bumpSample == NULL )
|
||||||
|
|
@ -421,7 +421,7 @@ ShaderFeature::Resources DeferredBumpFeatGLSL::getResources( const MaterialFeatu
|
||||||
return Parent::getResources( fd );
|
return Parent::getResources( fd );
|
||||||
|
|
||||||
Resources res;
|
Resources res;
|
||||||
if(!fd.features[MFT_SpecularMap])
|
if(!fd.features[MFT_PBRConfigMap])
|
||||||
{
|
{
|
||||||
res.numTex = 1;
|
res.numTex = 1;
|
||||||
res.numTexReg = 1;
|
res.numTexReg = 1;
|
||||||
|
|
@ -464,7 +464,7 @@ void DeferredBumpFeatGLSL::setTexData( Material::StageData &stageDat,
|
||||||
passData.mTexSlot[texIndex++].texObject = stageDat.getTex(MFT_DetailNormalMap);
|
passData.mTexSlot[texIndex++].texObject = stageDat.getTex(MFT_DetailNormalMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!fd.features[MFT_Parallax] && !fd.features[MFT_SpecularMap] &&
|
else if (!fd.features[MFT_Parallax] && !fd.features[MFT_PBRConfigMap] &&
|
||||||
( fd.features[MFT_DeferredConditioner]) )
|
( fd.features[MFT_DeferredConditioner]) )
|
||||||
{
|
{
|
||||||
passData.mTexType[ texIndex ] = Material::Bump;
|
passData.mTexType[ texIndex ] = Material::Bump;
|
||||||
|
|
|
||||||
|
|
@ -56,13 +56,13 @@ void DeferredSpecMapGLSL::processPix( Vector<ShaderComponent*> &componentList, c
|
||||||
}
|
}
|
||||||
|
|
||||||
// create texture var
|
// create texture var
|
||||||
Var *specularMap = new Var;
|
Var *pbrConfigMap = new Var;
|
||||||
specularMap->setType( "sampler2D" );
|
pbrConfigMap->setType( "sampler2D" );
|
||||||
specularMap->setName( "specularMap" );
|
pbrConfigMap->setName( "PBRConfigMap" );
|
||||||
specularMap->uniform = true;
|
pbrConfigMap->uniform = true;
|
||||||
specularMap->sampler = true;
|
pbrConfigMap->sampler = true;
|
||||||
specularMap->constNum = Var::getTexUnitNum();
|
pbrConfigMap->constNum = Var::getTexUnitNum();
|
||||||
LangElement *texOp = new GenOp( "tex2D(@, @)", specularMap, texCoord );
|
LangElement *texOp = new GenOp( "tex2D(@, @)", pbrConfigMap, texCoord );
|
||||||
|
|
||||||
Var *pbrConfig = (Var*)LangElement::find("PBRConfig");
|
Var *pbrConfig = (Var*)LangElement::find("PBRConfig");
|
||||||
if (!pbrConfig) pbrConfig = new Var("PBRConfig", "vec4");
|
if (!pbrConfig) pbrConfig = new Var("PBRConfig", "vec4");
|
||||||
|
|
@ -97,11 +97,11 @@ void DeferredSpecMapGLSL::setTexData( Material::StageData &stageDat,
|
||||||
RenderPassData &passData,
|
RenderPassData &passData,
|
||||||
U32 &texIndex )
|
U32 &texIndex )
|
||||||
{
|
{
|
||||||
GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap );
|
GFXTextureObject *tex = stageDat.getTex(MFT_PBRConfigMap);
|
||||||
if ( tex )
|
if ( tex )
|
||||||
{
|
{
|
||||||
passData.mTexType[ texIndex ] = Material::Standard;
|
passData.mTexType[ texIndex ] = Material::Standard;
|
||||||
passData.mSamplerNames[ texIndex ] = "specularMap";
|
passData.mSamplerNames[ texIndex ] = "PBRConfigMap";
|
||||||
passData.mTexSlot[ texIndex++ ].texObject = tex;
|
passData.mTexSlot[ texIndex++ ].texObject = tex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -421,7 +421,7 @@ void DeferredBumpFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
Parent::processPix( componentList, fd );
|
Parent::processPix( componentList, fd );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!fd.features[MFT_SpecularMap] )
|
else if (!fd.features[MFT_PBRConfigMap] )
|
||||||
{
|
{
|
||||||
Var *bumpSample = (Var *)LangElement::find( "bumpSample" );
|
Var *bumpSample = (Var *)LangElement::find( "bumpSample" );
|
||||||
if( bumpSample == NULL )
|
if( bumpSample == NULL )
|
||||||
|
|
@ -454,7 +454,7 @@ ShaderFeature::Resources DeferredBumpFeatHLSL::getResources( const MaterialFeatu
|
||||||
return Parent::getResources( fd );
|
return Parent::getResources( fd );
|
||||||
|
|
||||||
Resources res;
|
Resources res;
|
||||||
if(!fd.features[MFT_SpecularMap])
|
if(!fd.features[MFT_PBRConfigMap])
|
||||||
{
|
{
|
||||||
res.numTex = 1;
|
res.numTex = 1;
|
||||||
res.numTexReg = 1;
|
res.numTexReg = 1;
|
||||||
|
|
@ -497,7 +497,7 @@ void DeferredBumpFeatHLSL::setTexData( Material::StageData &stageDat,
|
||||||
passData.mTexSlot[ texIndex++ ].texObject = stageDat.getTex( MFT_DetailNormalMap );
|
passData.mTexSlot[ texIndex++ ].texObject = stageDat.getTex( MFT_DetailNormalMap );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( !fd.features[MFT_Parallax] && !fd.features[MFT_SpecularMap] &&
|
else if ( !fd.features[MFT_Parallax] && !fd.features[MFT_PBRConfigMap] &&
|
||||||
( fd.features[MFT_DeferredConditioner]) )
|
( fd.features[MFT_DeferredConditioner]) )
|
||||||
{
|
{
|
||||||
passData.mTexType[ texIndex ] = Material::Bump;
|
passData.mTexType[ texIndex ] = Material::Bump;
|
||||||
|
|
|
||||||
|
|
@ -56,20 +56,20 @@ void DeferredSpecMapHLSL::processPix( Vector<ShaderComponent*> &componentList, c
|
||||||
}
|
}
|
||||||
|
|
||||||
// create texture var
|
// create texture var
|
||||||
Var *specularMap = new Var;
|
Var * pbrConfigMap = new Var;
|
||||||
specularMap->setType( "SamplerState" );
|
pbrConfigMap->setType( "SamplerState" );
|
||||||
specularMap->setName( "specularMap" );
|
pbrConfigMap->setName( "PBRConfigMap" );
|
||||||
specularMap->uniform = true;
|
pbrConfigMap->uniform = true;
|
||||||
specularMap->sampler = true;
|
pbrConfigMap->sampler = true;
|
||||||
specularMap->constNum = Var::getTexUnitNum();
|
pbrConfigMap->constNum = Var::getTexUnitNum();
|
||||||
|
|
||||||
Var* specularMapTex = new Var;
|
Var* pbrConfigMapTex = new Var;
|
||||||
specularMapTex->setName("specularMapTex");
|
pbrConfigMapTex->setName("PBRConfigMapTex");
|
||||||
specularMapTex->setType("Texture2D");
|
pbrConfigMapTex->setType("Texture2D");
|
||||||
specularMapTex->uniform = true;
|
pbrConfigMapTex->uniform = true;
|
||||||
specularMapTex->texture = true;
|
pbrConfigMapTex->texture = true;
|
||||||
specularMapTex->constNum = specularMap->constNum;
|
pbrConfigMapTex->constNum = pbrConfigMap->constNum;
|
||||||
LangElement *texOp = new GenOp(" @.Sample(@, @)", specularMapTex, specularMap, texCoord);
|
LangElement *texOp = new GenOp(" @.Sample(@, @)", pbrConfigMapTex, pbrConfigMap, texCoord);
|
||||||
|
|
||||||
Var * pbrConfig = (Var*)LangElement::find("pbrConfig");
|
Var * pbrConfig = (Var*)LangElement::find("pbrConfig");
|
||||||
if (!pbrConfig) pbrConfig = new Var("pbrConfig", "float4");
|
if (!pbrConfig) pbrConfig = new Var("pbrConfig", "float4");
|
||||||
|
|
@ -103,11 +103,11 @@ void DeferredSpecMapHLSL::setTexData( Material::StageData &stageDat,
|
||||||
RenderPassData &passData,
|
RenderPassData &passData,
|
||||||
U32 &texIndex )
|
U32 &texIndex )
|
||||||
{
|
{
|
||||||
GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap );
|
GFXTextureObject *tex = stageDat.getTex(MFT_PBRConfigMap);
|
||||||
if ( tex )
|
if ( tex )
|
||||||
{
|
{
|
||||||
passData.mTexType[ texIndex ] = Material::Standard;
|
passData.mTexType[ texIndex ] = Material::Standard;
|
||||||
passData.mSamplerNames[ texIndex ] = "specularMap";
|
passData.mSamplerNames[ texIndex ] = "PBRConfigMap";
|
||||||
passData.mTexSlot[ texIndex++ ].texObject = tex;
|
passData.mTexSlot[ texIndex++ ].texObject = tex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -272,10 +272,10 @@ void Material::initPersistFields()
|
||||||
"Used to scale the strength of the detail normal map when blended with the base normal map." );
|
"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,
|
addField("smoothness", TypeF32, Offset(mSmoothness, Material), MAX_STAGES,
|
||||||
"The degree of smoothness when not using a specularMap." );
|
"The degree of smoothness when not using a PBRConfigMap." );
|
||||||
|
|
||||||
addField("metalness", TypeF32, Offset(mMetalness, Material), MAX_STAGES,
|
addField("metalness", TypeF32, Offset(mMetalness, Material), MAX_STAGES,
|
||||||
"The degree of Metalness when not using a specularMap." );
|
"The degree of Metalness when not using a PBRConfigMap." );
|
||||||
|
|
||||||
addProtectedField( "accuEnabled", TYPEID< bool >(), Offset( mAccuEnabled, Material ),
|
addProtectedField( "accuEnabled", TYPEID< bool >(), Offset( mAccuEnabled, Material ),
|
||||||
&_setAccuEnabled, &defaultProtectedGetFn, MAX_STAGES, "Accumulation texture." );
|
&_setAccuEnabled, &defaultProtectedGetFn, MAX_STAGES, "Accumulation texture." );
|
||||||
|
|
@ -301,7 +301,7 @@ void Material::initPersistFields()
|
||||||
addField("invertSmoothness", TypeBool, Offset(mInvertSmoothness, Material), MAX_STAGES,
|
addField("invertSmoothness", TypeBool, Offset(mInvertSmoothness, Material), MAX_STAGES,
|
||||||
"Treat Smoothness as Roughness");
|
"Treat Smoothness as Roughness");
|
||||||
|
|
||||||
addField( "specularMap", TypeImageFilename, Offset(mSpecularMapFilename, Material), MAX_STAGES,
|
addField( "specularMap", TypeImageFilename, Offset(mPBRConfigMapFilename, Material), MAX_STAGES,
|
||||||
"Prepacked specular map texture. The RGB channels of this texture provide per-pixel reference values for: "
|
"Prepacked specular map texture. The RGB channels of this texture provide per-pixel reference values for: "
|
||||||
"smoothness (R), Ambient Occlusion (G), and metalness(B)");
|
"smoothness (R), Ambient Occlusion (G), and metalness(B)");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -237,9 +237,9 @@ public:
|
||||||
|
|
||||||
bool mIsSRGb[MAX_STAGES];
|
bool mIsSRGb[MAX_STAGES];
|
||||||
bool mInvertSmoothness[MAX_STAGES];
|
bool mInvertSmoothness[MAX_STAGES];
|
||||||
FileName mSpecularMapFilename[MAX_STAGES];
|
FileName mPBRConfigMapFilename[MAX_STAGES];
|
||||||
StringTableEntry mSpecularMapAssetId[MAX_STAGES];
|
StringTableEntry mPBRConfigMapAssetId[MAX_STAGES];
|
||||||
AssetPtr<ImageAsset> mSpecularMapAsset[MAX_STAGES];
|
AssetPtr<ImageAsset> mPBRConfigMapAsset[MAX_STAGES];
|
||||||
FileName mRoughMapFilename[MAX_STAGES];
|
FileName mRoughMapFilename[MAX_STAGES];
|
||||||
StringTableEntry mRoughMapAssetId[MAX_STAGES];
|
StringTableEntry mRoughMapAssetId[MAX_STAGES];
|
||||||
AssetPtr<ImageAsset> mRoughMapAsset[MAX_STAGES];
|
AssetPtr<ImageAsset> mRoughMapAsset[MAX_STAGES];
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ ImplementFeatureType( MFT_DiffuseColor, MFG_Texture, 5.0f, true );
|
||||||
ImplementFeatureType( MFT_DiffuseVertColor, MFG_Texture, 6.0f, true );
|
ImplementFeatureType( MFT_DiffuseVertColor, MFG_Texture, 6.0f, true );
|
||||||
ImplementFeatureType( MFT_AlphaTest, MFG_Texture, 7.0f, true );
|
ImplementFeatureType( MFT_AlphaTest, MFG_Texture, 7.0f, true );
|
||||||
ImplementFeatureType(MFT_InvertSmoothness, U32(-1), -1, true);
|
ImplementFeatureType(MFT_InvertSmoothness, U32(-1), -1, true);
|
||||||
ImplementFeatureType( MFT_SpecularMap, MFG_Texture, 8.0f, true );
|
ImplementFeatureType( MFT_PBRConfigMap, MFG_Texture, 8.0f, true );
|
||||||
ImplementFeatureType( MFT_NormalMap, MFG_Texture, 9.0f, true );
|
ImplementFeatureType( MFT_NormalMap, MFG_Texture, 9.0f, true );
|
||||||
ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 10.0f, true );
|
ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 10.0f, true );
|
||||||
ImplementFeatureType( MFT_Imposter, U32(-1), -1, true );
|
ImplementFeatureType( MFT_Imposter, U32(-1), -1, true );
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ DeclareFeatureType( MFT_VertLitTone );
|
||||||
DeclareFeatureType( MFT_StaticCubemap );
|
DeclareFeatureType( MFT_StaticCubemap );
|
||||||
DeclareFeatureType( MFT_CubeMap );
|
DeclareFeatureType( MFT_CubeMap );
|
||||||
DeclareFeatureType( MFT_InvertSmoothness );
|
DeclareFeatureType( MFT_InvertSmoothness );
|
||||||
DeclareFeatureType( MFT_SpecularMap );
|
DeclareFeatureType( MFT_PBRConfigMap );
|
||||||
DeclareFeatureType( MFT_GlossMap );
|
DeclareFeatureType( MFT_GlossMap );
|
||||||
|
|
||||||
DeclareFeatureType( MFT_ReflectionProbes );
|
DeclareFeatureType( MFT_ReflectionProbes );
|
||||||
|
|
|
||||||
|
|
@ -472,12 +472,12 @@ void ProcessedMaterial::_setStageData()
|
||||||
if (mMaterial->mIsSRGb[i])
|
if (mMaterial->mIsSRGb[i])
|
||||||
profile = &GFXStaticTextureSRGBProfile;
|
profile = &GFXStaticTextureSRGBProfile;
|
||||||
|
|
||||||
// SpecularMap
|
// PBRConfig
|
||||||
if (mMaterial->mSpecularMapFilename[i].isNotEmpty())
|
if (mMaterial->mPBRConfigMapFilename[i].isNotEmpty())
|
||||||
{
|
{
|
||||||
mStages[i].setTex(MFT_SpecularMap, _createTexture(mMaterial->mSpecularMapFilename[i], profile));
|
mStages[i].setTex(MFT_PBRConfigMap, _createTexture(mMaterial->mPBRConfigMapFilename[i], profile));
|
||||||
if (!mStages[i].getTex(MFT_SpecularMap))
|
if (!mStages[i].getTex(MFT_PBRConfigMap))
|
||||||
mMaterial->logError("Failed to load specular map %s for stage %i", _getTexturePath(mMaterial->mSpecularMapFilename[i]).c_str(), i);
|
mMaterial->logError("Failed to load specular map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -488,11 +488,11 @@ void ProcessedMaterial::_setStageData()
|
||||||
inputKey[1] = mMaterial->mAOChan[i];
|
inputKey[1] = mMaterial->mAOChan[i];
|
||||||
inputKey[2] = mMaterial->mMetalChan[i];
|
inputKey[2] = mMaterial->mMetalChan[i];
|
||||||
inputKey[3] = NULL;
|
inputKey[3] = NULL;
|
||||||
mStages[i].setTex(MFT_SpecularMap, _createCompositeTexture(mMaterial->mRoughMapFilename[i], mMaterial->mAOMapFilename[i],
|
mStages[i].setTex(MFT_PBRConfigMap, _createCompositeTexture(mMaterial->mRoughMapFilename[i], mMaterial->mAOMapFilename[i],
|
||||||
mMaterial->mMetalMapFilename[i], "",
|
mMaterial->mMetalMapFilename[i], "",
|
||||||
inputKey, profile));
|
inputKey, profile));
|
||||||
if (!mStages[i].getTex(MFT_SpecularMap))
|
if (!mStages[i].getTex(MFT_PBRConfigMap))
|
||||||
mMaterial->logError("Failed to load specular map %s for stage %i", _getTexturePath(mMaterial->mSpecularMapFilename[i]).c_str(), i);
|
mMaterial->logError("Failed to load specular map %s for stage %i", _getTexturePath(mMaterial->mPBRConfigMapFilename[i]).c_str(), i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ void ShaderConstHandles::init( GFXShader *shader, Vector<CustomShaderFeatureData
|
||||||
mDiffuseColorSC = shader->getShaderConstHandle("$diffuseMaterialColor");
|
mDiffuseColorSC = shader->getShaderConstHandle("$diffuseMaterialColor");
|
||||||
mTexMatSC = shader->getShaderConstHandle(ShaderGenVars::texMat);
|
mTexMatSC = shader->getShaderConstHandle(ShaderGenVars::texMat);
|
||||||
mToneMapTexSC = shader->getShaderConstHandle(ShaderGenVars::toneMap);
|
mToneMapTexSC = shader->getShaderConstHandle(ShaderGenVars::toneMap);
|
||||||
mSpecularColorSC = shader->getShaderConstHandle(ShaderGenVars::specularColor);
|
mPBRConfigSC = shader->getShaderConstHandle(ShaderGenVars::pbrConfig);
|
||||||
mSmoothnessSC = shader->getShaderConstHandle(ShaderGenVars::smoothness);
|
mSmoothnessSC = shader->getShaderConstHandle(ShaderGenVars::smoothness);
|
||||||
mMetalnessSC = shader->getShaderConstHandle(ShaderGenVars::metalness);
|
mMetalnessSC = shader->getShaderConstHandle(ShaderGenVars::metalness);
|
||||||
mAccuScaleSC = shader->getShaderConstHandle("$accuScale");
|
mAccuScaleSC = shader->getShaderConstHandle("$accuScale");
|
||||||
|
|
@ -443,16 +443,16 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
||||||
// Without realtime lighting and on lower end
|
// Without realtime lighting and on lower end
|
||||||
// shader models disable the specular map.
|
// shader models disable the specular map.
|
||||||
if ( !fd.features[ MFT_RTLighting ] || shaderVersion == 2.0 )
|
if ( !fd.features[ MFT_RTLighting ] || shaderVersion == 2.0 )
|
||||||
fd.features.removeFeature( MFT_SpecularMap );
|
fd.features.removeFeature( MFT_PBRConfigMap );
|
||||||
|
|
||||||
// If we have a specular map then make sure we
|
// If we have a specular map then make sure we
|
||||||
// have per-pixel specular enabled.
|
// have per-pixel specular enabled.
|
||||||
if( fd.features[ MFT_SpecularMap ] )
|
if( fd.features[ MFT_PBRConfigMap ] )
|
||||||
{
|
{
|
||||||
// Check for an alpha channel on the specular map. If it has one (and it
|
// 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
|
// has values less than 255) than the artist has put the gloss map into
|
||||||
// the alpha channel.
|
// the alpha channel.
|
||||||
if( mStages[stageNum].getTex( MFT_SpecularMap )->mHasTransparency )
|
if( mStages[stageNum].getTex( MFT_PBRConfigMap )->mHasTransparency )
|
||||||
fd.features.addFeature( MFT_GlossMap );
|
fd.features.addFeature( MFT_GlossMap );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public:
|
||||||
GFXShaderConstHandle* mDiffuseColorSC;
|
GFXShaderConstHandle* mDiffuseColorSC;
|
||||||
GFXShaderConstHandle* mToneMapTexSC;
|
GFXShaderConstHandle* mToneMapTexSC;
|
||||||
GFXShaderConstHandle* mTexMatSC;
|
GFXShaderConstHandle* mTexMatSC;
|
||||||
GFXShaderConstHandle* mSpecularColorSC;
|
GFXShaderConstHandle* mPBRConfigSC;
|
||||||
GFXShaderConstHandle* mSmoothnessSC;
|
GFXShaderConstHandle* mSmoothnessSC;
|
||||||
GFXShaderConstHandle* mMetalnessSC;
|
GFXShaderConstHandle* mMetalnessSC;
|
||||||
GFXShaderConstHandle* mParallaxInfoSC;
|
GFXShaderConstHandle* mParallaxInfoSC;
|
||||||
|
|
|
||||||
|
|
@ -635,7 +635,7 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum,
|
||||||
newFeatures.addFeature(MFT_InvertSmoothness);
|
newFeatures.addFeature(MFT_InvertSmoothness);
|
||||||
|
|
||||||
// Deferred Shading : Specular
|
// Deferred Shading : Specular
|
||||||
if( mStages[stageNum].getTex( MFT_SpecularMap ) )
|
if( mStages[stageNum].getTex( MFT_PBRConfigMap ) )
|
||||||
{
|
{
|
||||||
newFeatures.addFeature( MFT_DeferredSpecMap );
|
newFeatures.addFeature( MFT_DeferredSpecMap );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
#include "gfx/gfxStructs.h"
|
#include "gfx/gfxStructs.h"
|
||||||
#include "shaderGen/shaderGen.h"
|
#include "shaderGen/shaderGen.h"
|
||||||
|
|
||||||
void SpecularMapGLSL::processVert(Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd)
|
void PBRConfigMapGLSL::processVert(Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd)
|
||||||
{
|
{
|
||||||
MultiLine *meta = new MultiLine;
|
MultiLine *meta = new MultiLine;
|
||||||
|
|
||||||
|
|
@ -43,19 +43,19 @@ void SpecularMapGLSL::processVert(Vector<ShaderComponent*> &componentList, const
|
||||||
output = meta;
|
output = meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpecularMapGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
void PBRConfigMapGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
// Get the texture coord.
|
// Get the texture coord.
|
||||||
Var *texCoord = getInTexCoord( "texCoord", "vec2", componentList );
|
Var *texCoord = getInTexCoord( "texCoord", "vec2", componentList );
|
||||||
|
|
||||||
// create texture var
|
// create texture var
|
||||||
Var *specularMap = new Var;
|
Var *pbrConfigMap = new Var;
|
||||||
specularMap->setType( "sampler2D" );
|
pbrConfigMap->setType( "sampler2D" );
|
||||||
specularMap->setName( "specularMap" );
|
pbrConfigMap->setName( "PBRConfigMap" );
|
||||||
specularMap->uniform = true;
|
pbrConfigMap->uniform = true;
|
||||||
specularMap->sampler = true;
|
pbrConfigMap->sampler = true;
|
||||||
specularMap->constNum = Var::getTexUnitNum();
|
pbrConfigMap->constNum = Var::getTexUnitNum();
|
||||||
LangElement *texOp = new GenOp( "texture(@, @)", specularMap, texCoord );
|
LangElement *texOp = new GenOp( "texture(@, @)", pbrConfigMap, texCoord );
|
||||||
|
|
||||||
Var * pbrConfig = new Var( "PBRConfig", "vec4" );
|
Var * pbrConfig = new Var( "PBRConfig", "vec4" );
|
||||||
Var *metalness = (Var*)LangElement::find("metalness");
|
Var *metalness = (Var*)LangElement::find("metalness");
|
||||||
|
|
@ -74,23 +74,23 @@ void SpecularMapGLSL::processPix( Vector<ShaderComponent*> &componentList, const
|
||||||
output = meta;
|
output = meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderFeature::Resources SpecularMapGLSL::getResources( const MaterialFeatureData &fd )
|
ShaderFeature::Resources PBRConfigMapGLSL::getResources( const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
Resources res;
|
Resources res;
|
||||||
res.numTex = 1;
|
res.numTex = 1;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpecularMapGLSL::setTexData( Material::StageData &stageDat,
|
void PBRConfigMapGLSL::setTexData( Material::StageData &stageDat,
|
||||||
const MaterialFeatureData &fd,
|
const MaterialFeatureData &fd,
|
||||||
RenderPassData &passData,
|
RenderPassData &passData,
|
||||||
U32 &texIndex )
|
U32 &texIndex )
|
||||||
{
|
{
|
||||||
GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap );
|
GFXTextureObject *tex = stageDat.getTex( MFT_PBRConfigMap );
|
||||||
if ( tex )
|
if ( tex )
|
||||||
{
|
{
|
||||||
passData.mTexType[ texIndex ] = Material::Standard;
|
passData.mTexType[ texIndex ] = Material::Standard;
|
||||||
passData.mSamplerNames[ texIndex ] = "specularMap";
|
passData.mSamplerNames[ texIndex ] = "PBRConfigMap";
|
||||||
passData.mTexSlot[ texIndex++ ].texObject = tex;
|
passData.mTexSlot[ texIndex++ ].texObject = tex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// A texture source for the PixSpecular feature
|
/// A texture source for the PixSpecular feature
|
||||||
class SpecularMapGLSL : public ShaderFeatureGLSL
|
class PBRConfigMapGLSL : public ShaderFeatureGLSL
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -47,7 +47,7 @@ public:
|
||||||
|
|
||||||
virtual String getName()
|
virtual String getName()
|
||||||
{
|
{
|
||||||
return "Specular Map";
|
return "PBRConfig Map";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
|
||||||
FEATUREMGR->registerFeature( MFT_StaticCubemap, new NamedFeatureGLSL( "Static Cubemap" ) );
|
FEATUREMGR->registerFeature( MFT_StaticCubemap, new NamedFeatureGLSL( "Static Cubemap" ) );
|
||||||
FEATUREMGR->registerFeature( MFT_CubeMap, new ReflectCubeFeatGLSL );
|
FEATUREMGR->registerFeature( MFT_CubeMap, new ReflectCubeFeatGLSL );
|
||||||
FEATUREMGR->registerFeature( MFT_InvertSmoothness, new NamedFeatureGLSL("Roughest = 1.0"));
|
FEATUREMGR->registerFeature( MFT_InvertSmoothness, new NamedFeatureGLSL("Roughest = 1.0"));
|
||||||
FEATUREMGR->registerFeature( MFT_SpecularMap, new SpecularMapGLSL );
|
FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapGLSL );
|
||||||
FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatGLSL );
|
FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatGLSL );
|
||||||
FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureGLSL( "Gloss Map" ) );
|
FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureGLSL( "Gloss Map" ) );
|
||||||
FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) );
|
FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) );
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
#include "gfx/gfxStructs.h"
|
#include "gfx/gfxStructs.h"
|
||||||
#include "shaderGen/shaderGen.h"
|
#include "shaderGen/shaderGen.h"
|
||||||
|
|
||||||
void SpecularMapHLSL::processVert(Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd)
|
void PBRConfigMapHLSL::processVert(Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd)
|
||||||
{
|
{
|
||||||
MultiLine *meta = new MultiLine;
|
MultiLine *meta = new MultiLine;
|
||||||
|
|
||||||
|
|
@ -43,26 +43,26 @@ void SpecularMapHLSL::processVert(Vector<ShaderComponent*> &componentList, const
|
||||||
output = meta;
|
output = meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpecularMapHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
void PBRConfigMapHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
// Get the texture coord.
|
// Get the texture coord.
|
||||||
Var *texCoord = getInTexCoord("texCoord", "float2", componentList);
|
Var *texCoord = getInTexCoord("texCoord", "float2", componentList);
|
||||||
|
|
||||||
// create texture var
|
// create texture var
|
||||||
Var *specularMap = new Var;
|
Var *pbrConfigMap = new Var;
|
||||||
specularMap->setType( "SamplerState" );
|
pbrConfigMap->setType( "SamplerState" );
|
||||||
specularMap->setName( "specularMap" );
|
pbrConfigMap->setName( "PBRConfigMap" );
|
||||||
specularMap->uniform = true;
|
pbrConfigMap->uniform = true;
|
||||||
specularMap->sampler = true;
|
pbrConfigMap->sampler = true;
|
||||||
specularMap->constNum = Var::getTexUnitNum();
|
pbrConfigMap->constNum = Var::getTexUnitNum();
|
||||||
|
|
||||||
Var *specularMapTex = new Var;
|
Var *pbrConfigMapTex = new Var;
|
||||||
specularMapTex->setName("specularMapTex");
|
pbrConfigMapTex->setName("PBRConfigMapTex");
|
||||||
specularMapTex->setType("Texture2D");
|
pbrConfigMapTex->setType("Texture2D");
|
||||||
specularMapTex->uniform = true;
|
pbrConfigMapTex->uniform = true;
|
||||||
specularMapTex->texture = true;
|
pbrConfigMapTex->texture = true;
|
||||||
specularMapTex->constNum = specularMap->constNum;
|
pbrConfigMapTex->constNum = pbrConfigMap->constNum;
|
||||||
LangElement *texOp = new GenOp("@.Sample(@, @)", specularMapTex, specularMap, texCoord);
|
LangElement *texOp = new GenOp("@.Sample(@, @)", pbrConfigMapTex, pbrConfigMap, texCoord);
|
||||||
|
|
||||||
|
|
||||||
Var * pbrConfig = new Var( "PBRConfig", "float4" );
|
Var * pbrConfig = new Var( "PBRConfig", "float4" );
|
||||||
|
|
@ -81,23 +81,23 @@ void SpecularMapHLSL::processPix( Vector<ShaderComponent*> &componentList, const
|
||||||
output = meta;
|
output = meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderFeature::Resources SpecularMapHLSL::getResources( const MaterialFeatureData &fd )
|
ShaderFeature::Resources PBRConfigMapHLSL::getResources( const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
Resources res;
|
Resources res;
|
||||||
res.numTex = 1;
|
res.numTex = 1;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpecularMapHLSL::setTexData( Material::StageData &stageDat,
|
void PBRConfigMapHLSL::setTexData( Material::StageData &stageDat,
|
||||||
const MaterialFeatureData &fd,
|
const MaterialFeatureData &fd,
|
||||||
RenderPassData &passData,
|
RenderPassData &passData,
|
||||||
U32 &texIndex )
|
U32 &texIndex )
|
||||||
{
|
{
|
||||||
GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap );
|
GFXTextureObject *tex = stageDat.getTex( MFT_PBRConfigMap );
|
||||||
if ( tex )
|
if ( tex )
|
||||||
{
|
{
|
||||||
passData.mTexType[ texIndex ] = Material::Standard;
|
passData.mTexType[ texIndex ] = Material::Standard;
|
||||||
passData.mSamplerNames[ texIndex ] = "specularMap";
|
passData.mSamplerNames[ texIndex ] = "PBRConfigMap";
|
||||||
passData.mTexSlot[ texIndex++ ].texObject = tex;
|
passData.mTexSlot[ texIndex++ ].texObject = tex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@
|
||||||
#include "shaderGen/HLSL/shaderFeatureHLSL.h"
|
#include "shaderGen/HLSL/shaderFeatureHLSL.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// A texture source for the PixSpecular feature
|
/// A texture source for the PBRConfigMap feature
|
||||||
class SpecularMapHLSL : public ShaderFeatureHLSL
|
class PBRConfigMapHLSL : public ShaderFeatureHLSL
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -47,7 +47,7 @@ public:
|
||||||
|
|
||||||
virtual String getName()
|
virtual String getName()
|
||||||
{
|
{
|
||||||
return "Specular Map";
|
return "PBRConfig Map";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1304,7 +1304,7 @@ void LightmapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
lightMapTex->texture = true;
|
lightMapTex->texture = true;
|
||||||
lightMapTex->constNum = lightMap->constNum;
|
lightMapTex->constNum = lightMap->constNum;
|
||||||
|
|
||||||
// argh, pixel specular should prob use this too
|
// argh, PBRConfigMap should prob use this too
|
||||||
if( fd.features[MFT_NormalMap] )
|
if( fd.features[MFT_NormalMap] )
|
||||||
{
|
{
|
||||||
Var *lmColor = new Var;
|
Var *lmColor = new Var;
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
|
||||||
FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureHLSL( "Translucent ZWrite" ) );
|
FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureHLSL( "Translucent ZWrite" ) );
|
||||||
FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatHLSL );
|
FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatHLSL );
|
||||||
FEATUREMGR->registerFeature( MFT_Fog, new FogFeatHLSL );
|
FEATUREMGR->registerFeature( MFT_Fog, new FogFeatHLSL );
|
||||||
FEATUREMGR->registerFeature( MFT_SpecularMap, new SpecularMapHLSL );
|
FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapHLSL );
|
||||||
FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatHLSL );
|
FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatHLSL );
|
||||||
FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureHLSL( "Gloss Map" ) );
|
FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureHLSL( "Gloss Map" ) );
|
||||||
FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureHLSL( "Lightbuffer MRT" ) );
|
FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureHLSL( "Lightbuffer MRT" ) );
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ const String ShaderGenVars::vectorLightDirection("$vectorLightDirection");
|
||||||
const String ShaderGenVars::vectorLightColor("$vectorLightColor");
|
const String ShaderGenVars::vectorLightColor("$vectorLightColor");
|
||||||
const String ShaderGenVars::vectorLightBrightness("$vectorLightBrightness");
|
const String ShaderGenVars::vectorLightBrightness("$vectorLightBrightness");
|
||||||
|
|
||||||
const String ShaderGenVars::specularColor("$specularColor");
|
const String ShaderGenVars::pbrConfig("$pbrConfig");
|
||||||
const String ShaderGenVars::smoothness("$smoothness");
|
const String ShaderGenVars::smoothness("$smoothness");
|
||||||
const String ShaderGenVars::metalness("$metalness");
|
const String ShaderGenVars::metalness("$metalness");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ struct ShaderGenVars
|
||||||
const static String vectorLightColor;
|
const static String vectorLightColor;
|
||||||
const static String vectorLightBrightness;
|
const static String vectorLightBrightness;
|
||||||
|
|
||||||
const static String specularColor;
|
const static String pbrConfig;
|
||||||
const static String smoothness;
|
const static String smoothness;
|
||||||
const static String metalness;
|
const static String metalness;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,6 @@ ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat)
|
||||||
// Get the <profile_COMMON>, <diffuse> and <specular> elements
|
// Get the <profile_COMMON>, <diffuse> and <specular> elements
|
||||||
const domProfile_COMMON* commonProfile = ColladaUtils::findEffectCommonProfile(effect);
|
const domProfile_COMMON* commonProfile = ColladaUtils::findEffectCommonProfile(effect);
|
||||||
const domCommon_color_or_texture_type_complexType* domDiffuse = findEffectDiffuse(effect);
|
const domCommon_color_or_texture_type_complexType* domDiffuse = findEffectDiffuse(effect);
|
||||||
const domCommon_color_or_texture_type_complexType* domSpecular = findEffectSpecular(effect);
|
|
||||||
|
|
||||||
// Wrap flags
|
// Wrap flags
|
||||||
if (effectExt->wrapU)
|
if (effectExt->wrapU)
|
||||||
|
|
@ -158,7 +157,6 @@ ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat)
|
||||||
// Get the paths for the various textures => Collada indirection at its finest!
|
// Get the paths for the various textures => Collada indirection at its finest!
|
||||||
// <texture>.<newparam>.<sampler2D>.<source>.<newparam>.<surface>.<init_from>.<image>.<init_from>
|
// <texture>.<newparam>.<sampler2D>.<source>.<newparam>.<surface>.<init_from>.<image>.<init_from>
|
||||||
diffuseMap = getSamplerImagePath(effect, getTextureSampler(effect, domDiffuse));
|
diffuseMap = getSamplerImagePath(effect, getTextureSampler(effect, domDiffuse));
|
||||||
specularMap = getSamplerImagePath(effect, getTextureSampler(effect, domSpecular));
|
|
||||||
normalMap = getSamplerImagePath(effect, effectExt->bumpSampler);
|
normalMap = getSamplerImagePath(effect, effectExt->bumpSampler);
|
||||||
|
|
||||||
// Set the material name
|
// Set the material name
|
||||||
|
|
@ -218,7 +216,6 @@ Material *ColladaAppMaterial::createMaterial(const Torque::Path& path) const
|
||||||
|
|
||||||
newMat->mDiffuseMapFilename[0] = diffuseMap;
|
newMat->mDiffuseMapFilename[0] = diffuseMap;
|
||||||
newMat->mNormalMapFilename[0] = normalMap;
|
newMat->mNormalMapFilename[0] = normalMap;
|
||||||
newMat->mSpecularMapFilename[0] = specularMap;
|
|
||||||
|
|
||||||
newMat->mDiffuse[0] = diffuseColor;
|
newMat->mDiffuse[0] = diffuseColor;
|
||||||
newMat->mSmoothness[0] = smoothness;
|
newMat->mSmoothness[0] = smoothness;
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ public:
|
||||||
// Settings extracted from the Collada file, and optionally saved to materials.cs
|
// Settings extracted from the Collada file, and optionally saved to materials.cs
|
||||||
String diffuseMap;
|
String diffuseMap;
|
||||||
String normalMap;
|
String normalMap;
|
||||||
String specularMap;
|
|
||||||
|
|
||||||
LinearColorF diffuseColor;
|
LinearColorF diffuseColor;
|
||||||
LinearColorF specularColor;
|
LinearColorF specularColor;
|
||||||
|
|
|
||||||
|
|
@ -499,7 +499,6 @@ void updateMaterialsScript(const Torque::Path &path, bool copyTextures = false)
|
||||||
|
|
||||||
copySketchupTexture(path, mat->mDiffuseMapFilename[0]);
|
copySketchupTexture(path, mat->mDiffuseMapFilename[0]);
|
||||||
copySketchupTexture(path, mat->mNormalMapFilename[0]);
|
copySketchupTexture(path, mat->mNormalMapFilename[0]);
|
||||||
copySketchupTexture(path, mat->mSpecularMapFilename[0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue