From 65cbf49c4acf4aefa88e50d0bcec6fb5ec3655b9 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 16 Oct 2019 15:51:02 -0500 Subject: [PATCH 01/17] backend specularMap to PBRConfigMap alts. left: addField( "specularMap", TypeImageFilename, Offset(mPBRConfigMapFilename, Material), MAX_STAGES, scripthook till last since that *will* break all current materials. --- .../glsl/advancedLightingFeaturesGLSL.cpp | 6 +-- .../glsl/deferredShadingFeaturesGLSL.cpp | 18 ++++----- .../hlsl/advancedLightingFeaturesHLSL.cpp | 6 +-- .../hlsl/deferredShadingFeaturesHLSL.cpp | 32 ++++++++-------- .../source/materials/materialDefinition.cpp | 6 +-- Engine/source/materials/materialDefinition.h | 6 +-- .../source/materials/materialFeatureTypes.cpp | 2 +- .../source/materials/materialFeatureTypes.h | 2 +- Engine/source/materials/processedMaterial.cpp | 16 ++++---- .../materials/processedShaderMaterial.cpp | 8 ++-- .../materials/processedShaderMaterial.h | 2 +- .../renderInstance/renderDeferredMgr.cpp | 2 +- .../source/shaderGen/GLSL/pixSpecularGLSL.cpp | 26 ++++++------- .../source/shaderGen/GLSL/pixSpecularGLSL.h | 4 +- .../shaderGen/GLSL/shaderGenGLSLInit.cpp | 2 +- .../source/shaderGen/HLSL/pixSpecularHLSL.cpp | 38 +++++++++---------- .../source/shaderGen/HLSL/pixSpecularHLSL.h | 6 +-- .../shaderGen/HLSL/shaderFeatureHLSL.cpp | 2 +- .../shaderGen/HLSL/shaderGenHLSLInit.cpp | 2 +- Engine/source/shaderGen/shaderGenVars.cpp | 2 +- Engine/source/shaderGen/shaderGenVars.h | 2 +- .../source/ts/collada/colladaAppMaterial.cpp | 3 -- Engine/source/ts/collada/colladaAppMaterial.h | 1 - .../source/ts/collada/colladaShapeLoader.cpp | 1 - 24 files changed, 95 insertions(+), 100 deletions(-) diff --git a/Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp b/Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp index c0c769645..e5830a519 100644 --- a/Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp +++ b/Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp @@ -390,7 +390,7 @@ void DeferredBumpFeatGLSL::processPix( Vector &componentList, Parent::processPix( componentList, fd ); return; } - else if (!fd.features[MFT_SpecularMap] ) + else if (!fd.features[MFT_PBRConfigMap] ) { Var *bumpSample = (Var *)LangElement::find( "bumpSample" ); if( bumpSample == NULL ) @@ -421,7 +421,7 @@ ShaderFeature::Resources DeferredBumpFeatGLSL::getResources( const MaterialFeatu return Parent::getResources( fd ); Resources res; - if(!fd.features[MFT_SpecularMap]) + if(!fd.features[MFT_PBRConfigMap]) { res.numTex = 1; res.numTexReg = 1; @@ -464,7 +464,7 @@ void DeferredBumpFeatGLSL::setTexData( Material::StageData &stageDat, 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]) ) { passData.mTexType[ texIndex ] = Material::Bump; diff --git a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp index f63a646cf..e92bad5cd 100644 --- a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp +++ b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp @@ -56,13 +56,13 @@ void DeferredSpecMapGLSL::processPix( Vector &componentList, c } // create texture var - Var *specularMap = new Var; - specularMap->setType( "sampler2D" ); - specularMap->setName( "specularMap" ); - specularMap->uniform = true; - specularMap->sampler = true; - specularMap->constNum = Var::getTexUnitNum(); - LangElement *texOp = new GenOp( "tex2D(@, @)", specularMap, texCoord ); + Var *pbrConfigMap = new Var; + pbrConfigMap->setType( "sampler2D" ); + pbrConfigMap->setName( "PBRConfigMap" ); + pbrConfigMap->uniform = true; + pbrConfigMap->sampler = true; + pbrConfigMap->constNum = Var::getTexUnitNum(); + LangElement *texOp = new GenOp( "tex2D(@, @)", pbrConfigMap, texCoord ); Var *pbrConfig = (Var*)LangElement::find("PBRConfig"); if (!pbrConfig) pbrConfig = new Var("PBRConfig", "vec4"); @@ -97,11 +97,11 @@ void DeferredSpecMapGLSL::setTexData( Material::StageData &stageDat, RenderPassData &passData, U32 &texIndex ) { - GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap ); + GFXTextureObject *tex = stageDat.getTex(MFT_PBRConfigMap); if ( tex ) { passData.mTexType[ texIndex ] = Material::Standard; - passData.mSamplerNames[ texIndex ] = "specularMap"; + passData.mSamplerNames[ texIndex ] = "PBRConfigMap"; passData.mTexSlot[ texIndex++ ].texObject = tex; } } diff --git a/Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp b/Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp index 9b495e0ff..11718e3dd 100644 --- a/Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp +++ b/Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp @@ -421,7 +421,7 @@ void DeferredBumpFeatHLSL::processPix( Vector &componentList, Parent::processPix( componentList, fd ); return; } - else if (!fd.features[MFT_SpecularMap] ) + else if (!fd.features[MFT_PBRConfigMap] ) { Var *bumpSample = (Var *)LangElement::find( "bumpSample" ); if( bumpSample == NULL ) @@ -454,7 +454,7 @@ ShaderFeature::Resources DeferredBumpFeatHLSL::getResources( const MaterialFeatu return Parent::getResources( fd ); Resources res; - if(!fd.features[MFT_SpecularMap]) + if(!fd.features[MFT_PBRConfigMap]) { res.numTex = 1; res.numTexReg = 1; @@ -497,7 +497,7 @@ void DeferredBumpFeatHLSL::setTexData( Material::StageData &stageDat, 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]) ) { passData.mTexType[ texIndex ] = Material::Bump; diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp index 7840a4740..fb1a75995 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp @@ -56,20 +56,20 @@ void DeferredSpecMapHLSL::processPix( Vector &componentList, c } // create texture var - Var *specularMap = new Var; - specularMap->setType( "SamplerState" ); - specularMap->setName( "specularMap" ); - specularMap->uniform = true; - specularMap->sampler = true; - specularMap->constNum = Var::getTexUnitNum(); + Var * pbrConfigMap = new Var; + pbrConfigMap->setType( "SamplerState" ); + pbrConfigMap->setName( "PBRConfigMap" ); + pbrConfigMap->uniform = true; + pbrConfigMap->sampler = true; + pbrConfigMap->constNum = Var::getTexUnitNum(); - Var* specularMapTex = new Var; - specularMapTex->setName("specularMapTex"); - specularMapTex->setType("Texture2D"); - specularMapTex->uniform = true; - specularMapTex->texture = true; - specularMapTex->constNum = specularMap->constNum; - LangElement *texOp = new GenOp(" @.Sample(@, @)", specularMapTex, specularMap, texCoord); + 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 = (Var*)LangElement::find("pbrConfig"); if (!pbrConfig) pbrConfig = new Var("pbrConfig", "float4"); @@ -103,11 +103,11 @@ void DeferredSpecMapHLSL::setTexData( Material::StageData &stageDat, RenderPassData &passData, U32 &texIndex ) { - GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap ); + GFXTextureObject *tex = stageDat.getTex(MFT_PBRConfigMap); if ( tex ) { passData.mTexType[ texIndex ] = Material::Standard; - passData.mSamplerNames[ texIndex ] = "specularMap"; + passData.mSamplerNames[ texIndex ] = "PBRConfigMap"; passData.mTexSlot[ texIndex++ ].texObject = tex; } } @@ -200,4 +200,4 @@ void DeferredEmissiveHLSL::processPix(Vector &componentList, c } output = new GenOp("@ = float4(@.rgb,0);", sceneColorVar, diffuseTargetVar); -} \ No newline at end of file +} diff --git a/Engine/source/materials/materialDefinition.cpp b/Engine/source/materials/materialDefinition.cpp index b6c0cbfab..9d3b3430f 100644 --- a/Engine/source/materials/materialDefinition.cpp +++ b/Engine/source/materials/materialDefinition.cpp @@ -272,10 +272,10 @@ void Material::initPersistFields() "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 specularMap." ); + "The degree of smoothness when not using a PBRConfigMap." ); 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 ), &_setAccuEnabled, &defaultProtectedGetFn, MAX_STAGES, "Accumulation texture." ); @@ -301,7 +301,7 @@ void Material::initPersistFields() addField("invertSmoothness", TypeBool, Offset(mInvertSmoothness, Material), MAX_STAGES, "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: " "smoothness (R), Ambient Occlusion (G), and metalness(B)"); diff --git a/Engine/source/materials/materialDefinition.h b/Engine/source/materials/materialDefinition.h index 346218158..8250401c7 100644 --- a/Engine/source/materials/materialDefinition.h +++ b/Engine/source/materials/materialDefinition.h @@ -237,9 +237,9 @@ public: bool mIsSRGb[MAX_STAGES]; bool mInvertSmoothness[MAX_STAGES]; - FileName mSpecularMapFilename[MAX_STAGES]; - StringTableEntry mSpecularMapAssetId[MAX_STAGES]; - AssetPtr mSpecularMapAsset[MAX_STAGES]; + FileName mPBRConfigMapFilename[MAX_STAGES]; + StringTableEntry mPBRConfigMapAssetId[MAX_STAGES]; + AssetPtr mPBRConfigMapAsset[MAX_STAGES]; FileName mRoughMapFilename[MAX_STAGES]; StringTableEntry mRoughMapAssetId[MAX_STAGES]; AssetPtr mRoughMapAsset[MAX_STAGES]; diff --git a/Engine/source/materials/materialFeatureTypes.cpp b/Engine/source/materials/materialFeatureTypes.cpp index cb209d3e6..a1dc0ed80 100644 --- a/Engine/source/materials/materialFeatureTypes.cpp +++ b/Engine/source/materials/materialFeatureTypes.cpp @@ -44,7 +44,7 @@ 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_SpecularMap, MFG_Texture, 8.0f, 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_Imposter, U32(-1), -1, true ); diff --git a/Engine/source/materials/materialFeatureTypes.h b/Engine/source/materials/materialFeatureTypes.h index b5cbce2e6..b22413683 100644 --- a/Engine/source/materials/materialFeatureTypes.h +++ b/Engine/source/materials/materialFeatureTypes.h @@ -125,7 +125,7 @@ DeclareFeatureType( MFT_VertLitTone ); DeclareFeatureType( MFT_StaticCubemap ); DeclareFeatureType( MFT_CubeMap ); DeclareFeatureType( MFT_InvertSmoothness ); -DeclareFeatureType( MFT_SpecularMap ); +DeclareFeatureType( MFT_PBRConfigMap ); DeclareFeatureType( MFT_GlossMap ); DeclareFeatureType( MFT_ReflectionProbes ); diff --git a/Engine/source/materials/processedMaterial.cpp b/Engine/source/materials/processedMaterial.cpp index 3455257a6..abc330a14 100644 --- a/Engine/source/materials/processedMaterial.cpp +++ b/Engine/source/materials/processedMaterial.cpp @@ -472,12 +472,12 @@ void ProcessedMaterial::_setStageData() if (mMaterial->mIsSRGb[i]) profile = &GFXStaticTextureSRGBProfile; - // SpecularMap - if (mMaterial->mSpecularMapFilename[i].isNotEmpty()) + // PBRConfig + if (mMaterial->mPBRConfigMapFilename[i].isNotEmpty()) { - mStages[i].setTex(MFT_SpecularMap, _createTexture(mMaterial->mSpecularMapFilename[i], profile)); - if (!mStages[i].getTex(MFT_SpecularMap)) - mMaterial->logError("Failed to load specular map %s for stage %i", _getTexturePath(mMaterial->mSpecularMapFilename[i]).c_str(), i); + 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); } else { @@ -488,11 +488,11 @@ void ProcessedMaterial::_setStageData() inputKey[1] = mMaterial->mAOChan[i]; inputKey[2] = mMaterial->mMetalChan[i]; 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], "", inputKey, profile)); - if (!mStages[i].getTex(MFT_SpecularMap)) - mMaterial->logError("Failed to load specular map %s for stage %i", _getTexturePath(mMaterial->mSpecularMapFilename[i]).c_str(), i); + 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 71dd22c09..dc07dc7d7 100644 --- a/Engine/source/materials/processedShaderMaterial.cpp +++ b/Engine/source/materials/processedShaderMaterial.cpp @@ -59,7 +59,7 @@ void ShaderConstHandles::init( GFXShader *shader, VectorgetShaderConstHandle("$diffuseMaterialColor"); mTexMatSC = shader->getShaderConstHandle(ShaderGenVars::texMat); mToneMapTexSC = shader->getShaderConstHandle(ShaderGenVars::toneMap); - mSpecularColorSC = shader->getShaderConstHandle(ShaderGenVars::specularColor); + mPBRConfigSC = shader->getShaderConstHandle(ShaderGenVars::pbrConfig); mSmoothnessSC = shader->getShaderConstHandle(ShaderGenVars::smoothness); mMetalnessSC = shader->getShaderConstHandle(ShaderGenVars::metalness); mAccuScaleSC = shader->getShaderConstHandle("$accuScale"); @@ -443,16 +443,16 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, // 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_SpecularMap ); + fd.features.removeFeature( MFT_PBRConfigMap ); // If we have a specular map then make sure we // 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 // has values less than 255) than the artist has put the gloss map into // the alpha channel. - if( mStages[stageNum].getTex( MFT_SpecularMap )->mHasTransparency ) + if( mStages[stageNum].getTex( MFT_PBRConfigMap )->mHasTransparency ) fd.features.addFeature( MFT_GlossMap ); } diff --git a/Engine/source/materials/processedShaderMaterial.h b/Engine/source/materials/processedShaderMaterial.h index e899137b4..c7e52368d 100644 --- a/Engine/source/materials/processedShaderMaterial.h +++ b/Engine/source/materials/processedShaderMaterial.h @@ -46,7 +46,7 @@ public: GFXShaderConstHandle* mDiffuseColorSC; GFXShaderConstHandle* mToneMapTexSC; GFXShaderConstHandle* mTexMatSC; - GFXShaderConstHandle* mSpecularColorSC; + GFXShaderConstHandle* mPBRConfigSC; GFXShaderConstHandle* mSmoothnessSC; GFXShaderConstHandle* mMetalnessSC; GFXShaderConstHandle* mParallaxInfoSC; diff --git a/Engine/source/renderInstance/renderDeferredMgr.cpp b/Engine/source/renderInstance/renderDeferredMgr.cpp index 22fe6164e..585a2d238 100644 --- a/Engine/source/renderInstance/renderDeferredMgr.cpp +++ b/Engine/source/renderInstance/renderDeferredMgr.cpp @@ -635,7 +635,7 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum, newFeatures.addFeature(MFT_InvertSmoothness); // Deferred Shading : Specular - if( mStages[stageNum].getTex( MFT_SpecularMap ) ) + if( mStages[stageNum].getTex( MFT_PBRConfigMap ) ) { newFeatures.addFeature( MFT_DeferredSpecMap ); } diff --git a/Engine/source/shaderGen/GLSL/pixSpecularGLSL.cpp b/Engine/source/shaderGen/GLSL/pixSpecularGLSL.cpp index 59a291cc8..a28b78272 100644 --- a/Engine/source/shaderGen/GLSL/pixSpecularGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/pixSpecularGLSL.cpp @@ -29,7 +29,7 @@ #include "gfx/gfxStructs.h" #include "shaderGen/shaderGen.h" -void SpecularMapGLSL::processVert(Vector &componentList, const MaterialFeatureData &fd) +void PBRConfigMapGLSL::processVert(Vector &componentList, const MaterialFeatureData &fd) { MultiLine *meta = new MultiLine; @@ -43,19 +43,19 @@ void SpecularMapGLSL::processVert(Vector &componentList, const output = meta; } -void SpecularMapGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) +void PBRConfigMapGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { // Get the texture coord. Var *texCoord = getInTexCoord( "texCoord", "vec2", componentList ); // create texture var - Var *specularMap = new Var; - specularMap->setType( "sampler2D" ); - specularMap->setName( "specularMap" ); - specularMap->uniform = true; - specularMap->sampler = true; - specularMap->constNum = Var::getTexUnitNum(); - LangElement *texOp = new GenOp( "texture(@, @)", specularMap, texCoord ); + 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"); @@ -74,23 +74,23 @@ void SpecularMapGLSL::processPix( Vector &componentList, const output = meta; } -ShaderFeature::Resources SpecularMapGLSL::getResources( const MaterialFeatureData &fd ) +ShaderFeature::Resources PBRConfigMapGLSL::getResources( const MaterialFeatureData &fd ) { Resources res; res.numTex = 1; return res; } -void SpecularMapGLSL::setTexData( Material::StageData &stageDat, +void PBRConfigMapGLSL::setTexData( Material::StageData &stageDat, const MaterialFeatureData &fd, RenderPassData &passData, U32 &texIndex ) { - GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap ); + GFXTextureObject *tex = stageDat.getTex( MFT_PBRConfigMap ); if ( tex ) { passData.mTexType[ texIndex ] = Material::Standard; - passData.mSamplerNames[ texIndex ] = "specularMap"; + 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 index 7450c5286..7dc5f1397 100644 --- a/Engine/source/shaderGen/GLSL/pixSpecularGLSL.h +++ b/Engine/source/shaderGen/GLSL/pixSpecularGLSL.h @@ -28,7 +28,7 @@ #endif /// A texture source for the PixSpecular feature -class SpecularMapGLSL : public ShaderFeatureGLSL +class PBRConfigMapGLSL : public ShaderFeatureGLSL { public: @@ -47,7 +47,7 @@ public: virtual String getName() { - return "Specular Map"; + return "PBRConfig Map"; } }; diff --git a/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp b/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp index 026461038..82f14b63d 100644 --- a/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp +++ b/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp @@ -66,7 +66,7 @@ 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_SpecularMap, new SpecularMapGLSL ); + FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapGLSL ); FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatGLSL ); FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureGLSL( "Gloss Map" ) ); FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) ); diff --git a/Engine/source/shaderGen/HLSL/pixSpecularHLSL.cpp b/Engine/source/shaderGen/HLSL/pixSpecularHLSL.cpp index f5f62da32..cdb50d147 100644 --- a/Engine/source/shaderGen/HLSL/pixSpecularHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/pixSpecularHLSL.cpp @@ -29,7 +29,7 @@ #include "gfx/gfxStructs.h" #include "shaderGen/shaderGen.h" -void SpecularMapHLSL::processVert(Vector &componentList, const MaterialFeatureData &fd) +void PBRConfigMapHLSL::processVert(Vector &componentList, const MaterialFeatureData &fd) { MultiLine *meta = new MultiLine; @@ -43,26 +43,26 @@ void SpecularMapHLSL::processVert(Vector &componentList, const output = meta; } -void SpecularMapHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) +void PBRConfigMapHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { // Get the texture coord. Var *texCoord = getInTexCoord("texCoord", "float2", componentList); // create texture var - Var *specularMap = new Var; - specularMap->setType( "SamplerState" ); - specularMap->setName( "specularMap" ); - specularMap->uniform = true; - specularMap->sampler = true; - specularMap->constNum = Var::getTexUnitNum(); + Var *pbrConfigMap = new Var; + pbrConfigMap->setType( "SamplerState" ); + pbrConfigMap->setName( "PBRConfigMap" ); + pbrConfigMap->uniform = true; + pbrConfigMap->sampler = true; + pbrConfigMap->constNum = Var::getTexUnitNum(); - Var *specularMapTex = new Var; - specularMapTex->setName("specularMapTex"); - specularMapTex->setType("Texture2D"); - specularMapTex->uniform = true; - specularMapTex->texture = true; - specularMapTex->constNum = specularMap->constNum; - LangElement *texOp = new GenOp("@.Sample(@, @)", specularMapTex, specularMap, texCoord); + 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" ); @@ -81,23 +81,23 @@ void SpecularMapHLSL::processPix( Vector &componentList, const output = meta; } -ShaderFeature::Resources SpecularMapHLSL::getResources( const MaterialFeatureData &fd ) +ShaderFeature::Resources PBRConfigMapHLSL::getResources( const MaterialFeatureData &fd ) { Resources res; res.numTex = 1; return res; } -void SpecularMapHLSL::setTexData( Material::StageData &stageDat, +void PBRConfigMapHLSL::setTexData( Material::StageData &stageDat, const MaterialFeatureData &fd, RenderPassData &passData, U32 &texIndex ) { - GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap ); + GFXTextureObject *tex = stageDat.getTex( MFT_PBRConfigMap ); if ( tex ) { passData.mTexType[ texIndex ] = Material::Standard; - passData.mSamplerNames[ texIndex ] = "specularMap"; + 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 index 3e3825ffb..725e1085f 100644 --- a/Engine/source/shaderGen/HLSL/pixSpecularHLSL.h +++ b/Engine/source/shaderGen/HLSL/pixSpecularHLSL.h @@ -27,8 +27,8 @@ #include "shaderGen/HLSL/shaderFeatureHLSL.h" #endif -/// A texture source for the PixSpecular feature -class SpecularMapHLSL : public ShaderFeatureHLSL +/// A texture source for the PBRConfigMap feature +class PBRConfigMapHLSL : public ShaderFeatureHLSL { public: @@ -47,7 +47,7 @@ public: virtual String getName() { - return "Specular Map"; + return "PBRConfig Map"; } }; diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index 070096097..925d3a5f2 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -1304,7 +1304,7 @@ void LightmapFeatHLSL::processPix( Vector &componentList, lightMapTex->texture = true; lightMapTex->constNum = lightMap->constNum; - // argh, pixel specular should prob use this too + // argh, PBRConfigMap should prob use this too if( fd.features[MFT_NormalMap] ) { Var *lmColor = new Var; diff --git a/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp b/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp index dcdabc9e2..45d33d80e 100644 --- a/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp +++ b/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp @@ -70,7 +70,7 @@ 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_SpecularMap, new SpecularMapHLSL ); + FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapHLSL ); FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatHLSL ); FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureHLSL( "Gloss Map" ) ); FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureHLSL( "Lightbuffer MRT" ) ); diff --git a/Engine/source/shaderGen/shaderGenVars.cpp b/Engine/source/shaderGen/shaderGenVars.cpp index 28df4b8dc..be80941a4 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::specularColor("$specularColor"); +const String ShaderGenVars::pbrConfig("$pbrConfig"); const String ShaderGenVars::smoothness("$smoothness"); const String ShaderGenVars::metalness("$metalness"); diff --git a/Engine/source/shaderGen/shaderGenVars.h b/Engine/source/shaderGen/shaderGenVars.h index 1ebb7e1e0..679dacb59 100644 --- a/Engine/source/shaderGen/shaderGenVars.h +++ b/Engine/source/shaderGen/shaderGenVars.h @@ -85,7 +85,7 @@ struct ShaderGenVars const static String vectorLightColor; const static String vectorLightBrightness; - const static String specularColor; + const static String pbrConfig; const static String smoothness; const static String metalness; diff --git a/Engine/source/ts/collada/colladaAppMaterial.cpp b/Engine/source/ts/collada/colladaAppMaterial.cpp index bb5be2eec..17c1ae492 100644 --- a/Engine/source/ts/collada/colladaAppMaterial.cpp +++ b/Engine/source/ts/collada/colladaAppMaterial.cpp @@ -86,7 +86,6 @@ ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat) // Get the , and elements const domProfile_COMMON* commonProfile = ColladaUtils::findEffectCommonProfile(effect); const domCommon_color_or_texture_type_complexType* domDiffuse = findEffectDiffuse(effect); - const domCommon_color_or_texture_type_complexType* domSpecular = findEffectSpecular(effect); // Wrap flags if (effectExt->wrapU) @@ -158,7 +157,6 @@ ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat) // Get the paths for the various textures => Collada indirection at its finest! // ........ diffuseMap = getSamplerImagePath(effect, getTextureSampler(effect, domDiffuse)); - specularMap = getSamplerImagePath(effect, getTextureSampler(effect, domSpecular)); normalMap = getSamplerImagePath(effect, effectExt->bumpSampler); // Set the material name @@ -218,7 +216,6 @@ Material *ColladaAppMaterial::createMaterial(const Torque::Path& path) const newMat->mDiffuseMapFilename[0] = diffuseMap; newMat->mNormalMapFilename[0] = normalMap; - newMat->mSpecularMapFilename[0] = specularMap; newMat->mDiffuse[0] = diffuseColor; newMat->mSmoothness[0] = smoothness; diff --git a/Engine/source/ts/collada/colladaAppMaterial.h b/Engine/source/ts/collada/colladaAppMaterial.h index cd6f17897..624ecdee7 100644 --- a/Engine/source/ts/collada/colladaAppMaterial.h +++ b/Engine/source/ts/collada/colladaAppMaterial.h @@ -43,7 +43,6 @@ public: // Settings extracted from the Collada file, and optionally saved to materials.cs String diffuseMap; String normalMap; - String specularMap; LinearColorF diffuseColor; LinearColorF specularColor; diff --git a/Engine/source/ts/collada/colladaShapeLoader.cpp b/Engine/source/ts/collada/colladaShapeLoader.cpp index afb53fdaf..2942c4d12 100644 --- a/Engine/source/ts/collada/colladaShapeLoader.cpp +++ b/Engine/source/ts/collada/colladaShapeLoader.cpp @@ -499,7 +499,6 @@ void updateMaterialsScript(const Torque::Path &path, bool copyTextures = false) copySketchupTexture(path, mat->mDiffuseMapFilename[0]); copySketchupTexture(path, mat->mNormalMapFilename[0]); - copySketchupTexture(path, mat->mSpecularMapFilename[0]); } } From 60df3744c7b50c119480aa28c1f3fee36215f8c6 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 16 Oct 2019 15:56:30 -0500 Subject: [PATCH 02/17] shift smoothness and metallness sliders on up to the same areas as the textureslots --- .../gui/guiMaterialPropertiesWindow.ed.gui | 247 +++++++++--------- 1 file changed, 124 insertions(+), 123 deletions(-) diff --git a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui index ee92ab0c0..80edd350c 100644 --- a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui +++ b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui @@ -566,6 +566,130 @@ Visible = "1"; tooltipprofile = "ToolsGuiToolTipProfile"; hovertime = "1000"; + + new GuiContainer(){ + profile = "ToolsGuiTransparentProfile"; + isContainer = "1"; + position = "0 0"; + Extent = "185 44"; + HorizSizing = "width"; + + new GuiTextCtrl() { + HorizSizing = "right"; + VertSizing = "bottom"; + position = "9 4"; + Extent = "72 16"; + text = "Smoothness"; + }; + + new GuiTextCtrl() { + HorizSizing = "right"; + VertSizing = "bottom"; + position = "9 26"; + Extent = "72 16"; + text = "Metalness"; + }; + + new GuiControl() { + class = "AggregateControl"; + position = "91 4"; + Extent = "96 20"; + + new GuiSliderCtrl() { + canSaveDynamicFields = "0"; + internalName = "SmoothnessSlider"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiSliderProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "0 1"; + Extent = "61 14"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);"; + AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);"; + tooltipprofile = "ToolsGuiDefaultProfile"; + ToolTip = "Sets Smoothness."; + hovertime = "1000"; + range = "0 1"; + ticks = "0"; + value = "0"; + }; + new GuiTextEditCtrl() { + canSaveDynamicFields = "0"; + internalName = "SmoothnessTextEdit"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "64 0"; + Extent = "29 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());"; + hovertime = "1000"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "0"; + }; + }; + + new GuiControl() { + class = "AggregateControl"; + position = "91 26"; + Extent = "96 20"; + + new GuiSliderCtrl() { + canSaveDynamicFields = "0"; + internalName = "MetalnessSlider"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiSliderProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "0 1"; + Extent = "61 14"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "MaterialEditorGui.updateActiveMaterial(\"Metalness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);"; + AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Metalness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);"; + tooltipprofile = "ToolsGuiDefaultProfile"; + ToolTip = "Sets Metalness."; + hovertime = "1000"; + range = "0 1"; + ticks = "0"; + value = "0"; + }; + new GuiTextEditCtrl() { + canSaveDynamicFields = "0"; + internalName = "MetalnessTextEdit"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "64 0"; + Extent = "29 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Metalness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());"; + hovertime = "1000"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "0"; + }; + }; + }; new GuiContainer(){ // spec Map options profile="ToolsGuiDefaultProfile"; @@ -2767,129 +2891,6 @@ tooltipprofile = "ToolsGuiToolTipProfile"; hovertime = "1000"; - new GuiContainer(){ // specular - profile = "ToolsGuiTransparentProfile"; - isContainer = "1"; - position = "0 0"; - Extent = "185 44"; - HorizSizing = "width"; - - new GuiTextCtrl() { - HorizSizing = "right"; - VertSizing = "bottom"; - position = "9 4"; - Extent = "72 16"; - text = "Smoothness"; - }; - - new GuiTextCtrl() { - HorizSizing = "right"; - VertSizing = "bottom"; - position = "9 26"; - Extent = "72 16"; - text = "Metalness"; - }; - - new GuiControl() { - class = "AggregateControl"; - position = "91 4"; - Extent = "96 20"; - - new GuiSliderCtrl() { - canSaveDynamicFields = "0"; - internalName = "SmoothnessSlider"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiSliderProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "0 1"; - Extent = "61 14"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);"; - AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);"; - tooltipprofile = "ToolsGuiDefaultProfile"; - ToolTip = "Sets Smoothness."; - hovertime = "1000"; - range = "0 1"; - ticks = "0"; - value = "0"; - }; - new GuiTextEditCtrl() { - canSaveDynamicFields = "0"; - internalName = "SmoothnessTextEdit"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiTextEditProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "64 0"; - Extent = "29 18"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Smoothness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());"; - hovertime = "1000"; - AnchorTop = "1"; - AnchorBottom = "0"; - AnchorLeft = "1"; - AnchorRight = "0"; - text = "0"; - }; - }; - - new GuiControl() { - class = "AggregateControl"; - position = "91 26"; - Extent = "96 20"; - - new GuiSliderCtrl() { - canSaveDynamicFields = "0"; - internalName = "MetalnessSlider"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiSliderProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "0 1"; - Extent = "61 14"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "MaterialEditorGui.updateActiveMaterial(\"Metalness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);"; - AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Metalness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);"; - tooltipprofile = "ToolsGuiDefaultProfile"; - ToolTip = "Sets Metalness."; - hovertime = "1000"; - range = "0 1"; - ticks = "0"; - value = "0"; - }; - new GuiTextEditCtrl() { - canSaveDynamicFields = "0"; - internalName = "MetalnessTextEdit"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiTextEditProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "64 0"; - Extent = "29 18"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"Metalness[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());"; - hovertime = "1000"; - AnchorTop = "1"; - AnchorBottom = "0"; - AnchorLeft = "1"; - AnchorRight = "0"; - text = "0"; - }; - }; - }; new GuiContainer(){ // glow emissive profile = "ToolsGuiTransparentProfile"; isContainer = "1"; From 7daf66cf9d86710602575e58f83746e514fc5bb5 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 22 Oct 2019 13:20:42 -0500 Subject: [PATCH 03/17] frontend work. stubbs in a glowMul slider, and a glow mask channel for composites (defaults to writing to the alpha chan) --- .../gui/guiMaterialPropertiesWindow.ed.gui | 297 +++++++++++++++++- .../scripts/materialEditor.ed.cs | 66 +++- 2 files changed, 360 insertions(+), 3 deletions(-) diff --git a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui index 80edd350c..be1c82290 100644 --- a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui +++ b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui @@ -571,7 +571,7 @@ profile = "ToolsGuiTransparentProfile"; isContainer = "1"; position = "0 0"; - Extent = "185 44"; + Extent = "185 68"; HorizSizing = "width"; new GuiTextCtrl() { @@ -580,6 +580,7 @@ position = "9 4"; Extent = "72 16"; text = "Smoothness"; + Profile = "ToolsGuiTextProfile"; }; new GuiTextCtrl() { @@ -588,6 +589,16 @@ position = "9 26"; Extent = "72 16"; text = "Metalness"; + Profile = "ToolsGuiTextProfile"; + }; + + new GuiTextCtrl() { + HorizSizing = "right"; + VertSizing = "bottom"; + position = "9 48"; + Extent = "72 16"; + text = "GlowMul"; + Profile = "ToolsGuiTextProfile"; }; new GuiControl() { @@ -689,6 +700,55 @@ text = "0"; }; }; + new GuiControl() { + class = "AggregateControl"; + position = "91 48"; + Extent = "96 20"; + + new GuiSliderCtrl() { + canSaveDynamicFields = "0"; + internalName = "GlowMulSlider"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiSliderProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "0 1"; + Extent = "61 14"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "MaterialEditorGui.updateActiveMaterial(\"GlowMul[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);"; + AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"GlowMul[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);"; + tooltipprofile = "ToolsGuiDefaultProfile"; + ToolTip = "Sets GlowMul."; + hovertime = "1000"; + range = "0 1"; + ticks = "0"; + value = "0"; + }; + new GuiTextEditCtrl() { + canSaveDynamicFields = "0"; + internalName = "GlowMulTextEdit"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "64 0"; + Extent = "29 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"GlowMul[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());"; + hovertime = "1000"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "0"; + }; + }; }; new GuiContainer(){ // spec Map options @@ -1676,6 +1736,241 @@ canSaveDynamicFields = "0"; }; }; + new GuiContainer() { + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "6 364"; + extent = "185 52"; + minExtent = "8 2"; + horizSizing = "width"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + canSave = "1"; + canSaveDynamicFields = "0"; + new GuiBitmapCtrl() { + bitmap = "tools/materialeditor/gui/unknownImage"; + wrap = "0"; + position = "1 1"; + extent = "48 48"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiButtonProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + internalName = "glowMapDisplayBitmap"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiTextCtrl() { + text = "glow"; + maxLength = "1024"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "56 5"; + extent = "35 8"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiTextProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiBitmapButtonCtrl() { + bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; + bitmapMode = "Stretched"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "1"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "1 1"; + extent = "48 48"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiButtonProfile"; + visible = "1"; + active = "1"; + command = "MaterialEditorGui.updateglowMap(1);"; + tooltipProfile = "GuiToolTipProfile"; + tooltip = "Change the glowness Map for this layer."; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiTextCtrl() { + text = "None"; + maxLength = "1024"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "56 17"; + extent = "143 17"; + minExtent = "8 2"; + horizSizing = "width"; + vertSizing = "bottom"; + profile = "ToolsGuiTextProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + internalName = "glowMapNameText"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiButtonCtrl() { + text = "Edit"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "134 34"; + extent = "40 16"; + minExtent = "8 2"; + horizSizing = "left"; + vertSizing = "bottom"; + profile = "ToolsGuiButtonProfile"; + visible = "1"; + active = "1"; + command = "MaterialEditorGui.updateglowMap(1);"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiBitmapButtonCtrl() { + bitmap = "tools/gui/images/delete"; + bitmapMode = "Stretched"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "1"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "177 34"; + extent = "16 16"; + minExtent = "8 2"; + horizSizing = "left"; + vertSizing = "bottom"; + profile = "ToolsGuiButtonProfile"; + visible = "1"; + active = "1"; + command = "MaterialEditorGui.updateglowMap(0);"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiRadioCtrl(glowChanBtn0) { + text = "R"; + groupNum = "3"; + buttonType = "RadioButton"; + useMouseEvents = "0"; + position = "100 5"; + extent = "20 10"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiRadioProfile"; + visible = "1"; + active = "1"; + command = "MaterialEditorGui.setglowChan(0);"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiRadioCtrl(glowChanBtn1) { + text = "G"; + groupNum = "3"; + buttonType = "RadioButton"; + useMouseEvents = "0"; + position = "121 5"; + extent = "20 10"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiRadioProfile"; + visible = "1"; + active = "1"; + command = "MaterialEditorGui.setglowChan(1);"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiRadioCtrl(glowChanBtn2) { + text = "B"; + groupNum = "3"; + buttonType = "RadioButton"; + useMouseEvents = "0"; + position = "142 5"; + extent = "20 10"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiRadioProfile"; + visible = "1"; + active = "1"; + command = "MaterialEditorGui.setglowChan(2);"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiRadioCtrl(glowChanBtn3) { + text = "A"; + groupNum = "3"; + buttonType = "RadioButton"; + useMouseEvents = "0"; + position = "163 5"; + extent = "20 10"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiRadioProfile"; + visible = "1"; + active = "1"; + command = "MaterialEditorGui.setglowChan(3);"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + }; }; }; new GuiRolloutCtrl(advancedTextureMapsRollout) { diff --git a/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs b/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs index ad15af568..5711388fa 100644 --- a/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs +++ b/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs @@ -614,6 +614,13 @@ function MaterialEditorGui::convertTextureFields(%this) %metalMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %metalMap); MaterialEditorGui.currentMaterial.metalMap[%metalI] = %metalMap; } + + for(%glowI = 0; %glowI < 4; %glowI++) + { + %glowMap = MaterialEditorGui.currentMaterial.glowMap[%glowI]; + %glowMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %glowMap); + MaterialEditorGui.currentMaterial.glowMap[%glowI] = %glowMap; + } } // still needs to be optimized further @@ -943,6 +950,17 @@ function MaterialEditorGui::guiSync( %this, %material ) MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.setBitmap( (%material).metalMap[%layer] ); } + if((%material).glowMap[%layer] $= "") + { + MaterialEditorPropertiesWindow-->glowMapNameText.setText( "None" ); + MaterialEditorPropertiesWindow-->glowMapDisplayBitmap.setBitmap( "tools/materialeditor/gui/unknownImage" ); + } + else + { + MaterialEditorPropertiesWindow-->glowMapNameText.setText( (%material).glowMap[%layer] ); + MaterialEditorPropertiesWindow-->glowMapDisplayBitmap.setBitmap( (%material).glowMap[%layer] ); + } + MaterialEditorPropertiesWindow-->accuScaleTextEdit.setText((%material).accuScale[%layer]); MaterialEditorPropertiesWindow-->accuScaleTextEdit.setText((%material).accuScale[%layer]); MaterialEditorPropertiesWindow-->accuDirectionTextEdit.setText((%material).accuDirection[%layer]); @@ -964,6 +982,8 @@ function MaterialEditorGui::guiSync( %this, %material ) MaterialEditorPropertiesWindow-->SmoothnessSlider.setValue((%material).Smoothness[%layer]); MaterialEditorPropertiesWindow-->MetalnessTextEdit.setText((%material).Metalness[%layer]); MaterialEditorPropertiesWindow-->MetalnessSlider.setValue((%material).Metalness[%layer]); + MaterialEditorPropertiesWindow-->glowMulTextEdit.setText((%material).glowMul[%layer]); + MaterialEditorPropertiesWindow-->glowMulSlider.setValue((%material).glowMul[%layer]); MaterialEditorPropertiesWindow-->glowCheckbox.setValue((%material).glow[%layer]); MaterialEditorPropertiesWindow-->emissiveCheckbox.setValue((%material).emissive[%layer]); MaterialEditorPropertiesWindow-->parallaxTextEdit.setText((%material).parallaxScale[%layer]); @@ -1038,6 +1058,7 @@ function MaterialEditorGui::guiSync( %this, %material ) %this.getRoughChan((%material).SmoothnessChan[%layer]); %this.getAOChan((%material).AOChan[%layer]); %this.getMetalChan((%material).metalChan[%layer]); + %this.getGlowChan((%material).glowChan[%layer]); %this.preventUndo = false; } @@ -1059,6 +1080,11 @@ function MaterialEditorGui::getMetalChan(%this, %channel) %guiElement = metalChanBtn @ %channel; %guiElement.setStateOn(true); } +function MaterialEditorGui::getGlowChan(%this, %channel) +{ + %guiElement = glowChanBtn @ %channel; + %guiElement.setStateOn(true); +} //======================================= // Material Update Functionality @@ -1354,6 +1380,34 @@ function MaterialEditorGui::updatemetalMap(%this,%action) MaterialEditorGui.guiSync( materialEd_previewMaterial ); } +function MaterialEditorGui::updateGlowMap(%this,%action) +{ + %layer = MaterialEditorGui.currentLayer; + + if( %action ) + { + %texture = MaterialEditorGui.openFile("texture"); + if( %texture !$= "" ) + { + MaterialEditorPropertiesWindow-->GlowMapDisplayBitmap.setBitmap(%texture); + + %bitmap = MaterialEditorPropertiesWindow-->GlowMapDisplayBitmap.bitmap; + %bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/",""); + MaterialEditorPropertiesWindow-->GlowMapDisplayBitmap.setBitmap(%bitmap); + MaterialEditorPropertiesWindow-->GlowMapNameText.setText(%bitmap); + MaterialEditorGui.updateActiveMaterial("glowMap[" @ %layer @ "]","\"" @ %bitmap @ "\""); + } + } + else + { + MaterialEditorPropertiesWindow-->GlowMapNameText.setText("None"); + MaterialEditorPropertiesWindow-->GlowMapDisplayBitmap.setBitmap("tools/materialeditor/gui/unknownImage"); + MaterialEditorGui.updateActiveMaterial("glowMap[" @ %layer @ "]",""); + } + + MaterialEditorGui.guiSync( materialEd_previewMaterial ); +} + function MaterialEditorGui::updateRotationOffset(%this, %isSlider, %onMouseUp) { %layer = MaterialEditorGui.currentLayer; @@ -2476,6 +2530,12 @@ function MaterialEditorGui::setMetalChan(%this, %value) MaterialEditorGui.guiSync( materialEd_previewMaterial ); } +function MaterialEditorGui::setGlowChan(%this, %value) +{ + MaterialEditorGui.updateActiveMaterial("glowChan[" @ MaterialEditorGui.currentLayer @ "]", %value); + MaterialEditorGui.guiSync( materialEd_previewMaterial ); +} + function MaterialEditorGui::saveCompositeMap(%this) { %saveAs = ""; @@ -2501,13 +2561,15 @@ function MaterialEditorGui::saveCompositeMap(%this) %roughMap = %material.roughMap[%layer]; %aoMap = %material.aoMap[%layer]; %metalMap = %material.metalMap[%layer]; + %glowMap = %material.glowMap[%layer]; %smooth = %material.SmoothnessChan[%layer]; %ao = %material.AOChan[%layer]; %metal = %material.metalChan[%layer]; + %glow = %material.glowChan[%layer]; - %channelKey = %smooth SPC %ao SPC %metal SPC 3; + %channelKey = %smooth SPC %ao SPC %metal SPC %glow; error("Storing: \"" @ %roughMap @"\" \""@ %aoMap @"\" \""@ %metalMap @"\" \""@ %channelKey @"\" \""@ %saveAs @"\""); - saveCompositeTexture(%roughMap,%aoMap,%metalMap,"",%channelKey, %saveAs); + saveCompositeTexture(%roughMap,%aoMap,%metalMap,%glowMap,%channelKey, %saveAs); %dlg.delete(); } From bfccfca0ce79b757dd241cd6e1e4d954cc05bdd2 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 22 Oct 2019 15:11:39 -0500 Subject: [PATCH 04/17] more conversionwork from specular entries to pbrconfig ones, adds backend glowmul and glowmap var tracking, as well as pbrconfigmap composite slip-in for the glowmap (sans shaderfeatures just yet). seems to have busted forward lit application though... --- .../glsl/advancedLightingFeaturesGLSL.h | 1 - .../glsl/deferredShadingFeaturesGLSL.cpp | 16 ++- .../glsl/deferredShadingFeaturesGLSL.h | 11 +- .../hlsl/advancedLightingFeaturesHLSL.h | 1 - .../hlsl/deferredShadingFeaturesHLSL.cpp | 16 ++- .../hlsl/deferredShadingFeaturesHLSL.h | 12 +- .../lighting/basic/basicLightManager.cpp | 2 - .../source/materials/materialDefinition.cpp | 20 +++- Engine/source/materials/materialDefinition.h | 7 +- .../source/materials/materialFeatureTypes.cpp | 11 +- .../source/materials/materialFeatureTypes.h | 6 +- Engine/source/materials/processedMaterial.cpp | 6 +- .../materials/processedShaderMaterial.cpp | 15 +-- .../renderInstance/renderDeferredMgr.cpp | 6 +- .../source/shaderGen/GLSL/pixSpecularGLSL.cpp | 96 ---------------- .../source/shaderGen/GLSL/pixSpecularGLSL.h | 54 --------- .../shaderGen/GLSL/shaderGenGLSLInit.cpp | 8 +- .../source/shaderGen/HLSL/pixSpecularHLSL.cpp | 103 ------------------ .../source/shaderGen/HLSL/pixSpecularHLSL.h | 54 --------- .../shaderGen/HLSL/shaderGenHLSLInit.cpp | 8 +- Engine/source/shaderGen/shaderGenVars.cpp | 2 +- 21 files changed, 68 insertions(+), 387 deletions(-) delete mode 100644 Engine/source/shaderGen/GLSL/pixSpecularGLSL.cpp delete mode 100644 Engine/source/shaderGen/GLSL/pixSpecularGLSL.h delete mode 100644 Engine/source/shaderGen/HLSL/pixSpecularHLSL.cpp delete mode 100644 Engine/source/shaderGen/HLSL/pixSpecularHLSL.h 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"); From ad216abc026d55214c42cba0f7aae4793ab53f28 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 23 Oct 2019 14:59:29 -0500 Subject: [PATCH 05/17] cleans up a few more spots of various variables that ammount to the "PBRConfig" in the end, as well as a MFT_isDeferred test for determining if that's stored off as a temp-val or in the gbuffer. though seem to have forgotten a catch, as it's not finding the MFT_PBRConfigMap feature and falling back to recreation come time to process MFT_ReflectionProbes --- .../hlsl/deferredShadingFeaturesHLSL.cpp | 107 ++++++++++++------ .../hlsl/deferredShadingFeaturesHLSL.h | 6 +- .../materials/processedShaderMaterial.cpp | 10 +- .../shaderGen/GLSL/shaderFeatureGLSL.cpp | 20 ++-- .../shaderGen/HLSL/shaderFeatureHLSL.cpp | 16 +-- 5 files changed, 96 insertions(+), 63 deletions(-) diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp index e69eb892e..b5b070f65 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp @@ -35,22 +35,38 @@ //**************************************************************************** // Deferred Shading Features //**************************************************************************** +U32 PBRConfigMapHLSL::getOutputTargets(const MaterialFeatureData& fd) const +{ + return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; +} void PBRConfigMapHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { // Get the texture coord. Var *texCoord = getInTexCoord( "texCoord", "float2", componentList ); - // search for color var - Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); - MultiLine * meta = new MultiLine; - if ( !material ) + MultiLine* meta = new MultiLine; + Var* pbrConfig; + if (fd.features[MFT_isDeferred]) { - // create color var - material = new Var; - material->setType( "fragout" ); - material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); - material->setStructName( "OUT" ); + pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2)); + if (!pbrConfig) + { + // create material var + pbrConfig = new Var; + pbrConfig->setType("fragout"); + pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2)); + pbrConfig->setStructName("OUT"); + } + } + else + { + pbrConfig = (Var*)LangElement::find("PBRConfig"); + if (!pbrConfig) + { + pbrConfig = new Var("PBRConfig", "float4"); + meta->addStatement(new GenOp(" @;\r\n", new DecOp(pbrConfig))); + } } // create texture var @@ -69,8 +85,6 @@ void PBRConfigMapHLSL::processPix( Vector &componentList, cons 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 *metalness = (Var*)LangElement::find("metalness"); if (!metalness) metalness = new Var("metalness", "float"); Var *smoothness = (Var*)LangElement::find("smoothness"); @@ -82,8 +96,9 @@ void PBRConfigMapHLSL::processPix( Vector &componentList, cons 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)); - meta->addStatement(new GenOp(" @.bga = float3(@,@.g,@);\r\n", material, smoothness, pbrConfig, metalness)); + if (!fd.features[MFT_isDeferred]) + meta->addStatement(new GenOp(" @ = @.ggga;\r\n", pbrConfig, texOp)); + meta->addStatement(new GenOp(" @.bga = float3(@,@.g,@);\r\n", pbrConfig, smoothness, pbrConfig, metalness)); output = meta; } @@ -126,14 +141,23 @@ void PBRConfigMapHLSL::processVert( Vector &componentList, void DeferredMatInfoFlagsHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { // search for material var - Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); - if ( !material ) + Var* pbrConfig; + if (fd.features[MFT_isDeferred]) { - // create material var - material = new Var; - material->setType( "fragout" ); - material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); - material->setStructName( "OUT" ); + pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2)); + if (!pbrConfig) + { + // create material var + pbrConfig = new Var; + pbrConfig->setType("fragout"); + pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2)); + pbrConfig->setStructName("OUT"); + } + } + else + { + pbrConfig = (Var*)LangElement::find("PBRConfig"); + if (!pbrConfig) pbrConfig = new Var("PBRConfig", "float4"); } Var *matInfoFlags = new Var; @@ -142,24 +166,36 @@ void DeferredMatInfoFlagsHLSL::processPix( Vector &componentLi matInfoFlags->uniform = true; matInfoFlags->constSortPos = cspPotentialPrimitive; - output = new GenOp( " @.r = @;\r\n", material, matInfoFlags ); + output = new GenOp( " @.r = @;\r\n", pbrConfig, matInfoFlags ); +} + +U32 PBRConfigVarsHLSL::getOutputTargets(const MaterialFeatureData& fd) const +{ + return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; } -// Spec Strength -> Blue Channel of Material Info Buffer. -// Spec Power -> Alpha Channel ( of Material Info Buffer. void PBRConfigVarsHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { - // search for material var - Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); - if ( !material ) + MultiLine* meta = new MultiLine; + Var* pbrConfig; + if (fd.features[MFT_isDeferred]) { - // create material var - material = new Var; - material->setType( "fragout" ); - material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); - material->setStructName( "OUT" ); + pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2)); + if (!pbrConfig) + { + // create material var + pbrConfig = new Var; + pbrConfig->setType("fragout"); + pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2)); + pbrConfig->setStructName("OUT"); + } + } + else + { + pbrConfig = (Var*)LangElement::find("PBRConfig"); + if (!pbrConfig) pbrConfig = new Var("PBRConfig", "float4"); + meta->addStatement(new GenOp(" @;\r\n", new DecOp(pbrConfig))); } - Var *metalness = new Var("metalness", "float"); metalness->uniform = true; metalness->constSortPos = cspPotentialPrimitive; @@ -168,13 +204,12 @@ void PBRConfigVarsHLSL::processPix( Vector &componentList, con smoothness->uniform = true; smoothness->constSortPos = cspPotentialPrimitive; - MultiLine * meta = new MultiLine; //matinfo.g slot reserved for AO later - meta->addStatement(new GenOp(" @.g = 1.0;\r\n", material)); - meta->addStatement(new GenOp(" @.b = @;\r\n", material, smoothness)); + meta->addStatement(new GenOp(" @.g = 1.0;\r\n", pbrConfig)); + meta->addStatement(new GenOp(" @.b = @;\r\n", pbrConfig, smoothness)); if (fd.features[MFT_InvertSmoothness]) meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness)); - meta->addStatement(new GenOp(" @.a = @;\r\n", material, metalness)); + meta->addStatement(new GenOp(" @.a = @;\r\n", pbrConfig, metalness)); output = meta; } diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h index 5bb4550a5..2db329173 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h @@ -31,6 +31,8 @@ class PBRConfigMapHLSL : public ShaderFeatureHLSL public: virtual String getName() { return "Deferred Shading: PBR Config Map"; } + virtual U32 getOutputTargets(const MaterialFeatureData& fd) const; + virtual void processPix( Vector &componentList, const MaterialFeatureData &fd ); @@ -62,10 +64,10 @@ class PBRConfigVarsHLSL : public ShaderFeatureHLSL public: virtual String getName() { return "Deferred Shading: PBR Config Explicit Numbers"; } + virtual U32 getOutputTargets(const MaterialFeatureData& fd) const; + virtual void processPix( Vector &componentList, const MaterialFeatureData &fd ); - - virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; } }; class DeferredEmissiveHLSL : public ShaderFeatureHLSL diff --git a/Engine/source/materials/processedShaderMaterial.cpp b/Engine/source/materials/processedShaderMaterial.cpp index 74bdc0831..d3d25d346 100644 --- a/Engine/source/materials/processedShaderMaterial.cpp +++ b/Engine/source/materials/processedShaderMaterial.cpp @@ -439,7 +439,15 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, fd.features[ MFT_NormalMap ] ) fd.features.addFeature( MFT_Parallax ); } - + + // Deferred Shading : PBR Config + if (mStages[stageNum].getTex(MFT_PBRConfigMap)) + { + fd.features.addFeature(MFT_PBRConfigMap); + } + else + fd.features.addFeature(MFT_PBRConfigVars); + if( fd.features[ MFT_PBRConfigMap ] ) { // Check for an alpha channel on the PBR Config map. If it has one (and it diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 09c3e6c1f..dbf4a3cef 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -837,8 +837,8 @@ Var* ShaderFeatureGLSL::getSurface(Vector& componentList, Mult Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - Var* matinfo = (Var*)LangElement::find("PBRConfig"); - if (!matinfo) + Var* pbrConfig = (Var*)LangElement::find("PBRConfig"); + if (!pbrConfig) { Var* metalness = (Var*)LangElement::find("metalness"); if (!metalness) @@ -856,9 +856,9 @@ Var* ShaderFeatureGLSL::getSurface(Vector& componentList, Mult smoothness->constSortPos = cspPotentialPrimitive; } - matinfo = new Var("PBRConfig", "vec4"); - LangElement* colorDecl = new DecOp(matinfo); - meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening + pbrConfig = new Var("PBRConfig", "vec4"); + LangElement* colorDecl = new DecOp(pbrConfig); + meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct pbrConfig, no ao darkening } Var* wsNormal = (Var*)LangElement::find("wsNormal"); @@ -895,7 +895,7 @@ Var* ShaderFeatureGLSL::getSurface(Vector& componentList, Mult if (!surface) { surface = new Var("surface", "Surface"); - meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, matinfo, + meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, pbrConfig, wsPosition, wsEyePos, wsView)); } @@ -3046,13 +3046,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector& componentList } Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - - Var *matinfo = (Var*)LangElement::find("PBRConfig"); - Var* metalness = (Var*)LangElement::find("metalness"); - Var* smoothness = (Var*)LangElement::find("smoothness"); - - Var* wsEyePos = (Var*)LangElement::find("eyePosWorld"); - + //Reflection vec String computeForwardProbes = String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); computeForwardProbes += String("@,@,\r\n\t\t"); diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index 925d3a5f2..4d86e1a54 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -829,8 +829,8 @@ Var* ShaderFeatureHLSL::getSurface(Vector& componentList, Mult Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - Var* matinfo = (Var*)LangElement::find("PBRConfig"); - if (!matinfo) + Var* pbrConfig = (Var*)LangElement::find("PBRConfig"); + if (!pbrConfig) { Var* metalness = (Var*)LangElement::find("metalness"); if (!metalness) @@ -848,8 +848,8 @@ Var* ShaderFeatureHLSL::getSurface(Vector& componentList, Mult smoothness->constSortPos = cspPotentialPrimitive; } - matinfo = new Var("PBRConfig", "float4"); - LangElement* colorDecl = new DecOp(matinfo); + pbrConfig = new Var("PBRConfig", "float4"); + LangElement* colorDecl = new DecOp(pbrConfig); meta->addStatement(new GenOp(" @ = float4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening } @@ -879,7 +879,7 @@ Var* ShaderFeatureHLSL::getSurface(Vector& componentList, Mult if (!surface) { surface = new Var("surface", "Surface"); - meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, matinfo, + meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, pbrConfig, wsPosition, wsEyePos, wsView)); } @@ -3106,12 +3106,6 @@ void ReflectionProbeFeatHLSL::processPix(Vector &componentList Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - Var *matinfo = (Var*)LangElement::find("PBRConfig"); - Var* metalness = (Var*)LangElement::find("metalness"); - Var* smoothness = (Var*)LangElement::find("smoothness"); - - Var* wsEyePos = (Var*)LangElement::find("eyePosWorld"); - //Reflection vec String computeForwardProbes = String::String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t"); computeForwardProbes += String::String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t"); From 8fac88dadc150c4df5040b64a8b9714e98350535 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 23 Oct 2019 20:38:13 -0500 Subject: [PATCH 06/17] more misc cleanup, including cutting down on sampling the pbrconfigmap by filling that out first, and drawing the smooth and metal vars from it, and filling out an ao var in case folks wanna use that later, as well as a bit more doubled up functionality prune-down. still tracing why forward lit seems to have lost the map config feature --- .../glsl/deferredShadingFeaturesGLSL.cpp | 2 +- .../glsl/deferredShadingFeaturesGLSL.h | 2 +- .../hlsl/deferredShadingFeaturesHLSL.cpp | 23 +++++++++++++------ .../hlsl/deferredShadingFeaturesHLSL.h | 6 ++--- .../source/materials/materialFeatureTypes.cpp | 12 +++++----- .../source/materials/materialFeatureTypes.h | 2 +- Engine/source/materials/processedMaterial.cpp | 2 +- .../materials/processedShaderMaterial.cpp | 12 ++++------ .../renderInstance/renderDeferredMgr.cpp | 4 +++- .../shaderGen/GLSL/shaderGenGLSLInit.cpp | 2 +- .../shaderGen/HLSL/shaderGenHLSLInit.cpp | 2 +- 11 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp index 354371ba4..a6a28ad4d 100644 --- a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp +++ b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp @@ -117,7 +117,7 @@ void PBRConfigMapGLSL::processVert( Vector &componentList, } // Material Info Flags -> Red ( Flags ) of Material Info Buffer. -void DeferredMatInfoFlagsGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) +void MatInfoFlagsGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { MultiLine *meta = new MultiLine; diff --git a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h index b2c0908fb..5e82d614e 100644 --- a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h +++ b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h @@ -47,7 +47,7 @@ public: const MaterialFeatureData &fd ); }; -class DeferredMatInfoFlagsGLSL : public ShaderFeatureGLSL +class MatInfoFlagsGLSL : public ShaderFeatureGLSL { public: virtual String getName() { return "Deferred Shading: Mat Info Flags"; } diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp index b5b070f65..67c7de10e 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp @@ -89,16 +89,20 @@ void PBRConfigMapHLSL::processPix( Vector &componentList, cons if (!metalness) metalness = new Var("metalness", "float"); Var *smoothness = (Var*)LangElement::find("smoothness"); if (!smoothness) smoothness = new Var("smoothness", "float"); + Var* ao = (Var*)LangElement::find("ao"); + if (!ao) ao = new Var("ao", "float"); - meta->addStatement(new GenOp(" @ = @.r;\r\n", new DecOp(smoothness), texOp)); - meta->addStatement(new GenOp(" @ = @.b;\r\n", new DecOp(metalness), texOp)); + meta->addStatement(new GenOp(" @.bga = @.rgb;\r\n", pbrConfig, texOp)); + + meta->addStatement(new GenOp(" @ = @.b;\r\n", new DecOp(smoothness), pbrConfig)); if (fd.features[MFT_InvertSmoothness]) + { + meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", pbrConfig, pbrConfig)); meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness)); - - if (!fd.features[MFT_isDeferred]) - meta->addStatement(new GenOp(" @ = @.ggga;\r\n", pbrConfig, texOp)); - meta->addStatement(new GenOp(" @.bga = float3(@,@.g,@);\r\n", pbrConfig, smoothness, pbrConfig, metalness)); + } + meta->addStatement(new GenOp(" @ = @.g;\r\n", new DecOp(ao), pbrConfig)); + meta->addStatement(new GenOp(" @ = @.a;\r\n", new DecOp(metalness), pbrConfig)); output = meta; } @@ -137,8 +141,13 @@ void PBRConfigMapHLSL::processVert( Vector &componentList, output = meta; } +U32 MatInfoFlagsHLSL::getOutputTargets(const MaterialFeatureData& fd) const +{ + return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; +} + // Material Info Flags -> Red ( Flags ) of Material Info Buffer. -void DeferredMatInfoFlagsHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) +void MatInfoFlagsHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { // search for material var Var* pbrConfig; diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h index 2db329173..1a53f9679 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h @@ -48,15 +48,15 @@ public: const MaterialFeatureData &fd ); }; -class DeferredMatInfoFlagsHLSL : public ShaderFeatureHLSL +class MatInfoFlagsHLSL : public ShaderFeatureHLSL { public: virtual String getName() { return "Deferred Shading: Mat Info Flags"; } virtual void processPix( Vector &componentList, const MaterialFeatureData &fd ); - - virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; } + + virtual U32 getOutputTargets(const MaterialFeatureData& fd) const; }; class PBRConfigVarsHLSL : public ShaderFeatureHLSL diff --git a/Engine/source/materials/materialFeatureTypes.cpp b/Engine/source/materials/materialFeatureTypes.cpp index 4987020bf..5b325fc01 100644 --- a/Engine/source/materials/materialFeatureTypes.cpp +++ b/Engine/source/materials/materialFeatureTypes.cpp @@ -44,9 +44,12 @@ 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_GlowMap, MFG_Texture, 9.0f, true ); -ImplementFeatureType( MFT_NormalMap, MFG_Texture, 10.0f, true ); -ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 11.0f, true ); +ImplementFeatureType( MFT_PBRConfigMap, MFG_Texture, 8.0f, false ); +ImplementFeatureType( MFT_PBRConfigVars, MFG_Texture, 8.0f, false ); +ImplementFeatureType( MFT_MatInfoFlags, MFG_Texture, 9.0f, false ); +ImplementFeatureType( MFT_GlowMap, MFG_Texture, 10.0f, true ); +ImplementFeatureType( MFT_NormalMap, MFG_Texture, 11.0f, true ); +ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 12.0f, true ); ImplementFeatureType( MFT_Imposter, U32(-1), -1, true ); ImplementFeatureType( MFT_AccuMap, MFG_PreLighting, 2.0f, true ); @@ -101,9 +104,6 @@ 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_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); ImplementFeatureType( MFT_HardwareSkinning, MFG_Transform,-2.0, false ); diff --git a/Engine/source/materials/materialFeatureTypes.h b/Engine/source/materials/materialFeatureTypes.h index 5b83a64bc..0fd3f361d 100644 --- a/Engine/source/materials/materialFeatureTypes.h +++ b/Engine/source/materials/materialFeatureTypes.h @@ -191,6 +191,6 @@ DeclareFeatureType( MFT_HardwareSkinning ); // Deferred Shading DeclareFeatureType( MFT_isDeferred ); DeclareFeatureType( MFT_SkyBox ); -DeclareFeatureType( MFT_DeferredMatInfoFlags ); +DeclareFeatureType( MFT_MatInfoFlags ); DeclareFeatureType( MFT_DeferredEmissive ); #endif // _MATERIALFEATURETYPES_H_ diff --git a/Engine/source/materials/processedMaterial.cpp b/Engine/source/materials/processedMaterial.cpp index c676c7eb5..60b4e6114 100644 --- a/Engine/source/materials/processedMaterial.cpp +++ b/Engine/source/materials/processedMaterial.cpp @@ -492,7 +492,7 @@ void ProcessedMaterial::_setStageData() 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); + mMaterial->logError("Failed to load PBR Config 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 d3d25d346..a427ce8bf 100644 --- a/Engine/source/materials/processedShaderMaterial.cpp +++ b/Engine/source/materials/processedShaderMaterial.cpp @@ -444,18 +444,14 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, if (mStages[stageNum].getTex(MFT_PBRConfigMap)) { fd.features.addFeature(MFT_PBRConfigMap); + if (mStages[stageNum].getTex(MFT_PBRConfigMap)->mHasTransparency) + fd.features.addFeature(MFT_GlowMap); } else fd.features.addFeature(MFT_PBRConfigVars); - if( fd.features[ MFT_PBRConfigMap ] ) - { - // 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_GlowMap ); - } + // Deferred Shading : Material Info Flags + fd.features.addFeature(MFT_MatInfoFlags); if ( mMaterial->mAccuEnabled[stageNum] ) { diff --git a/Engine/source/renderInstance/renderDeferredMgr.cpp b/Engine/source/renderInstance/renderDeferredMgr.cpp index f3222839a..d6ef29de7 100644 --- a/Engine/source/renderInstance/renderDeferredMgr.cpp +++ b/Engine/source/renderInstance/renderDeferredMgr.cpp @@ -638,12 +638,14 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum, if( mStages[stageNum].getTex( MFT_PBRConfigMap ) ) { newFeatures.addFeature( MFT_PBRConfigMap ); + if( mStages[stageNum].getTex( MFT_PBRConfigMap )->mHasTransparency ) + newFeatures.addFeature( MFT_GlowMap ); } else newFeatures.addFeature( MFT_PBRConfigVars ); // Deferred Shading : Material Info Flags - newFeatures.addFeature( MFT_DeferredMatInfoFlags ); + newFeatures.addFeature( MFT_MatInfoFlags ); for ( U32 i=0; i < fd.features.getCount(); i++ ) { diff --git a/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp b/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp index 63cf17564..3df67d48b 100644 --- a/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp +++ b/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp @@ -102,7 +102,7 @@ void _initShaderGenGLSL( ShaderGen *shaderGen ) FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureGLSL( "Deferred Material" ) ); FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapGLSL ); FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsGLSL ); - FEATUREMGR->registerFeature( MFT_DeferredMatInfoFlags, new DeferredMatInfoFlagsGLSL ); + FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsGLSL ); FEATUREMGR->registerFeature( MFT_SkyBox, new NamedFeatureGLSL( "skybox" ) ); FEATUREMGR->registerFeature( MFT_HardwareSkinning, new HardwareSkinningFeatureGLSL ); } diff --git a/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp b/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp index 68a69445f..28f5cde5a 100644 --- a/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp +++ b/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp @@ -104,7 +104,7 @@ void _initShaderGenHLSL( ShaderGen *shaderGen ) FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureHLSL( "Deferred Material" ) ); FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapHLSL); FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsHLSL); - FEATUREMGR->registerFeature( MFT_DeferredMatInfoFlags, new DeferredMatInfoFlagsHLSL ); + FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsHLSL ); FEATUREMGR->registerFeature( MFT_DeferredEmissive, new DeferredEmissiveHLSL); FEATUREMGR->registerFeature( MFT_SkyBox, new NamedFeatureHLSL( "skybox" ) ); FEATUREMGR->registerFeature( MFT_HardwareSkinning, new HardwareSkinningFeatureHLSL ); From 0f5ba17126be26819c847bc9db9290e917237b3d Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 29 Oct 2019 22:11:59 -0500 Subject: [PATCH 07/17] needed mft_pbrconfigmap or _convifgvars and _matinfocflags set to default=true to trip the forward lit side, shifted the mft_skybox test on down below the checks for the presence of those features to be inserted, and removed them on out if a skybox. --- .../source/materials/materialFeatureTypes.cpp | 8 ++++---- .../materials/processedShaderMaterial.cpp | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Engine/source/materials/materialFeatureTypes.cpp b/Engine/source/materials/materialFeatureTypes.cpp index 5b325fc01..1b2a21837 100644 --- a/Engine/source/materials/materialFeatureTypes.cpp +++ b/Engine/source/materials/materialFeatureTypes.cpp @@ -43,10 +43,10 @@ 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, false ); -ImplementFeatureType( MFT_PBRConfigVars, MFG_Texture, 8.0f, false ); -ImplementFeatureType( MFT_MatInfoFlags, MFG_Texture, 9.0f, false ); +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_MatInfoFlags, MFG_Texture, 9.0f, true); ImplementFeatureType( MFT_GlowMap, MFG_Texture, 10.0f, true ); ImplementFeatureType( MFT_NormalMap, MFG_Texture, 11.0f, true ); ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 12.0f, true ); diff --git a/Engine/source/materials/processedShaderMaterial.cpp b/Engine/source/materials/processedShaderMaterial.cpp index a427ce8bf..615df3406 100644 --- a/Engine/source/materials/processedShaderMaterial.cpp +++ b/Engine/source/materials/processedShaderMaterial.cpp @@ -385,14 +385,6 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, fd.features.addFeature( MFT_CubeMap ); } - if (features.hasFeature(MFT_SkyBox)) - { - fd.features.addFeature(MFT_StaticCubemap); - fd.features.addFeature(MFT_CubeMap); - fd.features.addFeature(MFT_SkyBox); - - fd.features.removeFeature(MFT_ReflectionProbes); - } fd.features.addFeature( MFT_Visibility ); if ( lastStage && @@ -453,6 +445,17 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, // Deferred Shading : Material Info Flags fd.features.addFeature(MFT_MatInfoFlags); + if (features.hasFeature(MFT_SkyBox)) + { + fd.features.addFeature(MFT_StaticCubemap); + fd.features.addFeature(MFT_CubeMap); + fd.features.addFeature(MFT_SkyBox); + + fd.features.removeFeature(MFT_ReflectionProbes); + fd.features.removeFeature(MFT_PBRConfigVars); + fd.features.removeFeature(MFT_MatInfoFlags); + } + if ( mMaterial->mAccuEnabled[stageNum] ) { mHasAccumulation = true; From f284524dd08030eb4e415447cf006cfb6a1134b9 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 30 Oct 2019 18:28:30 -0500 Subject: [PATCH 08/17] fix glowchan groupnum entry (used to group buttons) --- .../materialEditor/gui/guiMaterialPropertiesWindow.ed.gui | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui index be1c82290..484def860 100644 --- a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui +++ b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui @@ -1892,7 +1892,7 @@ }; new GuiRadioCtrl(glowChanBtn0) { text = "R"; - groupNum = "3"; + groupNum = "4"; buttonType = "RadioButton"; useMouseEvents = "0"; position = "100 5"; @@ -1912,7 +1912,7 @@ }; new GuiRadioCtrl(glowChanBtn1) { text = "G"; - groupNum = "3"; + groupNum = "4"; buttonType = "RadioButton"; useMouseEvents = "0"; position = "121 5"; @@ -1932,7 +1932,7 @@ }; new GuiRadioCtrl(glowChanBtn2) { text = "B"; - groupNum = "3"; + groupNum = "4"; buttonType = "RadioButton"; useMouseEvents = "0"; position = "142 5"; @@ -1952,7 +1952,7 @@ }; new GuiRadioCtrl(glowChanBtn3) { text = "A"; - groupNum = "3"; + groupNum = "4"; buttonType = "RadioButton"; useMouseEvents = "0"; position = "163 5"; From 070a9845a2c719d491a3a84b4a047d2a74b5a145 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 30 Oct 2019 18:29:11 -0500 Subject: [PATCH 09/17] preliminary glowmap+glowmul feature augmentation math --- .../hlsl/deferredShadingFeaturesHLSL.cpp | 17 ++++++++++++++++- Engine/source/materials/materialDefinition.cpp | 2 +- .../materials/processedShaderMaterial.cpp | 2 ++ .../source/materials/processedShaderMaterial.h | 1 + Engine/source/shaderGen/shaderGenVars.cpp | 1 + Engine/source/shaderGen/shaderGenVars.h | 1 + 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp index 67c7de10e..1f460d625 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp @@ -83,7 +83,7 @@ void PBRConfigMapHLSL::processPix( Vector &componentList, cons pbrConfigMapTex->uniform = true; pbrConfigMapTex->texture = true; pbrConfigMapTex->constNum = pbrConfigMap->constNum; - LangElement *texOp = new GenOp(" @.Sample(@, @)", pbrConfigMapTex, pbrConfigMap, texCoord); + LangElement *texOp = new GenOp("@.Sample(@, @)", pbrConfigMapTex, pbrConfigMap, texCoord); Var *metalness = (Var*)LangElement::find("metalness"); if (!metalness) metalness = new Var("metalness", "float"); @@ -103,6 +103,21 @@ void PBRConfigMapHLSL::processPix( Vector &componentList, cons } meta->addStatement(new GenOp(" @ = @.g;\r\n", new DecOp(ao), pbrConfig)); meta->addStatement(new GenOp(" @ = @.a;\r\n", new DecOp(metalness), pbrConfig)); + + if (fd.features[MFT_GlowMap]) + { + Var* glowMul = new Var("glowMul", "float"); + glowMul->uniform = true; + glowMul->constSortPos = cspPotentialPrimitive; + + ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget; + if (fd.features[MFT_isDeferred]) + targ = ShaderFeature::RenderTarget1; + + Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(targ)); + if (diffuseColor) + meta->addStatement(new GenOp(" @.rgb += @.rgb*float3(@,@,@)*@.aaa;\r\n", diffuseColor, diffuseColor, glowMul, glowMul, glowMul, texOp)); + } output = meta; } diff --git a/Engine/source/materials/materialDefinition.cpp b/Engine/source/materials/materialDefinition.cpp index b155baae7..e1b26b6c8 100644 --- a/Engine/source/materials/materialDefinition.cpp +++ b/Engine/source/materials/materialDefinition.cpp @@ -128,7 +128,7 @@ Material::Material() mSmoothnessChan[i] = 0; mAOChan[i] = 1; mMetalChan[i] = 2; - + mGlowChan[i] = 3; mAccuEnabled[i] = false; mAccuScale[i] = 1.0f; mAccuDirection[i] = 1.0f; diff --git a/Engine/source/materials/processedShaderMaterial.cpp b/Engine/source/materials/processedShaderMaterial.cpp index 615df3406..e9434f157 100644 --- a/Engine/source/materials/processedShaderMaterial.cpp +++ b/Engine/source/materials/processedShaderMaterial.cpp @@ -62,6 +62,7 @@ void ShaderConstHandles::init( GFXShader *shader, VectorgetShaderConstHandle(ShaderGenVars::pbrConfig); mSmoothnessSC = shader->getShaderConstHandle(ShaderGenVars::smoothness); mMetalnessSC = shader->getShaderConstHandle(ShaderGenVars::metalness); + mGlowMulSC = shader->getShaderConstHandle(ShaderGenVars::glowMul); mAccuScaleSC = shader->getShaderConstHandle("$accuScale"); mAccuDirectionSC = shader->getShaderConstHandle("$accuDirection"); mAccuStrengthSC = shader->getShaderConstHandle("$accuStrength"); @@ -1111,6 +1112,7 @@ void ProcessedShaderMaterial::_setShaderConstants(SceneRenderState * state, cons shaderConsts->setSafe(handles->mSmoothnessSC, mMaterial->mSmoothness[stageNum]); shaderConsts->setSafe(handles->mMetalnessSC, mMaterial->mMetalness[stageNum]); + shaderConsts->setSafe(handles->mGlowMulSC, mMaterial->mGlowMul[stageNum]); shaderConsts->setSafe(handles->mParallaxInfoSC, mMaterial->mParallaxScale[stageNum]); shaderConsts->setSafe(handles->mMinnaertConstantSC, mMaterial->mMinnaertConstant[stageNum]); diff --git a/Engine/source/materials/processedShaderMaterial.h b/Engine/source/materials/processedShaderMaterial.h index c7e52368d..89bd372bd 100644 --- a/Engine/source/materials/processedShaderMaterial.h +++ b/Engine/source/materials/processedShaderMaterial.h @@ -49,6 +49,7 @@ public: GFXShaderConstHandle* mPBRConfigSC; GFXShaderConstHandle* mSmoothnessSC; GFXShaderConstHandle* mMetalnessSC; + GFXShaderConstHandle* mGlowMulSC; GFXShaderConstHandle* mParallaxInfoSC; GFXShaderConstHandle* mAccuScaleSC; GFXShaderConstHandle* mAccuDirectionSC; diff --git a/Engine/source/shaderGen/shaderGenVars.cpp b/Engine/source/shaderGen/shaderGenVars.cpp index b28bb6447..4c75287b4 100644 --- a/Engine/source/shaderGen/shaderGenVars.cpp +++ b/Engine/source/shaderGen/shaderGenVars.cpp @@ -76,6 +76,7 @@ const String ShaderGenVars::vectorLightBrightness("$vectorLightBrightness"); const String ShaderGenVars::pbrConfig("$PBRConfig"); const String ShaderGenVars::smoothness("$smoothness"); const String ShaderGenVars::metalness("$metalness"); +const String ShaderGenVars::glowMul("$glowMul"); //Reflection Probes const String ShaderGenVars::probePosition("$inProbePosArray"); diff --git a/Engine/source/shaderGen/shaderGenVars.h b/Engine/source/shaderGen/shaderGenVars.h index 679dacb59..86055d6eb 100644 --- a/Engine/source/shaderGen/shaderGenVars.h +++ b/Engine/source/shaderGen/shaderGenVars.h @@ -88,6 +88,7 @@ struct ShaderGenVars const static String pbrConfig; const static String smoothness; const static String metalness; + const static String glowMul; //Reflection Probes const static String probePosition; From 25015eb72483d99cea9496385e8d5806b3eb4d94 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 31 Oct 2019 23:42:13 -0500 Subject: [PATCH 10/17] missing gui file entries. though it doesn't seem to be reflected in the end terrain material editor result... --- .../gui/guiTerrainMaterialDlg.ed.gui | 176 ++++++++++++++++++ 1 file changed, 176 insertions(+) diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui index 09a90ef26..bff4eb71b 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui @@ -621,6 +621,182 @@ sinkAllKeyEvents = "0"; passwordMask = "*"; }; + new GuiContainer() { + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "6 216"; + extent = "174 53"; + minExtent = "8 2"; + horizSizing = "width"; + vertSizing = "bottom"; + profile = "ToolsGuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiBitmapCtrl() { + bitmap = "tools/materialEditor/gui/unknownImage"; + color = "255 255 255 255"; + wrap = "0"; + position = "1 1"; + extent = "47 47"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + internalName = "compositeTexCtrl"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiBitmapButtonCtrl() { + bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; + bitmapMode = "Stretched"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "1"; + masked = "0"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "1 1"; + extent = "48 48"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiDefaultProfile"; + visible = "1"; + active = "1"; + command = "TerrainMaterialDlg.changecomposite();"; + tooltipProfile = "ToolsGuiDefaultProfile"; + tooltip = "Change the active composite Map for this layer."; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiTextCtrl() { + text = "Composite"; + maxLength = "1024"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "56 -3"; + extent = "61 18"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "EditorTextProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiTextCtrl() { + text = "None"; + maxLength = "1024"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "56 17"; + extent = "79 17"; + minExtent = "8 2"; + horizSizing = "width"; + vertSizing = "bottom"; + profile = "ToolsGuiTextProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiButtonCtrl() { + text = "Edit"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "111 0"; + extent = "40 16"; + minExtent = "8 2"; + horizSizing = "left"; + vertSizing = "bottom"; + profile = "ToolsGuiButtonProfile"; + visible = "1"; + active = "1"; + command = "TerrainMaterialDlg.changecomposite();"; + tooltipProfile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiBitmapButtonCtrl() { + bitmap = "tools/gui/images/delete"; + bitmapMode = "Stretched"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "1"; + masked = "0"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "154 0"; + extent = "16 16"; + minExtent = "8 2"; + horizSizing = "left"; + vertSizing = "bottom"; + profile = "ToolsGuiDefaultProfile"; + visible = "1"; + active = "1"; + command = "TerrainMaterialDlg-->compositeTexCtrl.setBitmap(\"tools/materialEditor/gui/unknownImage\");"; + tooltipProfile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiBitmapCtrl() { + bitmap = "tools/gui/images/separator-v"; + color = "255 255 255 255"; + wrap = "0"; + position = "4 51"; + extent = "148 2"; + minExtent = "8 2"; + horizSizing = "width"; + vertSizing = "bottom"; + profile = "ToolsGuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + }; }; new GuiBitmapCtrl() { From ac6fdf884e971a2bf7deb105dbbc24df7a569431 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Fri, 1 Nov 2019 03:24:23 -0500 Subject: [PATCH 11/17] from @rextimmy, we need to target the lightmap gbuffer slot, not the color one --- .../hlsl/deferredShadingFeaturesHLSL.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp index 1f460d625..cd30de096 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp @@ -37,7 +37,7 @@ //**************************************************************************** U32 PBRConfigMapHLSL::getOutputTargets(const MaterialFeatureData& fd) const { - return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; + return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget; } void PBRConfigMapHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) @@ -110,13 +110,17 @@ void PBRConfigMapHLSL::processPix( Vector &componentList, cons glowMul->uniform = true; glowMul->constSortPos = cspPotentialPrimitive; - ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget; + ShaderFeature::OutputTarget inTarg = ShaderFeature::DefaultTarget; + ShaderFeature::OutputTarget outTarg = ShaderFeature::DefaultTarget; if (fd.features[MFT_isDeferred]) - targ = ShaderFeature::RenderTarget1; + { + inTarg = ShaderFeature::RenderTarget1; + outTarg = ShaderFeature::RenderTarget3; + } + Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(inTarg)); + Var* emissionColor = (Var*)LangElement::find(getOutputTargetVarName(outTarg)); - Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(targ)); - if (diffuseColor) - meta->addStatement(new GenOp(" @.rgb += @.rgb*float3(@,@,@)*@.aaa;\r\n", diffuseColor, diffuseColor, glowMul, glowMul, glowMul, texOp)); + meta->addStatement(new GenOp(" @.rgb += @.rgb*float3(@,@,@)*@.aaa;\r\n", emissionColor, diffuseColor, glowMul, glowMul, glowMul, texOp)); } output = meta; } From d034895e8f48b02399095581df60e66c65e8e50f Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Fri, 1 Nov 2019 19:29:31 -0500 Subject: [PATCH 12/17] shifts glowmap out of the composite and to it's own texture, as well as featureset. (GL port pending design finalization) --- .../hlsl/deferredShadingFeaturesHLSL.cpp | 106 ++++++--- .../hlsl/deferredShadingFeaturesHLSL.h | 14 +- .../source/materials/materialDefinition.cpp | 4 +- Engine/source/materials/materialDefinition.h | 1 - .../source/materials/materialFeatureTypes.cpp | 10 +- .../source/materials/materialFeatureTypes.h | 1 - Engine/source/materials/processedMaterial.cpp | 10 +- .../materials/processedShaderMaterial.cpp | 2 - .../renderInstance/renderDeferredMgr.cpp | 9 +- .../shaderGen/GLSL/shaderGenGLSLInit.cpp | 1 - .../shaderGen/HLSL/shaderGenHLSLInit.cpp | 3 +- .../gui/guiMaterialPropertiesWindow.ed.gui | 217 +++++++----------- 12 files changed, 180 insertions(+), 198 deletions(-) diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp index cd30de096..0fad444a4 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp @@ -37,7 +37,7 @@ //**************************************************************************** U32 PBRConfigMapHLSL::getOutputTargets(const MaterialFeatureData& fd) const { - return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget; + return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; } void PBRConfigMapHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) @@ -104,24 +104,6 @@ void PBRConfigMapHLSL::processPix( Vector &componentList, cons meta->addStatement(new GenOp(" @ = @.g;\r\n", new DecOp(ao), pbrConfig)); meta->addStatement(new GenOp(" @ = @.a;\r\n", new DecOp(metalness), pbrConfig)); - if (fd.features[MFT_GlowMap]) - { - Var* glowMul = new Var("glowMul", "float"); - glowMul->uniform = true; - glowMul->constSortPos = cspPotentialPrimitive; - - ShaderFeature::OutputTarget inTarg = ShaderFeature::DefaultTarget; - ShaderFeature::OutputTarget outTarg = ShaderFeature::DefaultTarget; - if (fd.features[MFT_isDeferred]) - { - inTarg = ShaderFeature::RenderTarget1; - outTarg = ShaderFeature::RenderTarget3; - } - Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(inTarg)); - Var* emissionColor = (Var*)LangElement::find(getOutputTargetVarName(outTarg)); - - meta->addStatement(new GenOp(" @.rgb += @.rgb*float3(@,@,@)*@.aaa;\r\n", emissionColor, diffuseColor, glowMul, glowMul, glowMul, texOp)); - } output = meta; } @@ -241,24 +223,80 @@ void PBRConfigVarsHLSL::processPix( Vector &componentList, con output = meta; } -//deferred emissive -void DeferredEmissiveHLSL::processPix(Vector &componentList, const MaterialFeatureData &fd) +U32 GlowMapHLSL::getOutputTargets(const MaterialFeatureData& fd) const { - //for now emission just uses the diffuse color, we could plug in a separate texture for emission at some stage - Var *diffuseTargetVar = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1)); - if (!diffuseTargetVar) - return; //oh dear something is not right, maybe we should just write 0's instead + return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget; +} - // search for scene color target var - Var *sceneColorVar = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget3)); - if (!sceneColorVar) +//deferred emissive +void GlowMapHLSL::processPix(Vector &componentList, const MaterialFeatureData &fd) +{ + Var* texCoord = getInTexCoord("texCoord", "float2", componentList); + + // create texture var + Var* glowMap = new Var; + glowMap->setType("SamplerState"); + glowMap->setName("glowMap"); + glowMap->uniform = true; + glowMap->sampler = true; + glowMap->constNum = Var::getTexUnitNum(); + + Var* glowMapTex = new Var; + glowMapTex->setName("glowMapTex"); + glowMapTex->setType("Texture2D"); + glowMapTex->uniform = true; + glowMapTex->texture = true; + glowMapTex->constNum = glowMap->constNum; + LangElement* texOp = new GenOp("@.Sample(@, @)", glowMapTex, glowMap, texCoord); + + Var* glowMul = new Var("glowMul", "float"); + glowMul->uniform = true; + glowMul->constSortPos = cspPotentialPrimitive; + + Var *targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); + if (fd.features[MFT_isDeferred]) { - // create scene color target var - sceneColorVar = new Var; - sceneColorVar->setType("fragout"); - sceneColorVar->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3)); - sceneColorVar->setStructName("OUT"); + targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget3)); + if (!targ) + { + // create scene color target var + targ = new Var; + targ->setType("fragout"); + targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3)); + targ->setStructName("OUT"); + output = new GenOp("@ = float4(@.rgb*@,0);", targ, texOp, glowMul); + } + else + { + output = new GenOp("@ += float4(@.rgb*@,0);", targ, texOp, glowMul); + } + } + else + { + output = new GenOp("@ += float4(@.rgb*@,@.a);", targ, texOp, glowMul, targ); } - output = new GenOp("@ = float4(@.rgb,0);", sceneColorVar, diffuseTargetVar); +} + +ShaderFeature::Resources GlowMapHLSL::getResources(const MaterialFeatureData& fd) +{ + Resources res; + res.numTex = 1; + res.numTexReg = 1; + + return res; +} + +void GlowMapHLSL::setTexData(Material::StageData& stageDat, + const MaterialFeatureData& fd, + RenderPassData& passData, + U32& texIndex) +{ + GFXTextureObject* tex = stageDat.getTex(MFT_GlowMap); + if (tex) + { + passData.mTexType[texIndex] = Material::Standard; + passData.mSamplerNames[texIndex] = "glowMap"; + passData.mTexSlot[texIndex++].texObject = tex; + } } diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h index 1a53f9679..b2934ad92 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h @@ -70,15 +70,23 @@ public: const MaterialFeatureData &fd ); }; -class DeferredEmissiveHLSL : public ShaderFeatureHLSL +class GlowMapHLSL : public ShaderFeatureHLSL { public: - virtual String getName() { return "Deferred Shading: Emissive"; } + virtual String getName() { return "Glow Map"; } virtual void processPix(Vector &componentList, const MaterialFeatureData &fd); - virtual U32 getOutputTargets(const MaterialFeatureData &fd) const { return ShaderFeature::RenderTarget3; } + virtual U32 getOutputTargets(const MaterialFeatureData& fd) const; + + virtual Resources getResources(const MaterialFeatureData& fd); + + // Sets textures and texture flags for current pass + virtual void setTexData(Material::StageData& stageDat, + const MaterialFeatureData& fd, + RenderPassData& passData, + U32& texIndex); }; #endif diff --git a/Engine/source/materials/materialDefinition.cpp b/Engine/source/materials/materialDefinition.cpp index e1b26b6c8..3c12d14fd 100644 --- a/Engine/source/materials/materialDefinition.cpp +++ b/Engine/source/materials/materialDefinition.cpp @@ -128,7 +128,7 @@ Material::Material() mSmoothnessChan[i] = 0; mAOChan[i] = 1; mMetalChan[i] = 2; - mGlowChan[i] = 3; + mAccuEnabled[i] = false; mAccuScale[i] = 1.0f; mAccuDirection[i] = 1.0f; @@ -325,8 +325,6 @@ void Material::initPersistFields() 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, diff --git a/Engine/source/materials/materialDefinition.h b/Engine/source/materials/materialDefinition.h index 7003450f9..f9d13956b 100644 --- a/Engine/source/materials/materialDefinition.h +++ b/Engine/source/materials/materialDefinition.h @@ -256,7 +256,6 @@ public: 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. diff --git a/Engine/source/materials/materialFeatureTypes.cpp b/Engine/source/materials/materialFeatureTypes.cpp index 1b2a21837..e08c11463 100644 --- a/Engine/source/materials/materialFeatureTypes.cpp +++ b/Engine/source/materials/materialFeatureTypes.cpp @@ -47,7 +47,6 @@ 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_MatInfoFlags, MFG_Texture, 9.0f, true); -ImplementFeatureType( MFT_GlowMap, MFG_Texture, 10.0f, true ); ImplementFeatureType( MFT_NormalMap, MFG_Texture, 11.0f, true ); ImplementFeatureType( MFT_DetailNormalMap, MFG_Texture, 12.0f, true ); ImplementFeatureType( MFT_Imposter, U32(-1), -1, true ); @@ -56,9 +55,10 @@ ImplementFeatureType( MFT_AccuMap, MFG_PreLighting, 2.0f, true ); ImplementFeatureType(MFT_ReflectionProbes, MFG_Lighting, 1.0f, true); ImplementFeatureType( MFT_RTLighting, MFG_Lighting, 2.0f, true ); -ImplementFeatureType( MFT_LightMap, MFG_Lighting, 3.0f, true ); -ImplementFeatureType( MFT_ToneMap, MFG_Lighting, 4.0f, true ); -ImplementFeatureType( MFT_VertLitTone, MFG_Lighting, 5.0f, false ); +ImplementFeatureType( MFT_GlowMap, MFG_Lighting, 3.0f, true ); +ImplementFeatureType( MFT_LightMap, MFG_Lighting, 4.0f, true ); +ImplementFeatureType( MFT_ToneMap, MFG_Lighting, 5.0f, true ); +ImplementFeatureType( MFT_VertLitTone, MFG_Lighting, 6.0f, false ); ImplementFeatureType( MFT_StaticCubemap, U32(-1), -1.0, true ); ImplementFeatureType( MFT_CubeMap, MFG_Lighting, 7.0f, true ); ImplementFeatureType( MFT_SubSurface, MFG_Lighting, 8.0f, true ); @@ -104,7 +104,5 @@ 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_DeferredEmissive, MFG_Texture, 8.9f, false); - ImplementFeatureType( MFT_HardwareSkinning, MFG_Transform,-2.0, false ); diff --git a/Engine/source/materials/materialFeatureTypes.h b/Engine/source/materials/materialFeatureTypes.h index 0fd3f361d..440db5747 100644 --- a/Engine/source/materials/materialFeatureTypes.h +++ b/Engine/source/materials/materialFeatureTypes.h @@ -192,5 +192,4 @@ DeclareFeatureType( MFT_HardwareSkinning ); DeclareFeatureType( MFT_isDeferred ); DeclareFeatureType( MFT_SkyBox ); DeclareFeatureType( MFT_MatInfoFlags ); -DeclareFeatureType( MFT_DeferredEmissive ); #endif // _MATERIALFEATURETYPES_H_ diff --git a/Engine/source/materials/processedMaterial.cpp b/Engine/source/materials/processedMaterial.cpp index 60b4e6114..8d0ecc634 100644 --- a/Engine/source/materials/processedMaterial.cpp +++ b/Engine/source/materials/processedMaterial.cpp @@ -487,14 +487,20 @@ void ProcessedMaterial::_setStageData() inputKey[0] = mMaterial->mSmoothnessChan[i]; inputKey[1] = mMaterial->mAOChan[i]; inputKey[2] = mMaterial->mMetalChan[i]; - inputKey[3] = mMaterial->mGlowChan[i]; + inputKey[3] = 0; mStages[i].setTex(MFT_PBRConfigMap, _createCompositeTexture(mMaterial->mRoughMapFilename[i], mMaterial->mAOMapFilename[i], - mMaterial->mMetalMapFilename[i], mMaterial->mGlowMapFilename[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 (mMaterial->mGlowMapFilename[i].isNotEmpty()) + { + mStages[i].setTex(MFT_GlowMap, _createTexture(mMaterial->mGlowMapFilename[i], &GFXStaticTextureProfile)); + if (!mStages[i].getTex(MFT_GlowMap)) + mMaterial->logError("Failed to load glow map %s for stage %i", _getTexturePath(mMaterial->mGlowMapFilename[i]).c_str(), i); + } } mMaterial->mCubemapData = dynamic_cast(Sim::findObject(mMaterial->mCubemapName)); diff --git a/Engine/source/materials/processedShaderMaterial.cpp b/Engine/source/materials/processedShaderMaterial.cpp index e9434f157..1dbf04a73 100644 --- a/Engine/source/materials/processedShaderMaterial.cpp +++ b/Engine/source/materials/processedShaderMaterial.cpp @@ -437,8 +437,6 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, if (mStages[stageNum].getTex(MFT_PBRConfigMap)) { fd.features.addFeature(MFT_PBRConfigMap); - if (mStages[stageNum].getTex(MFT_PBRConfigMap)->mHasTransparency) - fd.features.addFeature(MFT_GlowMap); } else fd.features.addFeature(MFT_PBRConfigVars); diff --git a/Engine/source/renderInstance/renderDeferredMgr.cpp b/Engine/source/renderInstance/renderDeferredMgr.cpp index d6ef29de7..24fb4b133 100644 --- a/Engine/source/renderInstance/renderDeferredMgr.cpp +++ b/Engine/source/renderInstance/renderDeferredMgr.cpp @@ -644,6 +644,11 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum, else newFeatures.addFeature( MFT_PBRConfigVars ); + if (mStages[stageNum].getTex(MFT_GlowMap)) + { + newFeatures.addFeature(MFT_GlowMap); + } + // Deferred Shading : Material Info Flags newFeatures.addFeature( MFT_MatInfoFlags ); @@ -743,9 +748,7 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum, else { // If this object isn't lightmapped or emissive, add a zero-output feature for render target 3 - if (fd.features.hasFeature(MFT_IsEmissive)) - newFeatures.addFeature(MFT_DeferredEmissive); - else + if (!fd.features.hasFeature(MFT_IsEmissive)&&(!fd.features.hasFeature(MFT_GlowMap))) newFeatures.addFeature( MFT_RenderTarget3_Zero ); } } diff --git a/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp b/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp index 3df67d48b..e2f9b958e 100644 --- a/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp +++ b/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp @@ -66,7 +66,6 @@ void _initShaderGenGLSL( ShaderGen *shaderGen ) FEATUREMGR->registerFeature( MFT_CubeMap, new ReflectCubeFeatGLSL ); FEATUREMGR->registerFeature( MFT_InvertSmoothness, new NamedFeatureGLSL("Roughest = 1.0")); FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatGLSL ); - 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 ); diff --git a/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp b/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp index 28f5cde5a..4dffebbe6 100644 --- a/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp +++ b/Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp @@ -70,7 +70,6 @@ void _initShaderGenHLSL( ShaderGen *shaderGen ) FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatHLSL ); FEATUREMGR->registerFeature( MFT_Fog, new FogFeatHLSL ); FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatHLSL ); - 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 ) ); @@ -105,7 +104,7 @@ void _initShaderGenHLSL( ShaderGen *shaderGen ) FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapHLSL); FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsHLSL); FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsHLSL ); - FEATUREMGR->registerFeature( MFT_DeferredEmissive, new DeferredEmissiveHLSL); + FEATUREMGR->registerFeature( MFT_GlowMap, new GlowMapHLSL); FEATUREMGR->registerFeature( MFT_SkyBox, new NamedFeatureHLSL( "skybox" ) ); FEATUREMGR->registerFeature( MFT_HardwareSkinning, new HardwareSkinningFeatureHLSL ); } diff --git a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui index 484def860..b8fd54aa7 100644 --- a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui +++ b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui @@ -571,7 +571,7 @@ profile = "ToolsGuiTransparentProfile"; isContainer = "1"; position = "0 0"; - Extent = "185 68"; + Extent = "185 50"; HorizSizing = "width"; new GuiTextCtrl() { @@ -592,15 +592,6 @@ Profile = "ToolsGuiTextProfile"; }; - new GuiTextCtrl() { - HorizSizing = "right"; - VertSizing = "bottom"; - position = "9 48"; - Extent = "72 16"; - text = "GlowMul"; - Profile = "ToolsGuiTextProfile"; - }; - new GuiControl() { class = "AggregateControl"; position = "91 4"; @@ -700,55 +691,6 @@ text = "0"; }; }; - new GuiControl() { - class = "AggregateControl"; - position = "91 48"; - Extent = "96 20"; - - new GuiSliderCtrl() { - canSaveDynamicFields = "0"; - internalName = "GlowMulSlider"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiSliderProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "0 1"; - Extent = "61 14"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "MaterialEditorGui.updateActiveMaterial(\"GlowMul[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);"; - AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"GlowMul[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);"; - tooltipprofile = "ToolsGuiDefaultProfile"; - ToolTip = "Sets GlowMul."; - hovertime = "1000"; - range = "0 1"; - ticks = "0"; - value = "0"; - }; - new GuiTextEditCtrl() { - canSaveDynamicFields = "0"; - internalName = "GlowMulTextEdit"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiTextEditProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "64 0"; - Extent = "29 18"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"GlowMul[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());"; - hovertime = "1000"; - AnchorTop = "1"; - AnchorBottom = "0"; - AnchorLeft = "1"; - AnchorRight = "0"; - text = "0"; - }; - }; }; new GuiContainer(){ // spec Map options @@ -1736,6 +1678,23 @@ canSaveDynamicFields = "0"; }; }; + new GuiBitmapCtrl() { + bitmap = "tools/gui/images/separator-v"; + wrap = "0"; + position = "6 75"; + extent = "175 2"; + minExtent = "8 2"; + horizSizing = "width"; + vertSizing = "bottom"; + profile = "ToolsGuiButtonProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; new GuiContainer() { margin = "0 0 0 0"; padding = "0 0 0 0"; @@ -1744,7 +1703,7 @@ anchorLeft = "1"; anchorRight = "0"; position = "6 364"; - extent = "185 52"; + extent = "185 67"; minExtent = "8 2"; horizSizing = "width"; vertSizing = "bottom"; @@ -1890,86 +1849,64 @@ canSave = "1"; canSaveDynamicFields = "0"; }; - new GuiRadioCtrl(glowChanBtn0) { - text = "R"; - groupNum = "4"; - buttonType = "RadioButton"; - useMouseEvents = "0"; - position = "100 5"; - extent = "20 10"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "ToolsGuiRadioProfile"; - visible = "1"; - active = "1"; - command = "MaterialEditorGui.setglowChan(0);"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiRadioCtrl(glowChanBtn1) { - text = "G"; - groupNum = "4"; - buttonType = "RadioButton"; - useMouseEvents = "0"; - position = "121 5"; - extent = "20 10"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "ToolsGuiRadioProfile"; - visible = "1"; - active = "1"; - command = "MaterialEditorGui.setglowChan(1);"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiRadioCtrl(glowChanBtn2) { - text = "B"; - groupNum = "4"; - buttonType = "RadioButton"; - useMouseEvents = "0"; - position = "142 5"; - extent = "20 10"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "ToolsGuiRadioProfile"; - visible = "1"; - active = "1"; - command = "MaterialEditorGui.setglowChan(2);"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiRadioCtrl(glowChanBtn3) { - text = "A"; - groupNum = "4"; - buttonType = "RadioButton"; - useMouseEvents = "0"; - position = "163 5"; - extent = "20 10"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "ToolsGuiRadioProfile"; - visible = "1"; - active = "1"; - command = "MaterialEditorGui.setglowChan(3);"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; + new GuiTextCtrl() { + HorizSizing = "right"; + VertSizing = "bottom"; + position = "9 48"; + Extent = "72 16"; + text = "GlowMul"; + Profile = "ToolsGuiTextProfile"; + }; + + new GuiControl() { + class = "AggregateControl"; + position = "91 48"; + Extent = "96 20"; + + new GuiSliderCtrl() { + canSaveDynamicFields = "0"; + internalName = "GlowMulSlider"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiSliderProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "0 1"; + Extent = "61 14"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "MaterialEditorGui.updateActiveMaterial(\"GlowMul[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, true);"; + AltCommand = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"GlowMul[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue(), true, false);"; + tooltipprofile = "ToolsGuiDefaultProfile"; + ToolTip = "Sets GlowMul."; + hovertime = "1000"; + range = "0 20"; + ticks = "0"; + value = "0"; + }; + new GuiTextEditCtrl() { + canSaveDynamicFields = "0"; + internalName = "GlowMulTextEdit"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "64 0"; + Extent = "29 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "$ThisControl.getParent().updateFromChild($ThisControl); MaterialEditorGui.updateActiveMaterial(\"GlowMul[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());"; + hovertime = "1000"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "0"; + }; + }; }; }; }; From 091af6bdff081e90f174ab41c4677716e006f7d2 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 4 Nov 2019 00:40:09 -0600 Subject: [PATCH 13/17] glowmap gl port rev1: debug yells about "ShaderFeatureGLSL::getInTexCoord - Type mismatch!", so will need to hunt that down before calling it final, but otherwise, functions. --- .../glsl/deferredShadingFeaturesGLSL.cpp | 209 ++++++++++++++---- .../glsl/deferredShadingFeaturesGLSL.h | 28 ++- .../shaderGen/GLSL/shaderGenGLSLInit.cpp | 1 + 3 files changed, 191 insertions(+), 47 deletions(-) diff --git a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp index a6a28ad4d..2dea95f22 100644 --- a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp +++ b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp @@ -35,22 +35,38 @@ //**************************************************************************** // Deferred Shading Features //**************************************************************************** +U32 PBRConfigMapGLSL::getOutputTargets(const MaterialFeatureData& fd) const +{ + return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; +} void PBRConfigMapGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { // Get the texture coord. Var *texCoord = getInTexCoord( "texCoord", "vec2", componentList ); - - // search for color var - Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); - MultiLine * meta = new MultiLine; - if ( !material ) + + MultiLine* meta = new MultiLine; + Var* pbrConfig; + if (fd.features[MFT_isDeferred]) { - // create color var - material = new Var; - material->setType( "vec4" ); - material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); - material->setStructName("OUT"); + pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2)); + if (!pbrConfig) + { + // create material var + pbrConfig = new Var; + pbrConfig->setType("vec4"); + pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2)); + pbrConfig->setStructName("OUT"); + } + } + else + { + pbrConfig = (Var*)LangElement::find("PBRConfig"); + if (!pbrConfig) + { + pbrConfig = new Var("PBRConfig", "vec4"); + meta->addStatement(new GenOp(" @;\r\n", new DecOp(pbrConfig))); + } } // create texture var @@ -62,22 +78,25 @@ void PBRConfigMapGLSL::processPix( Vector &componentList, cons pbrConfigMap->constNum = Var::getTexUnitNum(); LangElement *texOp = new GenOp( "tex2D(@, @)", pbrConfigMap, texCoord ); - Var *pbrConfig = (Var*)LangElement::find("PBRConfig"); - if (!pbrConfig) 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"); + Var* ao = (Var*)LangElement::find("ao"); + if (!ao) ao = new Var("ao", "float"); - meta->addStatement(new GenOp(" @ = @.r;\r\n", new DecOp(smoothness), texOp)); - meta->addStatement(new GenOp(" @ = @.b;\r\n", new DecOp(metalness), texOp)); + meta->addStatement(new GenOp(" @.bga = @.rgb;\r\n", pbrConfig, texOp)); + + meta->addStatement(new GenOp(" @ = @.b;\r\n", new DecOp(smoothness), pbrConfig)); if (fd.features[MFT_InvertSmoothness]) + { + meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", pbrConfig, pbrConfig)); meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness)); + } + meta->addStatement(new GenOp(" @ = @.g;\r\n", new DecOp(ao), pbrConfig)); + meta->addStatement(new GenOp(" @ = @.a;\r\n", new DecOp(metalness), pbrConfig)); - meta->addStatement(new GenOp(" @ = @.ggga;\r\n", new DecOp(pbrConfig), texOp)); - - meta->addStatement(new GenOp(" @.bga = vec3(@,@.g,@);\r\n", material, smoothness, pbrConfig, metalness)); output = meta; } @@ -116,20 +135,37 @@ void PBRConfigMapGLSL::processVert( Vector &componentList, output = meta; } +U32 MatInfoFlagsGLSL::getOutputTargets(const MaterialFeatureData& fd) const +{ + return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; +} + // Material Info Flags -> Red ( Flags ) of Material Info Buffer. void MatInfoFlagsGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { MultiLine *meta = new MultiLine; - // search for material var - Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); - if ( !material ) + Var* pbrConfig; + if (fd.features[MFT_isDeferred]) { - // create material var - material = new Var; - material->setType( "vec4" ); - material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); - material->setStructName("OUT"); + pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2)); + if (!pbrConfig) + { + // create material var + pbrConfig = new Var; + pbrConfig->setType("vec4"); + pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2)); + pbrConfig->setStructName("OUT"); + } + } + else + { + pbrConfig = (Var*)LangElement::find("PBRConfig"); + if (!pbrConfig) + { + pbrConfig = new Var("PBRConfig", "vec4"); + meta->addStatement(new GenOp(" @;\r\n", new DecOp(pbrConfig))); + } } Var *matInfoFlags = new Var; @@ -138,39 +174,126 @@ void MatInfoFlagsGLSL::processPix( Vector &componentList, cons matInfoFlags->uniform = true; matInfoFlags->constSortPos = cspPotentialPrimitive; - meta->addStatement(output = new GenOp(" @.r = @;\r\n", material, matInfoFlags)); + meta->addStatement(output = new GenOp(" @.r = @;\r\n", pbrConfig, matInfoFlags)); output = meta; } +U32 PBRConfigVarsGLSL::getOutputTargets(const MaterialFeatureData& fd) const +{ + return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; +} + // Spec Strength -> Blue Channel of Material Info Buffer. // Spec Power -> Alpha Channel ( of Material Info Buffer. void PBRConfigVarsGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { + MultiLine* meta = new MultiLine; - // search for material var - Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); - if ( !material ) + Var* pbrConfig; + if (fd.features[MFT_isDeferred]) { - // create material var - material = new Var; - material->setType( "vec4" ); - material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); - material->setStructName("OUT"); + pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2)); + if (!pbrConfig) + { + // create material var + pbrConfig = new Var; + pbrConfig->setType("vec4"); + pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2)); + pbrConfig->setStructName("OUT"); + } } - - Var *metalness = new Var("metalness", "float"); + else + { + pbrConfig = (Var*)LangElement::find("PBRConfig"); + if (!pbrConfig) + { + pbrConfig = new Var("PBRConfig", "vec4"); + meta->addStatement(new GenOp(" @;\r\n", new DecOp(pbrConfig))); + } + } + Var* metalness = new Var("metalness", "float"); metalness->uniform = true; metalness->constSortPos = cspPotentialPrimitive; - Var *smoothness = new Var("smoothness", "float"); + Var* smoothness = new Var("smoothness", "float"); smoothness->uniform = true; smoothness->constSortPos = cspPotentialPrimitive; - MultiLine *meta = new MultiLine; - meta->addStatement(new GenOp(" @.g = 1.0;\r\n", material)); - meta->addStatement(new GenOp(" @.b = @;\r\n", material, smoothness)); - if (fd.features[MFT_InvertSmoothness]) - meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness)); - meta->addStatement(new GenOp(" @.a = @;\r\n", material, metalness)); + //matinfo.g slot reserved for AO later + meta->addStatement(new GenOp(" @.g = 1.0;\r\n", pbrConfig)); + meta->addStatement(new GenOp(" @.b = @;\r\n", pbrConfig, smoothness)); + if (fd.features[MFT_InvertSmoothness]) + meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness)); + meta->addStatement(new GenOp(" @.a = @;\r\n", pbrConfig, metalness)); output = meta; } + +U32 GlowMapGLSL::getOutputTargets(const MaterialFeatureData& fd) const +{ + return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget; +} + +//deferred emissive +void GlowMapGLSL::processPix(Vector& componentList, const MaterialFeatureData& fd) +{ + Var* texCoord = getInTexCoord("texCoord", "float2", componentList); + + Var* glowMap = new Var; + glowMap->setType("sampler2D"); + glowMap->setName("glowMap"); + glowMap->uniform = true; + glowMap->sampler = true; + glowMap->constNum = Var::getTexUnitNum(); + LangElement* texOp = new GenOp("tex2D(@, @)", glowMap, texCoord); + + Var* glowMul = new Var("glowMul", "float"); + glowMul->uniform = true; + glowMul->constSortPos = cspPotentialPrimitive; + + Var* targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); + if (fd.features[MFT_isDeferred]) + { + targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget3)); + if (!targ) + { + // create scene color target var + targ = new Var; + targ->setType("vec4"); + targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3)); + targ->setStructName("OUT"); + output = new GenOp("@ = vec4(@.rgb*@,0);", targ, texOp, glowMul); + } + else + { + output = new GenOp("@ += vec4(@.rgb*@,0);", targ, texOp, glowMul); + } + } + else + { + output = new GenOp("@ += vec4(@.rgb*@,@.a);", targ, texOp, glowMul, targ); + } + +} + +ShaderFeature::Resources GlowMapGLSL::getResources(const MaterialFeatureData& fd) +{ + Resources res; + res.numTex = 1; + res.numTexReg = 1; + + return res; +} + +void GlowMapGLSL::setTexData(Material::StageData& stageDat, + const MaterialFeatureData& fd, + RenderPassData& passData, + U32& texIndex) +{ + GFXTextureObject* tex = stageDat.getTex(MFT_GlowMap); + if (tex) + { + passData.mTexType[texIndex] = Material::Standard; + passData.mSamplerNames[texIndex] = "glowMap"; + passData.mTexSlot[texIndex++].texObject = tex; + } +} diff --git a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h index 5e82d614e..27fce45db 100644 --- a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h +++ b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.h @@ -32,6 +32,8 @@ class PBRConfigMapGLSL : public ShaderFeatureGLSL public: virtual String getName() { return "Deferred Shading: PBR Config Map"; } + virtual U32 getOutputTargets(const MaterialFeatureData& fd) const; + virtual void processPix( Vector &componentList, const MaterialFeatureData &fd ); @@ -54,8 +56,8 @@ public: virtual void processPix( Vector &componentList, const MaterialFeatureData &fd ); - - virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; } + + virtual U32 getOutputTargets(const MaterialFeatureData& fd) const; }; class PBRConfigVarsGLSL : public ShaderFeatureGLSL @@ -63,10 +65,28 @@ class PBRConfigVarsGLSL : public ShaderFeatureGLSL public: virtual String getName() { return "Deferred Shading: PBR Config Explicit Numbers"; } + virtual U32 getOutputTargets(const MaterialFeatureData& fd) const; + virtual void processPix( Vector &componentList, const MaterialFeatureData &fd ); - - virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; } }; +class GlowMapGLSL : public ShaderFeatureGLSL +{ +public: + virtual String getName() { return "Glow Map"; } + + virtual void processPix(Vector& componentList, + const MaterialFeatureData& fd); + + virtual U32 getOutputTargets(const MaterialFeatureData& fd) const; + + virtual Resources getResources(const MaterialFeatureData& fd); + + // Sets textures and texture flags for current pass + virtual void setTexData(Material::StageData& stageDat, + const MaterialFeatureData& fd, + RenderPassData& passData, + U32& texIndex); +}; #endif diff --git a/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp b/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp index e2f9b958e..8630a6918 100644 --- a/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp +++ b/Engine/source/shaderGen/GLSL/shaderGenGLSLInit.cpp @@ -102,6 +102,7 @@ void _initShaderGenGLSL( ShaderGen *shaderGen ) FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapGLSL ); FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsGLSL ); FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsGLSL ); + FEATUREMGR->registerFeature( MFT_GlowMap, new GlowMapGLSL); FEATUREMGR->registerFeature( MFT_SkyBox, new NamedFeatureGLSL( "skybox" ) ); FEATUREMGR->registerFeature( MFT_HardwareSkinning, new HardwareSkinningFeatureGLSL ); } From a67d2c52cd427ab6b782fe9168d11b3d44b74108 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 5 Nov 2019 06:22:04 -0600 Subject: [PATCH 14/17] "ShaderFeatureGLSL::getInTexCoord - Type mismatch!" bit turned out to be a simple typofix --- .../lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp index 2dea95f22..c3e94c79f 100644 --- a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp +++ b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp @@ -236,7 +236,7 @@ U32 GlowMapGLSL::getOutputTargets(const MaterialFeatureData& fd) const //deferred emissive void GlowMapGLSL::processPix(Vector& componentList, const MaterialFeatureData& fd) { - Var* texCoord = getInTexCoord("texCoord", "float2", componentList); + Var* texCoord = getInTexCoord("texCoord", "vec2", componentList); Var* glowMap = new Var; glowMap->setType("sampler2D"); From fb67458eaf40e23e663aadaddd642698fb19fe7b Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 7 Nov 2019 03:27:44 -0600 Subject: [PATCH 15/17] fix terrain default values when not applying a pbrConfigMap --- Engine/source/terrain/glsl/terrFeatureGLSL.cpp | 6 ++---- Engine/source/terrain/hlsl/terrFeatureHLSL.cpp | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Engine/source/terrain/glsl/terrFeatureGLSL.cpp b/Engine/source/terrain/glsl/terrFeatureGLSL.cpp index 92019a651..d5c12f3ab 100644 --- a/Engine/source/terrain/glsl/terrFeatureGLSL.cpp +++ b/Engine/source/terrain/glsl/terrFeatureGLSL.cpp @@ -1298,14 +1298,12 @@ ShaderFeature::Resources TerrainCompositeMapFeatGLSL::getResources(const Materia } -//here, it's merely a cutout for now, so that lightmapping (target3) doesn't get mangled. -//we'll most likely revisit that later. possibly several ways... - U32 TerrainBlankInfoMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const { return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1; } +// reminder, the matinfo buffer is flags, smooth, ao, metal void TerrainBlankInfoMapFeatGLSL::processPix(Vector &componentList, const MaterialFeatureData &fd) { @@ -1328,7 +1326,7 @@ void TerrainBlankInfoMapFeatGLSL::processPix(Vector &component material->setStructName("OUT"); } - meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,0.0,0.0001);\r\n", material)); + meta->addStatement(new GenOp(" @ = vec4(0.0,0.0,1.0,0);\r\n", material)); output = meta; } diff --git a/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp b/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp index 68396653d..3650aa5f6 100644 --- a/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp +++ b/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp @@ -1315,9 +1315,7 @@ ShaderFeature::Resources TerrainCompositeMapFeatHLSL::getResources(const Materia return res; } -//here, it's merely a cutout for now, so that lightmapping (target3) doesn't get mangled. -//we'll most likely revisit that later. possibly several ways... - +// reminder, the matinfo buffer is flags, smooth, ao, metal U32 TerrainBlankInfoMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const { return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1; @@ -1345,7 +1343,7 @@ void TerrainBlankInfoMapFeatHLSL::processPix(Vector &component material->setStructName("OUT"); } - meta->addStatement(new GenOp(" @ = float4(0.0,1.0,0.0,0.0001);\r\n", material)); + meta->addStatement(new GenOp(" @ = float4(0.0,0.0,1.0,0);\r\n", material)); output = meta; } From 60d2b0a0f669598eca263df1c4d5bedb14e80e7d Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 7 Nov 2019 03:46:31 -0600 Subject: [PATCH 16/17] conversion lockin: cleans out eroneous editor refs to specmap and specularmap in favor of the desired PBRConfigMap var name for the combined (smooth,ao,metalness) map used throughout --- .../source/materials/materialDefinition.cpp | 2 +- .../scripts/assetTypes/material.cs | 6 ++-- .../gui/guiMaterialPropertiesWindow.ed.gui | 14 ++++---- .../scripts/materialEditor.ed.cs | 34 +++++++++---------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Engine/source/materials/materialDefinition.cpp b/Engine/source/materials/materialDefinition.cpp index a4aa4fa59..e9c36b12d 100644 --- a/Engine/source/materials/materialDefinition.cpp +++ b/Engine/source/materials/materialDefinition.cpp @@ -304,7 +304,7 @@ void Material::initPersistFields() addField("invertSmoothness", TypeBool, Offset(mInvertSmoothness, Material), MAX_STAGES, "Treat Smoothness as Roughness"); - addField( "specularMap", TypeImageFilename, Offset(mPBRConfigMapFilename, Material), MAX_STAGES, + addField( "PBRConfigMap", TypeImageFilename, Offset(mPBRConfigMapFilename, Material), MAX_STAGES, "Prepacked specular map texture. The RGB channels of this texture provide per-pixel reference values for: " "smoothness (R), Ambient Occlusion (G), and metalness(B)"); diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs index 6463da6e4..7a2f384d9 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs @@ -385,10 +385,10 @@ function AssetBrowser::importMaterialAsset(%this, %assetItem) %file.writeline(" AOMap[0] = \"" @ %assetItem.AOImageAsset.filePath @"\";"); %file.writeline(" AOMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.AOImageAsset.assetName @"\";"); } - if(%assetItem.compositeImageAsset) + if(%assetItem.PBRConfigMapImageAsset) { - %file.writeline(" CompositeMap[0] = \"" @ %assetItem.compositeImageAsset.filePath @"\";"); - %file.writeline(" CompositeMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.compositeImageAsset.assetName @"\";"); + %file.writeline(" PBRConfigMap[0] = \"" @ %assetItem.compositeImageAsset.filePath @"\";"); + %file.writeline(" PBRConfigMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.compositeImageAsset.assetName @"\";"); } %file.writeline("};"); %file.writeline("//--- OBJECT WRITE END ---"); diff --git a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui index b8fd54aa7..3c47b1568 100644 --- a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui +++ b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui @@ -731,7 +731,7 @@ HorizSizing = "right"; VertSizing = "bottom"; position = "70 2"; - Extent = "57 16"; + Extent = "107 16"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; @@ -772,7 +772,7 @@ new GuiBitmapCtrl() { canSaveDynamicFields = "0"; - internalName = "specMapDisplayBitmap"; + internalName = "PBRConfigMapDisplayBitmap"; Enabled = "1"; isContainer = "0"; Profile = "ToolsGuiDefaultProfile"; @@ -806,7 +806,7 @@ AnchorBottom = "0"; AnchorLeft = "1"; AnchorRight = "0"; - text = "Composite Map"; + text = "PBR Config Map"; maxLength = "1024"; }; new GuiBitmapButtonCtrl() { @@ -821,7 +821,7 @@ MinExtent = "8 2"; canSave = "1"; Visible = "1"; - Command = "MaterialEditorGui.updateSpecMap(1);"; + Command = "MaterialEditorGui.updatePBRConfigMap(1);"; tooltipprofile = "ToolsGuiDefaultProfile"; ToolTip = "Change the packed spec map for this layer. \n Smoothness (R), Ambient Occlusion (G), and Metalness(B))"; hovertime = "1000"; @@ -832,7 +832,7 @@ }; new GuiTextCtrl() { canSaveDynamicFields = "0"; - internalName = "specMapNameText"; + internalName = "PBRConfigMapNameText"; Enabled = "1"; isContainer = "0"; Profile = "ToolsGuiTextProfile"; @@ -861,7 +861,7 @@ position = "134 34"; Extent = "40 16"; buttonType = "PushButton"; - command="MaterialEditorGui.updateSpecMap(1);"; + command="MaterialEditorGui.updatePBRConfigMap(1);"; }; new GuiBitmapButtonCtrl() { canSaveDynamicFields = "0"; @@ -875,7 +875,7 @@ MinExtent = "8 2"; canSave = "1"; Visible = "1"; - Command = "MaterialEditorGui.updateSpecMap(0);"; + Command = "MaterialEditorGui.updatePBRConfigMap(0);"; hovertime = "1000"; groupNum = "-1"; buttonType = "PushButton"; diff --git a/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs b/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs index 5711388fa..cf29fc85f 100644 --- a/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs +++ b/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.cs @@ -589,9 +589,9 @@ function MaterialEditorGui::convertTextureFields(%this) for(%specI = 0; %specI < 4; %specI++) { - %specMap = MaterialEditorGui.currentMaterial.specularMap[%specI]; - %specMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %specMap); - MaterialEditorGui.currentMaterial.specularMap[%specI] = %specMap; + %PBRConfigMap = MaterialEditorGui.currentMaterial.PBRConfigMap[%specI]; + %PBRConfigMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %PBRConfigMap); + MaterialEditorGui.currentMaterial.PBRConfigMap[%specI] = %PBRConfigMap; } for(%roughI = 0; %roughI < 4; %roughI++) @@ -906,15 +906,15 @@ function MaterialEditorGui::guiSync( %this, %material ) MaterialEditorPropertiesWindow-->isSRGBCheckbox.setValue((%material).isSRGB[%layer]); MaterialEditorPropertiesWindow-->invertSmoothnessCheckbox.setValue((%material).invertSmoothness[%layer]); - if((%material).specularMap[%layer] $= "") + if((%material).PBRConfigMap[%layer] $= "") { - MaterialEditorPropertiesWindow-->specMapNameText.setText( "None" ); - MaterialEditorPropertiesWindow-->specMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" ); + MaterialEditorPropertiesWindow-->PBRConfigMapNameText.setText( "None" ); + MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" ); } else { - MaterialEditorPropertiesWindow-->specMapNameText.setText( (%material).specularMap[%layer] ); - MaterialEditorPropertiesWindow-->specMapDisplayBitmap.setBitmap( (%material).specularMap[%layer] ); + MaterialEditorPropertiesWindow-->PBRConfigMapNameText.setText( (%material).PBRConfigMap[%layer] ); + MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap( (%material).PBRConfigMap[%layer] ); } if((%material).roughMap[%layer] $= "") @@ -1266,7 +1266,7 @@ function MaterialEditorGui::updateDetailNormalStrength(%this,%newStrength) MaterialEditorGui.updateActiveMaterial("detailNormalMapStrength[" @ %layer @ "]", %detailStrength); } -function MaterialEditorGui::updateSpecMap(%this,%action) +function MaterialEditorGui::updatePBRConfigMap(%this,%action) { %layer = MaterialEditorGui.currentLayer; @@ -1277,20 +1277,20 @@ function MaterialEditorGui::updateSpecMap(%this,%action) { MaterialEditorGui.updateActiveMaterial("pixelSpecular[" @ MaterialEditorGui.currentLayer @ "]", 0); - MaterialEditorPropertiesWindow-->specMapDisplayBitmap.setBitmap(%texture); + MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap(%texture); - %bitmap = MaterialEditorPropertiesWindow-->specMapDisplayBitmap.bitmap; + %bitmap = MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.bitmap; %bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/",""); - MaterialEditorPropertiesWindow-->specMapDisplayBitmap.setBitmap(%bitmap); - MaterialEditorPropertiesWindow-->specMapNameText.setText(%bitmap); - MaterialEditorGui.updateActiveMaterial("specularMap[" @ %layer @ "]","\"" @ %bitmap @ "\""); + MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap(%bitmap); + MaterialEditorPropertiesWindow-->PBRConfigMapNameText.setText(%bitmap); + MaterialEditorGui.updateActiveMaterial("PBRConfigMap[" @ %layer @ "]","\"" @ %bitmap @ "\""); } } else { - MaterialEditorPropertiesWindow-->specMapNameText.setText("None"); - MaterialEditorPropertiesWindow-->specMapDisplayBitmap.setBitmap("tools/materialEditor/gui/unknownImage"); - MaterialEditorGui.updateActiveMaterial("specularMap[" @ %layer @ "]",""); + MaterialEditorPropertiesWindow-->PBRConfigMapNameText.setText("None"); + MaterialEditorPropertiesWindow-->PBRConfigMapDisplayBitmap.setBitmap("tools/materialEditor/gui/unknownImage"); + MaterialEditorGui.updateActiveMaterial("PBRConfigMap[" @ %layer @ "]",""); } MaterialEditorGui.guiSync( materialEd_previewMaterial ); From 63a4d69a33d2f8802a3a20771c463fc8b5313892 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Fri, 8 Nov 2019 05:54:30 -0600 Subject: [PATCH 17/17] clip out eroneous test casuing issues with MFT_SubSurface --- Engine/source/renderInstance/renderDeferredMgr.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Engine/source/renderInstance/renderDeferredMgr.cpp b/Engine/source/renderInstance/renderDeferredMgr.cpp index 24fb4b133..8632b36a3 100644 --- a/Engine/source/renderInstance/renderDeferredMgr.cpp +++ b/Engine/source/renderInstance/renderDeferredMgr.cpp @@ -745,10 +745,8 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum, newFeatures.addFeature( MFT_VertLit ); newFeatures.addFeature( MFT_LightbufferMRT ); } - else + else if (!fd.features.hasFeature(MFT_GlowMap)) { - // If this object isn't lightmapped or emissive, add a zero-output feature for render target 3 - if (!fd.features.hasFeature(MFT_IsEmissive)&&(!fd.features.hasFeature(MFT_GlowMap))) newFeatures.addFeature( MFT_RenderTarget3_Zero ); } }