From 56e4484ff612a70456e2ebd1e6ffff4c1508c47e Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 30 May 2024 17:29:42 -0500 Subject: [PATCH] remove glowbin as it's own render pass --- .../glsl/deferredShadingFeaturesGLSL.cpp | 6 +- .../hlsl/deferredShadingFeaturesHLSL.cpp | 6 +- .../source/materials/materialFeatureTypes.cpp | 3 +- Engine/source/materials/processedMaterial.cpp | 14 +- Engine/source/materials/processedMaterial.h | 7 +- .../materials/processedShaderMaterial.cpp | 4 +- Engine/source/materials/sceneData.h | 4 - .../renderInstance/renderDeferredMgr.cpp | 3 +- .../source/renderInstance/renderGlowMgr.cpp | 282 ------------------ Engine/source/renderInstance/renderGlowMgr.h | 90 ------ .../renderInstance/renderPassManager.cpp | 1 - .../shaderGen/GLSL/shaderFeatureGLSL.cpp | 23 +- .../source/shaderGen/GLSL/shaderFeatureGLSL.h | 4 +- .../shaderGen/HLSL/shaderFeatureHLSL.cpp | 23 +- .../source/shaderGen/HLSL/shaderFeatureHLSL.h | 4 +- .../DepthOfField/DepthOfFieldPostFX.tscript | 2 +- .../postFX/scripts/Glow/GlowPostFX.tscript | 71 ----- .../Turbulence/TurbulencePostFX.tscript | 2 +- .../rendering/scripts/renderManager.tscript | 5 +- 19 files changed, 44 insertions(+), 510 deletions(-) delete mode 100644 Engine/source/renderInstance/renderGlowMgr.cpp delete mode 100644 Engine/source/renderInstance/renderGlowMgr.h diff --git a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp index 3d881b398..66e451ab7 100644 --- a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp +++ b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp @@ -261,16 +261,16 @@ void GlowMapGLSL::processPix(Vector& componentList, const Mate targ->setType("vec4"); targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3)); targ->setStructName("OUT"); - output = new GenOp("@ = vec4(@.rgb*@,0);", targ, texOp, glowMul); + output = new GenOp("@ = vec4(pow(max(@.rgb*@,0.0),vec3(3.54406804435,3.54406804435,3.54406804435)),0);", targ, texOp, glowMul); } else { - output = new GenOp("@ += vec4(@.rgb*@,0);", targ, texOp, glowMul); + output = new GenOp("@ += vec4(pow(max(@.rgb*@,0.0),vec3(3.54406804435,3.54406804435,3.54406804435)),0);", targ, texOp, glowMul); } } else { - output = new GenOp("@ += vec4(@.rgb*@,@.a);", targ, texOp, glowMul, targ); + output = new GenOp("@ += vec4(pow(max(@.rgb*@,0.0),vec3(3.54406804435,3.54406804435,3.54406804435)),@.a);", targ, texOp, glowMul, targ); } } diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp index 42518830a..8b7d3c0bb 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp @@ -264,16 +264,16 @@ void GlowMapHLSL::processPix(Vector &componentList, const Mate targ->setType("fragout"); targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3)); targ->setStructName("OUT"); - output = new GenOp("@ = float4(@.rgb*@,0);", targ, texOp, glowMul); + output = new GenOp("@ = float4(pow(max(@.rgb*@,0.0),3.54406804435),0);", targ, texOp, glowMul); } else { - output = new GenOp("@ += float4(@.rgb*@,0);", targ, texOp, glowMul); + output = new GenOp("@ += float4(pow(max(@.rgb*@,0.0),3.54406804435),0);", targ, texOp, glowMul); } } else { - output = new GenOp("@ += float4(@.rgb*@,@.a);", targ, texOp, glowMul, targ); + output = new GenOp("@ += float4(pow(max(@.rgb*@,0.0),3.54406804435),@.a);", targ, texOp, glowMul, targ); } } diff --git a/Engine/source/materials/materialFeatureTypes.cpp b/Engine/source/materials/materialFeatureTypes.cpp index 44220a9b1..2a5736ae3 100644 --- a/Engine/source/materials/materialFeatureTypes.cpp +++ b/Engine/source/materials/materialFeatureTypes.cpp @@ -56,6 +56,7 @@ 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_GlowMap, MFG_Lighting, 3.0f, true ); +ImplementFeatureType( MFT_GlowMask, MFG_Lighting, 3.1f, 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 ); @@ -65,8 +66,6 @@ ImplementFeatureType( MFT_SubSurface, MFG_Lighting, 8.0f, true ); ImplementFeatureType( MFT_VertLit, MFG_Lighting, 9.0f, true ); ImplementFeatureType( MFT_MinnaertShading, MFG_Lighting, 10.0f, true ); - -ImplementFeatureType( MFT_GlowMask, MFG_PostLighting, 1.0f, true ); ImplementFeatureType( MFT_Visibility, MFG_PostLighting, 2.0f, true ); ImplementFeatureType( MFT_Fog, MFG_PostProcess, 3.0f, true ); diff --git a/Engine/source/materials/processedMaterial.cpp b/Engine/source/materials/processedMaterial.cpp index 79b08249a..f4b0d2417 100644 --- a/Engine/source/materials/processedMaterial.cpp +++ b/Engine/source/materials/processedMaterial.cpp @@ -197,7 +197,7 @@ void ProcessedMaterial::addStateBlockDesc(const GFXStateBlockDesc& sb) mUserDefined = sb; } -void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateGlow, GFXStateBlockDesc& stateReflect) +void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateReflect) { // Translucency stateTranslucent.blendDefined = true; @@ -211,10 +211,6 @@ void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslu stateTranslucent.alphaTestFunc = GFXCmpGreaterEqual; stateTranslucent.samplersDefined = true; - // Glow - stateGlow.zDefined = true; - stateGlow.zWriteEnable = false; - // Reflect stateReflect.cullDefined = true; stateReflect.cullMode = mMaterial->mDoubleSided ? GFXCullNone : GFXCullCW; @@ -316,11 +312,10 @@ void ProcessedMaterial::_initPassStateBlock( RenderPassData *rpd, GFXStateBlockD void ProcessedMaterial::_initRenderStateStateBlocks( RenderPassData *rpd ) { GFXStateBlockDesc stateTranslucent; - GFXStateBlockDesc stateGlow; GFXStateBlockDesc stateReflect; GFXStateBlockDesc statePass; - _initStateBlockTemplates( stateTranslucent, stateGlow, stateReflect ); + _initStateBlockTemplates( stateTranslucent, stateReflect ); _initPassStateBlock( rpd, statePass ); // Ok, we've got our templates set up, let's combine them together based on state and @@ -333,8 +328,6 @@ void ProcessedMaterial::_initRenderStateStateBlocks( RenderPassData *rpd ) stateFinal.addDesc(stateReflect); if (i & RenderPassData::STATE_TRANSLUCENT) stateFinal.addDesc(stateTranslucent); - if (i & RenderPassData::STATE_GLOW) - stateFinal.addDesc(stateGlow); stateFinal.addDesc(statePass); @@ -359,9 +352,6 @@ U32 ProcessedMaterial::_getRenderStateIndex( const SceneRenderState *sceneState, // For example sgData.visibility would be bad to use // in here without changing how RenderMeshMgr works. - if ( sgData.binType == SceneData::GlowBin ) - currState |= RenderPassData::STATE_GLOW; - if ( sceneState && sceneState->isReflectPass() ) currState |= RenderPassData::STATE_REFLECT; diff --git a/Engine/source/materials/processedMaterial.h b/Engine/source/materials/processedMaterial.h index d316fc450..4efc338bc 100644 --- a/Engine/source/materials/processedMaterial.h +++ b/Engine/source/materials/processedMaterial.h @@ -98,9 +98,8 @@ public: { STATE_REFLECT = 1, STATE_TRANSLUCENT = 2, - STATE_GLOW = 4, - STATE_WIREFRAME = 8, - STATE_MAX = 16 + STATE_WIREFRAME = 4, + STATE_MAX = 8 }; /// @@ -301,7 +300,7 @@ protected: /// @{ /// Creates the default state block templates, used by initStateBlocks. - virtual void _initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateGlow, GFXStateBlockDesc& stateReflect); + virtual void _initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateReflect); /// Does the base render state block setting, normally per pass. virtual void _initPassStateBlock( RenderPassData *rpd, GFXStateBlockDesc& result); diff --git a/Engine/source/materials/processedShaderMaterial.cpp b/Engine/source/materials/processedShaderMaterial.cpp index 77566ef29..521ec04c6 100644 --- a/Engine/source/materials/processedShaderMaterial.cpp +++ b/Engine/source/materials/processedShaderMaterial.cpp @@ -348,7 +348,6 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, // if ( features.hasFeature( MFT_UseInstancing ) && mMaxStages == 1 && - !mMaterial->mGlow[0] && shaderVersion >= 3.0f ) fd.features.addFeature( MFT_UseInstancing ); @@ -520,6 +519,9 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, if ( mMaterial->mVertColor[ stageNum ] && mVertexFormat->hasColor() ) fd.features.addFeature( MFT_DiffuseVertColor ); + + if (mMaterial->mGlow[stageNum]) + fd.features.addFeature(MFT_GlowMask); // Allow features to add themselves. for ( U32 i = 0; i < FEATUREMGR->getFeatureCount(); i++ ) diff --git a/Engine/source/materials/sceneData.h b/Engine/source/materials/sceneData.h index 67a521923..bd99e3e00 100644 --- a/Engine/source/materials/sceneData.h +++ b/Engine/source/materials/sceneData.h @@ -45,10 +45,6 @@ struct SceneData /// the special bins we care about. RegularBin = 0, - /// The glow render bin. - /// @see RenderGlowMgr - GlowBin, - /// The deferred render bin. /// @RenderDeferredMgr DeferredBin, diff --git a/Engine/source/renderInstance/renderDeferredMgr.cpp b/Engine/source/renderInstance/renderDeferredMgr.cpp index 664302528..65276a111 100644 --- a/Engine/source/renderInstance/renderDeferredMgr.cpp +++ b/Engine/source/renderInstance/renderDeferredMgr.cpp @@ -683,7 +683,8 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum, type == MFT_UseInstancing || type == MFT_DiffuseVertColor || type == MFT_DetailMap || - type == MFT_DiffuseMapAtlas) + type == MFT_DiffuseMapAtlas|| + type == MFT_GlowMask) newFeatures.addFeature( type ); // Add any transform features. diff --git a/Engine/source/renderInstance/renderGlowMgr.cpp b/Engine/source/renderInstance/renderGlowMgr.cpp deleted file mode 100644 index 17ae78c60..000000000 --- a/Engine/source/renderInstance/renderGlowMgr.cpp +++ /dev/null @@ -1,282 +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 "renderInstance/renderGlowMgr.h" -#include "renderInstance/renderParticleMgr.h" - -#include "scene/sceneManager.h" -#include "scene/sceneRenderState.h" -#include "materials/sceneData.h" -#include "materials/matInstance.h" -#include "materials/materialFeatureTypes.h" -#include "materials/processedMaterial.h" -#include "postFx/postEffect.h" -#include "gfx/gfxTransformSaver.h" -#include "gfx/gfxDebugEvent.h" -#include "math/util/matrixSet.h" - -IMPLEMENT_CONOBJECT( RenderGlowMgr ); - - -ConsoleDocClass( RenderGlowMgr, - "@brief A render bin for the glow pass.\n\n" - "When the glow buffer PostEffect is enabled this bin gathers mesh render " - "instances with glow materials and renders them to the #glowbuffer offscreen " - "render target.\n\n" - "This render target is then used by the 'GlowPostFx' PostEffect to blur and " - "render the glowing portions of the screen.\n\n" - "@ingroup RenderBin\n" ); - -const MatInstanceHookType RenderGlowMgr::GlowMaterialHook::Type( "Glow" ); - - -RenderGlowMgr::GlowMaterialHook::GlowMaterialHook( BaseMatInstance *matInst ) - : mGlowMatInst( NULL ) -{ - mGlowMatInst = (MatInstance*)matInst->getMaterial()->createMatInstance(); - mGlowMatInst->getFeaturesDelegate().bind( &GlowMaterialHook::_overrideFeatures ); - mGlowMatInst->setUserObject(matInst->getUserObject()); - mGlowMatInst->init( matInst->getRequestedFeatures(), - matInst->getVertexFormat() ); -} - -RenderGlowMgr::GlowMaterialHook::~GlowMaterialHook() -{ - SAFE_DELETE( mGlowMatInst ); -} - -void RenderGlowMgr::GlowMaterialHook::_overrideFeatures( ProcessedMaterial *mat, - U32 stageNum, - MaterialFeatureData &fd, - const FeatureSet &features ) -{ - // If this isn't a glow pass... then add the glow mask feature. - if ( mat->getMaterial() && - !mat->getMaterial()->mGlow[stageNum] ) - fd.features.addFeature( MFT_GlowMask ); - - // Don't allow fog or HDR encoding on - // the glow materials. - fd.features.removeFeature( MFT_Fog ); - fd.features.addFeature( MFT_Imposter ); -} - -RenderGlowMgr::RenderGlowMgr() - : RenderTexTargetBinManager( RenderPassManager::RIT_Mesh, - 1.0f, - 1.0f, - GFXFormatR8G8B8A8, - Point2I( 512, 512 ) ) -{ - notifyType( RenderPassManager::RIT_Decal ); - notifyType( RenderPassManager::RIT_DecalRoad ); - notifyType( RenderPassManager::RIT_Translucent ); - notifyType( RenderPassManager::RIT_Particle ); - - mParticleRenderMgr = NULL; - - mNamedTarget.registerWithName( "glowbuffer" ); - mTargetSizeType = WindowSize; -} - -RenderGlowMgr::~RenderGlowMgr() -{ -} - -PostEffect* RenderGlowMgr::getGlowEffect() -{ - if ( !mGlowEffect ) - mGlowEffect = dynamic_cast( Sim::findObject( "GlowPostFx" ) ); - - return mGlowEffect; -} - -bool RenderGlowMgr::isGlowEnabled() -{ - return getGlowEffect() && getGlowEffect()->isEnabled(); -} - -void RenderGlowMgr::addElement( RenderInst *inst ) -{ - // Skip out if we don't have the glow post - // effect enabled at this time. - if ( !isGlowEnabled() ) - return; - - // TODO: We need to get the scene state here in a more reliable - // manner so we can skip glow in a non-diffuse render pass. - //if ( !mParentManager->getSceneManager()->getSceneState()->isDiffusePass() ) - //return RenderBinManager::arSkipped; - ParticleRenderInst *particleInst = NULL; - if(inst->type == RenderPassManager::RIT_Particle) - particleInst = static_cast(inst); - if(particleInst && particleInst->glow) - { - internalAddElement(inst); - return; - } - - // Skip it if we don't have a glowing material. - BaseMatInstance *matInst = getMaterial( inst ); - if ( !matInst || !matInst->hasGlow() ) - return; - - internalAddElement(inst); -} - -void RenderGlowMgr::render( SceneRenderState *state ) -{ - PROFILE_SCOPE( RenderGlowMgr_Render ); - - if ( !isGlowEnabled() ) - return; - - const U32 binSize = mElementList.size(); - - // If this is a non-diffuse pass or we have no objects to - // render then tell the effect to skip rendering. - if ( !state->isDiffusePass() || binSize == 0 ) - { - getGlowEffect()->setSkip( true ); - return; - } - - GFXDEBUGEVENT_SCOPE( RenderGlowMgr_Render, ColorI::GREEN ); - - GFXTransformSaver saver; - - // Respect the current viewport - mNamedTarget.setViewport(GFX->getViewport()); - - // Tell the superclass we're about to render, preserve contents - const bool isRenderingToTarget = _onPreRender( state, true ); - - // Clear all the buffers to black. - GFX->clear( GFXClearTarget, ColorI::BLACK, 1.0f, 0); - - // Restore transforms - MatrixSet &matrixSet = getRenderPass()->getMatrixSet(); - matrixSet.restoreSceneViewProjection(); - - // init loop data - SceneData sgData; - sgData.init( state, SceneData::GlowBin ); - - for( U32 j=0; jtype == RenderPassManager::RIT_Particle) - { - // Find the particle render manager (if we don't have it) - if(mParticleRenderMgr == NULL) - { - RenderPassManager *rpm = state->getRenderPass(); - for( U32 i = 0; i < rpm->getManagerCount(); i++ ) - { - RenderBinManager *bin = rpm->getManager(i); - if( bin->getRenderInstType() == RenderParticleMgr::RIT_Particles ) - { - mParticleRenderMgr = reinterpret_cast(bin); - break; - } - } - } - - ParticleRenderInst *ri = static_cast(_ri); - - GFX->setStateBlock(mParticleRenderMgr->_getHighResStateBlock(ri)); - mParticleRenderMgr->_getShaderConsts().mShaderConsts->setSafe(mParticleRenderMgr->_getShaderConsts().mModelViewProjSC, *ri->modelViewProj); - - mParticleRenderMgr->renderParticle(ri, state); - j++; - continue; - } - - MeshRenderInst *ri = static_cast(_ri); - - setupSGData( ri, sgData ); - - BaseMatInstance *mat = ri->matInst; - GlowMaterialHook *hook = mat->getHook(); - if ( !hook ) - { - hook = new GlowMaterialHook( ri->matInst ); - ri->matInst->addHook( hook ); - } - BaseMatInstance *glowMat = hook->getMatInstance(); - - U32 matListEnd = j; - - while( glowMat && glowMat->setupPass( state, sgData ) ) - { - U32 a; - for( a=j; atype == RenderPassManager::RIT_Particle) - break; - - MeshRenderInst *passRI = static_cast(mElementList[a].inst); - - if ( newPassNeeded( ri, passRI ) ) - break; - - matrixSet.setWorld(*passRI->objectToWorld); - matrixSet.setView(*passRI->worldToCamera); - matrixSet.setProjection(*passRI->projection); - glowMat->setTransforms(matrixSet, state); - - // Setup HW skinning transforms if applicable - if (glowMat->usesHardwareSkinning()) - { - glowMat->setNodeTransforms(passRI->mNodeTransforms, passRI->mNodeTransformCount); - } - - //push along any overriden fields that are instance-specific as well - if (passRI->mCustomShaderData.size() > 0) - { - mat->setCustomShaderData(passRI->mCustomShaderData); - } - - glowMat->setSceneInfo(state, sgData); - glowMat->setBuffers(passRI->vertBuff, passRI->primBuff); - - if ( passRI->prim ) - GFX->drawPrimitive( *passRI->prim ); - else - GFX->drawPrimitive( passRI->primBuffIndex ); - } - matListEnd = a; - setupSGData( ri, sgData ); - } - - // force increment if none happened, otherwise go to end of batch - j = ( j == matListEnd ) ? j+1 : matListEnd; - } - - // Finish up. - if ( isRenderingToTarget ) - _onPostRender(); - - // Make sure the effect is gonna render. - getGlowEffect()->setSkip( false ); -} diff --git a/Engine/source/renderInstance/renderGlowMgr.h b/Engine/source/renderInstance/renderGlowMgr.h deleted file mode 100644 index 27ff7a03f..000000000 --- a/Engine/source/renderInstance/renderGlowMgr.h +++ /dev/null @@ -1,90 +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 _RENDERGLOWMGR_H_ -#define _RENDERGLOWMGR_H_ - -#ifndef _TEXTARGETBIN_MGR_H_ -#include "renderInstance/renderTexTargetBinManager.h" -#endif -#include - - -class PostEffect; - - -/// -class RenderGlowMgr : public RenderTexTargetBinManager -{ - typedef RenderTexTargetBinManager Parent; - -public: - - RenderGlowMgr(); - virtual ~RenderGlowMgr(); - - /// Returns the glow post effect. - PostEffect* getGlowEffect(); - - /// Returns true if the glow post effect is - /// enabled and the glow buffer should be updated. - bool isGlowEnabled(); - - // RenderBinManager - void addElement( RenderInst *inst ) override; - void render( SceneRenderState *state ) override; - - // ConsoleObject - DECLARE_CONOBJECT( RenderGlowMgr ); - -protected: - - class GlowMaterialHook : public MatInstanceHook - { - public: - - GlowMaterialHook( BaseMatInstance *matInst ); - virtual ~GlowMaterialHook(); - - virtual BaseMatInstance *getMatInstance() { return mGlowMatInst; } - - const MatInstanceHookType& getType() const override { return Type; } - - /// Our material hook type. - static const MatInstanceHookType Type; - - protected: - - static void _overrideFeatures( ProcessedMaterial *mat, - U32 stageNum, - MaterialFeatureData &fd, - const FeatureSet &features ); - - BaseMatInstance *mGlowMatInst; - }; - - SimObjectPtr mGlowEffect; - RenderParticleMgr *mParticleRenderMgr; -}; - - -#endif // _RENDERGLOWMGR_H_ diff --git a/Engine/source/renderInstance/renderPassManager.cpp b/Engine/source/renderInstance/renderPassManager.cpp index 5c88041c7..fdcf76936 100644 --- a/Engine/source/renderInstance/renderPassManager.cpp +++ b/Engine/source/renderInstance/renderPassManager.cpp @@ -35,7 +35,6 @@ #include "renderInstance/renderObjectMgr.h" #include "renderInstance/renderMeshMgr.h" #include "renderInstance/renderTranslucentMgr.h" -#include "renderInstance/renderGlowMgr.h" #include "renderInstance/renderTerrainMgr.h" #include "core/util/safeDelete.h" #include "math/util/matrixSet.h" diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 33c3f520d..1fd6276d3 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -2519,23 +2519,22 @@ void AlphaTestGLSL::processPix( Vector &componentList, //**************************************************************************** // GlowMask //**************************************************************************** - void GlowMaskGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { - output = NULL; - - // Get the output color... and make it black to mask out - // glow passes rendered before us. - // - // The shader compiler will optimize out all the other - // code above that doesn't contribute to the alpha mask. - Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - if ( color ) - output = new GenOp( " @.rgb = vec3(0);\r\n", color ); + //determine output target + ShaderFeature::OutputTarget inTarg, outTarg; + inTarg = outTarg = ShaderFeature::DefaultTarget; + if (fd.features[MFT_isDeferred]) + { + inTarg = ShaderFeature::RenderTarget1; + outTarg = ShaderFeature::RenderTarget3; + } + Var* inCol = (Var*)LangElement::find(getOutputTargetVarName(inTarg)); + Var* outCol = (Var*)LangElement::find(getOutputTargetVarName(outTarg)); + output = new GenOp(" @.rgb += @.rgb*10;\r\n", outCol, inCol); } - //**************************************************************************** // RenderTargetZero //**************************************************************************** diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.h b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.h index 5db741ded..e7bcea21f 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.h +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.h @@ -552,11 +552,9 @@ public: class GlowMaskGLSL : public ShaderFeatureGLSL { public: + void processPix( Vector &componentList, const MaterialFeatureData &fd ) override; - - Material::BlendOp getBlendOp() override { return Material::None; } - String getName() override { return "Glow Mask"; diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index 0f1bf06fd..8e7542052 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -2592,23 +2592,22 @@ void AlphaTestHLSL::processPix( Vector &componentList, //**************************************************************************** // GlowMask //**************************************************************************** - void GlowMaskHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { - output = NULL; - - // Get the output color... and make it black to mask out - // glow passes rendered before us. - // - // The shader compiler will optimize out all the other - // code above that doesn't contribute to the alpha mask. - Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - if ( color ) - output = new GenOp( " @.rgb = 0;\r\n", color ); + //determine output target + ShaderFeature::OutputTarget inTarg, outTarg; + inTarg = outTarg = ShaderFeature::DefaultTarget; + if (fd.features[MFT_isDeferred]) + { + inTarg = ShaderFeature::RenderTarget1; + outTarg = ShaderFeature::RenderTarget3; + } + Var* inCol = (Var*)LangElement::find(getOutputTargetVarName(inTarg)); + Var* outCol = (Var*)LangElement::find(getOutputTargetVarName(outTarg)); + output = new GenOp(" @.rgb += @.rgb*10;\r\n", outCol, inCol); } - //**************************************************************************** // RenderTargetZero //**************************************************************************** diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.h b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.h index 49c32e66e..627f1019a 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.h +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.h @@ -555,11 +555,9 @@ public: class GlowMaskHLSL : public ShaderFeatureHLSL { public: + void processPix( Vector &componentList, const MaterialFeatureData &fd ) override; - - Material::BlendOp getBlendOp() override { return Material::None; } - String getName() override { return "Glow Mask"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.tscript b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.tscript index 74feb289d..d77dc2511 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.tscript +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.tscript @@ -407,7 +407,7 @@ singleton PostEffect( DepthOfFieldPostFX ) enabled = false; renderTime = "PFXAfterBin"; - renderBin = "GlowBin"; + renderBin = "FogBin"; renderPriority = 0.1; shader = PFX_DOFDownSampleShader; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.tscript b/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.tscript index 8f2c5a72d..0e3ce4457 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.tscript +++ b/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.tscript @@ -20,29 +20,6 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- - -singleton ShaderData( PFX_GlowBlurVertShader ) -{ - DXVertexShaderFile = "./glowBlurV.hlsl"; - DXPixelShaderFile = "./glowBlurP.hlsl"; - - OGLVertexShaderFile = "./glowBlurV.glsl"; - OGLPixelShaderFile = "./glowBlurP.glsl"; - - defines = "BLUR_DIR=float2(0.0,1.0)"; - - samplerNames[0] = "$diffuseMap"; - - pixVersion = 2.0; -}; - - -singleton ShaderData( PFX_GlowBlurHorzShader : PFX_GlowBlurVertShader ) -{ - defines = "BLUR_DIR=float2(1.0,0.0)"; -}; - - singleton GFXStateBlockData( PFX_GlowCombineStateBlock : PFX_DefaultStateBlock ) { // Use alpha test to save some fillrate @@ -59,54 +36,6 @@ singleton GFXStateBlockData( PFX_GlowCombineStateBlock : PFX_DefaultStateBlock ) blendDest = GFXBlendOne; }; - -singleton PostEffect( GlowPostFX ) -{ - // Do not allow the glow effect to work in reflection - // passes by default so we don't do the extra drawing. - allowReflectPass = false; - - renderTime = "PFXAfterBin"; - renderBin = "GlowBin"; - renderPriority = 1; - - // First we down sample the glow buffer. - shader = PFX_PassthruShader; - stateBlock = PFX_DefaultStateBlock; - texture[0] = "#glowbuffer"; - target = "$outTex"; - targetScale = "0.5 0.5"; - - enabled = true; - - // Blur vertically - new PostEffect() - { - shader = PFX_GlowBlurVertShader; - stateBlock = PFX_DefaultStateBlock; - texture[0] = "$inTex"; - target = "$outTex"; - }; - - // Blur horizontally - new PostEffect() - { - shader = PFX_GlowBlurHorzShader; - stateBlock = PFX_DefaultStateBlock; - texture[0] = "$inTex"; - target = "$outTex"; - }; - - // Upsample and combine with the back buffer. - new PostEffect() - { - shader = PFX_PassthruShader; - stateBlock = PFX_GlowCombineStateBlock; - texture[0] = "$inTex"; - target = "$backBuffer"; - }; -}; - singleton ShaderData( PFX_VolFogGlowBlurVertShader ) { DXVertexShaderFile = "./glowBlurV.hlsl"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.tscript b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.tscript index 2d30550a5..781333dce 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.tscript +++ b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.tscript @@ -48,7 +48,7 @@ singleton PostEffect( TurbulencePostFX ) allowReflectPass = true; renderTime = "PFXAfterDiffuse"; - renderBin = "GlowBin"; + renderBin = "FogBin"; renderPriority = 0.5; // Render after the glows themselves shader = PFX_TurbulenceShader; diff --git a/Templates/BaseGame/game/core/rendering/scripts/renderManager.tscript b/Templates/BaseGame/game/core/rendering/scripts/renderManager.tscript index 34a48f64a..e3461b199 100644 --- a/Templates/BaseGame/game/core/rendering/scripts/renderManager.tscript +++ b/Templates/BaseGame/game/core/rendering/scripts/renderManager.tscript @@ -79,10 +79,7 @@ function initRenderManager() DiffuseRenderPassManager.addManager( new RenderTranslucentMgr(TranslucentBin){ renderOrder = 1.4; processAddOrder = 1.4; } ); DiffuseRenderPassManager.addManager(new RenderObjectMgr(FogBin){ bintype = "ObjectVolumetricFog"; renderOrder = 1.45; processAddOrder = 1.45; } ); - - // Note that the GlowPostFx is triggered after this bin. - DiffuseRenderPassManager.addManager( new RenderGlowMgr(GlowBin) { renderOrder = 1.5; processAddOrder = 1.5; } ); - + // We render any editor stuff from this bin. Note that the HDR is // completed before this bin to keep editor elements from tone mapping. DiffuseRenderPassManager.addManager( new RenderObjectMgr(EditorBin) { bintype = "Editor"; renderOrder = 1.6; processAddOrder = 1.6; } );