diff --git a/Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.h b/Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.h index ffda4105b..f59231f2a 100644 --- a/Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.h +++ b/Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.h @@ -25,7 +25,6 @@ #include "shaderGen/GLSL/shaderFeatureGLSL.h" #include "shaderGen/GLSL/bumpGLSL.h" -#include "shaderGen/GLSL/pixSpecularGLSL.h" class ConditionerMethodDependency; diff --git a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp index e92bad5cd..354371ba4 100644 --- a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp +++ b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp @@ -36,9 +36,7 @@ // Deferred Shading Features //**************************************************************************** -// Specular Map -> Blue of Material Buffer ( greyscaled ) -// Gloss Map (Alpha Channel of Specular Map) -> Alpha ( Spec Power ) of Material Info Buffer. -void DeferredSpecMapGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) +void PBRConfigMapGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { // Get the texture coord. Var *texCoord = getInTexCoord( "texCoord", "vec2", componentList ); @@ -58,7 +56,7 @@ void DeferredSpecMapGLSL::processPix( Vector &componentList, c // create texture var Var *pbrConfigMap = new Var; pbrConfigMap->setType( "sampler2D" ); - pbrConfigMap->setName( "PBRConfigMap" ); + pbrConfigMap->setName( "pbrConfigMap" ); pbrConfigMap->uniform = true; pbrConfigMap->sampler = true; pbrConfigMap->constNum = Var::getTexUnitNum(); @@ -83,7 +81,7 @@ void DeferredSpecMapGLSL::processPix( Vector &componentList, c output = meta; } -ShaderFeature::Resources DeferredSpecMapGLSL::getResources( const MaterialFeatureData &fd ) +ShaderFeature::Resources PBRConfigMapGLSL::getResources( const MaterialFeatureData &fd ) { Resources res; res.numTex = 1; @@ -92,7 +90,7 @@ ShaderFeature::Resources DeferredSpecMapGLSL::getResources( const MaterialFeatur return res; } -void DeferredSpecMapGLSL::setTexData( Material::StageData &stageDat, +void PBRConfigMapGLSL::setTexData( Material::StageData &stageDat, const MaterialFeatureData &fd, RenderPassData &passData, U32 &texIndex ) @@ -101,12 +99,12 @@ void DeferredSpecMapGLSL::setTexData( Material::StageData &stageDat, if ( tex ) { passData.mTexType[ texIndex ] = Material::Standard; - passData.mSamplerNames[ texIndex ] = "PBRConfigMap"; + passData.mSamplerNames[ texIndex ] = "pbrConfigMap"; passData.mTexSlot[ texIndex++ ].texObject = tex; } } -void DeferredSpecMapGLSL::processVert( Vector &componentList, +void PBRConfigMapGLSL::processVert( Vector &componentList, const MaterialFeatureData &fd ) { MultiLine *meta = new MultiLine; @@ -146,7 +144,7 @@ void DeferredMatInfoFlagsGLSL::processPix( Vector &componentLi // Spec Strength -> Blue Channel of Material Info Buffer. // Spec Power -> Alpha Channel ( of Material Info Buffer. -void DeferredSpecVarsGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) +void PBRConfigVarsGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { // search for material var diff --git a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h index 77bdbddbf..b2c0908fb 100644 --- a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h +++ b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h @@ -25,13 +25,12 @@ #include "shaderGen/GLSL/shaderFeatureGLSL.h" #include "shaderGen/GLSL/bumpGLSL.h" -#include "shaderGen/GLSL/pixSpecularGLSL.h" // Specular Outputs -class DeferredSpecMapGLSL : public ShaderFeatureGLSL +class PBRConfigMapGLSL : public ShaderFeatureGLSL { public: - virtual String getName() { return "Deferred Shading: Specular Map"; } + virtual String getName() { return "Deferred Shading: PBR Config Map"; } virtual void processPix( Vector &componentList, const MaterialFeatureData &fd ); @@ -59,10 +58,10 @@ public: virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; } }; -class DeferredSpecVarsGLSL : public ShaderFeatureGLSL +class PBRConfigVarsGLSL : public ShaderFeatureGLSL { public: - virtual String getName() { return "Deferred Shading: Specular Explicit Numbers"; } + virtual String getName() { return "Deferred Shading: PBR Config Explicit Numbers"; } virtual void processPix( Vector &componentList, const MaterialFeatureData &fd ); @@ -70,4 +69,4 @@ public: virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; } }; -#endif \ No newline at end of file +#endif diff --git a/Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.h b/Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.h index 8087516b2..1ab4225a4 100644 --- a/Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.h +++ b/Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.h @@ -25,7 +25,6 @@ #include "shaderGen/HLSL/shaderFeatureHLSL.h" #include "shaderGen/HLSL/bumpHLSL.h" -#include "shaderGen/HLSL/pixSpecularHLSL.h" class ConditionerMethodDependency; diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp index fb1a75995..e69eb892e 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp @@ -36,9 +36,7 @@ // Deferred Shading Features //**************************************************************************** -// Specular Map -> Blue of Material Buffer ( greyscaled ) -// Gloss Map (Alpha Channel of Specular Map) -> Alpha ( Spec Power ) of Material Info Buffer. -void DeferredSpecMapHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) +void PBRConfigMapHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { // Get the texture coord. Var *texCoord = getInTexCoord( "texCoord", "float2", componentList ); @@ -71,8 +69,8 @@ void DeferredSpecMapHLSL::processPix( Vector &componentList, c pbrConfigMapTex->constNum = pbrConfigMap->constNum; LangElement *texOp = new GenOp(" @.Sample(@, @)", pbrConfigMapTex, pbrConfigMap, texCoord); - Var * pbrConfig = (Var*)LangElement::find("pbrConfig"); - if (!pbrConfig) pbrConfig = new Var("pbrConfig", "float4"); + Var * pbrConfig = (Var*)LangElement::find("PBRConfig"); + if (!pbrConfig) pbrConfig = new Var("PBRConfig", "float4"); Var *metalness = (Var*)LangElement::find("metalness"); if (!metalness) metalness = new Var("metalness", "float"); Var *smoothness = (Var*)LangElement::find("smoothness"); @@ -89,7 +87,7 @@ void DeferredSpecMapHLSL::processPix( Vector &componentList, c output = meta; } -ShaderFeature::Resources DeferredSpecMapHLSL::getResources( const MaterialFeatureData &fd ) +ShaderFeature::Resources PBRConfigMapHLSL::getResources( const MaterialFeatureData &fd ) { Resources res; res.numTex = 1; @@ -98,7 +96,7 @@ ShaderFeature::Resources DeferredSpecMapHLSL::getResources( const MaterialFeatur return res; } -void DeferredSpecMapHLSL::setTexData( Material::StageData &stageDat, +void PBRConfigMapHLSL::setTexData( Material::StageData &stageDat, const MaterialFeatureData &fd, RenderPassData &passData, U32 &texIndex ) @@ -112,7 +110,7 @@ void DeferredSpecMapHLSL::setTexData( Material::StageData &stageDat, } } -void DeferredSpecMapHLSL::processVert( Vector &componentList, +void PBRConfigMapHLSL::processVert( Vector &componentList, const MaterialFeatureData &fd ) { MultiLine *meta = new MultiLine; @@ -149,7 +147,7 @@ void DeferredMatInfoFlagsHLSL::processPix( Vector &componentLi // Spec Strength -> Blue Channel of Material Info Buffer. // Spec Power -> Alpha Channel ( of Material Info Buffer. -void DeferredSpecVarsHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) +void PBRConfigVarsHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { // search for material var Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h index 4f76226fb..5bb4550a5 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h @@ -25,13 +25,11 @@ #include "shaderGen/HLSL/shaderFeatureHLSL.h" #include "shaderGen/HLSL/bumpHLSL.h" -#include "shaderGen/HLSL/pixSpecularHLSL.h" -// Specular Outputs -class DeferredSpecMapHLSL : public ShaderFeatureHLSL +class PBRConfigMapHLSL : public ShaderFeatureHLSL { public: - virtual String getName() { return "Deferred Shading: Specular Map"; } + virtual String getName() { return "Deferred Shading: PBR Config Map"; } virtual void processPix( Vector &componentList, const MaterialFeatureData &fd ); @@ -59,10 +57,10 @@ public: virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; } }; -class DeferredSpecVarsHLSL : public ShaderFeatureHLSL +class PBRConfigVarsHLSL : public ShaderFeatureHLSL { public: - virtual String getName() { return "Deferred Shading: Specular Explicit Numbers"; } + virtual String getName() { return "Deferred Shading: PBR Config Explicit Numbers"; } virtual void processPix( Vector &componentList, const MaterialFeatureData &fd ); @@ -81,4 +79,4 @@ public: virtual U32 getOutputTargets(const MaterialFeatureData &fd) const { return ShaderFeature::RenderTarget3; } }; -#endif \ No newline at end of file +#endif diff --git a/Engine/source/lighting/basic/basicLightManager.cpp b/Engine/source/lighting/basic/basicLightManager.cpp index 1da8d6493..9beaacb2f 100644 --- a/Engine/source/lighting/basic/basicLightManager.cpp +++ b/Engine/source/lighting/basic/basicLightManager.cpp @@ -43,14 +43,12 @@ #include "shaderGen/featureMgr.h" #include "shaderGen/HLSL/shaderFeatureHLSL.h" #include "shaderGen/HLSL/bumpHLSL.h" -#include "shaderGen/HLSL/pixSpecularHLSL.h" #include "lighting/basic/blTerrainSystem.h" #include "lighting/common/projectedShadow.h" #if defined( TORQUE_OPENGL ) #include "shaderGen/GLSL/shaderFeatureGLSL.h" #include "shaderGen/GLSL/bumpGLSL.h" -#include "shaderGen/GLSL/pixSpecularGLSL.h" #endif diff --git a/Engine/source/materials/materialDefinition.cpp b/Engine/source/materials/materialDefinition.cpp index 9d3b3430f..b155baae7 100644 --- a/Engine/source/materials/materialDefinition.cpp +++ b/Engine/source/materials/materialDefinition.cpp @@ -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." ); diff --git a/Engine/source/materials/materialDefinition.h b/Engine/source/materials/materialDefinition.h index 8250401c7..7003450f9 100644 --- a/Engine/source/materials/materialDefinition.h +++ b/Engine/source/materials/materialDefinition.h @@ -253,6 +253,11 @@ public: AssetPtr mMetalMapAsset[MAX_STAGES]; F32 mMetalChan[MAX_STAGES]; + FileName mGlowMapFilename[MAX_STAGES]; + StringTableEntry mGlowMapAssetId[MAX_STAGES]; + AssetPtr 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; diff --git a/Engine/source/materials/materialFeatureTypes.cpp b/Engine/source/materials/materialFeatureTypes.cpp index a1dc0ed80..4987020bf 100644 --- a/Engine/source/materials/materialFeatureTypes.cpp +++ b/Engine/source/materials/materialFeatureTypes.cpp @@ -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); diff --git a/Engine/source/materials/materialFeatureTypes.h b/Engine/source/materials/materialFeatureTypes.h index b22413683..5b83a64bc 100644 --- a/Engine/source/materials/materialFeatureTypes.h +++ b/Engine/source/materials/materialFeatureTypes.h @@ -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_ diff --git a/Engine/source/materials/processedMaterial.cpp b/Engine/source/materials/processedMaterial.cpp index abc330a14..c676c7eb5 100644 --- a/Engine/source/materials/processedMaterial.cpp +++ b/Engine/source/materials/processedMaterial.cpp @@ -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); diff --git a/Engine/source/materials/processedShaderMaterial.cpp b/Engine/source/materials/processedShaderMaterial.cpp index dc07dc7d7..74bdc0831 100644 --- a/Engine/source/materials/processedShaderMaterial.cpp +++ b/Engine/source/materials/processedShaderMaterial.cpp @@ -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] ) diff --git a/Engine/source/renderInstance/renderDeferredMgr.cpp b/Engine/source/renderInstance/renderDeferredMgr.cpp index 585a2d238..f3222839a 100644 --- a/Engine/source/renderInstance/renderDeferredMgr.cpp +++ b/Engine/source/renderInstance/renderDeferredMgr.cpp @@ -634,13 +634,13 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum, if (mMaterial->mInvertSmoothness[stageNum]) newFeatures.addFeature(MFT_InvertSmoothness); - // Deferred Shading : Specular + // Deferred Shading : PBR Config if( mStages[stageNum].getTex( MFT_PBRConfigMap ) ) { - newFeatures.addFeature( MFT_DeferredSpecMap ); + newFeatures.addFeature( MFT_PBRConfigMap ); } else - newFeatures.addFeature( MFT_DeferredSpecVars ); + newFeatures.addFeature( MFT_PBRConfigVars ); // Deferred Shading : Material Info Flags newFeatures.addFeature( MFT_DeferredMatInfoFlags ); diff --git a/Engine/source/shaderGen/GLSL/pixSpecularGLSL.cpp b/Engine/source/shaderGen/GLSL/pixSpecularGLSL.cpp deleted file mode 100644 index a28b78272..000000000 --- a/Engine/source/shaderGen/GLSL/pixSpecularGLSL.cpp +++ /dev/null @@ -1,96 +0,0 @@ -//----------------------------------------------------------------------------- -// Copyright (c) 2012 GarageGames, LLC -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -//----------------------------------------------------------------------------- - -#include "platform/platform.h" -#include "shaderGen/GLSL/pixSpecularGLSL.h" -#include "materials/processedMaterial.h" -#include "materials/materialFeatureTypes.h" -#include "shaderGen/shaderOp.h" -#include "shaderGen/shaderGenVars.h" -#include "gfx/gfxStructs.h" -#include "shaderGen/shaderGen.h" - -void PBRConfigMapGLSL::processVert(Vector &componentList, const MaterialFeatureData &fd) -{ - MultiLine *meta = new MultiLine; - - // Add the texture coords. - getOutTexCoord("texCoord", - "vec2", - fd.features[MFT_TexAnim], - meta, - componentList); - - output = meta; -} - -void PBRConfigMapGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) -{ - // Get the texture coord. - Var *texCoord = getInTexCoord( "texCoord", "vec2", componentList ); - - // create texture var - Var *pbrConfigMap = new Var; - pbrConfigMap->setType( "sampler2D" ); - pbrConfigMap->setName( "PBRConfigMap" ); - pbrConfigMap->uniform = true; - pbrConfigMap->sampler = true; - pbrConfigMap->constNum = Var::getTexUnitNum(); - LangElement *texOp = new GenOp( "texture(@, @)", pbrConfigMap, texCoord ); - - Var * pbrConfig = new Var( "PBRConfig", "vec4" ); - Var *metalness = (Var*)LangElement::find("metalness"); - if (!metalness) metalness = new Var("metalness", "float"); - Var *smoothness = (Var*)LangElement::find("smoothness"); - if (!smoothness) smoothness = new Var("smoothness", "float"); - MultiLine * meta = new MultiLine; - - meta->addStatement(new GenOp(" @ = @.r;\r\n", new DecOp(smoothness), texOp)); - meta->addStatement(new GenOp(" @ = @.b;\r\n", new DecOp(metalness), texOp)); - - if (fd.features[MFT_InvertSmoothness]) - meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness)); - - meta->addStatement(new GenOp(" @ = @.ggga;\r\n", new DecOp(pbrConfig), texOp)); - output = meta; -} - -ShaderFeature::Resources PBRConfigMapGLSL::getResources( const MaterialFeatureData &fd ) -{ - Resources res; - res.numTex = 1; - return res; -} - -void PBRConfigMapGLSL::setTexData( Material::StageData &stageDat, - const MaterialFeatureData &fd, - RenderPassData &passData, - U32 &texIndex ) -{ - GFXTextureObject *tex = stageDat.getTex( MFT_PBRConfigMap ); - if ( tex ) - { - passData.mTexType[ texIndex ] = Material::Standard; - passData.mSamplerNames[ texIndex ] = "PBRConfigMap"; - passData.mTexSlot[ texIndex++ ].texObject = tex; - } -} diff --git a/Engine/source/shaderGen/GLSL/pixSpecularGLSL.h b/Engine/source/shaderGen/GLSL/pixSpecularGLSL.h deleted file mode 100644 index 7dc5f1397..000000000 --- a/Engine/source/shaderGen/GLSL/pixSpecularGLSL.h +++ /dev/null @@ -1,54 +0,0 @@ -//----------------------------------------------------------------------------- -// Copyright (c) 2012 GarageGames, LLC -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -//----------------------------------------------------------------------------- - -#ifndef _PIXSPECULAR_GLSL_H_ -#define _PIXSPECULAR_GLSL_H_ - -#ifndef _SHADERGEN_GLSL_SHADERFEATUREGLSL_H_ -#include "shaderGen/GLSL/shaderFeatureGLSL.h" -#endif - -/// A texture source for the PixSpecular feature -class PBRConfigMapGLSL : public ShaderFeatureGLSL -{ - -public: - virtual void processVert( Vector &componentList, - const MaterialFeatureData &fd ); - - virtual void processPix( Vector &componentList, - const MaterialFeatureData &fd ); - - virtual Resources getResources( const MaterialFeatureData &fd ); - - virtual void setTexData( Material::StageData &stageDat, - const MaterialFeatureData &fd, - RenderPassData &passData, - U32 &texIndex ); - - virtual String getName() - { - return "PBRConfig Map"; - } -}; - -#endif // _PIXSPECULAR_HLSL_H_ diff --git a/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp b/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp index 82f14b63d..63cf17564 100644 --- a/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp +++ b/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp @@ -27,7 +27,6 @@ #include "shaderGen/GLSL/shaderFeatureGLSL.h" #include "shaderGen/featureMgr.h" #include "shaderGen/GLSL/bumpGLSL.h" -#include "shaderGen/GLSL/pixSpecularGLSL.h" #include "shaderGen/GLSL/depthGLSL.h" #include "shaderGen/GLSL/paraboloidGLSL.h" #include "materials/materialFeatureTypes.h" @@ -66,9 +65,8 @@ void _initShaderGenGLSL( ShaderGen *shaderGen ) FEATUREMGR->registerFeature( MFT_StaticCubemap, new NamedFeatureGLSL( "Static Cubemap" ) ); FEATUREMGR->registerFeature( MFT_CubeMap, new ReflectCubeFeatGLSL ); FEATUREMGR->registerFeature( MFT_InvertSmoothness, new NamedFeatureGLSL("Roughest = 1.0")); - FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapGLSL ); FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatGLSL ); - FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureGLSL( "Gloss Map" ) ); + FEATUREMGR->registerFeature( MFT_GlowMap, new NamedFeatureGLSL( "Glow Map" ) ); FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) ); FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureGLSL( "Translucent ZWrite" ) ); FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatGLSL ); @@ -102,8 +100,8 @@ void _initShaderGenGLSL( ShaderGen *shaderGen ) // Deferred Shading FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureGLSL( "Deferred Material" ) ); - FEATUREMGR->registerFeature( MFT_DeferredSpecMap, new DeferredSpecMapGLSL ); - FEATUREMGR->registerFeature( MFT_DeferredSpecVars, new DeferredSpecVarsGLSL ); + FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapGLSL ); + FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsGLSL ); FEATUREMGR->registerFeature( MFT_DeferredMatInfoFlags, new DeferredMatInfoFlagsGLSL ); FEATUREMGR->registerFeature( MFT_SkyBox, new NamedFeatureGLSL( "skybox" ) ); FEATUREMGR->registerFeature( MFT_HardwareSkinning, new HardwareSkinningFeatureGLSL ); diff --git a/Engine/source/shaderGen/HLSL/pixSpecularHLSL.cpp b/Engine/source/shaderGen/HLSL/pixSpecularHLSL.cpp deleted file mode 100644 index cdb50d147..000000000 --- a/Engine/source/shaderGen/HLSL/pixSpecularHLSL.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//----------------------------------------------------------------------------- -// Copyright (c) 2012 GarageGames, LLC -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -//----------------------------------------------------------------------------- - -#include "platform/platform.h" -#include "shaderGen/HLSL/pixSpecularHLSL.h" -#include "materials/processedMaterial.h" -#include "materials/materialFeatureTypes.h" -#include "shaderGen/shaderOp.h" -#include "shaderGen/shaderGenVars.h" -#include "gfx/gfxStructs.h" -#include "shaderGen/shaderGen.h" - -void PBRConfigMapHLSL::processVert(Vector &componentList, const MaterialFeatureData &fd) -{ - MultiLine *meta = new MultiLine; - - // Add the texture coords. - getOutTexCoord("texCoord", - "float2", - fd.features[MFT_TexAnim], - meta, - componentList); - - output = meta; -} - -void PBRConfigMapHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) -{ - // Get the texture coord. - Var *texCoord = getInTexCoord("texCoord", "float2", componentList); - - // create texture var - Var *pbrConfigMap = new Var; - pbrConfigMap->setType( "SamplerState" ); - pbrConfigMap->setName( "PBRConfigMap" ); - pbrConfigMap->uniform = true; - pbrConfigMap->sampler = true; - pbrConfigMap->constNum = Var::getTexUnitNum(); - - Var *pbrConfigMapTex = new Var; - pbrConfigMapTex->setName("PBRConfigMapTex"); - pbrConfigMapTex->setType("Texture2D"); - pbrConfigMapTex->uniform = true; - pbrConfigMapTex->texture = true; - pbrConfigMapTex->constNum = pbrConfigMap->constNum; - LangElement *texOp = new GenOp("@.Sample(@, @)", pbrConfigMapTex, pbrConfigMap, texCoord); - - - Var * pbrConfig = new Var( "PBRConfig", "float4" ); - Var *metalness = (Var*)LangElement::find("metalness"); - if (!metalness) metalness = new Var("metalness", "float"); - Var *smoothness = (Var*)LangElement::find("smoothness"); - if (!smoothness) smoothness = new Var("smoothness", "float"); - MultiLine * meta = new MultiLine; - - meta->addStatement(new GenOp(" @ = @.r;\r\n", new DecOp(smoothness), texOp)); - meta->addStatement(new GenOp(" @ = @.b;\r\n", new DecOp(metalness), texOp)); - - if (fd.features[MFT_InvertSmoothness]) - meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness)); - meta->addStatement(new GenOp(" @ = @.ggga;\r\n", new DecOp(pbrConfig), texOp)); - output = meta; -} - -ShaderFeature::Resources PBRConfigMapHLSL::getResources( const MaterialFeatureData &fd ) -{ - Resources res; - res.numTex = 1; - return res; -} - -void PBRConfigMapHLSL::setTexData( Material::StageData &stageDat, - const MaterialFeatureData &fd, - RenderPassData &passData, - U32 &texIndex ) -{ - GFXTextureObject *tex = stageDat.getTex( MFT_PBRConfigMap ); - if ( tex ) - { - passData.mTexType[ texIndex ] = Material::Standard; - passData.mSamplerNames[ texIndex ] = "PBRConfigMap"; - passData.mTexSlot[ texIndex++ ].texObject = tex; - } -} diff --git a/Engine/source/shaderGen/HLSL/pixSpecularHLSL.h b/Engine/source/shaderGen/HLSL/pixSpecularHLSL.h deleted file mode 100644 index 725e1085f..000000000 --- a/Engine/source/shaderGen/HLSL/pixSpecularHLSL.h +++ /dev/null @@ -1,54 +0,0 @@ -//----------------------------------------------------------------------------- -// Copyright (c) 2012 GarageGames, LLC -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -//----------------------------------------------------------------------------- - -#ifndef _PIXSPECULAR_HLSL_H_ -#define _PIXSPECULAR_HLSL_H_ - -#ifndef _SHADERGEN_HLSL_SHADERFEATUREHLSL_H_ -#include "shaderGen/HLSL/shaderFeatureHLSL.h" -#endif - -/// A texture source for the PBRConfigMap feature -class PBRConfigMapHLSL : public ShaderFeatureHLSL -{ - -public: - virtual void processVert( Vector &componentList, - const MaterialFeatureData &fd ); - - virtual void processPix( Vector &componentList, - const MaterialFeatureData &fd ); - - virtual Resources getResources( const MaterialFeatureData &fd ); - - virtual void setTexData( Material::StageData &stageDat, - const MaterialFeatureData &fd, - RenderPassData &passData, - U32 &texIndex ); - - virtual String getName() - { - return "PBRConfig Map"; - } -}; - -#endif // _PIXSPECULAR_HLSL_H_ diff --git a/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp b/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp index 45d33d80e..68a69445f 100644 --- a/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp +++ b/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp @@ -27,7 +27,6 @@ #include "shaderGen/HLSL/shaderFeatureHLSL.h" #include "shaderGen/featureMgr.h" #include "shaderGen/HLSL/bumpHLSL.h" -#include "shaderGen/HLSL/pixSpecularHLSL.h" #include "shaderGen/HLSL/depthHLSL.h" #include "shaderGen/HLSL/paraboloidHLSL.h" #include "materials/materialFeatureTypes.h" @@ -70,9 +69,8 @@ void _initShaderGenHLSL( ShaderGen *shaderGen ) FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureHLSL( "Translucent ZWrite" ) ); FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatHLSL ); FEATUREMGR->registerFeature( MFT_Fog, new FogFeatHLSL ); - FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapHLSL ); FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatHLSL ); - FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureHLSL( "Gloss Map" ) ); + FEATUREMGR->registerFeature( MFT_GlowMap, new NamedFeatureHLSL( "Glow Map" ) ); FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureHLSL( "Lightbuffer MRT" ) ); FEATUREMGR->registerFeature( MFT_RenderTarget1_Zero, new RenderTargetZeroHLSL( ShaderFeature::RenderTarget1 ) ); FEATUREMGR->registerFeature( MFT_RenderTarget2_Zero, new RenderTargetZeroHLSL( ShaderFeature::RenderTarget2 ) ); @@ -104,8 +102,8 @@ void _initShaderGenHLSL( ShaderGen *shaderGen ) FEATUREMGR->registerFeature( MFT_ImposterVert, new ImposterVertFeatureHLSL ); FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureHLSL( "Deferred Material" ) ); - FEATUREMGR->registerFeature( MFT_DeferredSpecMap, new DeferredSpecMapHLSL ); - FEATUREMGR->registerFeature( MFT_DeferredSpecVars, new DeferredSpecVarsHLSL ); + FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapHLSL); + FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsHLSL); FEATUREMGR->registerFeature( MFT_DeferredMatInfoFlags, new DeferredMatInfoFlagsHLSL ); FEATUREMGR->registerFeature( MFT_DeferredEmissive, new DeferredEmissiveHLSL); FEATUREMGR->registerFeature( MFT_SkyBox, new NamedFeatureHLSL( "skybox" ) ); diff --git a/Engine/source/shaderGen/shaderGenVars.cpp b/Engine/source/shaderGen/shaderGenVars.cpp index be80941a4..b28bb6447 100644 --- a/Engine/source/shaderGen/shaderGenVars.cpp +++ b/Engine/source/shaderGen/shaderGenVars.cpp @@ -73,7 +73,7 @@ const String ShaderGenVars::vectorLightDirection("$vectorLightDirection"); const String ShaderGenVars::vectorLightColor("$vectorLightColor"); const String ShaderGenVars::vectorLightBrightness("$vectorLightBrightness"); -const String ShaderGenVars::pbrConfig("$pbrConfig"); +const String ShaderGenVars::pbrConfig("$PBRConfig"); const String ShaderGenVars::smoothness("$smoothness"); const String ShaderGenVars::metalness("$metalness");