Using Post Effects Without Advanced Lighting
by Greg G · in Torque 3D Professional · 06/04/2009 (5:19 pm) · 10 replies
Why do post effects only work when advanced lighting is turned on? If advanced lighting is required to use post effects is there any way to turn off dynamic shadows and still have post effects?
#2
In basicLightManager.cpp, add these:
Then in your script:
06/04/2009 (7:14 pm)
In basicLightManager.h, add this line...class RenderPrePassMgr;
class BasicLightManager : public LightManager
{
// ...
Map<GFXShader*, LightingShaderConstants> mConstantLookup;
GFXShader *mLastShader;
LightingShaderConstants *mLastConstants;
SimObjectPtr<RenderPrePassMgr> mPrePassRenderBin; // ADD THIS
};In basicLightManager.cpp, add these:
#include "renderInstance/renderPrePassMgr.h"
// ...
void BasicLightManager::activate( SceneGraph *sceneManager )
{
// ...
FEATUREMGR->unregisterFeature( MFT_MinnaertShading );
FEATUREMGR->unregisterFeature( MFT_SubSurface );
// ADD THESE LINES
// Look for the prepass bin...
RenderPrePassMgr *prePassBin = NULL;
RenderPassManager *rpm = getSceneManager()->getRenderPass();
for( U32 i = 0; i < rpm->getManagerCount(); i++ )
{
RenderBinManager *bin = rpm->getManager(i);
if( bin->getRenderInstType() == RenderPrePassMgr::RIT_PrePass )
{
prePassBin = (RenderPrePassMgr*)bin;
break;
}
}
// If we didn't find the prepass bin, and the pref for a pre-pass bin is set,
// than create one.
const bool bBLMPrePass = Con::getBoolVariable("$pref::basicLightingPrePass", false);
if ( !prePassBin && bBLMPrePass )
{
// Find a 64bit format that supports blending.
Vector<GFXFormat> formats;
formats.push_back( GFXFormatR16G16B16A16 );
formats.push_back( GFXFormatR16G16B16A16F );
GFXFormat gBufferFormat = GFX->selectSupportedFormat( &GFXDefaultRenderTargetProfile,
formats,
true,
true );
prePassBin = new RenderPrePassMgr( true, gBufferFormat );
prePassBin->registerObject();
rpm->addManager( prePassBin );
mPrePassRenderBin = prePassBin;
}
gClientSceneGraph->setPostEffectFog( bBLMPrePass );
// END ADD
// ...
[code]
void BasicLightManager::deactivate()
{
Parent::deactivate();
// ADD THESE LINES
if ( mPrePassRenderBin )
mPrePassRenderBin->deleteObject();
mPrePassRenderBin = NULL;
// END ADD
// ...
}Then in your script:
$pref::basicLightingPrePass = true;
#4
PostEffects that depend on AL features like having access to the depth buffer and scene normals do not work in BL.
As Pat shows you can add the PrePass bin to BL.... but it sort of defeats the purpose of BL. If your rendering the scene twice and holding on to an extra buffer of depth info why not use Advanced Lighting and get deferred lights and shadows as part of it.
Anyways.... you have the code ... hack away! :)
06/04/2009 (8:10 pm)
PostEffects work in BL mode.PostEffects that depend on AL features like having access to the depth buffer and scene normals do not work in BL.
As Pat shows you can add the PrePass bin to BL.... but it sort of defeats the purpose of BL. If your rendering the scene twice and holding on to an extra buffer of depth info why not use Advanced Lighting and get deferred lights and shadows as part of it.
Anyways.... you have the code ... hack away! :)
#5
Yes... don't check 'Use Shadows' on your lights.
06/04/2009 (8:11 pm)
And...Quote:is there any way to turn off dynamic shadows
Yes... don't check 'Use Shadows' on your lights.
#6
Heh, I don't know why this just made me laugh. I'm going to take this to assume there isn't a setting to override this value.
I think that's what Greg was thinking. Use AL but turn off the shadow pass. Though I'm not sure what improvement that would be since it's already done a lot of the work at that point.
06/05/2009 (8:54 am)
Quote:Yes... don't check 'Use Shadows' on your lights.
Heh, I don't know why this just made me laugh. I'm going to take this to assume there isn't a setting to override this value.
I think that's what Greg was thinking. Use AL but turn off the shadow pass. Though I'm not sure what improvement that would be since it's already done a lot of the work at that point.
#7
@Brett: the MOST expensive feature in the AL is the actual rendering of the shadows to the screen. As example, currently a GeForce 6800 can handle AL without shadows fine. Heck, actually *updating* the shadow buffer isn't taxing my test 6800, its the shader that draws it to the screen that's expensive: if I move the camera so I see mostly the sky, my framerate increasea a lot.
The current shadow shaders are designed for cards spec'ed from NV8800 and above, which have tons of fillrate: the softening algorithm uses diffuse sampling which kills anything using GDDR2, or integrated.
It has been reported that in the future more options will be added so shadows can scale down to lower specs. I'd be very happy with a simple PCF, which should run acceptably even on a NV 9400.
06/05/2009 (9:19 am)
From what I see, Basic Lighting purpose it to support the lowest of the lowest hardware (like the DX8 mode in Valve's Source Engine), while Advanced Lighting will be updated to be scalable to support mid-range and even low-mid-range cards.@Brett: the MOST expensive feature in the AL is the actual rendering of the shadows to the screen. As example, currently a GeForce 6800 can handle AL without shadows fine. Heck, actually *updating* the shadow buffer isn't taxing my test 6800, its the shader that draws it to the screen that's expensive: if I move the camera so I see mostly the sky, my framerate increasea a lot.
The current shadow shaders are designed for cards spec'ed from NV8800 and above, which have tons of fillrate: the softening algorithm uses diffuse sampling which kills anything using GDDR2, or integrated.
It has been reported that in the future more options will be added so shadows can scale down to lower specs. I'd be very happy with a simple PCF, which should run acceptably even on a NV 9400.
#8
06/05/2009 (10:10 am)
Thanks for all the info. Yeah, I'm just trying to figure how inter dependent all the effects are since our project requires us to be able to precisely control performance as much as possible. We also have multiple view ports and we would like to control performance per view port. So I was just trying to get a broad overview of how things fit together.
#9
Good info Manoel, thanks.
06/05/2009 (10:35 am)
Definitely. Breaking down the different pieces to find out what affects performance in what scenarios really gives an idea of what options need to be configurable and to what extent.Good info Manoel, thanks.
#10
06/05/2009 (11:39 am)
Taking a look at the shadow shaders, I just found out that there's seem to be support for using RGBA8888 for shadowmaps, with the depth values "encoded" across the RGBA channels. That'll surely be a blessing for not-so-modern videocards, where simply dealing with FP textures or higher precision formats is expensive. I remember a *very* old ATI demo that did that, and it ran pretty fast on virtually anything capable of shaders.
Associate Steve Acaster
[YorkshireRifles.com]
In the meantime, if you want to save a little fps, disable "castshadows" in sun object. It should still allow for post effects like edge smoothing.