mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
Merge pull request #1284 from Azaezel/nukeGlow
remove glowbin as it's own render pass
This commit is contained in:
commit
eeb002ce6b
19 changed files with 44 additions and 510 deletions
|
|
@ -261,16 +261,16 @@ void GlowMapGLSL::processPix(Vector<ShaderComponent*>& componentList, const Mate
|
||||||
targ->setType("vec4");
|
targ->setType("vec4");
|
||||||
targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3));
|
targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3));
|
||||||
targ->setStructName("OUT");
|
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
|
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
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -264,16 +264,16 @@ void GlowMapHLSL::processPix(Vector<ShaderComponent*> &componentList, const Mate
|
||||||
targ->setType("fragout");
|
targ->setType("fragout");
|
||||||
targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3));
|
targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3));
|
||||||
targ->setStructName("OUT");
|
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
|
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
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ ImplementFeatureType( MFT_AccuMap, MFG_PreLighting, 2.0f, true );
|
||||||
ImplementFeatureType(MFT_ReflectionProbes, MFG_Lighting, 1.0f, true);
|
ImplementFeatureType(MFT_ReflectionProbes, MFG_Lighting, 1.0f, true);
|
||||||
ImplementFeatureType( MFT_RTLighting, MFG_Lighting, 2.0f, true );
|
ImplementFeatureType( MFT_RTLighting, MFG_Lighting, 2.0f, true );
|
||||||
ImplementFeatureType( MFT_GlowMap, MFG_Lighting, 3.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_LightMap, MFG_Lighting, 4.0f, true );
|
||||||
ImplementFeatureType( MFT_ToneMap, MFG_Lighting, 5.0f, true );
|
ImplementFeatureType( MFT_ToneMap, MFG_Lighting, 5.0f, true );
|
||||||
ImplementFeatureType( MFT_VertLitTone, MFG_Lighting, 6.0f, false );
|
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_VertLit, MFG_Lighting, 9.0f, true );
|
||||||
ImplementFeatureType( MFT_MinnaertShading, MFG_Lighting, 10.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_Visibility, MFG_PostLighting, 2.0f, true );
|
||||||
ImplementFeatureType( MFT_Fog, MFG_PostProcess, 3.0f, true );
|
ImplementFeatureType( MFT_Fog, MFG_PostProcess, 3.0f, true );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ void ProcessedMaterial::addStateBlockDesc(const GFXStateBlockDesc& sb)
|
||||||
mUserDefined = sb;
|
mUserDefined = sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateGlow, GFXStateBlockDesc& stateReflect)
|
void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateReflect)
|
||||||
{
|
{
|
||||||
// Translucency
|
// Translucency
|
||||||
stateTranslucent.blendDefined = true;
|
stateTranslucent.blendDefined = true;
|
||||||
|
|
@ -211,10 +211,6 @@ void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslu
|
||||||
stateTranslucent.alphaTestFunc = GFXCmpGreaterEqual;
|
stateTranslucent.alphaTestFunc = GFXCmpGreaterEqual;
|
||||||
stateTranslucent.samplersDefined = true;
|
stateTranslucent.samplersDefined = true;
|
||||||
|
|
||||||
// Glow
|
|
||||||
stateGlow.zDefined = true;
|
|
||||||
stateGlow.zWriteEnable = false;
|
|
||||||
|
|
||||||
// Reflect
|
// Reflect
|
||||||
stateReflect.cullDefined = true;
|
stateReflect.cullDefined = true;
|
||||||
stateReflect.cullMode = mMaterial->mDoubleSided ? GFXCullNone : GFXCullCW;
|
stateReflect.cullMode = mMaterial->mDoubleSided ? GFXCullNone : GFXCullCW;
|
||||||
|
|
@ -316,11 +312,10 @@ void ProcessedMaterial::_initPassStateBlock( RenderPassData *rpd, GFXStateBlockD
|
||||||
void ProcessedMaterial::_initRenderStateStateBlocks( RenderPassData *rpd )
|
void ProcessedMaterial::_initRenderStateStateBlocks( RenderPassData *rpd )
|
||||||
{
|
{
|
||||||
GFXStateBlockDesc stateTranslucent;
|
GFXStateBlockDesc stateTranslucent;
|
||||||
GFXStateBlockDesc stateGlow;
|
|
||||||
GFXStateBlockDesc stateReflect;
|
GFXStateBlockDesc stateReflect;
|
||||||
GFXStateBlockDesc statePass;
|
GFXStateBlockDesc statePass;
|
||||||
|
|
||||||
_initStateBlockTemplates( stateTranslucent, stateGlow, stateReflect );
|
_initStateBlockTemplates( stateTranslucent, stateReflect );
|
||||||
_initPassStateBlock( rpd, statePass );
|
_initPassStateBlock( rpd, statePass );
|
||||||
|
|
||||||
// Ok, we've got our templates set up, let's combine them together based on state and
|
// 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);
|
stateFinal.addDesc(stateReflect);
|
||||||
if (i & RenderPassData::STATE_TRANSLUCENT)
|
if (i & RenderPassData::STATE_TRANSLUCENT)
|
||||||
stateFinal.addDesc(stateTranslucent);
|
stateFinal.addDesc(stateTranslucent);
|
||||||
if (i & RenderPassData::STATE_GLOW)
|
|
||||||
stateFinal.addDesc(stateGlow);
|
|
||||||
|
|
||||||
stateFinal.addDesc(statePass);
|
stateFinal.addDesc(statePass);
|
||||||
|
|
||||||
|
|
@ -359,9 +352,6 @@ U32 ProcessedMaterial::_getRenderStateIndex( const SceneRenderState *sceneState,
|
||||||
// For example sgData.visibility would be bad to use
|
// For example sgData.visibility would be bad to use
|
||||||
// in here without changing how RenderMeshMgr works.
|
// in here without changing how RenderMeshMgr works.
|
||||||
|
|
||||||
if ( sgData.binType == SceneData::GlowBin )
|
|
||||||
currState |= RenderPassData::STATE_GLOW;
|
|
||||||
|
|
||||||
if ( sceneState && sceneState->isReflectPass() )
|
if ( sceneState && sceneState->isReflectPass() )
|
||||||
currState |= RenderPassData::STATE_REFLECT;
|
currState |= RenderPassData::STATE_REFLECT;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,8 @@ public:
|
||||||
{
|
{
|
||||||
STATE_REFLECT = 1,
|
STATE_REFLECT = 1,
|
||||||
STATE_TRANSLUCENT = 2,
|
STATE_TRANSLUCENT = 2,
|
||||||
STATE_GLOW = 4,
|
STATE_WIREFRAME = 4,
|
||||||
STATE_WIREFRAME = 8,
|
STATE_MAX = 8
|
||||||
STATE_MAX = 16
|
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
@ -301,7 +300,7 @@ protected:
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
/// Creates the default state block templates, used by initStateBlocks.
|
/// 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.
|
/// Does the base render state block setting, normally per pass.
|
||||||
virtual void _initPassStateBlock( RenderPassData *rpd, GFXStateBlockDesc& result);
|
virtual void _initPassStateBlock( RenderPassData *rpd, GFXStateBlockDesc& result);
|
||||||
|
|
|
||||||
|
|
@ -348,7 +348,6 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
||||||
//
|
//
|
||||||
if ( features.hasFeature( MFT_UseInstancing ) &&
|
if ( features.hasFeature( MFT_UseInstancing ) &&
|
||||||
mMaxStages == 1 &&
|
mMaxStages == 1 &&
|
||||||
!mMaterial->mGlow[0] &&
|
|
||||||
shaderVersion >= 3.0f )
|
shaderVersion >= 3.0f )
|
||||||
fd.features.addFeature( MFT_UseInstancing );
|
fd.features.addFeature( MFT_UseInstancing );
|
||||||
|
|
||||||
|
|
@ -521,6 +520,9 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
||||||
mVertexFormat->hasColor() )
|
mVertexFormat->hasColor() )
|
||||||
fd.features.addFeature( MFT_DiffuseVertColor );
|
fd.features.addFeature( MFT_DiffuseVertColor );
|
||||||
|
|
||||||
|
if (mMaterial->mGlow[stageNum])
|
||||||
|
fd.features.addFeature(MFT_GlowMask);
|
||||||
|
|
||||||
// Allow features to add themselves.
|
// Allow features to add themselves.
|
||||||
for ( U32 i = 0; i < FEATUREMGR->getFeatureCount(); i++ )
|
for ( U32 i = 0; i < FEATUREMGR->getFeatureCount(); i++ )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,6 @@ struct SceneData
|
||||||
/// the special bins we care about.
|
/// the special bins we care about.
|
||||||
RegularBin = 0,
|
RegularBin = 0,
|
||||||
|
|
||||||
/// The glow render bin.
|
|
||||||
/// @see RenderGlowMgr
|
|
||||||
GlowBin,
|
|
||||||
|
|
||||||
/// The deferred render bin.
|
/// The deferred render bin.
|
||||||
/// @RenderDeferredMgr
|
/// @RenderDeferredMgr
|
||||||
DeferredBin,
|
DeferredBin,
|
||||||
|
|
|
||||||
|
|
@ -683,7 +683,8 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum,
|
||||||
type == MFT_UseInstancing ||
|
type == MFT_UseInstancing ||
|
||||||
type == MFT_DiffuseVertColor ||
|
type == MFT_DiffuseVertColor ||
|
||||||
type == MFT_DetailMap ||
|
type == MFT_DetailMap ||
|
||||||
type == MFT_DiffuseMapAtlas)
|
type == MFT_DiffuseMapAtlas||
|
||||||
|
type == MFT_GlowMask)
|
||||||
newFeatures.addFeature( type );
|
newFeatures.addFeature( type );
|
||||||
|
|
||||||
// Add any transform features.
|
// Add any transform features.
|
||||||
|
|
|
||||||
|
|
@ -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<PostEffect*>( 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<ParticleRenderInst*>(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; j<binSize; )
|
|
||||||
{
|
|
||||||
RenderInst *_ri = mElementList[j].inst;
|
|
||||||
if(_ri->type == 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<RenderParticleMgr *>(bin);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ParticleRenderInst *ri = static_cast<ParticleRenderInst*>(_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<MeshRenderInst*>(_ri);
|
|
||||||
|
|
||||||
setupSGData( ri, sgData );
|
|
||||||
|
|
||||||
BaseMatInstance *mat = ri->matInst;
|
|
||||||
GlowMaterialHook *hook = mat->getHook<GlowMaterialHook>();
|
|
||||||
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; a<binSize; a++ )
|
|
||||||
{
|
|
||||||
if (mElementList[a].inst->type == RenderPassManager::RIT_Particle)
|
|
||||||
break;
|
|
||||||
|
|
||||||
MeshRenderInst *passRI = static_cast<MeshRenderInst*>(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 );
|
|
||||||
}
|
|
||||||
|
|
@ -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 <renderInstance/renderParticleMgr.h>
|
|
||||||
|
|
||||||
|
|
||||||
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<PostEffect> mGlowEffect;
|
|
||||||
RenderParticleMgr *mParticleRenderMgr;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _RENDERGLOWMGR_H_
|
|
||||||
|
|
@ -35,7 +35,6 @@
|
||||||
#include "renderInstance/renderObjectMgr.h"
|
#include "renderInstance/renderObjectMgr.h"
|
||||||
#include "renderInstance/renderMeshMgr.h"
|
#include "renderInstance/renderMeshMgr.h"
|
||||||
#include "renderInstance/renderTranslucentMgr.h"
|
#include "renderInstance/renderTranslucentMgr.h"
|
||||||
#include "renderInstance/renderGlowMgr.h"
|
|
||||||
#include "renderInstance/renderTerrainMgr.h"
|
#include "renderInstance/renderTerrainMgr.h"
|
||||||
#include "core/util/safeDelete.h"
|
#include "core/util/safeDelete.h"
|
||||||
#include "math/util/matrixSet.h"
|
#include "math/util/matrixSet.h"
|
||||||
|
|
|
||||||
|
|
@ -2519,23 +2519,22 @@ void AlphaTestGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
// GlowMask
|
// GlowMask
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
|
|
||||||
void GlowMaskGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
void GlowMaskGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd )
|
const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
output = NULL;
|
//determine output target
|
||||||
|
ShaderFeature::OutputTarget inTarg, outTarg;
|
||||||
// Get the output color... and make it black to mask out
|
inTarg = outTarg = ShaderFeature::DefaultTarget;
|
||||||
// glow passes rendered before us.
|
if (fd.features[MFT_isDeferred])
|
||||||
//
|
{
|
||||||
// The shader compiler will optimize out all the other
|
inTarg = ShaderFeature::RenderTarget1;
|
||||||
// code above that doesn't contribute to the alpha mask.
|
outTarg = ShaderFeature::RenderTarget3;
|
||||||
Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
}
|
||||||
if ( color )
|
Var* inCol = (Var*)LangElement::find(getOutputTargetVarName(inTarg));
|
||||||
output = new GenOp( " @.rgb = vec3(0);\r\n", color );
|
Var* outCol = (Var*)LangElement::find(getOutputTargetVarName(outTarg));
|
||||||
|
output = new GenOp(" @.rgb += @.rgb*10;\r\n", outCol, inCol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
// RenderTargetZero
|
// RenderTargetZero
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -552,11 +552,9 @@ public:
|
||||||
class GlowMaskGLSL : public ShaderFeatureGLSL
|
class GlowMaskGLSL : public ShaderFeatureGLSL
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void processPix( Vector<ShaderComponent*> &componentList,
|
void processPix( Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd ) override;
|
const MaterialFeatureData &fd ) override;
|
||||||
|
|
||||||
Material::BlendOp getBlendOp() override { return Material::None; }
|
|
||||||
|
|
||||||
String getName() override
|
String getName() override
|
||||||
{
|
{
|
||||||
return "Glow Mask";
|
return "Glow Mask";
|
||||||
|
|
|
||||||
|
|
@ -2592,23 +2592,22 @@ void AlphaTestHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
// GlowMask
|
// GlowMask
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
|
|
||||||
void GlowMaskHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
void GlowMaskHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd )
|
const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
output = NULL;
|
//determine output target
|
||||||
|
ShaderFeature::OutputTarget inTarg, outTarg;
|
||||||
// Get the output color... and make it black to mask out
|
inTarg = outTarg = ShaderFeature::DefaultTarget;
|
||||||
// glow passes rendered before us.
|
if (fd.features[MFT_isDeferred])
|
||||||
//
|
{
|
||||||
// The shader compiler will optimize out all the other
|
inTarg = ShaderFeature::RenderTarget1;
|
||||||
// code above that doesn't contribute to the alpha mask.
|
outTarg = ShaderFeature::RenderTarget3;
|
||||||
Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
}
|
||||||
if ( color )
|
Var* inCol = (Var*)LangElement::find(getOutputTargetVarName(inTarg));
|
||||||
output = new GenOp( " @.rgb = 0;\r\n", color );
|
Var* outCol = (Var*)LangElement::find(getOutputTargetVarName(outTarg));
|
||||||
|
output = new GenOp(" @.rgb += @.rgb*10;\r\n", outCol, inCol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
// RenderTargetZero
|
// RenderTargetZero
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -555,11 +555,9 @@ public:
|
||||||
class GlowMaskHLSL : public ShaderFeatureHLSL
|
class GlowMaskHLSL : public ShaderFeatureHLSL
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void processPix( Vector<ShaderComponent*> &componentList,
|
void processPix( Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd ) override;
|
const MaterialFeatureData &fd ) override;
|
||||||
|
|
||||||
Material::BlendOp getBlendOp() override { return Material::None; }
|
|
||||||
|
|
||||||
String getName() override
|
String getName() override
|
||||||
{
|
{
|
||||||
return "Glow Mask";
|
return "Glow Mask";
|
||||||
|
|
|
||||||
|
|
@ -407,7 +407,7 @@ singleton PostEffect( DepthOfFieldPostFX )
|
||||||
enabled = false;
|
enabled = false;
|
||||||
|
|
||||||
renderTime = "PFXAfterBin";
|
renderTime = "PFXAfterBin";
|
||||||
renderBin = "GlowBin";
|
renderBin = "FogBin";
|
||||||
renderPriority = 0.1;
|
renderPriority = 0.1;
|
||||||
|
|
||||||
shader = PFX_DOFDownSampleShader;
|
shader = PFX_DOFDownSampleShader;
|
||||||
|
|
|
||||||
|
|
@ -20,29 +20,6 @@
|
||||||
// IN THE SOFTWARE.
|
// 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 )
|
singleton GFXStateBlockData( PFX_GlowCombineStateBlock : PFX_DefaultStateBlock )
|
||||||
{
|
{
|
||||||
// Use alpha test to save some fillrate
|
// Use alpha test to save some fillrate
|
||||||
|
|
@ -59,54 +36,6 @@ singleton GFXStateBlockData( PFX_GlowCombineStateBlock : PFX_DefaultStateBlock )
|
||||||
blendDest = GFXBlendOne;
|
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 )
|
singleton ShaderData( PFX_VolFogGlowBlurVertShader )
|
||||||
{
|
{
|
||||||
DXVertexShaderFile = "./glowBlurV.hlsl";
|
DXVertexShaderFile = "./glowBlurV.hlsl";
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ singleton PostEffect( TurbulencePostFX )
|
||||||
allowReflectPass = true;
|
allowReflectPass = true;
|
||||||
|
|
||||||
renderTime = "PFXAfterDiffuse";
|
renderTime = "PFXAfterDiffuse";
|
||||||
renderBin = "GlowBin";
|
renderBin = "FogBin";
|
||||||
renderPriority = 0.5; // Render after the glows themselves
|
renderPriority = 0.5; // Render after the glows themselves
|
||||||
|
|
||||||
shader = PFX_TurbulenceShader;
|
shader = PFX_TurbulenceShader;
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,6 @@ function initRenderManager()
|
||||||
|
|
||||||
DiffuseRenderPassManager.addManager(new RenderObjectMgr(FogBin){ bintype = "ObjectVolumetricFog"; renderOrder = 1.45; processAddOrder = 1.45; } );
|
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
|
// We render any editor stuff from this bin. Note that the HDR is
|
||||||
// completed before this bin to keep editor elements from tone mapping.
|
// completed before this bin to keep editor elements from tone mapping.
|
||||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(EditorBin) { bintype = "Editor"; renderOrder = 1.6; processAddOrder = 1.6; } );
|
DiffuseRenderPassManager.addManager( new RenderObjectMgr(EditorBin) { bintype = "Editor"; renderOrder = 1.6; processAddOrder = 1.6; } );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue