mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
Goes and replaces the references/names that use Prepass to be Deferred, since we're actually using deferred.
This commit is contained in:
parent
b052a1f970
commit
af8fbf0e3a
122 changed files with 641 additions and 641 deletions
|
|
@ -1214,7 +1214,7 @@ void DecalManager::prepRenderImage( SceneRenderState* state )
|
||||||
|
|
||||||
// Make it the sort distance the max distance so that
|
// Make it the sort distance the max distance so that
|
||||||
// it renders after all the other opaque geometry in
|
// it renders after all the other opaque geometry in
|
||||||
// the prepass bin.
|
// the deferred bin.
|
||||||
baseRenderInst.sortDistSq = F32_MAX;
|
baseRenderInst.sortDistSq = F32_MAX;
|
||||||
|
|
||||||
Vector<DecalBatch> batches;
|
Vector<DecalBatch> batches;
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
#include "materials/sceneData.h"
|
#include "materials/sceneData.h"
|
||||||
#include "materials/materialFeatureTypes.h"
|
#include "materials/materialFeatureTypes.h"
|
||||||
#include "materials/matInstance.h"
|
#include "materials/matInstance.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
#include "console/engineAPI.h"
|
#include "console/engineAPI.h"
|
||||||
|
|
||||||
/// This is used for rendering ground cover billboards.
|
/// This is used for rendering ground cover billboards.
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,7 @@ void LevelInfo::_onLMActivate(const char *lm, bool enable)
|
||||||
{
|
{
|
||||||
AssertFatal(dynamic_cast<AdvancedLightManager *>(LIGHTMGR), "Bad light manager type!");
|
AssertFatal(dynamic_cast<AdvancedLightManager *>(LIGHTMGR), "Bad light manager type!");
|
||||||
AdvancedLightManager *lightMgr = static_cast<AdvancedLightManager *>(LIGHTMGR);
|
AdvancedLightManager *lightMgr = static_cast<AdvancedLightManager *>(LIGHTMGR);
|
||||||
lightMgr->getLightBinManager()->MRTLightmapsDuringPrePass(mAdvancedLightmapSupport);
|
lightMgr->getLightBinManager()->MRTLightmapsDuringDeferred(mAdvancedLightmapSupport);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ VolumetricFog::VolumetricFog()
|
||||||
|
|
||||||
mTypeMask |= EnvironmentObjectType | StaticObjectType;
|
mTypeMask |= EnvironmentObjectType | StaticObjectType;
|
||||||
|
|
||||||
mPrepassTarget = NULL;
|
mDeferredTarget = NULL;
|
||||||
mDepthBufferTarget = NULL;
|
mDepthBufferTarget = NULL;
|
||||||
mFrontBufferTarget = NULL;
|
mFrontBufferTarget = NULL;
|
||||||
|
|
||||||
|
|
@ -771,17 +771,17 @@ void VolumetricFog::_leaveFog(ShapeBase *control)
|
||||||
|
|
||||||
bool VolumetricFog::setupRenderer()
|
bool VolumetricFog::setupRenderer()
|
||||||
{
|
{
|
||||||
// Search for the prepass rendertarget and shadermacros.
|
// Search for the deferred rendertarget and shadermacros.
|
||||||
mPrepassTarget = NamedTexTarget::find("prepass");
|
mDeferredTarget = NamedTexTarget::find("deferred");
|
||||||
if (!mPrepassTarget.isValid())
|
if (!mDeferredTarget.isValid())
|
||||||
{
|
{
|
||||||
Con::errorf("VolumetricFog::setupRenderer - could not find PrepassTarget");
|
Con::errorf("VolumetricFog::setupRenderer - could not find DeferredTarget");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<GFXShaderMacro> macros;
|
Vector<GFXShaderMacro> macros;
|
||||||
if (mPrepassTarget)
|
if (mDeferredTarget)
|
||||||
mPrepassTarget->getShaderMacros(¯os);
|
mDeferredTarget->getShaderMacros(¯os);
|
||||||
|
|
||||||
// Search the depth and frontbuffers which are created by the VolumetricFogRTManager
|
// Search the depth and frontbuffers which are created by the VolumetricFogRTManager
|
||||||
|
|
||||||
|
|
@ -799,27 +799,27 @@ bool VolumetricFog::setupRenderer()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find and setup the prepass Shader
|
// Find and setup the deferred Shader
|
||||||
|
|
||||||
ShaderData *shaderData;
|
ShaderData *shaderData;
|
||||||
mPrePassShader = Sim::findObject("VolumetricFogPrePassShader", shaderData) ?
|
mDeferredShader = Sim::findObject("VolumetricFogDeferredShader", shaderData) ?
|
||||||
shaderData->getShader() : NULL;
|
shaderData->getShader() : NULL;
|
||||||
if (!mPrePassShader)
|
if (!mDeferredShader)
|
||||||
{
|
{
|
||||||
Con::errorf("VolumetricFog::setupRenderer - could not find VolumetricFogPrePassShader");
|
Con::errorf("VolumetricFog::setupRenderer - could not find VolumetricFogDeferredShader");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create ShaderConstBuffer and Handles
|
// Create ShaderConstBuffer and Handles
|
||||||
|
|
||||||
mPPShaderConsts = mPrePassShader->allocConstBuffer();
|
mPPShaderConsts = mDeferredShader->allocConstBuffer();
|
||||||
if (mPPShaderConsts.isNull())
|
if (mPPShaderConsts.isNull())
|
||||||
{
|
{
|
||||||
Con::errorf("VolumetricFog::setupRenderer - could not allocate ShaderConstants 1.");
|
Con::errorf("VolumetricFog::setupRenderer - could not allocate ShaderConstants 1.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPPModelViewProjSC = mPrePassShader->getShaderConstHandle("$modelView");
|
mPPModelViewProjSC = mDeferredShader->getShaderConstHandle("$modelView");
|
||||||
|
|
||||||
// Find and setup the VolumetricFog Shader
|
// Find and setup the VolumetricFog Shader
|
||||||
|
|
||||||
|
|
@ -878,7 +878,7 @@ bool VolumetricFog::setupRenderer()
|
||||||
mReflFogDensitySC = mReflectionShader->getShaderConstHandle("$fogDensity");
|
mReflFogDensitySC = mReflectionShader->getShaderConstHandle("$fogDensity");
|
||||||
mReflFogStrengthSC = mReflectionShader->getShaderConstHandle("$reflStrength");
|
mReflFogStrengthSC = mReflectionShader->getShaderConstHandle("$reflStrength");
|
||||||
|
|
||||||
// Create the prepass StateBlock
|
// Create the deferred StateBlock
|
||||||
|
|
||||||
desc_preD.setCullMode(GFXCullCW);
|
desc_preD.setCullMode(GFXCullCW);
|
||||||
desc_preD.setBlend(true);
|
desc_preD.setBlend(true);
|
||||||
|
|
@ -895,7 +895,7 @@ bool VolumetricFog::setupRenderer()
|
||||||
descD.setBlend(true);
|
descD.setBlend(true);
|
||||||
descD.setZReadWrite(false, false);// desc.setZReadWrite(true, false);
|
descD.setZReadWrite(false, false);// desc.setZReadWrite(true, false);
|
||||||
|
|
||||||
// prepassBuffer sampler
|
// deferredBuffer sampler
|
||||||
descD.samplersDefined = true;
|
descD.samplersDefined = true;
|
||||||
descD.samplers[0].addressModeU = GFXAddressClamp;
|
descD.samplers[0].addressModeU = GFXAddressClamp;
|
||||||
descD.samplers[0].addressModeV = GFXAddressClamp;
|
descD.samplers[0].addressModeV = GFXAddressClamp;
|
||||||
|
|
@ -1063,7 +1063,7 @@ void VolumetricFog::render(ObjectRenderInst *ri, SceneRenderState *state, BaseMa
|
||||||
mat.scale(mObjScale);
|
mat.scale(mObjScale);
|
||||||
GFX->multWorld(mat);
|
GFX->multWorld(mat);
|
||||||
|
|
||||||
GFX->setShader(mPrePassShader);
|
GFX->setShader(mDeferredShader);
|
||||||
GFX->setShaderConstBuffer(mPPShaderConsts);
|
GFX->setShaderConstBuffer(mPPShaderConsts);
|
||||||
GFX->setStateBlock(mStateblock_preD);
|
GFX->setStateBlock(mStateblock_preD);
|
||||||
|
|
||||||
|
|
@ -1127,9 +1127,9 @@ void VolumetricFog::render(ObjectRenderInst *ri, SceneRenderState *state, BaseMa
|
||||||
mShaderConsts->setSafe(mTexScaleSC, mTexScale * mFOV);
|
mShaderConsts->setSafe(mTexScaleSC, mTexScale * mFOV);
|
||||||
mShaderConsts->setSafe(mTexTilesSC, mTexTiles);
|
mShaderConsts->setSafe(mTexTilesSC, mTexTiles);
|
||||||
|
|
||||||
GFXTextureObject *prepasstex = mPrepassTarget ? mPrepassTarget->getTexture(0) : NULL;
|
GFXTextureObject *deferredtex = mDeferredTarget ? mDeferredTarget->getTexture(0) : NULL;
|
||||||
|
|
||||||
GFX->setTexture(0, prepasstex);
|
GFX->setTexture(0, deferredtex);
|
||||||
GFX->setTexture(1, mDepthBuffer);
|
GFX->setTexture(1, mDepthBuffer);
|
||||||
GFX->setTexture(2, mFrontBuffer);
|
GFX->setTexture(2, mFrontBuffer);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ class VolumetricFog : public SceneObject
|
||||||
protected:
|
protected:
|
||||||
// Rendertargets;
|
// Rendertargets;
|
||||||
GFXTextureTargetRef z_buf;
|
GFXTextureTargetRef z_buf;
|
||||||
NamedTexTargetRef mPrepassTarget;
|
NamedTexTargetRef mDeferredTarget;
|
||||||
NamedTexTargetRef mDepthBufferTarget;
|
NamedTexTargetRef mDepthBufferTarget;
|
||||||
NamedTexTargetRef mFrontBufferTarget;
|
NamedTexTargetRef mFrontBufferTarget;
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ class VolumetricFog : public SceneObject
|
||||||
|
|
||||||
// Shaders
|
// Shaders
|
||||||
GFXShaderRef mShader;
|
GFXShaderRef mShader;
|
||||||
GFXShaderRef mPrePassShader;
|
GFXShaderRef mDeferredShader;
|
||||||
GFXShaderRef mReflectionShader;
|
GFXShaderRef mReflectionShader;
|
||||||
|
|
||||||
// Stateblocks
|
// Stateblocks
|
||||||
|
|
|
||||||
|
|
@ -739,7 +739,7 @@ void DecalRoad::prepRenderImage( SceneRenderState* state )
|
||||||
|
|
||||||
// Make it the sort distance the max distance so that
|
// Make it the sort distance the max distance so that
|
||||||
// it renders after all the other opaque geometry in
|
// it renders after all the other opaque geometry in
|
||||||
// the prepass bin.
|
// the deferred bin.
|
||||||
coreRI.sortDistSq = F32_MAX;
|
coreRI.sortDistSq = F32_MAX;
|
||||||
|
|
||||||
// If we need lights then set them up.
|
// If we need lights then set them up.
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ ConsoleDocClass( WaterObject,
|
||||||
"\t- Paramable water fog and color shift.\n\n"
|
"\t- Paramable water fog and color shift.\n\n"
|
||||||
|
|
||||||
"It will, however, look significantly different depending on the LightingManager "
|
"It will, however, look significantly different depending on the LightingManager "
|
||||||
"that is active. With Basic Lighting, we do not have a prepass texture to "
|
"that is active. With Basic Lighting, we do not have a deferred texture to "
|
||||||
"lookup per-pixel depth and therefore cannot use our rendering techniques that depend on it.\n\n"
|
"lookup per-pixel depth and therefore cannot use our rendering techniques that depend on it.\n\n"
|
||||||
|
|
||||||
"In particular, the following field groups are not used under Basic Lighting:\n"
|
"In particular, the following field groups are not used under Basic Lighting:\n"
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
#include "lighting/shadowMap/shadowMapPass.h"
|
#include "lighting/shadowMap/shadowMapPass.h"
|
||||||
#include "lighting/shadowMap/lightShadowMap.h"
|
#include "lighting/shadowMap/lightShadowMap.h"
|
||||||
#include "lighting/common/lightMapParams.h"
|
#include "lighting/common/lightMapParams.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
#include "gfx/gfxTransformSaver.h"
|
#include "gfx/gfxTransformSaver.h"
|
||||||
#include "scene/sceneManager.h"
|
#include "scene/sceneManager.h"
|
||||||
#include "scene/sceneRenderState.h"
|
#include "scene/sceneRenderState.h"
|
||||||
|
|
@ -130,7 +130,7 @@ AdvancedLightBinManager::AdvancedLightBinManager( AdvancedLightManager *lm /* =
|
||||||
// We want a full-resolution buffer
|
// We want a full-resolution buffer
|
||||||
mTargetSizeType = RenderTexTargetBinManager::WindowSize;
|
mTargetSizeType = RenderTexTargetBinManager::WindowSize;
|
||||||
|
|
||||||
mMRTLightmapsDuringPrePass = false;
|
mMRTLightmapsDuringDeferred = false;
|
||||||
|
|
||||||
Con::NotifyDelegate callback( this, &AdvancedLightBinManager::_deleteLightMaterials );
|
Con::NotifyDelegate callback( this, &AdvancedLightBinManager::_deleteLightMaterials );
|
||||||
Con::addVariableNotify( "$pref::Shadows::filterMode", callback );
|
Con::addVariableNotify( "$pref::Shadows::filterMode", callback );
|
||||||
|
|
@ -253,7 +253,7 @@ void AdvancedLightBinManager::render( SceneRenderState *state )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Clear as long as there isn't MRT population of light buffer with lightmap data
|
// Clear as long as there isn't MRT population of light buffer with lightmap data
|
||||||
if ( !MRTLightmapsDuringPrePass() )
|
if ( !MRTLightmapsDuringDeferred() )
|
||||||
GFX->clear(GFXClearTarget, ColorI(0, 0, 0, 0), 1.0f, 0);
|
GFX->clear(GFXClearTarget, ColorI(0, 0, 0, 0), 1.0f, 0);
|
||||||
|
|
||||||
// Restore transforms
|
// Restore transforms
|
||||||
|
|
@ -550,23 +550,23 @@ void AdvancedLightBinManager::setupSGData( SceneData &data, const SceneRenderSta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvancedLightBinManager::MRTLightmapsDuringPrePass( bool val )
|
void AdvancedLightBinManager::MRTLightmapsDuringDeferred( bool val )
|
||||||
{
|
{
|
||||||
// Do not enable if the GFX device can't do MRT's
|
// Do not enable if the GFX device can't do MRT's
|
||||||
if ( GFX->getNumRenderTargets() < 2 )
|
if ( GFX->getNumRenderTargets() < 2 )
|
||||||
val = false;
|
val = false;
|
||||||
|
|
||||||
if ( mMRTLightmapsDuringPrePass != val )
|
if ( mMRTLightmapsDuringDeferred != val )
|
||||||
{
|
{
|
||||||
mMRTLightmapsDuringPrePass = val;
|
mMRTLightmapsDuringDeferred = val;
|
||||||
|
|
||||||
// Reload materials to cause a feature recalculation on prepass materials
|
// Reload materials to cause a feature recalculation on deferred materials
|
||||||
if(mLightManager->isActive())
|
if(mLightManager->isActive())
|
||||||
MATMGR->flushAndReInitInstances();
|
MATMGR->flushAndReInitInstances();
|
||||||
|
|
||||||
RenderPrePassMgr *prepass;
|
RenderDeferredMgr *deferred;
|
||||||
if ( Sim::findObject( "AL_PrePassBin", prepass ) && prepass->getTargetTexture( 0 ) )
|
if ( Sim::findObject( "AL_DeferredBin", deferred ) && deferred->getTargetTexture( 0 ) )
|
||||||
prepass->updateTargets();
|
deferred->updateTargets();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -834,21 +834,21 @@ bool LightMatInstance::init( const FeatureSet &features, const GFXVertexFormat *
|
||||||
// in the same way.
|
// in the same way.
|
||||||
litState.separateAlphaBlendDefined = true;
|
litState.separateAlphaBlendDefined = true;
|
||||||
litState.separateAlphaBlendEnable = false;
|
litState.separateAlphaBlendEnable = false;
|
||||||
litState.stencilMask = RenderPrePassMgr::OpaqueDynamicLitMask | RenderPrePassMgr::OpaqueStaticLitMask;
|
litState.stencilMask = RenderDeferredMgr::OpaqueDynamicLitMask | RenderDeferredMgr::OpaqueStaticLitMask;
|
||||||
mLitState[DynamicLight] = GFX->createStateBlock(litState);
|
mLitState[DynamicLight] = GFX->createStateBlock(litState);
|
||||||
|
|
||||||
// StaticLightNonLMGeometry State: This will treat non-lightmapped geometry
|
// StaticLightNonLMGeometry State: This will treat non-lightmapped geometry
|
||||||
// in the usual way, but will not effect lightmapped geometry.
|
// in the usual way, but will not effect lightmapped geometry.
|
||||||
litState.separateAlphaBlendDefined = true;
|
litState.separateAlphaBlendDefined = true;
|
||||||
litState.separateAlphaBlendEnable = false;
|
litState.separateAlphaBlendEnable = false;
|
||||||
litState.stencilMask = RenderPrePassMgr::OpaqueDynamicLitMask;
|
litState.stencilMask = RenderDeferredMgr::OpaqueDynamicLitMask;
|
||||||
mLitState[StaticLightNonLMGeometry] = GFX->createStateBlock(litState);
|
mLitState[StaticLightNonLMGeometry] = GFX->createStateBlock(litState);
|
||||||
|
|
||||||
// StaticLightLMGeometry State: This will add specular information (alpha) but
|
// StaticLightLMGeometry State: This will add specular information (alpha) but
|
||||||
// multiply-darken color information.
|
// multiply-darken color information.
|
||||||
litState.blendDest = GFXBlendSrcColor;
|
litState.blendDest = GFXBlendSrcColor;
|
||||||
litState.blendSrc = GFXBlendZero;
|
litState.blendSrc = GFXBlendZero;
|
||||||
litState.stencilMask = RenderPrePassMgr::OpaqueStaticLitMask;
|
litState.stencilMask = RenderDeferredMgr::OpaqueStaticLitMask;
|
||||||
litState.separateAlphaBlendDefined = true;
|
litState.separateAlphaBlendDefined = true;
|
||||||
litState.separateAlphaBlendEnable = true;
|
litState.separateAlphaBlendEnable = true;
|
||||||
litState.separateAlphaBlendSrc = GFXBlendOne;
|
litState.separateAlphaBlendSrc = GFXBlendOne;
|
||||||
|
|
|
||||||
|
|
@ -121,8 +121,8 @@ public:
|
||||||
// ConsoleObject interface
|
// ConsoleObject interface
|
||||||
DECLARE_CONOBJECT(AdvancedLightBinManager);
|
DECLARE_CONOBJECT(AdvancedLightBinManager);
|
||||||
|
|
||||||
bool MRTLightmapsDuringPrePass() const { return mMRTLightmapsDuringPrePass; }
|
bool MRTLightmapsDuringDeferred() const { return mMRTLightmapsDuringDeferred; }
|
||||||
void MRTLightmapsDuringPrePass(bool val);
|
void MRTLightmapsDuringDeferred(bool val);
|
||||||
|
|
||||||
|
|
||||||
typedef Signal<void(SceneRenderState *, AdvancedLightBinManager *)> RenderSignal;
|
typedef Signal<void(SceneRenderState *, AdvancedLightBinManager *)> RenderSignal;
|
||||||
|
|
@ -195,7 +195,7 @@ protected:
|
||||||
Vector<LightBinEntry> mLightBin;
|
Vector<LightBinEntry> mLightBin;
|
||||||
typedef Vector<LightBinEntry>::iterator LightBinIterator;
|
typedef Vector<LightBinEntry>::iterator LightBinIterator;
|
||||||
|
|
||||||
bool mMRTLightmapsDuringPrePass;
|
bool mMRTLightmapsDuringDeferred;
|
||||||
|
|
||||||
/// Used in setupSGData to set the object transform.
|
/// Used in setupSGData to set the object transform.
|
||||||
MatrixF mLightMat;
|
MatrixF mLightMat;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
#include "lighting/common/sceneLighting.h"
|
#include "lighting/common/sceneLighting.h"
|
||||||
#include "lighting/common/lightMapParams.h"
|
#include "lighting/common/lightMapParams.h"
|
||||||
#include "core/util/safeDelete.h"
|
#include "core/util/safeDelete.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
#include "materials/materialManager.h"
|
#include "materials/materialManager.h"
|
||||||
#include "math/util/sphereMesh.h"
|
#include "math/util/sphereMesh.h"
|
||||||
#include "console/consoleTypes.h"
|
#include "console/consoleTypes.h"
|
||||||
|
|
@ -115,27 +115,27 @@ void AdvancedLightManager::activate( SceneManager *sceneManager )
|
||||||
mLightBinManager = new AdvancedLightBinManager( this, SHADOWMGR, blendTargetFormat );
|
mLightBinManager = new AdvancedLightBinManager( this, SHADOWMGR, blendTargetFormat );
|
||||||
mLightBinManager->assignName( "AL_LightBinMgr" );
|
mLightBinManager->assignName( "AL_LightBinMgr" );
|
||||||
|
|
||||||
// First look for the prepass bin...
|
// First look for the deferred bin...
|
||||||
RenderPrePassMgr *prePassBin = _findPrePassRenderBin();
|
RenderDeferredMgr *prePassBin = _findDeferredRenderBin();
|
||||||
|
|
||||||
// If we didn't find the prepass bin then add one.
|
// If we didn't find the deferred bin then add one.
|
||||||
if ( !prePassBin )
|
if ( !prePassBin )
|
||||||
{
|
{
|
||||||
prePassBin = new RenderPrePassMgr( true, blendTargetFormat );
|
prePassBin = new RenderDeferredMgr( true, blendTargetFormat );
|
||||||
prePassBin->assignName( "AL_PrePassBin" );
|
prePassBin->assignName( "AL_DeferredBin" );
|
||||||
prePassBin->registerObject();
|
prePassBin->registerObject();
|
||||||
getSceneManager()->getDefaultRenderPass()->addManager( prePassBin );
|
getSceneManager()->getDefaultRenderPass()->addManager( prePassBin );
|
||||||
mPrePassRenderBin = prePassBin;
|
mDeferredRenderBin = prePassBin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell the material manager that prepass is enabled.
|
// Tell the material manager that deferred is enabled.
|
||||||
MATMGR->setPrePassEnabled( true );
|
MATMGR->setDeferredEnabled( true );
|
||||||
|
|
||||||
// Insert our light bin manager.
|
// Insert our light bin manager.
|
||||||
mLightBinManager->setRenderOrder( prePassBin->getRenderOrder() + 0.01f );
|
mLightBinManager->setRenderOrder( prePassBin->getRenderOrder() + 0.01f );
|
||||||
getSceneManager()->getDefaultRenderPass()->addManager( mLightBinManager );
|
getSceneManager()->getDefaultRenderPass()->addManager( mLightBinManager );
|
||||||
|
|
||||||
AdvancedLightingFeatures::registerFeatures(mPrePassRenderBin->getTargetFormat(), mLightBinManager->getTargetFormat());
|
AdvancedLightingFeatures::registerFeatures(mDeferredRenderBin->getTargetFormat(), mLightBinManager->getTargetFormat());
|
||||||
|
|
||||||
// Last thing... let everyone know we're active.
|
// Last thing... let everyone know we're active.
|
||||||
smActivateSignal.trigger( getId(), true );
|
smActivateSignal.trigger( getId(), true );
|
||||||
|
|
@ -151,14 +151,14 @@ void AdvancedLightManager::deactivate()
|
||||||
// removing itself from the render passes.
|
// removing itself from the render passes.
|
||||||
if( mLightBinManager )
|
if( mLightBinManager )
|
||||||
{
|
{
|
||||||
mLightBinManager->MRTLightmapsDuringPrePass(false);
|
mLightBinManager->MRTLightmapsDuringDeferred(false);
|
||||||
mLightBinManager->deleteObject();
|
mLightBinManager->deleteObject();
|
||||||
}
|
}
|
||||||
mLightBinManager = NULL;
|
mLightBinManager = NULL;
|
||||||
|
|
||||||
if ( mPrePassRenderBin )
|
if ( mDeferredRenderBin )
|
||||||
mPrePassRenderBin->deleteObject();
|
mDeferredRenderBin->deleteObject();
|
||||||
mPrePassRenderBin = NULL;
|
mDeferredRenderBin = NULL;
|
||||||
|
|
||||||
SHADOWMGR->deactivate();
|
SHADOWMGR->deactivate();
|
||||||
|
|
||||||
|
|
@ -348,8 +348,8 @@ void AdvancedLightManager::setLightInfo( ProcessedMaterial *pmat,
|
||||||
U32 pass,
|
U32 pass,
|
||||||
GFXShaderConstBuffer *shaderConsts)
|
GFXShaderConstBuffer *shaderConsts)
|
||||||
{
|
{
|
||||||
// Skip this if we're rendering from the prepass bin.
|
// Skip this if we're rendering from the deferred bin.
|
||||||
if ( sgData.binType == SceneData::PrePassBin )
|
if ( sgData.binType == SceneData::DeferredBin )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PROFILE_SCOPE(AdvancedLightManager_setLightInfo);
|
PROFILE_SCOPE(AdvancedLightManager_setLightInfo);
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
|
|
||||||
class AvailableSLInterfaces;
|
class AvailableSLInterfaces;
|
||||||
class AdvancedLightBinManager;
|
class AdvancedLightBinManager;
|
||||||
class RenderPrePassMgr;
|
class RenderDeferredMgr;
|
||||||
class BaseMatInstance;
|
class BaseMatInstance;
|
||||||
class MaterialParameters;
|
class MaterialParameters;
|
||||||
class MaterialParameterHandle;
|
class MaterialParameterHandle;
|
||||||
|
|
@ -115,7 +115,7 @@ protected:
|
||||||
|
|
||||||
SimObjectPtr<AdvancedLightBinManager> mLightBinManager;
|
SimObjectPtr<AdvancedLightBinManager> mLightBinManager;
|
||||||
|
|
||||||
SimObjectPtr<RenderPrePassMgr> mPrePassRenderBin;
|
SimObjectPtr<RenderDeferredMgr> mDeferredRenderBin;
|
||||||
|
|
||||||
LightConstantMap mConstantLookup;
|
LightConstantMap mConstantLookup;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
bool AdvancedLightingFeatures::smFeaturesRegistered = false;
|
bool AdvancedLightingFeatures::smFeaturesRegistered = false;
|
||||||
|
|
||||||
void AdvancedLightingFeatures::registerFeatures( const GFXFormat &prepassTargetFormat, const GFXFormat &lightInfoTargetFormat )
|
void AdvancedLightingFeatures::registerFeatures( const GFXFormat &deferredTargetFormat, const GFXFormat &lightInfoTargetFormat )
|
||||||
{
|
{
|
||||||
AssertFatal( !smFeaturesRegistered, "AdvancedLightingFeatures::registerFeatures() - Features already registered. Bad!" );
|
AssertFatal( !smFeaturesRegistered, "AdvancedLightingFeatures::registerFeatures() - Features already registered. Bad!" );
|
||||||
|
|
||||||
|
|
@ -56,8 +56,8 @@ void AdvancedLightingFeatures::registerFeatures( const GFXFormat &prepassTargetF
|
||||||
if(GFX->getAdapterType() == OpenGL)
|
if(GFX->getAdapterType() == OpenGL)
|
||||||
{
|
{
|
||||||
#if defined( TORQUE_OPENGL )
|
#if defined( TORQUE_OPENGL )
|
||||||
cond = new GBufferConditionerGLSL( prepassTargetFormat, GBufferConditionerGLSL::ViewSpace );
|
cond = new GBufferConditionerGLSL( deferredTargetFormat, GBufferConditionerGLSL::ViewSpace );
|
||||||
FEATUREMGR->registerFeature(MFT_PrePassConditioner, cond);
|
FEATUREMGR->registerFeature(MFT_DeferredConditioner, cond);
|
||||||
FEATUREMGR->registerFeature(MFT_RTLighting, new DeferredRTLightingFeatGLSL());
|
FEATUREMGR->registerFeature(MFT_RTLighting, new DeferredRTLightingFeatGLSL());
|
||||||
FEATUREMGR->registerFeature(MFT_NormalMap, new DeferredBumpFeatGLSL());
|
FEATUREMGR->registerFeature(MFT_NormalMap, new DeferredBumpFeatGLSL());
|
||||||
FEATUREMGR->registerFeature(MFT_PixSpecular, new DeferredPixelSpecularGLSL());
|
FEATUREMGR->registerFeature(MFT_PixSpecular, new DeferredPixelSpecularGLSL());
|
||||||
|
|
@ -68,8 +68,8 @@ void AdvancedLightingFeatures::registerFeatures( const GFXFormat &prepassTargetF
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined( TORQUE_OS_WIN )
|
#if defined( TORQUE_OS_WIN )
|
||||||
cond = new GBufferConditionerHLSL( prepassTargetFormat, GBufferConditionerHLSL::ViewSpace );
|
cond = new GBufferConditionerHLSL( deferredTargetFormat, GBufferConditionerHLSL::ViewSpace );
|
||||||
FEATUREMGR->registerFeature(MFT_PrePassConditioner, cond);
|
FEATUREMGR->registerFeature(MFT_DeferredConditioner, cond);
|
||||||
FEATUREMGR->registerFeature(MFT_RTLighting, new DeferredRTLightingFeatHLSL());
|
FEATUREMGR->registerFeature(MFT_RTLighting, new DeferredRTLightingFeatHLSL());
|
||||||
FEATUREMGR->registerFeature(MFT_NormalMap, new DeferredBumpFeatHLSL());
|
FEATUREMGR->registerFeature(MFT_NormalMap, new DeferredBumpFeatHLSL());
|
||||||
FEATUREMGR->registerFeature(MFT_PixSpecular, new DeferredPixelSpecularHLSL());
|
FEATUREMGR->registerFeature(MFT_PixSpecular, new DeferredPixelSpecularHLSL());
|
||||||
|
|
@ -78,7 +78,7 @@ void AdvancedLightingFeatures::registerFeatures( const GFXFormat &prepassTargetF
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
NamedTexTarget *target = NamedTexTarget::find( "prepass" );
|
NamedTexTarget *target = NamedTexTarget::find( "deferred" );
|
||||||
if ( target )
|
if ( target )
|
||||||
target->setConditioner( cond );
|
target->setConditioner( cond );
|
||||||
|
|
||||||
|
|
@ -87,11 +87,11 @@ void AdvancedLightingFeatures::registerFeatures( const GFXFormat &prepassTargetF
|
||||||
|
|
||||||
void AdvancedLightingFeatures::unregisterFeatures()
|
void AdvancedLightingFeatures::unregisterFeatures()
|
||||||
{
|
{
|
||||||
NamedTexTarget *target = NamedTexTarget::find( "prepass" );
|
NamedTexTarget *target = NamedTexTarget::find( "deferred" );
|
||||||
if ( target )
|
if ( target )
|
||||||
target->setConditioner( NULL );
|
target->setConditioner( NULL );
|
||||||
|
|
||||||
FEATUREMGR->unregisterFeature(MFT_PrePassConditioner);
|
FEATUREMGR->unregisterFeature(MFT_DeferredConditioner);
|
||||||
FEATUREMGR->unregisterFeature(MFT_RTLighting);
|
FEATUREMGR->unregisterFeature(MFT_RTLighting);
|
||||||
FEATUREMGR->unregisterFeature(MFT_NormalMap);
|
FEATUREMGR->unregisterFeature(MFT_NormalMap);
|
||||||
FEATUREMGR->unregisterFeature(MFT_PixSpecular);
|
FEATUREMGR->unregisterFeature(MFT_PixSpecular);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class AdvancedLightingFeatures
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void registerFeatures( const GFXFormat &prepassTargetFormat, const GFXFormat &lightInfoTargetFormat );
|
static void registerFeatures( const GFXFormat &deferredTargetFormat, const GFXFormat &lightInfoTargetFormat );
|
||||||
static void unregisterFeatures();
|
static void unregisterFeatures();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include "shaderGen/langElement.h"
|
#include "shaderGen/langElement.h"
|
||||||
#include "shaderGen/shaderOp.h"
|
#include "shaderGen/shaderOp.h"
|
||||||
#include "shaderGen/conditionerFeature.h"
|
#include "shaderGen/conditionerFeature.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
#include "materials/processedMaterial.h"
|
#include "materials/processedMaterial.h"
|
||||||
#include "materials/materialFeatureTypes.h"
|
#include "materials/materialFeatureTypes.h"
|
||||||
|
|
||||||
|
|
@ -144,7 +144,7 @@ void DeferredRTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
||||||
unconditionLightInfo.c_str() ), lightInfoBuffer, uvScene, d_lightcolor, d_NL_Att, d_specular ) );
|
unconditionLightInfo.c_str() ), lightInfoBuffer, uvScene, d_lightcolor, d_NL_Att, d_specular ) );
|
||||||
|
|
||||||
// If this has an interlaced pre-pass, do averaging here
|
// If this has an interlaced pre-pass, do averaging here
|
||||||
if( fd.features[MFT_InterlacedPrePass] )
|
if( fd.features[MFT_InterlacedDeferred] )
|
||||||
{
|
{
|
||||||
Var *oneOverTargetSize = (Var*) LangElement::find( "oneOverTargetSize" );
|
Var *oneOverTargetSize = (Var*) LangElement::find( "oneOverTargetSize" );
|
||||||
if( !oneOverTargetSize )
|
if( !oneOverTargetSize )
|
||||||
|
|
@ -216,7 +216,7 @@ void DeferredRTLightingFeatGLSL::setTexData( Material::StageData &stageDat,
|
||||||
void DeferredBumpFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
void DeferredBumpFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd )
|
const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
if( fd.features[MFT_PrePassConditioner] )
|
if( fd.features[MFT_DeferredConditioner] )
|
||||||
{
|
{
|
||||||
// There is an output conditioner active, so we need to supply a transform
|
// There is an output conditioner active, so we need to supply a transform
|
||||||
// to the pixel shader.
|
// to the pixel shader.
|
||||||
|
|
@ -264,7 +264,7 @@ void DeferredBumpFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
// NULL output in case nothing gets handled
|
// NULL output in case nothing gets handled
|
||||||
output = NULL;
|
output = NULL;
|
||||||
|
|
||||||
if( fd.features[MFT_PrePassConditioner] )
|
if( fd.features[MFT_DeferredConditioner] )
|
||||||
{
|
{
|
||||||
MultiLine *meta = new MultiLine;
|
MultiLine *meta = new MultiLine;
|
||||||
|
|
||||||
|
|
@ -312,7 +312,7 @@ void DeferredBumpFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
}
|
}
|
||||||
|
|
||||||
// This var is read from GBufferConditionerGLSL and
|
// This var is read from GBufferConditionerGLSL and
|
||||||
// used in the prepass output.
|
// used in the deferred output.
|
||||||
//
|
//
|
||||||
// By using the 'half' type here we get a bunch of partial
|
// By using the 'half' type here we get a bunch of partial
|
||||||
// precision optimized code on further operations on the normal
|
// precision optimized code on further operations on the normal
|
||||||
|
|
@ -425,7 +425,7 @@ ShaderFeature::Resources DeferredBumpFeatGLSL::getResources( const MaterialFeatu
|
||||||
res.numTex = 1;
|
res.numTex = 1;
|
||||||
res.numTexReg = 1;
|
res.numTexReg = 1;
|
||||||
|
|
||||||
if ( fd.features[MFT_PrePassConditioner] &&
|
if ( fd.features[MFT_DeferredConditioner] &&
|
||||||
fd.features.hasFeature( MFT_DetailNormalMap ) )
|
fd.features.hasFeature( MFT_DetailNormalMap ) )
|
||||||
{
|
{
|
||||||
res.numTex += 1;
|
res.numTex += 1;
|
||||||
|
|
@ -450,7 +450,7 @@ void DeferredBumpFeatGLSL::setTexData( Material::StageData &stageDat,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fd.features[MFT_PrePassConditioner] && fd.features[MFT_AccuMap])
|
if (!fd.features[MFT_DeferredConditioner] && fd.features[MFT_AccuMap])
|
||||||
{
|
{
|
||||||
passData.mTexType[texIndex] = Material::Bump;
|
passData.mTexType[texIndex] = Material::Bump;
|
||||||
passData.mSamplerNames[texIndex] = "bumpMap";
|
passData.mSamplerNames[texIndex] = "bumpMap";
|
||||||
|
|
@ -464,14 +464,14 @@ void DeferredBumpFeatGLSL::setTexData( Material::StageData &stageDat,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!fd.features[MFT_Parallax] && !fd.features[MFT_SpecularMap] &&
|
else if (!fd.features[MFT_Parallax] && !fd.features[MFT_SpecularMap] &&
|
||||||
( fd.features[MFT_PrePassConditioner] ||
|
( fd.features[MFT_DeferredConditioner] ||
|
||||||
fd.features[MFT_PixSpecular] ) )
|
fd.features[MFT_PixSpecular] ) )
|
||||||
{
|
{
|
||||||
passData.mTexType[ texIndex ] = Material::Bump;
|
passData.mTexType[ texIndex ] = Material::Bump;
|
||||||
passData.mSamplerNames[ texIndex ] = "bumpMap";
|
passData.mSamplerNames[ texIndex ] = "bumpMap";
|
||||||
passData.mTexSlot[ texIndex++ ].texObject = stageDat.getTex( MFT_NormalMap );
|
passData.mTexSlot[ texIndex++ ].texObject = stageDat.getTex( MFT_NormalMap );
|
||||||
|
|
||||||
if ( fd.features[MFT_PrePassConditioner] &&
|
if ( fd.features[MFT_DeferredConditioner] &&
|
||||||
fd.features.hasFeature( MFT_DetailNormalMap ) )
|
fd.features.hasFeature( MFT_DetailNormalMap ) )
|
||||||
{
|
{
|
||||||
passData.mTexType[ texIndex ] = Material::DetailBump;
|
passData.mTexType[ texIndex ] = Material::DetailBump;
|
||||||
|
|
@ -604,11 +604,11 @@ void DeferredMinnaertGLSL::setTexData( Material::StageData &stageDat,
|
||||||
{
|
{
|
||||||
if( !fd.features[MFT_ForwardShading] && fd.features[MFT_RTLighting] )
|
if( !fd.features[MFT_ForwardShading] && fd.features[MFT_RTLighting] )
|
||||||
{
|
{
|
||||||
NamedTexTarget *texTarget = NamedTexTarget::find(RenderPrePassMgr::BufferName);
|
NamedTexTarget *texTarget = NamedTexTarget::find(RenderDeferredMgr::BufferName);
|
||||||
if ( texTarget )
|
if ( texTarget )
|
||||||
{
|
{
|
||||||
passData.mTexType[texIndex] = Material::TexTarget;
|
passData.mTexType[texIndex] = Material::TexTarget;
|
||||||
passData.mSamplerNames[texIndex] = "prepassBuffer";
|
passData.mSamplerNames[texIndex] = "deferredBuffer";
|
||||||
passData.mTexSlot[ texIndex++ ].texTarget = texTarget;
|
passData.mTexSlot[ texIndex++ ].texTarget = texTarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -620,11 +620,11 @@ void DeferredMinnaertGLSL::processPixMacros( Vector<GFXShaderMacro> ¯os,
|
||||||
if( !fd.features[MFT_ForwardShading] && fd.features[MFT_RTLighting] )
|
if( !fd.features[MFT_ForwardShading] && fd.features[MFT_RTLighting] )
|
||||||
{
|
{
|
||||||
// Pull in the uncondition method for the g buffer
|
// Pull in the uncondition method for the g buffer
|
||||||
NamedTexTarget *texTarget = NamedTexTarget::find( RenderPrePassMgr::BufferName );
|
NamedTexTarget *texTarget = NamedTexTarget::find( RenderDeferredMgr::BufferName );
|
||||||
if ( texTarget && texTarget->getConditioner() )
|
if ( texTarget && texTarget->getConditioner() )
|
||||||
{
|
{
|
||||||
ConditionerMethodDependency *unconditionMethod = texTarget->getConditioner()->getConditionerMethodDependency(ConditionerFeature::UnconditionMethod);
|
ConditionerMethodDependency *unconditionMethod = texTarget->getConditioner()->getConditionerMethodDependency(ConditionerFeature::UnconditionMethod);
|
||||||
unconditionMethod->createMethodMacro( String::ToLower(RenderPrePassMgr::BufferName) + "Uncondition", macros );
|
unconditionMethod->createMethodMacro( String::ToLower(RenderDeferredMgr::BufferName) + "Uncondition", macros );
|
||||||
addDependency(unconditionMethod);
|
addDependency(unconditionMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -664,12 +664,12 @@ void DeferredMinnaertGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
minnaertConstant->constSortPos = cspPotentialPrimitive;
|
minnaertConstant->constSortPos = cspPotentialPrimitive;
|
||||||
|
|
||||||
// create texture var
|
// create texture var
|
||||||
Var *prepassBuffer = new Var;
|
Var *deferredBuffer = new Var;
|
||||||
prepassBuffer->setType( "sampler2D" );
|
deferredBuffer->setType( "sampler2D" );
|
||||||
prepassBuffer->setName( "prepassBuffer" );
|
deferredBuffer->setName( "deferredBuffer" );
|
||||||
prepassBuffer->uniform = true;
|
deferredBuffer->uniform = true;
|
||||||
prepassBuffer->sampler = true;
|
deferredBuffer->sampler = true;
|
||||||
prepassBuffer->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
deferredBuffer->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||||
|
|
||||||
// Texture coord
|
// Texture coord
|
||||||
Var *uvScene = (Var*) LangElement::find( "uvScene" );
|
Var *uvScene = (Var*) LangElement::find( "uvScene" );
|
||||||
|
|
@ -680,11 +680,11 @@ void DeferredMinnaertGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
// Get the world space view vector.
|
// Get the world space view vector.
|
||||||
Var *wsViewVec = getWsView( getInWsPosition( componentList ), meta );
|
Var *wsViewVec = getWsView( getInWsPosition( componentList ), meta );
|
||||||
|
|
||||||
String unconditionPrePassMethod = String::ToLower(RenderPrePassMgr::BufferName) + "Uncondition";
|
String unconditionDeferredMethod = String::ToLower(RenderDeferredMgr::BufferName) + "Uncondition";
|
||||||
|
|
||||||
Var *d_NL_Att = (Var*)LangElement::find( "d_NL_Att" );
|
Var *d_NL_Att = (Var*)LangElement::find( "d_NL_Att" );
|
||||||
|
|
||||||
meta->addStatement( new GenOp( avar( " vec4 normalDepth = %s(@, @);\r\n", unconditionPrePassMethod.c_str() ), prepassBuffer, uvScene ) );
|
meta->addStatement( new GenOp( avar( " vec4 normalDepth = %s(@, @);\r\n", unconditionDeferredMethod.c_str() ), deferredBuffer, uvScene ) );
|
||||||
meta->addStatement( new GenOp( " float vDotN = dot(normalDepth.xyz, @);\r\n", wsViewVec ) );
|
meta->addStatement( new GenOp( " float vDotN = dot(normalDepth.xyz, @);\r\n", wsViewVec ) );
|
||||||
meta->addStatement( new GenOp( " float Minnaert = pow( @, @) * pow(vDotN, 1.0 - @);\r\n", d_NL_Att, minnaertConstant, minnaertConstant ) );
|
meta->addStatement( new GenOp( " float Minnaert = pow( @, @) * pow(vDotN, 1.0 - @);\r\n", d_NL_Att, minnaertConstant, minnaertConstant ) );
|
||||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "vec4(Minnaert, Minnaert, Minnaert, 1.0)" ), Material::Mul ) ) );
|
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "vec4(Minnaert, Minnaert, Minnaert, 1.0)" ), Material::Mul ) ) );
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,13 @@
|
||||||
class ConditionerMethodDependency;
|
class ConditionerMethodDependency;
|
||||||
|
|
||||||
|
|
||||||
/// Lights the pixel by sampling from the light prepass
|
/// Lights the pixel by sampling from the light deferred
|
||||||
/// buffer. It will fall back to forward lighting
|
/// buffer. It will fall back to forward lighting
|
||||||
/// functionality for non-deferred rendered surfaces.
|
/// functionality for non-deferred rendered surfaces.
|
||||||
///
|
///
|
||||||
/// Also note that this feature is only used in the
|
/// Also note that this feature is only used in the
|
||||||
/// forward rendering pass. It is not used during the
|
/// forward rendering pass. It is not used during the
|
||||||
/// prepass step.
|
/// deferred step.
|
||||||
///
|
///
|
||||||
class DeferredRTLightingFeatGLSL : public RTLightingFeatGLSL
|
class DeferredRTLightingFeatGLSL : public RTLightingFeatGLSL
|
||||||
{
|
{
|
||||||
|
|
@ -103,7 +103,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/// Generates specular highlights in the forward pass
|
/// Generates specular highlights in the forward pass
|
||||||
/// from the light prepass buffer.
|
/// from the light deferred buffer.
|
||||||
class DeferredPixelSpecularGLSL : public PixelSpecularGLSL
|
class DeferredPixelSpecularGLSL : public PixelSpecularGLSL
|
||||||
{
|
{
|
||||||
typedef PixelSpecularGLSL Parent;
|
typedef PixelSpecularGLSL Parent;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include "shaderGen/langElement.h"
|
#include "shaderGen/langElement.h"
|
||||||
#include "shaderGen/shaderOp.h"
|
#include "shaderGen/shaderOp.h"
|
||||||
#include "shaderGen/conditionerFeature.h"
|
#include "shaderGen/conditionerFeature.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
#include "materials/processedMaterial.h"
|
#include "materials/processedMaterial.h"
|
||||||
#include "materials/materialFeatureTypes.h"
|
#include "materials/materialFeatureTypes.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ void GBufferConditionerGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
||||||
|
|
||||||
LangElement *outputDecl = new DecOp( unconditionedOut );
|
LangElement *outputDecl = new DecOp( unconditionedOut );
|
||||||
|
|
||||||
// If we're doing prepass blending then we need
|
// If we're doing deferred blending then we need
|
||||||
// to steal away the alpha channel before the
|
// to steal away the alpha channel before the
|
||||||
// conditioner stomps on it.
|
// conditioner stomps on it.
|
||||||
Var *alphaVal = NULL;
|
Var *alphaVal = NULL;
|
||||||
|
|
@ -174,7 +174,7 @@ void GBufferConditionerGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
||||||
}
|
}
|
||||||
|
|
||||||
// If using interlaced normals, invert the normal
|
// If using interlaced normals, invert the normal
|
||||||
if(fd.features[MFT_InterlacedPrePass])
|
if(fd.features[MFT_InterlacedDeferred])
|
||||||
{
|
{
|
||||||
// NOTE: Its safe to not call ShaderFeatureGLSL::addOutVpos() in the vertex
|
// NOTE: Its safe to not call ShaderFeatureGLSL::addOutVpos() in the vertex
|
||||||
// shader as for SM 3.0 nothing is needed there.
|
// shader as for SM 3.0 nothing is needed there.
|
||||||
|
|
@ -190,7 +190,7 @@ void GBufferConditionerGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
||||||
meta->addStatement( new GenOp(" @ = @;", outputDecl, new GenOp( "float4(normalize(@), @)", gbNormal, depth ) ) );
|
meta->addStatement( new GenOp(" @ = @;", outputDecl, new GenOp( "float4(normalize(@), @)", gbNormal, depth ) ) );
|
||||||
meta->addStatement( assignOutput( unconditionedOut ) );
|
meta->addStatement( assignOutput( unconditionedOut ) );
|
||||||
|
|
||||||
// If we have an alpha var then we're doing prepass lerp blending.
|
// If we have an alpha var then we're doing deferred lerp blending.
|
||||||
if ( alphaVal )
|
if ( alphaVal )
|
||||||
{
|
{
|
||||||
Var *outColor = (Var*)LangElement::find( getOutputTargetVarName( DefaultTarget ) );
|
Var *outColor = (Var*)LangElement::find( getOutputTargetVarName( DefaultTarget ) );
|
||||||
|
|
@ -227,10 +227,10 @@ Var* GBufferConditionerGLSL::printMethodHeader( MethodType methodType, const Str
|
||||||
methodVar->setType("float4");
|
methodVar->setType("float4");
|
||||||
DecOp *methodDecl = new DecOp(methodVar);
|
DecOp *methodDecl = new DecOp(methodVar);
|
||||||
|
|
||||||
Var *prepassSampler = new Var;
|
Var *deferredSampler = new Var;
|
||||||
prepassSampler->setName("prepassSamplerVar");
|
deferredSampler->setName("deferredSamplerVar");
|
||||||
prepassSampler->setType("sampler2D");
|
deferredSampler->setType("sampler2D");
|
||||||
DecOp *prepassSamplerDecl = new DecOp(prepassSampler);
|
DecOp *deferredSamplerDecl = new DecOp(deferredSampler);
|
||||||
|
|
||||||
Var *screenUV = new Var;
|
Var *screenUV = new Var;
|
||||||
screenUV->setName("screenUVVar");
|
screenUV->setName("screenUVVar");
|
||||||
|
|
@ -242,7 +242,7 @@ Var* GBufferConditionerGLSL::printMethodHeader( MethodType methodType, const Str
|
||||||
bufferSample->setType("float4");
|
bufferSample->setType("float4");
|
||||||
DecOp *bufferSampleDecl = new DecOp(bufferSample);
|
DecOp *bufferSampleDecl = new DecOp(bufferSample);
|
||||||
|
|
||||||
meta->addStatement( new GenOp( "@(@, @)\r\n", methodDecl, prepassSamplerDecl, screenUVDecl ) );
|
meta->addStatement( new GenOp( "@(@, @)\r\n", methodDecl, deferredSamplerDecl, screenUVDecl ) );
|
||||||
|
|
||||||
meta->addStatement( new GenOp( "{\r\n" ) );
|
meta->addStatement( new GenOp( "{\r\n" ) );
|
||||||
|
|
||||||
|
|
@ -250,14 +250,14 @@ Var* GBufferConditionerGLSL::printMethodHeader( MethodType methodType, const Str
|
||||||
|
|
||||||
#ifdef TORQUE_OS_XENON
|
#ifdef TORQUE_OS_XENON
|
||||||
meta->addStatement( new GenOp( " @;\r\n", bufferSampleDecl ) );
|
meta->addStatement( new GenOp( " @;\r\n", bufferSampleDecl ) );
|
||||||
meta->addStatement( new GenOp( " asm { tfetch2D @, @, @, MagFilter = point, MinFilter = point, MipFilter = point };\r\n", bufferSample, screenUV, prepassSampler ) );
|
meta->addStatement( new GenOp( " asm { tfetch2D @, @, @, MagFilter = point, MinFilter = point, MipFilter = point };\r\n", bufferSample, screenUV, deferredSampler ) );
|
||||||
#else
|
#else
|
||||||
// The gbuffer has no mipmaps, so use tex2dlod when
|
// The gbuffer has no mipmaps, so use tex2dlod when
|
||||||
// possible so that the shader compiler can optimize.
|
// possible so that the shader compiler can optimize.
|
||||||
meta->addStatement( new GenOp( " #if TORQUE_SM >= 30\r\n" ) );
|
meta->addStatement( new GenOp( " #if TORQUE_SM >= 30\r\n" ) );
|
||||||
meta->addStatement( new GenOp( " @ = tex2Dlod(@, float4(@,0,0));\r\n", bufferSampleDecl, prepassSampler, screenUV ) );
|
meta->addStatement( new GenOp( " @ = tex2Dlod(@, float4(@,0,0));\r\n", bufferSampleDecl, deferredSampler, screenUV ) );
|
||||||
meta->addStatement( new GenOp( " #else\r\n" ) );
|
meta->addStatement( new GenOp( " #else\r\n" ) );
|
||||||
meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n", bufferSampleDecl, prepassSampler, screenUV ) );
|
meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n", bufferSampleDecl, deferredSampler, screenUV ) );
|
||||||
meta->addStatement( new GenOp( " #endif\r\n\r\n" ) );
|
meta->addStatement( new GenOp( " #endif\r\n\r\n" ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include "shaderGen/langElement.h"
|
#include "shaderGen/langElement.h"
|
||||||
#include "shaderGen/shaderOp.h"
|
#include "shaderGen/shaderOp.h"
|
||||||
#include "shaderGen/conditionerFeature.h"
|
#include "shaderGen/conditionerFeature.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
#include "materials/processedMaterial.h"
|
#include "materials/processedMaterial.h"
|
||||||
#include "materials/materialFeatureTypes.h"
|
#include "materials/materialFeatureTypes.h"
|
||||||
|
|
||||||
|
|
@ -160,7 +160,7 @@ void DeferredRTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
||||||
unconditionLightInfo.c_str()), lightInfoBuffer, uvScene, d_lightcolor, d_NL_Att, d_specular));
|
unconditionLightInfo.c_str()), lightInfoBuffer, uvScene, d_lightcolor, d_NL_Att, d_specular));
|
||||||
|
|
||||||
// If this has an interlaced pre-pass, do averaging here
|
// If this has an interlaced pre-pass, do averaging here
|
||||||
if( fd.features[MFT_InterlacedPrePass] )
|
if( fd.features[MFT_InterlacedDeferred] )
|
||||||
{
|
{
|
||||||
Var *oneOverTargetSize = (Var*) LangElement::find( "oneOverTargetSize" );
|
Var *oneOverTargetSize = (Var*) LangElement::find( "oneOverTargetSize" );
|
||||||
if( !oneOverTargetSize )
|
if( !oneOverTargetSize )
|
||||||
|
|
@ -236,7 +236,7 @@ void DeferredRTLightingFeatHLSL::setTexData( Material::StageData &stageDat,
|
||||||
void DeferredBumpFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
void DeferredBumpFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd )
|
const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
if( fd.features[MFT_PrePassConditioner] )
|
if( fd.features[MFT_DeferredConditioner] )
|
||||||
{
|
{
|
||||||
// There is an output conditioner active, so we need to supply a transform
|
// There is an output conditioner active, so we need to supply a transform
|
||||||
// to the pixel shader.
|
// to the pixel shader.
|
||||||
|
|
@ -284,7 +284,7 @@ void DeferredBumpFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
// NULL output in case nothing gets handled
|
// NULL output in case nothing gets handled
|
||||||
output = NULL;
|
output = NULL;
|
||||||
|
|
||||||
if( fd.features[MFT_PrePassConditioner] )
|
if( fd.features[MFT_DeferredConditioner] )
|
||||||
{
|
{
|
||||||
MultiLine *meta = new MultiLine;
|
MultiLine *meta = new MultiLine;
|
||||||
|
|
||||||
|
|
@ -358,7 +358,7 @@ void DeferredBumpFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
}
|
}
|
||||||
|
|
||||||
// This var is read from GBufferConditionerHLSL and
|
// This var is read from GBufferConditionerHLSL and
|
||||||
// used in the prepass output.
|
// used in the deferred output.
|
||||||
//
|
//
|
||||||
// By using the 'half' type here we get a bunch of partial
|
// By using the 'half' type here we get a bunch of partial
|
||||||
// precision optimized code on further operations on the normal
|
// precision optimized code on further operations on the normal
|
||||||
|
|
@ -500,7 +500,7 @@ ShaderFeature::Resources DeferredBumpFeatHLSL::getResources( const MaterialFeatu
|
||||||
res.numTex = 1;
|
res.numTex = 1;
|
||||||
res.numTexReg = 1;
|
res.numTexReg = 1;
|
||||||
|
|
||||||
if ( fd.features[MFT_PrePassConditioner] &&
|
if ( fd.features[MFT_DeferredConditioner] &&
|
||||||
fd.features.hasFeature( MFT_DetailNormalMap ) )
|
fd.features.hasFeature( MFT_DetailNormalMap ) )
|
||||||
{
|
{
|
||||||
res.numTex += 1;
|
res.numTex += 1;
|
||||||
|
|
@ -525,7 +525,7 @@ void DeferredBumpFeatHLSL::setTexData( Material::StageData &stageDat,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !fd.features[MFT_PrePassConditioner] && fd.features[MFT_AccuMap] )
|
if ( !fd.features[MFT_DeferredConditioner] && fd.features[MFT_AccuMap] )
|
||||||
{
|
{
|
||||||
passData.mTexType[ texIndex ] = Material::Bump;
|
passData.mTexType[ texIndex ] = Material::Bump;
|
||||||
passData.mSamplerNames[ texIndex ] = "bumpMap";
|
passData.mSamplerNames[ texIndex ] = "bumpMap";
|
||||||
|
|
@ -539,14 +539,14 @@ void DeferredBumpFeatHLSL::setTexData( Material::StageData &stageDat,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( !fd.features[MFT_Parallax] && !fd.features[MFT_SpecularMap] &&
|
else if ( !fd.features[MFT_Parallax] && !fd.features[MFT_SpecularMap] &&
|
||||||
( fd.features[MFT_PrePassConditioner] ||
|
( fd.features[MFT_DeferredConditioner] ||
|
||||||
fd.features[MFT_PixSpecular] ) )
|
fd.features[MFT_PixSpecular] ) )
|
||||||
{
|
{
|
||||||
passData.mTexType[ texIndex ] = Material::Bump;
|
passData.mTexType[ texIndex ] = Material::Bump;
|
||||||
passData.mSamplerNames[ texIndex ] = "bumpMap";
|
passData.mSamplerNames[ texIndex ] = "bumpMap";
|
||||||
passData.mTexSlot[ texIndex++ ].texObject = stageDat.getTex( MFT_NormalMap );
|
passData.mTexSlot[ texIndex++ ].texObject = stageDat.getTex( MFT_NormalMap );
|
||||||
|
|
||||||
if ( fd.features[MFT_PrePassConditioner] &&
|
if ( fd.features[MFT_DeferredConditioner] &&
|
||||||
fd.features.hasFeature( MFT_DetailNormalMap ) )
|
fd.features.hasFeature( MFT_DetailNormalMap ) )
|
||||||
{
|
{
|
||||||
passData.mTexType[ texIndex ] = Material::DetailBump;
|
passData.mTexType[ texIndex ] = Material::DetailBump;
|
||||||
|
|
@ -681,11 +681,11 @@ void DeferredMinnaertHLSL::setTexData( Material::StageData &stageDat,
|
||||||
{
|
{
|
||||||
if( !fd.features[MFT_ForwardShading] && fd.features[MFT_RTLighting] )
|
if( !fd.features[MFT_ForwardShading] && fd.features[MFT_RTLighting] )
|
||||||
{
|
{
|
||||||
NamedTexTarget *texTarget = NamedTexTarget::find(RenderPrePassMgr::BufferName);
|
NamedTexTarget *texTarget = NamedTexTarget::find(RenderDeferredMgr::BufferName);
|
||||||
if ( texTarget )
|
if ( texTarget )
|
||||||
{
|
{
|
||||||
passData.mTexType[texIndex] = Material::TexTarget;
|
passData.mTexType[texIndex] = Material::TexTarget;
|
||||||
passData.mSamplerNames[texIndex] = "prepassBuffer";
|
passData.mSamplerNames[texIndex] = "deferredBuffer";
|
||||||
passData.mTexSlot[ texIndex++ ].texTarget = texTarget;
|
passData.mTexSlot[ texIndex++ ].texTarget = texTarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -697,11 +697,11 @@ void DeferredMinnaertHLSL::processPixMacros( Vector<GFXShaderMacro> ¯os,
|
||||||
if( !fd.features[MFT_ForwardShading] && fd.features[MFT_RTLighting] )
|
if( !fd.features[MFT_ForwardShading] && fd.features[MFT_RTLighting] )
|
||||||
{
|
{
|
||||||
// Pull in the uncondition method for the g buffer
|
// Pull in the uncondition method for the g buffer
|
||||||
NamedTexTarget *texTarget = NamedTexTarget::find( RenderPrePassMgr::BufferName );
|
NamedTexTarget *texTarget = NamedTexTarget::find( RenderDeferredMgr::BufferName );
|
||||||
if ( texTarget && texTarget->getConditioner() )
|
if ( texTarget && texTarget->getConditioner() )
|
||||||
{
|
{
|
||||||
ConditionerMethodDependency *unconditionMethod = texTarget->getConditioner()->getConditionerMethodDependency(ConditionerFeature::UnconditionMethod);
|
ConditionerMethodDependency *unconditionMethod = texTarget->getConditioner()->getConditionerMethodDependency(ConditionerFeature::UnconditionMethod);
|
||||||
unconditionMethod->createMethodMacro( String::ToLower(RenderPrePassMgr::BufferName) + "Uncondition", macros );
|
unconditionMethod->createMethodMacro( String::ToLower(RenderDeferredMgr::BufferName) + "Uncondition", macros );
|
||||||
addDependency(unconditionMethod);
|
addDependency(unconditionMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -741,23 +741,23 @@ void DeferredMinnaertHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
minnaertConstant->constSortPos = cspPotentialPrimitive;
|
minnaertConstant->constSortPos = cspPotentialPrimitive;
|
||||||
|
|
||||||
// create texture var
|
// create texture var
|
||||||
Var *prepassBuffer = new Var;
|
Var *deferredBuffer = new Var;
|
||||||
prepassBuffer->setType( "sampler2D" );
|
deferredBuffer->setType( "sampler2D" );
|
||||||
prepassBuffer->setName( "prepassBuffer" );
|
deferredBuffer->setName( "deferredBuffer" );
|
||||||
prepassBuffer->uniform = true;
|
deferredBuffer->uniform = true;
|
||||||
prepassBuffer->sampler = true;
|
deferredBuffer->sampler = true;
|
||||||
prepassBuffer->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
deferredBuffer->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||||
|
|
||||||
Var* prePassTex = NULL;
|
Var* prePassTex = NULL;
|
||||||
if (mIsDirect3D11)
|
if (mIsDirect3D11)
|
||||||
{
|
{
|
||||||
prepassBuffer->setType("SamplerState");
|
deferredBuffer->setType("SamplerState");
|
||||||
prePassTex = new Var;
|
prePassTex = new Var;
|
||||||
prePassTex->setName("prePassTex");
|
prePassTex->setName("prePassTex");
|
||||||
prePassTex->setType("Texture2D");
|
prePassTex->setType("Texture2D");
|
||||||
prePassTex->uniform = true;
|
prePassTex->uniform = true;
|
||||||
prePassTex->texture = true;
|
prePassTex->texture = true;
|
||||||
prePassTex->constNum = prepassBuffer->constNum;
|
prePassTex->constNum = deferredBuffer->constNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Texture coord
|
// Texture coord
|
||||||
|
|
@ -769,14 +769,14 @@ void DeferredMinnaertHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
// Get the world space view vector.
|
// Get the world space view vector.
|
||||||
Var *wsViewVec = getWsView( getInWsPosition( componentList ), meta );
|
Var *wsViewVec = getWsView( getInWsPosition( componentList ), meta );
|
||||||
|
|
||||||
String unconditionPrePassMethod = String::ToLower(RenderPrePassMgr::BufferName) + "Uncondition";
|
String unconditionDeferredMethod = String::ToLower(RenderDeferredMgr::BufferName) + "Uncondition";
|
||||||
|
|
||||||
Var *d_NL_Att = (Var*)LangElement::find( "d_NL_Att" );
|
Var *d_NL_Att = (Var*)LangElement::find( "d_NL_Att" );
|
||||||
|
|
||||||
if (mIsDirect3D11)
|
if (mIsDirect3D11)
|
||||||
meta->addStatement(new GenOp(avar(" float4 normalDepth = %s(@, ,@, @);\r\n", unconditionPrePassMethod.c_str()), prepassBuffer, prePassTex, uvScene));
|
meta->addStatement(new GenOp(avar(" float4 normalDepth = %s(@, ,@, @);\r\n", unconditionDeferredMethod.c_str()), deferredBuffer, prePassTex, uvScene));
|
||||||
else
|
else
|
||||||
meta->addStatement(new GenOp(avar(" float4 normalDepth = %s(@, @);\r\n", unconditionPrePassMethod.c_str()), prepassBuffer, uvScene));
|
meta->addStatement(new GenOp(avar(" float4 normalDepth = %s(@, @);\r\n", unconditionDeferredMethod.c_str()), deferredBuffer, uvScene));
|
||||||
|
|
||||||
meta->addStatement( new GenOp( " float vDotN = dot(normalDepth.xyz, @);\r\n", wsViewVec ) );
|
meta->addStatement( new GenOp( " float vDotN = dot(normalDepth.xyz, @);\r\n", wsViewVec ) );
|
||||||
meta->addStatement( new GenOp( " float Minnaert = pow( @, @) * pow(vDotN, 1.0 - @);\r\n", d_NL_Att, minnaertConstant, minnaertConstant ) );
|
meta->addStatement( new GenOp( " float Minnaert = pow( @, @) * pow(vDotN, 1.0 - @);\r\n", d_NL_Att, minnaertConstant, minnaertConstant ) );
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,13 @@
|
||||||
class ConditionerMethodDependency;
|
class ConditionerMethodDependency;
|
||||||
|
|
||||||
|
|
||||||
/// Lights the pixel by sampling from the light prepass
|
/// Lights the pixel by sampling from the light deferred
|
||||||
/// buffer. It will fall back to forward lighting
|
/// buffer. It will fall back to forward lighting
|
||||||
/// functionality for non-deferred rendered surfaces.
|
/// functionality for non-deferred rendered surfaces.
|
||||||
///
|
///
|
||||||
/// Also note that this feature is only used in the
|
/// Also note that this feature is only used in the
|
||||||
/// forward rendering pass. It is not used during the
|
/// forward rendering pass. It is not used during the
|
||||||
/// prepass step.
|
/// deferred step.
|
||||||
///
|
///
|
||||||
class DeferredRTLightingFeatHLSL : public RTLightingFeatHLSL
|
class DeferredRTLightingFeatHLSL : public RTLightingFeatHLSL
|
||||||
{
|
{
|
||||||
|
|
@ -103,7 +103,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/// Generates specular highlights in the forward pass
|
/// Generates specular highlights in the forward pass
|
||||||
/// from the light prepass buffer.
|
/// from the light deferred buffer.
|
||||||
class DeferredPixelSpecularHLSL : public PixelSpecularHLSL
|
class DeferredPixelSpecularHLSL : public PixelSpecularHLSL
|
||||||
{
|
{
|
||||||
typedef PixelSpecularHLSL Parent;
|
typedef PixelSpecularHLSL Parent;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include "shaderGen/langElement.h"
|
#include "shaderGen/langElement.h"
|
||||||
#include "shaderGen/shaderOp.h"
|
#include "shaderGen/shaderOp.h"
|
||||||
#include "shaderGen/conditionerFeature.h"
|
#include "shaderGen/conditionerFeature.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
#include "materials/processedMaterial.h"
|
#include "materials/processedMaterial.h"
|
||||||
#include "materials/materialFeatureTypes.h"
|
#include "materials/materialFeatureTypes.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ void GBufferConditionerHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
||||||
|
|
||||||
LangElement *outputDecl = new DecOp( unconditionedOut );
|
LangElement *outputDecl = new DecOp( unconditionedOut );
|
||||||
|
|
||||||
// If we're doing prepass blending then we need
|
// If we're doing deferred blending then we need
|
||||||
// to steal away the alpha channel before the
|
// to steal away the alpha channel before the
|
||||||
// conditioner stomps on it.
|
// conditioner stomps on it.
|
||||||
Var *alphaVal = NULL;
|
Var *alphaVal = NULL;
|
||||||
|
|
@ -174,7 +174,7 @@ void GBufferConditionerHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
||||||
}
|
}
|
||||||
|
|
||||||
// If using interlaced normals, invert the normal
|
// If using interlaced normals, invert the normal
|
||||||
if(fd.features[MFT_InterlacedPrePass])
|
if(fd.features[MFT_InterlacedDeferred])
|
||||||
{
|
{
|
||||||
// NOTE: Its safe to not call ShaderFeatureHLSL::addOutVpos() in the vertex
|
// NOTE: Its safe to not call ShaderFeatureHLSL::addOutVpos() in the vertex
|
||||||
// shader as for SM 3.0 nothing is needed there.
|
// shader as for SM 3.0 nothing is needed there.
|
||||||
|
|
@ -190,7 +190,7 @@ void GBufferConditionerHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
||||||
meta->addStatement( new GenOp(" @ = @;", outputDecl, new GenOp( "float4(normalize(@), @)", gbNormal, depth ) ) );
|
meta->addStatement( new GenOp(" @ = @;", outputDecl, new GenOp( "float4(normalize(@), @)", gbNormal, depth ) ) );
|
||||||
meta->addStatement( assignOutput( unconditionedOut ) );
|
meta->addStatement( assignOutput( unconditionedOut ) );
|
||||||
|
|
||||||
// If we have an alpha var then we're doing prepass lerp blending.
|
// If we have an alpha var then we're doing deferred lerp blending.
|
||||||
if ( alphaVal )
|
if ( alphaVal )
|
||||||
{
|
{
|
||||||
Var *outColor = (Var*)LangElement::find( getOutputTargetVarName( DefaultTarget ) );
|
Var *outColor = (Var*)LangElement::find( getOutputTargetVarName( DefaultTarget ) );
|
||||||
|
|
@ -228,27 +228,27 @@ Var* GBufferConditionerHLSL::printMethodHeader( MethodType methodType, const Str
|
||||||
methodVar->setType("inline float4");
|
methodVar->setType("inline float4");
|
||||||
DecOp *methodDecl = new DecOp(methodVar);
|
DecOp *methodDecl = new DecOp(methodVar);
|
||||||
|
|
||||||
Var *prepassSampler = new Var;
|
Var *deferredSampler = new Var;
|
||||||
prepassSampler->setName("prepassSamplerVar");
|
deferredSampler->setName("deferredSamplerVar");
|
||||||
prepassSampler->setType("sampler2D");
|
deferredSampler->setType("sampler2D");
|
||||||
DecOp *prepassSamplerDecl = new DecOp(prepassSampler);
|
DecOp *deferredSamplerDecl = new DecOp(deferredSampler);
|
||||||
|
|
||||||
Var *screenUV = new Var;
|
Var *screenUV = new Var;
|
||||||
screenUV->setName("screenUVVar");
|
screenUV->setName("screenUVVar");
|
||||||
screenUV->setType("float2");
|
screenUV->setType("float2");
|
||||||
DecOp *screenUVDecl = new DecOp(screenUV);
|
DecOp *screenUVDecl = new DecOp(screenUV);
|
||||||
|
|
||||||
Var *prepassTex = NULL;
|
Var *deferredTex = NULL;
|
||||||
DecOp *prepassTexDecl = NULL;
|
DecOp *deferredTexDecl = NULL;
|
||||||
if (isDirect3D11)
|
if (isDirect3D11)
|
||||||
{
|
{
|
||||||
prepassSampler->setType("SamplerState");
|
deferredSampler->setType("SamplerState");
|
||||||
prepassTex = new Var;
|
deferredTex = new Var;
|
||||||
prepassTex->setName("prepassTexVar");
|
deferredTex->setName("deferredTexVar");
|
||||||
prepassTex->setType("Texture2D");
|
deferredTex->setType("Texture2D");
|
||||||
prepassTex->texture = true;
|
deferredTex->texture = true;
|
||||||
prepassTex->constNum = prepassSampler->constNum;
|
deferredTex->constNum = deferredSampler->constNum;
|
||||||
prepassTexDecl = new DecOp(prepassTex);
|
deferredTexDecl = new DecOp(deferredTex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Var *bufferSample = new Var;
|
Var *bufferSample = new Var;
|
||||||
|
|
@ -257,9 +257,9 @@ Var* GBufferConditionerHLSL::printMethodHeader( MethodType methodType, const Str
|
||||||
DecOp *bufferSampleDecl = new DecOp(bufferSample);
|
DecOp *bufferSampleDecl = new DecOp(bufferSample);
|
||||||
|
|
||||||
if (isDirect3D11)
|
if (isDirect3D11)
|
||||||
meta->addStatement(new GenOp("@(@, @, @)\r\n", methodDecl, prepassSamplerDecl, prepassTexDecl, screenUVDecl));
|
meta->addStatement(new GenOp("@(@, @, @)\r\n", methodDecl, deferredSamplerDecl, deferredTexDecl, screenUVDecl));
|
||||||
else
|
else
|
||||||
meta->addStatement( new GenOp( "@(@, @)\r\n", methodDecl, prepassSamplerDecl, screenUVDecl ) );
|
meta->addStatement( new GenOp( "@(@, @)\r\n", methodDecl, deferredSamplerDecl, screenUVDecl ) );
|
||||||
|
|
||||||
meta->addStatement( new GenOp( "{\r\n" ) );
|
meta->addStatement( new GenOp( "{\r\n" ) );
|
||||||
|
|
||||||
|
|
@ -267,18 +267,18 @@ Var* GBufferConditionerHLSL::printMethodHeader( MethodType methodType, const Str
|
||||||
|
|
||||||
#ifdef TORQUE_OS_XENON
|
#ifdef TORQUE_OS_XENON
|
||||||
meta->addStatement( new GenOp( " @;\r\n", bufferSampleDecl ) );
|
meta->addStatement( new GenOp( " @;\r\n", bufferSampleDecl ) );
|
||||||
meta->addStatement( new GenOp( " asm { tfetch2D @, @, @, MagFilter = point, MinFilter = point, MipFilter = point };\r\n", bufferSample, screenUV, prepassSampler ) );
|
meta->addStatement( new GenOp( " asm { tfetch2D @, @, @, MagFilter = point, MinFilter = point, MipFilter = point };\r\n", bufferSample, screenUV, deferredSampler ) );
|
||||||
#else
|
#else
|
||||||
// The gbuffer has no mipmaps, so use tex2dlod when
|
// The gbuffer has no mipmaps, so use tex2dlod when
|
||||||
// possible so that the shader compiler can optimize.
|
// possible so that the shader compiler can optimize.
|
||||||
meta->addStatement( new GenOp( " #if TORQUE_SM >= 30\r\n" ) );
|
meta->addStatement( new GenOp( " #if TORQUE_SM >= 30\r\n" ) );
|
||||||
if (isDirect3D11)
|
if (isDirect3D11)
|
||||||
meta->addStatement(new GenOp(" @ = @.SampleLevel(@, @,0);\r\n", bufferSampleDecl, prepassTex, prepassSampler, screenUV));
|
meta->addStatement(new GenOp(" @ = @.SampleLevel(@, @,0);\r\n", bufferSampleDecl, deferredTex, deferredSampler, screenUV));
|
||||||
else
|
else
|
||||||
meta->addStatement(new GenOp(" @ = tex2Dlod(@, float4(@,0,0));\r\n", bufferSampleDecl, prepassSampler, screenUV));
|
meta->addStatement(new GenOp(" @ = tex2Dlod(@, float4(@,0,0));\r\n", bufferSampleDecl, deferredSampler, screenUV));
|
||||||
|
|
||||||
meta->addStatement(new GenOp(" #else\r\n"));
|
meta->addStatement(new GenOp(" #else\r\n"));
|
||||||
meta->addStatement(new GenOp(" @ = tex2D(@, @);\r\n", bufferSampleDecl, prepassSampler, screenUV));
|
meta->addStatement(new GenOp(" @ = tex2D(@, @);\r\n", bufferSampleDecl, deferredSampler, screenUV));
|
||||||
meta->addStatement(new GenOp(" #endif\r\n\r\n"));
|
meta->addStatement(new GenOp(" #endif\r\n\r\n"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
#include "materials/materialFeatureTypes.h"
|
#include "materials/materialFeatureTypes.h"
|
||||||
#include "math/util/frustum.h"
|
#include "math/util/frustum.h"
|
||||||
#include "scene/sceneObject.h"
|
#include "scene/sceneObject.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
#include "shaderGen/featureMgr.h"
|
#include "shaderGen/featureMgr.h"
|
||||||
#include "shaderGen/HLSL/shaderFeatureHLSL.h"
|
#include "shaderGen/HLSL/shaderFeatureHLSL.h"
|
||||||
#include "shaderGen/HLSL/bumpHLSL.h"
|
#include "shaderGen/HLSL/bumpHLSL.h"
|
||||||
|
|
@ -184,8 +184,8 @@ void BasicLightManager::activate( SceneManager *sceneManager )
|
||||||
FEATUREMGR->unregisterFeature( MFT_MinnaertShading );
|
FEATUREMGR->unregisterFeature( MFT_MinnaertShading );
|
||||||
FEATUREMGR->unregisterFeature( MFT_SubSurface );
|
FEATUREMGR->unregisterFeature( MFT_SubSurface );
|
||||||
|
|
||||||
// First look for the prepass bin...
|
// First look for the deferred bin...
|
||||||
RenderPrePassMgr *prePassBin = _findPrePassRenderBin();
|
RenderDeferredMgr *prePassBin = _findDeferredRenderBin();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// If you would like to use forward shading, and have a linear depth pre-pass
|
// If you would like to use forward shading, and have a linear depth pre-pass
|
||||||
|
|
@ -204,19 +204,19 @@ void BasicLightManager::activate( SceneManager *sceneManager )
|
||||||
// Uncomment this for a no-color-write z-fill pass.
|
// Uncomment this for a no-color-write z-fill pass.
|
||||||
//linearDepthFormat = GFXFormat_COUNT;
|
//linearDepthFormat = GFXFormat_COUNT;
|
||||||
|
|
||||||
prePassBin = new RenderPrePassMgr( linearDepthFormat != GFXFormat_COUNT, linearDepthFormat );
|
prePassBin = new RenderDeferredMgr( linearDepthFormat != GFXFormat_COUNT, linearDepthFormat );
|
||||||
prePassBin->registerObject();
|
prePassBin->registerObject();
|
||||||
rpm->addManager( prePassBin );
|
rpm->addManager( prePassBin );
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
mPrePassRenderBin = prePassBin;
|
mDeferredRenderBin = prePassBin;
|
||||||
|
|
||||||
// If there is a prepass bin
|
// If there is a deferred bin
|
||||||
MATMGR->setPrePassEnabled( mPrePassRenderBin.isValid() );
|
MATMGR->setDeferredEnabled( mDeferredRenderBin.isValid() );
|
||||||
sceneManager->setPostEffectFog( mPrePassRenderBin.isValid() && mPrePassRenderBin->getTargetChainLength() > 0 );
|
sceneManager->setPostEffectFog( mDeferredRenderBin.isValid() && mDeferredRenderBin->getTargetChainLength() > 0 );
|
||||||
|
|
||||||
// Tell the material manager that we don't use prepass.
|
// Tell the material manager that we don't use deferred.
|
||||||
MATMGR->setPrePassEnabled( false );
|
MATMGR->setDeferredEnabled( false );
|
||||||
|
|
||||||
GFXShader::addGlobalMacro( "TORQUE_BASIC_LIGHTING" );
|
GFXShader::addGlobalMacro( "TORQUE_BASIC_LIGHTING" );
|
||||||
|
|
||||||
|
|
@ -241,9 +241,9 @@ void BasicLightManager::deactivate()
|
||||||
}
|
}
|
||||||
mConstantLookup.clear();
|
mConstantLookup.clear();
|
||||||
|
|
||||||
if ( mPrePassRenderBin )
|
if ( mDeferredRenderBin )
|
||||||
mPrePassRenderBin->deleteObject();
|
mDeferredRenderBin->deleteObject();
|
||||||
mPrePassRenderBin = NULL;
|
mDeferredRenderBin = NULL;
|
||||||
|
|
||||||
GFXShader::removeGlobalMacro( "TORQUE_BASIC_LIGHTING" );
|
GFXShader::removeGlobalMacro( "TORQUE_BASIC_LIGHTING" );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
class AvailableSLInterfaces;
|
class AvailableSLInterfaces;
|
||||||
class GFXShaderConstHandle;
|
class GFXShaderConstHandle;
|
||||||
class RenderPrePassMgr;
|
class RenderDeferredMgr;
|
||||||
class PlatformTimer;
|
class PlatformTimer;
|
||||||
|
|
||||||
class blTerrainSystem;
|
class blTerrainSystem;
|
||||||
|
|
@ -77,7 +77,7 @@ protected:
|
||||||
BasicLightManager();
|
BasicLightManager();
|
||||||
virtual ~BasicLightManager();
|
virtual ~BasicLightManager();
|
||||||
|
|
||||||
SimObjectPtr<RenderPrePassMgr> mPrePassRenderBin;
|
SimObjectPtr<RenderDeferredMgr> mDeferredRenderBin;
|
||||||
|
|
||||||
struct LightingShaderConstants
|
struct LightingShaderConstants
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
#include "T3D/gameBase/gameConnection.h"
|
#include "T3D/gameBase/gameConnection.h"
|
||||||
#include "gfx/gfxStringEnumTranslate.h"
|
#include "gfx/gfxStringEnumTranslate.h"
|
||||||
#include "console/engineAPI.h"
|
#include "console/engineAPI.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
|
|
||||||
|
|
||||||
Signal<void(const char*,bool)> LightManager::smActivateSignal;
|
Signal<void(const char*,bool)> LightManager::smActivateSignal;
|
||||||
|
|
@ -419,15 +419,15 @@ bool LightManager::lightScene( const char* callback, const char* param )
|
||||||
return sl->lightScene( callback, flags );
|
return sl->lightScene( callback, flags );
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPrePassMgr* LightManager::_findPrePassRenderBin()
|
RenderDeferredMgr* LightManager::_findDeferredRenderBin()
|
||||||
{
|
{
|
||||||
RenderPassManager* rpm = getSceneManager()->getDefaultRenderPass();
|
RenderPassManager* rpm = getSceneManager()->getDefaultRenderPass();
|
||||||
for( U32 i = 0; i < rpm->getManagerCount(); i++ )
|
for( U32 i = 0; i < rpm->getManagerCount(); i++ )
|
||||||
{
|
{
|
||||||
RenderBinManager *bin = rpm->getManager( i );
|
RenderBinManager *bin = rpm->getManager( i );
|
||||||
if( bin->getRenderInstType() == RenderPrePassMgr::RIT_PrePass )
|
if( bin->getRenderInstType() == RenderDeferredMgr::RIT_Deferred )
|
||||||
{
|
{
|
||||||
return ( RenderPrePassMgr* ) bin;
|
return ( RenderDeferredMgr* ) bin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class GFXShaderConstBuffer;
|
||||||
class GFXShaderConstHandle;
|
class GFXShaderConstHandle;
|
||||||
class ShaderConstHandles;
|
class ShaderConstHandles;
|
||||||
class SceneRenderState;
|
class SceneRenderState;
|
||||||
class RenderPrePassMgr;
|
class RenderDeferredMgr;
|
||||||
class Frustum;
|
class Frustum;
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
@ -167,7 +167,7 @@ protected:
|
||||||
static LightManager *smActiveLM;
|
static LightManager *smActiveLM;
|
||||||
|
|
||||||
/// Find the pre-pass render bin on the scene's default render pass.
|
/// Find the pre-pass render bin on the scene's default render pass.
|
||||||
RenderPrePassMgr* _findPrePassRenderBin();
|
RenderDeferredMgr* _findDeferredRenderBin();
|
||||||
|
|
||||||
/// This helper function sets the shader constansts
|
/// This helper function sets the shader constansts
|
||||||
/// for the stock 4 light forward lighting code.
|
/// for the stock 4 light forward lighting code.
|
||||||
|
|
|
||||||
|
|
@ -519,7 +519,7 @@ void LightingShaderConstants::init(GFXShader* shader)
|
||||||
mLightSpotParamsSC = shader->getShaderConstHandle("$lightSpotParams");
|
mLightSpotParamsSC = shader->getShaderConstHandle("$lightSpotParams");
|
||||||
|
|
||||||
// NOTE: These are the shader constants used for doing lighting
|
// NOTE: These are the shader constants used for doing lighting
|
||||||
// during the forward pass. Do not confuse these for the prepass
|
// during the forward pass. Do not confuse these for the deferred
|
||||||
// lighting constants which are used from AdvancedLightBinManager.
|
// lighting constants which are used from AdvancedLightBinManager.
|
||||||
mLightPositionSC = shader->getShaderConstHandle( ShaderGenVars::lightPosition );
|
mLightPositionSC = shader->getShaderConstHandle( ShaderGenVars::lightPosition );
|
||||||
mLightDiffuseSC = shader->getShaderConstHandle( ShaderGenVars::lightDiffuse );
|
mLightDiffuseSC = shader->getShaderConstHandle( ShaderGenVars::lightDiffuse );
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ struct LightingShaderConstants
|
||||||
|
|
||||||
// NOTE: These are the shader constants used for doing
|
// NOTE: These are the shader constants used for doing
|
||||||
// lighting during the forward pass. Do not confuse
|
// lighting during the forward pass. Do not confuse
|
||||||
// these for the prepass lighting constants which are
|
// these for the deferred lighting constants which are
|
||||||
// used from AdvancedLightBinManager.
|
// used from AdvancedLightBinManager.
|
||||||
GFXShaderConstHandle *mLightPositionSC;
|
GFXShaderConstHandle *mLightPositionSC;
|
||||||
GFXShaderConstHandle *mLightDiffuseSC;
|
GFXShaderConstHandle *mLightDiffuseSC;
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ void ShadowMaterialHook::init( BaseMatInstance *inMat )
|
||||||
forced.setBlend( false );
|
forced.setBlend( false );
|
||||||
forced.setAlphaTest( false );
|
forced.setAlphaTest( false );
|
||||||
|
|
||||||
// We should force on zwrite as the prepass
|
// We should force on zwrite as the deferred
|
||||||
// will disable it by default.
|
// will disable it by default.
|
||||||
forced.setZReadWrite( true, true );
|
forced.setZReadWrite( true, true );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ protected:
|
||||||
/// It is up to the derived class to set this variable appropriately.
|
/// It is up to the derived class to set this variable appropriately.
|
||||||
bool mIsValid;
|
bool mIsValid;
|
||||||
|
|
||||||
/// This is set by initialization and used by the prepass.
|
/// This is set by initialization and used by the deferred.
|
||||||
bool mHasNormalMaps;
|
bool mHasNormalMaps;
|
||||||
|
|
||||||
/// This material makes use of bone transforms
|
/// This material makes use of bone transforms
|
||||||
|
|
|
||||||
|
|
@ -73,13 +73,13 @@ ImplementFeatureType( MFT_IsEmissive, U32(-1), -1, true );
|
||||||
ImplementFeatureType( MFT_GlossMap, U32(-1), -1, true );
|
ImplementFeatureType( MFT_GlossMap, U32(-1), -1, true );
|
||||||
ImplementFeatureType( MFT_DiffuseMapAtlas, U32(-1), -1, true );
|
ImplementFeatureType( MFT_DiffuseMapAtlas, U32(-1), -1, true );
|
||||||
ImplementFeatureType( MFT_NormalMapAtlas, U32(-1), -1, true );
|
ImplementFeatureType( MFT_NormalMapAtlas, U32(-1), -1, true );
|
||||||
ImplementFeatureType( MFT_InterlacedPrePass, U32(-1), -1, true );
|
ImplementFeatureType( MFT_InterlacedDeferred, U32(-1), -1, true );
|
||||||
|
|
||||||
ImplementFeatureType( MFT_ParaboloidVertTransform, MFG_Transform, -1, false );
|
ImplementFeatureType( MFT_ParaboloidVertTransform, MFG_Transform, -1, false );
|
||||||
ImplementFeatureType( MFT_IsSinglePassParaboloid, U32(-1), -1, false );
|
ImplementFeatureType( MFT_IsSinglePassParaboloid, U32(-1), -1, false );
|
||||||
ImplementFeatureType( MFT_EyeSpaceDepthOut, MFG_PostLighting, 2.0f, false );
|
ImplementFeatureType( MFT_EyeSpaceDepthOut, MFG_PostLighting, 2.0f, false );
|
||||||
ImplementFeatureType( MFT_DepthOut, MFG_PostLighting, 3.0f, false );
|
ImplementFeatureType( MFT_DepthOut, MFG_PostLighting, 3.0f, false );
|
||||||
ImplementFeatureType( MFT_PrePassConditioner, MFG_PostProcess, 1.0f, false );
|
ImplementFeatureType( MFT_DeferredConditioner, MFG_PostProcess, 1.0f, false );
|
||||||
ImplementFeatureType( MFT_NormalsOut, MFG_PreLighting, 1.0f, false );
|
ImplementFeatureType( MFT_NormalsOut, MFG_PreLighting, 1.0f, false );
|
||||||
|
|
||||||
ImplementFeatureType( MFT_LightbufferMRT, MFG_PreLighting, 1.0f, false );
|
ImplementFeatureType( MFT_LightbufferMRT, MFG_PreLighting, 1.0f, false );
|
||||||
|
|
|
||||||
|
|
@ -150,8 +150,8 @@ DeclareFeatureType( MFT_Fog );
|
||||||
DeclareFeatureType( MFT_HDROut );
|
DeclareFeatureType( MFT_HDROut );
|
||||||
|
|
||||||
///
|
///
|
||||||
DeclareFeatureType( MFT_PrePassConditioner );
|
DeclareFeatureType( MFT_DeferredConditioner );
|
||||||
DeclareFeatureType( MFT_InterlacedPrePass );
|
DeclareFeatureType( MFT_InterlacedDeferred );
|
||||||
|
|
||||||
/// This feature causes MFT_ToneMap and MFT_LightMap to output their light color
|
/// This feature causes MFT_ToneMap and MFT_LightMap to output their light color
|
||||||
/// to the second render-target
|
/// to the second render-target
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ MaterialManager::MaterialManager()
|
||||||
|
|
||||||
mMaterialSet = NULL;
|
mMaterialSet = NULL;
|
||||||
|
|
||||||
mUsingPrePass = false;
|
mUsingDeferred = false;
|
||||||
|
|
||||||
mFlushAndReInit = false;
|
mFlushAndReInit = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,11 +79,11 @@ public:
|
||||||
/// Gets the global warning material instance, callers should not free this copy
|
/// Gets the global warning material instance, callers should not free this copy
|
||||||
BaseMatInstance * getWarningMatInstance();
|
BaseMatInstance * getWarningMatInstance();
|
||||||
|
|
||||||
/// Set the prepass enabled state.
|
/// Set the deferred enabled state.
|
||||||
void setPrePassEnabled( bool enabled ) { mUsingPrePass = enabled; }
|
void setDeferredEnabled( bool enabled ) { mUsingDeferred = enabled; }
|
||||||
|
|
||||||
/// Get the prepass enabled state.
|
/// Get the deferred enabled state.
|
||||||
bool getPrePassEnabled() const { return mUsingPrePass; }
|
bool getDeferredEnabled() const { return mUsingDeferred; }
|
||||||
|
|
||||||
#ifndef TORQUE_SHIPPING
|
#ifndef TORQUE_SHIPPING
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@ protected:
|
||||||
typedef Map<String, String> MaterialMap;
|
typedef Map<String, String> MaterialMap;
|
||||||
MaterialMap mMaterialMap;
|
MaterialMap mMaterialMap;
|
||||||
|
|
||||||
bool mUsingPrePass;
|
bool mUsingDeferred;
|
||||||
|
|
||||||
// time tracking
|
// time tracking
|
||||||
F32 mDt;
|
F32 mDt;
|
||||||
|
|
|
||||||
|
|
@ -288,9 +288,9 @@ void ProcessedMaterial::_initPassStateBlock( RenderPassData *rpd, GFXStateBlockD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The prepass will take care of writing to the
|
// The deferred will take care of writing to the
|
||||||
// zbuffer, so we don't have to by default.
|
// zbuffer, so we don't have to by default.
|
||||||
if ( MATMGR->getPrePassEnabled() &&
|
if ( MATMGR->getDeferredEnabled() &&
|
||||||
!mFeatures.hasFeature(MFT_ForwardShading))
|
!mFeatures.hasFeature(MFT_ForwardShading))
|
||||||
result.setZReadWrite( result.zEnable, false );
|
result.setZReadWrite( result.zEnable, false );
|
||||||
|
|
||||||
|
|
@ -350,7 +350,7 @@ U32 ProcessedMaterial::_getRenderStateIndex( const SceneRenderState *sceneState,
|
||||||
if ( sceneState && sceneState->isReflectPass() )
|
if ( sceneState && sceneState->isReflectPass() )
|
||||||
currState |= RenderPassData::STATE_REFLECT;
|
currState |= RenderPassData::STATE_REFLECT;
|
||||||
|
|
||||||
if ( sgData.binType != SceneData::PrePassBin &&
|
if ( sgData.binType != SceneData::DeferredBin &&
|
||||||
mMaterial->isTranslucent() )
|
mMaterial->isTranslucent() )
|
||||||
currState |= RenderPassData::STATE_TRANSLUCENT;
|
currState |= RenderPassData::STATE_TRANSLUCENT;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
||||||
|
|
||||||
if ( mMaterial->isTranslucent() )
|
if ( mMaterial->isTranslucent() )
|
||||||
{
|
{
|
||||||
// Note: This is for decal blending into the prepass
|
// Note: This is for decal blending into the deferred
|
||||||
// for AL... it probably needs to be made clearer.
|
// for AL... it probably needs to be made clearer.
|
||||||
if ( mMaterial->mTranslucentBlendOp == Material::LerpAlpha &&
|
if ( mMaterial->mTranslucentBlendOp == Material::LerpAlpha &&
|
||||||
mMaterial->mTranslucentZWrite )
|
mMaterial->mTranslucentZWrite )
|
||||||
|
|
@ -318,11 +318,11 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
||||||
if ( dStrcmp( LIGHTMGR->getId(), "BLM" ) == 0 )
|
if ( dStrcmp( LIGHTMGR->getId(), "BLM" ) == 0 )
|
||||||
fd.features.addFeature( MFT_ForwardShading );
|
fd.features.addFeature( MFT_ForwardShading );
|
||||||
|
|
||||||
// Disabling the InterlacedPrePass feature for now. It is not ready for prime-time
|
// Disabling the InterlacedDeferred feature for now. It is not ready for prime-time
|
||||||
// and it should not be triggered off of the DoubleSided parameter. [2/5/2010 Pat]
|
// and it should not be triggered off of the DoubleSided parameter. [2/5/2010 Pat]
|
||||||
/*if ( mMaterial->isDoubleSided() )
|
/*if ( mMaterial->isDoubleSided() )
|
||||||
{
|
{
|
||||||
fd.features.addFeature( MFT_InterlacedPrePass );
|
fd.features.addFeature( MFT_InterlacedDeferred );
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// Allow instancing if it was requested and the card supports
|
// Allow instancing if it was requested and the card supports
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,9 @@ struct SceneData
|
||||||
/// @see RenderGlowMgr
|
/// @see RenderGlowMgr
|
||||||
GlowBin,
|
GlowBin,
|
||||||
|
|
||||||
/// The prepass render bin.
|
/// The deferred render bin.
|
||||||
/// @RenderPrePassMgr
|
/// @RenderDeferredMgr
|
||||||
PrePassBin,
|
DeferredBin,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This defines when we're rendering a special bin
|
/// This defines when we're rendering a special bin
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
|
|
||||||
#include "gfx/gfxTransformSaver.h"
|
#include "gfx/gfxTransformSaver.h"
|
||||||
#include "materials/sceneData.h"
|
#include "materials/sceneData.h"
|
||||||
|
|
@ -51,40 +51,40 @@
|
||||||
#include "materials/shaderData.h"
|
#include "materials/shaderData.h"
|
||||||
#include "gfx/sim/cubemapData.h"
|
#include "gfx/sim/cubemapData.h"
|
||||||
|
|
||||||
const MatInstanceHookType PrePassMatInstanceHook::Type( "PrePass" );
|
const MatInstanceHookType DeferredMatInstanceHook::Type( "Deferred" );
|
||||||
const String RenderPrePassMgr::BufferName("prepass");
|
const String RenderDeferredMgr::BufferName("deferred");
|
||||||
const RenderInstType RenderPrePassMgr::RIT_PrePass("PrePass");
|
const RenderInstType RenderDeferredMgr::RIT_Deferred("Deferred");
|
||||||
const String RenderPrePassMgr::ColorBufferName("color");
|
const String RenderDeferredMgr::ColorBufferName("color");
|
||||||
const String RenderPrePassMgr::MatInfoBufferName("matinfo");
|
const String RenderDeferredMgr::MatInfoBufferName("matinfo");
|
||||||
|
|
||||||
IMPLEMENT_CONOBJECT(RenderPrePassMgr);
|
IMPLEMENT_CONOBJECT(RenderDeferredMgr);
|
||||||
|
|
||||||
ConsoleDocClass( RenderPrePassMgr,
|
ConsoleDocClass( RenderDeferredMgr,
|
||||||
"@brief The render bin which performs a z+normals prepass used in Advanced Lighting.\n\n"
|
"@brief The render bin which performs a z+normals deferred used in Advanced Lighting.\n\n"
|
||||||
"This render bin is used in Advanced Lighting to gather all opaque mesh render instances "
|
"This render bin is used in Advanced Lighting to gather all opaque mesh render instances "
|
||||||
"and render them to the g-buffer for use in lighting the scene and doing effects.\n\n"
|
"and render them to the g-buffer for use in lighting the scene and doing effects.\n\n"
|
||||||
"PostEffect and other shaders can access the output of this bin by using the #prepass "
|
"PostEffect and other shaders can access the output of this bin by using the #deferred "
|
||||||
"texture target name. See the edge anti-aliasing post effect for an example.\n\n"
|
"texture target name. See the edge anti-aliasing post effect for an example.\n\n"
|
||||||
"@see game/core/scripts/client/postFx/edgeAA.cs\n"
|
"@see game/core/scripts/client/postFx/edgeAA.cs\n"
|
||||||
"@ingroup RenderBin\n" );
|
"@ingroup RenderBin\n" );
|
||||||
|
|
||||||
|
|
||||||
RenderPrePassMgr::RenderSignal& RenderPrePassMgr::getRenderSignal()
|
RenderDeferredMgr::RenderSignal& RenderDeferredMgr::getRenderSignal()
|
||||||
{
|
{
|
||||||
static RenderSignal theSignal;
|
static RenderSignal theSignal;
|
||||||
return theSignal;
|
return theSignal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RenderPrePassMgr::RenderPrePassMgr( bool gatherDepth,
|
RenderDeferredMgr::RenderDeferredMgr( bool gatherDepth,
|
||||||
GFXFormat format )
|
GFXFormat format )
|
||||||
: Parent( RIT_PrePass,
|
: Parent( RIT_Deferred,
|
||||||
0.01f,
|
0.01f,
|
||||||
0.01f,
|
0.01f,
|
||||||
format,
|
format,
|
||||||
Point2I( Parent::DefaultTargetSize, Parent::DefaultTargetSize),
|
Point2I( Parent::DefaultTargetSize, Parent::DefaultTargetSize),
|
||||||
gatherDepth ? Parent::DefaultTargetChainLength : 0 ),
|
gatherDepth ? Parent::DefaultTargetChainLength : 0 ),
|
||||||
mPrePassMatInstance( NULL )
|
mDeferredMatInstance( NULL )
|
||||||
{
|
{
|
||||||
notifyType( RenderPassManager::RIT_Decal );
|
notifyType( RenderPassManager::RIT_Decal );
|
||||||
notifyType( RenderPassManager::RIT_DecalRoad );
|
notifyType( RenderPassManager::RIT_DecalRoad );
|
||||||
|
|
@ -107,30 +107,30 @@ RenderPrePassMgr::RenderPrePassMgr( bool gatherDepth,
|
||||||
_registerFeatures();
|
_registerFeatures();
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPrePassMgr::~RenderPrePassMgr()
|
RenderDeferredMgr::~RenderDeferredMgr()
|
||||||
{
|
{
|
||||||
GFXShader::removeGlobalMacro( "TORQUE_LINEAR_DEPTH" );
|
GFXShader::removeGlobalMacro( "TORQUE_LINEAR_DEPTH" );
|
||||||
|
|
||||||
mColorTarget.release();
|
mColorTarget.release();
|
||||||
mMatInfoTarget.release();
|
mMatInfoTarget.release();
|
||||||
_unregisterFeatures();
|
_unregisterFeatures();
|
||||||
SAFE_DELETE( mPrePassMatInstance );
|
SAFE_DELETE( mDeferredMatInstance );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPrePassMgr::_registerFeatures()
|
void RenderDeferredMgr::_registerFeatures()
|
||||||
{
|
{
|
||||||
ConditionerFeature *cond = new LinearEyeDepthConditioner( getTargetFormat() );
|
ConditionerFeature *cond = new LinearEyeDepthConditioner( getTargetFormat() );
|
||||||
FEATUREMGR->registerFeature( MFT_PrePassConditioner, cond );
|
FEATUREMGR->registerFeature( MFT_DeferredConditioner, cond );
|
||||||
mNamedTarget.setConditioner( cond );
|
mNamedTarget.setConditioner( cond );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPrePassMgr::_unregisterFeatures()
|
void RenderDeferredMgr::_unregisterFeatures()
|
||||||
{
|
{
|
||||||
mNamedTarget.setConditioner( NULL );
|
mNamedTarget.setConditioner( NULL );
|
||||||
FEATUREMGR->unregisterFeature(MFT_PrePassConditioner);
|
FEATUREMGR->unregisterFeature(MFT_DeferredConditioner);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderPrePassMgr::setTargetSize(const Point2I &newTargetSize)
|
bool RenderDeferredMgr::setTargetSize(const Point2I &newTargetSize)
|
||||||
{
|
{
|
||||||
bool ret = Parent::setTargetSize( newTargetSize );
|
bool ret = Parent::setTargetSize( newTargetSize );
|
||||||
mNamedTarget.setViewport( GFX->getViewport() );
|
mNamedTarget.setViewport( GFX->getViewport() );
|
||||||
|
|
@ -139,14 +139,14 @@ bool RenderPrePassMgr::setTargetSize(const Point2I &newTargetSize)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderPrePassMgr::_updateTargets()
|
bool RenderDeferredMgr::_updateTargets()
|
||||||
{
|
{
|
||||||
PROFILE_SCOPE(RenderPrePassMgr_updateTargets);
|
PROFILE_SCOPE(RenderDeferredMgr_updateTargets);
|
||||||
|
|
||||||
bool ret = Parent::_updateTargets();
|
bool ret = Parent::_updateTargets();
|
||||||
|
|
||||||
// check for an output conditioner, and update it's format
|
// check for an output conditioner, and update it's format
|
||||||
ConditionerFeature *outputConditioner = dynamic_cast<ConditionerFeature *>(FEATUREMGR->getByType(MFT_PrePassConditioner));
|
ConditionerFeature *outputConditioner = dynamic_cast<ConditionerFeature *>(FEATUREMGR->getByType(MFT_DeferredConditioner));
|
||||||
if( outputConditioner && outputConditioner->setBufferFormat(mTargetFormat) )
|
if( outputConditioner && outputConditioner->setBufferFormat(mTargetFormat) )
|
||||||
{
|
{
|
||||||
// reload materials, the conditioner needs to alter the generated shaders
|
// reload materials, the conditioner needs to alter the generated shaders
|
||||||
|
|
@ -193,7 +193,7 @@ bool RenderPrePassMgr::_updateTargets()
|
||||||
// lightmapped geometry in the scene.
|
// lightmapped geometry in the scene.
|
||||||
AdvancedLightBinManager *lightBin;
|
AdvancedLightBinManager *lightBin;
|
||||||
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) &&
|
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) &&
|
||||||
lightBin->MRTLightmapsDuringPrePass() &&
|
lightBin->MRTLightmapsDuringDeferred() &&
|
||||||
lightBin->isProperlyAdded() )
|
lightBin->isProperlyAdded() )
|
||||||
{
|
{
|
||||||
// Update the size of the light bin target here. This will call _updateTargets
|
// Update the size of the light bin target here. This will call _updateTargets
|
||||||
|
|
@ -218,28 +218,28 @@ bool RenderPrePassMgr::_updateTargets()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPrePassMgr::_createPrePassMaterial()
|
void RenderDeferredMgr::_createDeferredMaterial()
|
||||||
{
|
{
|
||||||
SAFE_DELETE(mPrePassMatInstance);
|
SAFE_DELETE(mDeferredMatInstance);
|
||||||
|
|
||||||
const GFXVertexFormat *vertexFormat = getGFXVertexFormat<GFXVertexPNTTB>();
|
const GFXVertexFormat *vertexFormat = getGFXVertexFormat<GFXVertexPNTTB>();
|
||||||
|
|
||||||
MatInstance* prepassMat = static_cast<MatInstance*>(MATMGR->createMatInstance("AL_DefaultPrePassMaterial", vertexFormat));
|
MatInstance* deferredMat = static_cast<MatInstance*>(MATMGR->createMatInstance("AL_DefaultDeferredMaterial", vertexFormat));
|
||||||
AssertFatal( prepassMat, "TODO: Handle this better." );
|
AssertFatal( deferredMat, "TODO: Handle this better." );
|
||||||
mPrePassMatInstance = new PrePassMatInstance(prepassMat, this);
|
mDeferredMatInstance = new DeferredMatInstance(deferredMat, this);
|
||||||
mPrePassMatInstance->init( MATMGR->getDefaultFeatures(), vertexFormat);
|
mDeferredMatInstance->init( MATMGR->getDefaultFeatures(), vertexFormat);
|
||||||
delete prepassMat;
|
delete deferredMat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPrePassMgr::setPrePassMaterial( PrePassMatInstance *mat )
|
void RenderDeferredMgr::setDeferredMaterial( DeferredMatInstance *mat )
|
||||||
{
|
{
|
||||||
SAFE_DELETE(mPrePassMatInstance);
|
SAFE_DELETE(mDeferredMatInstance);
|
||||||
mPrePassMatInstance = mat;
|
mDeferredMatInstance = mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPrePassMgr::addElement( RenderInst *inst )
|
void RenderDeferredMgr::addElement( RenderInst *inst )
|
||||||
{
|
{
|
||||||
PROFILE_SCOPE( RenderPrePassMgr_addElement )
|
PROFILE_SCOPE( RenderDeferredMgr_addElement )
|
||||||
|
|
||||||
// Skip out if this bin is disabled.
|
// Skip out if this bin is disabled.
|
||||||
if ( gClientSceneGraph->getCurrentRenderState() &&
|
if ( gClientSceneGraph->getCurrentRenderState() &&
|
||||||
|
|
@ -269,8 +269,8 @@ void RenderPrePassMgr::addElement( RenderInst *inst )
|
||||||
static_cast<CustomMaterial*>(matInst->getMaterial())->mRefract)
|
static_cast<CustomMaterial*>(matInst->getMaterial())->mRefract)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Make sure we got a prepass material.
|
// Make sure we got a deferred material.
|
||||||
matInst = getPrePassMaterial(matInst);
|
matInst = getDeferredMaterial(matInst);
|
||||||
if (!matInst || !matInst->isValid())
|
if (!matInst || !matInst->isValid())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -302,36 +302,36 @@ void RenderPrePassMgr::addElement( RenderInst *inst )
|
||||||
elem.key2 = originalKey;
|
elem.key2 = originalKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPrePassMgr::sort()
|
void RenderDeferredMgr::sort()
|
||||||
{
|
{
|
||||||
PROFILE_SCOPE( RenderPrePassMgr_sort );
|
PROFILE_SCOPE( RenderDeferredMgr_sort );
|
||||||
Parent::sort();
|
Parent::sort();
|
||||||
dQsort( mTerrainElementList.address(), mTerrainElementList.size(), sizeof(MainSortElem), cmpKeyFunc);
|
dQsort( mTerrainElementList.address(), mTerrainElementList.size(), sizeof(MainSortElem), cmpKeyFunc);
|
||||||
dQsort( mObjectElementList.address(), mObjectElementList.size(), sizeof(MainSortElem), cmpKeyFunc);
|
dQsort( mObjectElementList.address(), mObjectElementList.size(), sizeof(MainSortElem), cmpKeyFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPrePassMgr::clear()
|
void RenderDeferredMgr::clear()
|
||||||
{
|
{
|
||||||
Parent::clear();
|
Parent::clear();
|
||||||
mTerrainElementList.clear();
|
mTerrainElementList.clear();
|
||||||
mObjectElementList.clear();
|
mObjectElementList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPrePassMgr::render( SceneRenderState *state )
|
void RenderDeferredMgr::render( SceneRenderState *state )
|
||||||
{
|
{
|
||||||
PROFILE_SCOPE(RenderPrePassMgr_render);
|
PROFILE_SCOPE(RenderDeferredMgr_render);
|
||||||
|
|
||||||
// Take a look at the SceneRenderState and see if we should skip drawing the pre-pass
|
// Take a look at the SceneRenderState and see if we should skip drawing the pre-pass
|
||||||
if ( state->disableAdvancedLightingBins() )
|
if ( state->disableAdvancedLightingBins() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// NOTE: We don't early out here when the element list is
|
// NOTE: We don't early out here when the element list is
|
||||||
// zero because we need the prepass to be cleared.
|
// zero because we need the deferred to be cleared.
|
||||||
|
|
||||||
// Automagically save & restore our viewport and transforms.
|
// Automagically save & restore our viewport and transforms.
|
||||||
GFXTransformSaver saver;
|
GFXTransformSaver saver;
|
||||||
|
|
||||||
GFXDEBUGEVENT_SCOPE( RenderPrePassMgr_Render, ColorI::RED );
|
GFXDEBUGEVENT_SCOPE( RenderDeferredMgr_Render, ColorI::RED );
|
||||||
|
|
||||||
// Tell the superclass we're about to render
|
// Tell the superclass we're about to render
|
||||||
const bool isRenderingToTarget = _onPreRender(state);
|
const bool isRenderingToTarget = _onPreRender(state);
|
||||||
|
|
@ -344,13 +344,13 @@ void RenderPrePassMgr::render( SceneRenderState *state )
|
||||||
matrixSet.restoreSceneViewProjection();
|
matrixSet.restoreSceneViewProjection();
|
||||||
const MatrixF worldViewXfm = GFX->getWorldMatrix();
|
const MatrixF worldViewXfm = GFX->getWorldMatrix();
|
||||||
|
|
||||||
// Setup the default prepass material for object instances.
|
// Setup the default deferred material for object instances.
|
||||||
if ( !mPrePassMatInstance )
|
if ( !mDeferredMatInstance )
|
||||||
_createPrePassMaterial();
|
_createDeferredMaterial();
|
||||||
if ( mPrePassMatInstance )
|
if ( mDeferredMatInstance )
|
||||||
{
|
{
|
||||||
matrixSet.setWorld(MatrixF::Identity);
|
matrixSet.setWorld(MatrixF::Identity);
|
||||||
mPrePassMatInstance->setTransforms(matrixSet, state);
|
mDeferredMatInstance->setTransforms(matrixSet, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signal start of pre-pass
|
// Signal start of pre-pass
|
||||||
|
|
@ -361,16 +361,16 @@ void RenderPrePassMgr::render( SceneRenderState *state )
|
||||||
// on the smaller meshes and objects.
|
// on the smaller meshes and objects.
|
||||||
|
|
||||||
// The terrain doesn't need any scene graph data
|
// The terrain doesn't need any scene graph data
|
||||||
// in the the prepass... so just clear it.
|
// in the the deferred... so just clear it.
|
||||||
SceneData sgData;
|
SceneData sgData;
|
||||||
sgData.init( state, SceneData::PrePassBin );
|
sgData.init( state, SceneData::DeferredBin );
|
||||||
|
|
||||||
Vector< MainSortElem >::const_iterator itr = mTerrainElementList.begin();
|
Vector< MainSortElem >::const_iterator itr = mTerrainElementList.begin();
|
||||||
for ( ; itr != mTerrainElementList.end(); itr++ )
|
for ( ; itr != mTerrainElementList.end(); itr++ )
|
||||||
{
|
{
|
||||||
TerrainRenderInst *ri = static_cast<TerrainRenderInst*>( itr->inst );
|
TerrainRenderInst *ri = static_cast<TerrainRenderInst*>( itr->inst );
|
||||||
|
|
||||||
TerrainCellMaterial *mat = ri->cellMat->getPrePassMat();
|
TerrainCellMaterial *mat = ri->cellMat->getDeferredMat();
|
||||||
|
|
||||||
GFX->setPrimitiveBuffer( ri->primBuff );
|
GFX->setPrimitiveBuffer( ri->primBuff );
|
||||||
GFX->setVertexBuffer( ri->vertBuff );
|
GFX->setVertexBuffer( ri->vertBuff );
|
||||||
|
|
@ -396,8 +396,8 @@ void RenderPrePassMgr::render( SceneRenderState *state )
|
||||||
{
|
{
|
||||||
MeshRenderInst *ri = static_cast<MeshRenderInst*>( itr->inst );
|
MeshRenderInst *ri = static_cast<MeshRenderInst*>( itr->inst );
|
||||||
|
|
||||||
// Get the prepass material.
|
// Get the deferred material.
|
||||||
BaseMatInstance *mat = getPrePassMaterial( ri->matInst );
|
BaseMatInstance *mat = getDeferredMaterial( ri->matInst );
|
||||||
|
|
||||||
// Set up SG data proper like and flag it
|
// Set up SG data proper like and flag it
|
||||||
// as a pre-pass render
|
// as a pre-pass render
|
||||||
|
|
@ -414,9 +414,9 @@ void RenderPrePassMgr::render( SceneRenderState *state )
|
||||||
|
|
||||||
// Check to see if we need to break this batch.
|
// Check to see if we need to break this batch.
|
||||||
//
|
//
|
||||||
// NOTE: We're comparing the non-prepass materials
|
// NOTE: We're comparing the non-deferred materials
|
||||||
// here so we don't incur the cost of looking up the
|
// here so we don't incur the cost of looking up the
|
||||||
// prepass hook on each inst.
|
// deferred hook on each inst.
|
||||||
//
|
//
|
||||||
if ( newPassNeeded( ri, passRI ) )
|
if ( newPassNeeded( ri, passRI ) )
|
||||||
break;
|
break;
|
||||||
|
|
@ -523,7 +523,7 @@ void RenderPrePassMgr::render( SceneRenderState *state )
|
||||||
{
|
{
|
||||||
ObjectRenderInst *ri = static_cast<ObjectRenderInst*>( itr->inst );
|
ObjectRenderInst *ri = static_cast<ObjectRenderInst*>( itr->inst );
|
||||||
if ( ri->renderDelegate )
|
if ( ri->renderDelegate )
|
||||||
ri->renderDelegate( ri, state, mPrePassMatInstance );
|
ri->renderDelegate( ri, state, mDeferredMatInstance );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signal end of pre-pass
|
// Signal end of pre-pass
|
||||||
|
|
@ -533,7 +533,7 @@ void RenderPrePassMgr::render( SceneRenderState *state )
|
||||||
_onPostRender();
|
_onPostRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
const GFXStateBlockDesc & RenderPrePassMgr::getOpaqueStenciWriteDesc( bool lightmappedGeometry /*= true*/ )
|
const GFXStateBlockDesc & RenderDeferredMgr::getOpaqueStenciWriteDesc( bool lightmappedGeometry /*= true*/ )
|
||||||
{
|
{
|
||||||
static bool sbInit = false;
|
static bool sbInit = false;
|
||||||
static GFXStateBlockDesc sOpaqueStaticLitStencilWriteDesc;
|
static GFXStateBlockDesc sOpaqueStaticLitStencilWriteDesc;
|
||||||
|
|
@ -548,7 +548,7 @@ const GFXStateBlockDesc & RenderPrePassMgr::getOpaqueStenciWriteDesc( bool light
|
||||||
sOpaqueStaticLitStencilWriteDesc.stencilEnable = true;
|
sOpaqueStaticLitStencilWriteDesc.stencilEnable = true;
|
||||||
sOpaqueStaticLitStencilWriteDesc.stencilWriteMask = 0x03;
|
sOpaqueStaticLitStencilWriteDesc.stencilWriteMask = 0x03;
|
||||||
sOpaqueStaticLitStencilWriteDesc.stencilMask = 0x03;
|
sOpaqueStaticLitStencilWriteDesc.stencilMask = 0x03;
|
||||||
sOpaqueStaticLitStencilWriteDesc.stencilRef = RenderPrePassMgr::OpaqueStaticLitMask;
|
sOpaqueStaticLitStencilWriteDesc.stencilRef = RenderDeferredMgr::OpaqueStaticLitMask;
|
||||||
sOpaqueStaticLitStencilWriteDesc.stencilPassOp = GFXStencilOpReplace;
|
sOpaqueStaticLitStencilWriteDesc.stencilPassOp = GFXStencilOpReplace;
|
||||||
sOpaqueStaticLitStencilWriteDesc.stencilFailOp = GFXStencilOpKeep;
|
sOpaqueStaticLitStencilWriteDesc.stencilFailOp = GFXStencilOpKeep;
|
||||||
sOpaqueStaticLitStencilWriteDesc.stencilZFailOp = GFXStencilOpKeep;
|
sOpaqueStaticLitStencilWriteDesc.stencilZFailOp = GFXStencilOpKeep;
|
||||||
|
|
@ -556,13 +556,13 @@ const GFXStateBlockDesc & RenderPrePassMgr::getOpaqueStenciWriteDesc( bool light
|
||||||
|
|
||||||
// Same only dynamic
|
// Same only dynamic
|
||||||
sOpaqueDynamicLitStencilWriteDesc = sOpaqueStaticLitStencilWriteDesc;
|
sOpaqueDynamicLitStencilWriteDesc = sOpaqueStaticLitStencilWriteDesc;
|
||||||
sOpaqueDynamicLitStencilWriteDesc.stencilRef = RenderPrePassMgr::OpaqueDynamicLitMask;
|
sOpaqueDynamicLitStencilWriteDesc.stencilRef = RenderDeferredMgr::OpaqueDynamicLitMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (lightmappedGeometry ? sOpaqueStaticLitStencilWriteDesc : sOpaqueDynamicLitStencilWriteDesc);
|
return (lightmappedGeometry ? sOpaqueStaticLitStencilWriteDesc : sOpaqueDynamicLitStencilWriteDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
const GFXStateBlockDesc & RenderPrePassMgr::getOpaqueStencilTestDesc()
|
const GFXStateBlockDesc & RenderDeferredMgr::getOpaqueStencilTestDesc()
|
||||||
{
|
{
|
||||||
static bool sbInit = false;
|
static bool sbInit = false;
|
||||||
static GFXStateBlockDesc sOpaqueStencilTestDesc;
|
static GFXStateBlockDesc sOpaqueStencilTestDesc;
|
||||||
|
|
@ -589,13 +589,13 @@ const GFXStateBlockDesc & RenderPrePassMgr::getOpaqueStencilTestDesc()
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
ProcessedPrePassMaterial::ProcessedPrePassMaterial( Material& mat, const RenderPrePassMgr *prePassMgr )
|
ProcessedDeferredMaterial::ProcessedDeferredMaterial( Material& mat, const RenderDeferredMgr *prePassMgr )
|
||||||
: Parent(mat), mPrePassMgr(prePassMgr)
|
: Parent(mat), mDeferredMgr(prePassMgr)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessedPrePassMaterial::_determineFeatures( U32 stageNum,
|
void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum,
|
||||||
MaterialFeatureData &fd,
|
MaterialFeatureData &fd,
|
||||||
const FeatureSet &features )
|
const FeatureSet &features )
|
||||||
{
|
{
|
||||||
|
|
@ -605,7 +605,7 @@ void ProcessedPrePassMaterial::_determineFeatures( U32 stageNum,
|
||||||
bool bEnableMRTLightmap = false;
|
bool bEnableMRTLightmap = false;
|
||||||
AdvancedLightBinManager *lightBin;
|
AdvancedLightBinManager *lightBin;
|
||||||
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
||||||
bEnableMRTLightmap = lightBin->MRTLightmapsDuringPrePass();
|
bEnableMRTLightmap = lightBin->MRTLightmapsDuringDeferred();
|
||||||
|
|
||||||
// If this material has a lightmap or tonemap (texture or baked vertex color),
|
// If this material has a lightmap or tonemap (texture or baked vertex color),
|
||||||
// it must be static. Otherwise it is dynamic.
|
// it must be static. Otherwise it is dynamic.
|
||||||
|
|
@ -617,17 +617,17 @@ void ProcessedPrePassMaterial::_determineFeatures( U32 stageNum,
|
||||||
fd.features.hasFeature( MFT_IsTranslucentZWrite) ) ) );
|
fd.features.hasFeature( MFT_IsTranslucentZWrite) ) ) );
|
||||||
|
|
||||||
// Integrate proper opaque stencil write state
|
// Integrate proper opaque stencil write state
|
||||||
mUserDefined.addDesc( mPrePassMgr->getOpaqueStenciWriteDesc( mIsLightmappedGeometry ) );
|
mUserDefined.addDesc( mDeferredMgr->getOpaqueStenciWriteDesc( mIsLightmappedGeometry ) );
|
||||||
|
|
||||||
FeatureSet newFeatures;
|
FeatureSet newFeatures;
|
||||||
|
|
||||||
// These are always on for prepass.
|
// These are always on for deferred.
|
||||||
newFeatures.addFeature( MFT_EyeSpaceDepthOut );
|
newFeatures.addFeature( MFT_EyeSpaceDepthOut );
|
||||||
newFeatures.addFeature( MFT_PrePassConditioner );
|
newFeatures.addFeature( MFT_DeferredConditioner );
|
||||||
|
|
||||||
#ifndef TORQUE_DEDICATED
|
#ifndef TORQUE_DEDICATED
|
||||||
|
|
||||||
//tag all materials running through prepass as deferred
|
//tag all materials running through deferred as deferred
|
||||||
newFeatures.addFeature(MFT_isDeferred);
|
newFeatures.addFeature(MFT_isDeferred);
|
||||||
|
|
||||||
// Deferred Shading : Diffuse
|
// Deferred Shading : Diffuse
|
||||||
|
|
@ -677,7 +677,7 @@ void ProcessedPrePassMaterial::_determineFeatures( U32 stageNum,
|
||||||
type == MFT_DetailNormalMap ||
|
type == MFT_DetailNormalMap ||
|
||||||
type == MFT_AlphaTest ||
|
type == MFT_AlphaTest ||
|
||||||
type == MFT_Parallax ||
|
type == MFT_Parallax ||
|
||||||
type == MFT_InterlacedPrePass ||
|
type == MFT_InterlacedDeferred ||
|
||||||
type == MFT_Visibility ||
|
type == MFT_Visibility ||
|
||||||
type == MFT_UseInstancing ||
|
type == MFT_UseInstancing ||
|
||||||
type == MFT_DiffuseVertColor ||
|
type == MFT_DiffuseVertColor ||
|
||||||
|
|
@ -764,7 +764,7 @@ void ProcessedPrePassMaterial::_determineFeatures( U32 stageNum,
|
||||||
fd.features = newFeatures;
|
fd.features = newFeatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
U32 ProcessedPrePassMaterial::getNumStages()
|
U32 ProcessedDeferredMaterial::getNumStages()
|
||||||
{
|
{
|
||||||
// Loops through all stages to determine how many
|
// Loops through all stages to determine how many
|
||||||
// stages we actually use.
|
// stages we actually use.
|
||||||
|
|
@ -816,12 +816,12 @@ U32 ProcessedPrePassMaterial::getNumStages()
|
||||||
return numStages;
|
return numStages;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessedPrePassMaterial::addStateBlockDesc(const GFXStateBlockDesc& desc)
|
void ProcessedDeferredMaterial::addStateBlockDesc(const GFXStateBlockDesc& desc)
|
||||||
{
|
{
|
||||||
GFXStateBlockDesc prePassStateBlock = desc;
|
GFXStateBlockDesc prePassStateBlock = desc;
|
||||||
|
|
||||||
// Adjust color writes if this is a pure z-fill pass
|
// Adjust color writes if this is a pure z-fill pass
|
||||||
const bool pixelOutEnabled = mPrePassMgr->getTargetChainLength() > 0;
|
const bool pixelOutEnabled = mDeferredMgr->getTargetChainLength() > 0;
|
||||||
if ( !pixelOutEnabled )
|
if ( !pixelOutEnabled )
|
||||||
{
|
{
|
||||||
prePassStateBlock.colorWriteDefined = true;
|
prePassStateBlock.colorWriteDefined = true;
|
||||||
|
|
@ -832,12 +832,12 @@ void ProcessedPrePassMaterial::addStateBlockDesc(const GFXStateBlockDesc& desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Never allow the alpha test state when rendering
|
// Never allow the alpha test state when rendering
|
||||||
// the prepass as we use the alpha channel for the
|
// the deferred as we use the alpha channel for the
|
||||||
// depth information... MFT_AlphaTest will handle it.
|
// depth information... MFT_AlphaTest will handle it.
|
||||||
prePassStateBlock.alphaDefined = true;
|
prePassStateBlock.alphaDefined = true;
|
||||||
prePassStateBlock.alphaTestEnable = false;
|
prePassStateBlock.alphaTestEnable = false;
|
||||||
|
|
||||||
// If we're translucent then we're doing prepass blending
|
// If we're translucent then we're doing deferred blending
|
||||||
// which never writes to the depth channels.
|
// which never writes to the depth channels.
|
||||||
const bool isTranslucent = getMaterial()->isTranslucent();
|
const bool isTranslucent = getMaterial()->isTranslucent();
|
||||||
if ( isTranslucent )
|
if ( isTranslucent )
|
||||||
|
|
@ -853,24 +853,24 @@ void ProcessedPrePassMaterial::addStateBlockDesc(const GFXStateBlockDesc& desc)
|
||||||
Parent::addStateBlockDesc(prePassStateBlock);
|
Parent::addStateBlockDesc(prePassStateBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrePassMatInstance::PrePassMatInstance(MatInstance* root, const RenderPrePassMgr *prePassMgr)
|
DeferredMatInstance::DeferredMatInstance(MatInstance* root, const RenderDeferredMgr *prePassMgr)
|
||||||
: Parent(*root->getMaterial()), mPrePassMgr(prePassMgr)
|
: Parent(*root->getMaterial()), mDeferredMgr(prePassMgr)
|
||||||
{
|
{
|
||||||
mFeatureList = root->getRequestedFeatures();
|
mFeatureList = root->getRequestedFeatures();
|
||||||
mVertexFormat = root->getVertexFormat();
|
mVertexFormat = root->getVertexFormat();
|
||||||
mUserObject = root->getUserObject();
|
mUserObject = root->getUserObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
PrePassMatInstance::~PrePassMatInstance()
|
DeferredMatInstance::~DeferredMatInstance()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessedMaterial* PrePassMatInstance::getShaderMaterial()
|
ProcessedMaterial* DeferredMatInstance::getShaderMaterial()
|
||||||
{
|
{
|
||||||
return new ProcessedPrePassMaterial(*mMaterial, mPrePassMgr);
|
return new ProcessedDeferredMaterial(*mMaterial, mDeferredMgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrePassMatInstance::init( const FeatureSet &features,
|
bool DeferredMatInstance::init( const FeatureSet &features,
|
||||||
const GFXVertexFormat *vertexFormat )
|
const GFXVertexFormat *vertexFormat )
|
||||||
{
|
{
|
||||||
bool vaild = Parent::init(features, vertexFormat);
|
bool vaild = Parent::init(features, vertexFormat);
|
||||||
|
|
@ -891,27 +891,27 @@ bool PrePassMatInstance::init( const FeatureSet &features,
|
||||||
return vaild;
|
return vaild;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrePassMatInstanceHook::PrePassMatInstanceHook( MatInstance *baseMatInst,
|
DeferredMatInstanceHook::DeferredMatInstanceHook( MatInstance *baseMatInst,
|
||||||
const RenderPrePassMgr *prePassMgr )
|
const RenderDeferredMgr *prePassMgr )
|
||||||
: mHookedPrePassMatInst(NULL), mPrePassManager(prePassMgr)
|
: mHookedDeferredMatInst(NULL), mDeferredManager(prePassMgr)
|
||||||
{
|
{
|
||||||
// If the material is a custom material then
|
// If the material is a custom material then
|
||||||
// hope that using DefaultPrePassMaterial gives
|
// hope that using DefaultDeferredMaterial gives
|
||||||
// them a good prepass.
|
// them a good deferred.
|
||||||
if ( baseMatInst->isCustomMaterial() )
|
if ( baseMatInst->isCustomMaterial() )
|
||||||
{
|
{
|
||||||
MatInstance* dummyInst = static_cast<MatInstance*>( MATMGR->createMatInstance( "AL_DefaultPrePassMaterial", baseMatInst->getVertexFormat() ) );
|
MatInstance* dummyInst = static_cast<MatInstance*>( MATMGR->createMatInstance( "AL_DefaultDeferredMaterial", baseMatInst->getVertexFormat() ) );
|
||||||
|
|
||||||
mHookedPrePassMatInst = new PrePassMatInstance( dummyInst, prePassMgr );
|
mHookedDeferredMatInst = new DeferredMatInstance( dummyInst, prePassMgr );
|
||||||
mHookedPrePassMatInst->init( dummyInst->getRequestedFeatures(), baseMatInst->getVertexFormat());
|
mHookedDeferredMatInst->init( dummyInst->getRequestedFeatures(), baseMatInst->getVertexFormat());
|
||||||
|
|
||||||
delete dummyInst;
|
delete dummyInst;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the prepass material instance.
|
// Create the deferred material instance.
|
||||||
mHookedPrePassMatInst = new PrePassMatInstance(baseMatInst, prePassMgr);
|
mHookedDeferredMatInst = new DeferredMatInstance(baseMatInst, prePassMgr);
|
||||||
mHookedPrePassMatInst->getFeaturesDelegate() = baseMatInst->getFeaturesDelegate();
|
mHookedDeferredMatInst->getFeaturesDelegate() = baseMatInst->getFeaturesDelegate();
|
||||||
|
|
||||||
// Get the features, but remove the instancing feature if the
|
// Get the features, but remove the instancing feature if the
|
||||||
// original material didn't end up using it.
|
// original material didn't end up using it.
|
||||||
|
|
@ -920,12 +920,12 @@ PrePassMatInstanceHook::PrePassMatInstanceHook( MatInstance *baseMatInst,
|
||||||
features.removeFeature( MFT_UseInstancing );
|
features.removeFeature( MFT_UseInstancing );
|
||||||
|
|
||||||
// Initialize the material.
|
// Initialize the material.
|
||||||
mHookedPrePassMatInst->init(features, baseMatInst->getVertexFormat());
|
mHookedDeferredMatInst->init(features, baseMatInst->getVertexFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
PrePassMatInstanceHook::~PrePassMatInstanceHook()
|
DeferredMatInstanceHook::~DeferredMatInstanceHook()
|
||||||
{
|
{
|
||||||
SAFE_DELETE(mHookedPrePassMatInst);
|
SAFE_DELETE(mHookedDeferredMatInst);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -1027,10 +1027,10 @@ Var* LinearEyeDepthConditioner::printMethodHeader( MethodType methodType, const
|
||||||
methodVar->setType("inline float4");
|
methodVar->setType("inline float4");
|
||||||
DecOp *methodDecl = new DecOp(methodVar);
|
DecOp *methodDecl = new DecOp(methodVar);
|
||||||
|
|
||||||
Var *prepassSampler = new Var;
|
Var *deferredSampler = new Var;
|
||||||
prepassSampler->setName("prepassSamplerVar");
|
deferredSampler->setName("deferredSamplerVar");
|
||||||
prepassSampler->setType("sampler2D");
|
deferredSampler->setType("sampler2D");
|
||||||
DecOp *prepassSamplerDecl = new DecOp(prepassSampler);
|
DecOp *deferredSamplerDecl = new DecOp(deferredSampler);
|
||||||
|
|
||||||
Var *screenUV = new Var;
|
Var *screenUV = new Var;
|
||||||
screenUV->setName("screenUVVar");
|
screenUV->setName("screenUVVar");
|
||||||
|
|
@ -1048,7 +1048,7 @@ Var* LinearEyeDepthConditioner::printMethodHeader( MethodType methodType, const
|
||||||
bufferSample->setType("float4");
|
bufferSample->setType("float4");
|
||||||
DecOp *bufferSampleDecl = new DecOp(bufferSample);
|
DecOp *bufferSampleDecl = new DecOp(bufferSample);
|
||||||
|
|
||||||
meta->addStatement( new GenOp( "@(@, @)\r\n", methodDecl, prepassSamplerDecl, screenUVDecl ) );
|
meta->addStatement( new GenOp( "@(@, @)\r\n", methodDecl, deferredSamplerDecl, screenUVDecl ) );
|
||||||
|
|
||||||
meta->addStatement( new GenOp( "{\r\n" ) );
|
meta->addStatement( new GenOp( "{\r\n" ) );
|
||||||
|
|
||||||
|
|
@ -1058,14 +1058,14 @@ Var* LinearEyeDepthConditioner::printMethodHeader( MethodType methodType, const
|
||||||
// possible so that the shader compiler can optimize.
|
// possible so that the shader compiler can optimize.
|
||||||
meta->addStatement( new GenOp( " #if TORQUE_SM >= 30\r\n" ) );
|
meta->addStatement( new GenOp( " #if TORQUE_SM >= 30\r\n" ) );
|
||||||
if (GFX->getAdapterType() == OpenGL)
|
if (GFX->getAdapterType() == OpenGL)
|
||||||
meta->addStatement( new GenOp( " @ = textureLod(@, @, 0); \r\n", bufferSampleDecl, prepassSampler, screenUV) );
|
meta->addStatement( new GenOp( " @ = textureLod(@, @, 0); \r\n", bufferSampleDecl, deferredSampler, screenUV) );
|
||||||
else
|
else
|
||||||
meta->addStatement( new GenOp( " @ = tex2Dlod(@, float4(@,0,0));\r\n", bufferSampleDecl, prepassSampler, screenUV ) );
|
meta->addStatement( new GenOp( " @ = tex2Dlod(@, float4(@,0,0));\r\n", bufferSampleDecl, deferredSampler, screenUV ) );
|
||||||
meta->addStatement( new GenOp( " #else\r\n" ) );
|
meta->addStatement( new GenOp( " #else\r\n" ) );
|
||||||
if (GFX->getAdapterType() == OpenGL)
|
if (GFX->getAdapterType() == OpenGL)
|
||||||
meta->addStatement( new GenOp( " @ = texture(@, @);\r\n", bufferSampleDecl, prepassSampler, screenUV) );
|
meta->addStatement( new GenOp( " @ = texture(@, @);\r\n", bufferSampleDecl, deferredSampler, screenUV) );
|
||||||
else
|
else
|
||||||
meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n", bufferSampleDecl, prepassSampler, screenUV ) );
|
meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n", bufferSampleDecl, deferredSampler, screenUV ) );
|
||||||
meta->addStatement( new GenOp( " #endif\r\n\r\n" ) );
|
meta->addStatement( new GenOp( " #endif\r\n\r\n" ) );
|
||||||
|
|
||||||
// We don't use this way of passing var's around, so this should cause a crash
|
// We don't use this way of passing var's around, so this should cause a crash
|
||||||
|
|
@ -1076,7 +1076,7 @@ Var* LinearEyeDepthConditioner::printMethodHeader( MethodType methodType, const
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPrePassMgr::_initShaders()
|
void RenderDeferredMgr::_initShaders()
|
||||||
{
|
{
|
||||||
if ( mClearGBufferShader ) return;
|
if ( mClearGBufferShader ) return;
|
||||||
|
|
||||||
|
|
@ -1084,7 +1084,7 @@ void RenderPrePassMgr::_initShaders()
|
||||||
ShaderData *shaderData;
|
ShaderData *shaderData;
|
||||||
mClearGBufferShader = Sim::findObject( "ClearGBufferShader", shaderData ) ? shaderData->getShader() : NULL;
|
mClearGBufferShader = Sim::findObject( "ClearGBufferShader", shaderData ) ? shaderData->getShader() : NULL;
|
||||||
if ( !mClearGBufferShader )
|
if ( !mClearGBufferShader )
|
||||||
Con::errorf( "RenderPrePassMgr::_initShaders - could not find ClearGBufferShader" );
|
Con::errorf( "RenderDeferredMgr::_initShaders - could not find ClearGBufferShader" );
|
||||||
|
|
||||||
// Create StateBlocks
|
// Create StateBlocks
|
||||||
GFXStateBlockDesc desc;
|
GFXStateBlockDesc desc;
|
||||||
|
|
@ -1108,7 +1108,7 @@ void RenderPrePassMgr::_initShaders()
|
||||||
mSpecularPowerSC = mClearGBufferShader->getShaderConstHandle( "$specularPower" );
|
mSpecularPowerSC = mClearGBufferShader->getShaderConstHandle( "$specularPower" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPrePassMgr::clearBuffers()
|
void RenderDeferredMgr::clearBuffers()
|
||||||
{
|
{
|
||||||
// Clear z-buffer.
|
// Clear z-buffer.
|
||||||
GFX->clear( GFXClearTarget | GFXClearZBuffer | GFXClearStencil, ColorI::ZERO, 1.0f, 0);
|
GFX->clear( GFXClearTarget | GFXClearZBuffer | GFXClearStencil, ColorI::ZERO, 1.0f, 0);
|
||||||
|
|
@ -29,12 +29,12 @@
|
||||||
#include "core/util/autoPtr.h"
|
#include "core/util/autoPtr.h"
|
||||||
|
|
||||||
// Forward declare
|
// Forward declare
|
||||||
class PrePassMatInstance;
|
class DeferredMatInstance;
|
||||||
|
|
||||||
// This render manager renders opaque objects to the z-buffer as a z-fill pass.
|
// This render manager renders opaque objects to the z-buffer as a z-fill pass.
|
||||||
// It can optionally accumulate data from this opaque render pass into a render
|
// It can optionally accumulate data from this opaque render pass into a render
|
||||||
// target for later use.
|
// target for later use.
|
||||||
class RenderPrePassMgr : public RenderTexTargetBinManager
|
class RenderDeferredMgr : public RenderTexTargetBinManager
|
||||||
{
|
{
|
||||||
typedef RenderTexTargetBinManager Parent;
|
typedef RenderTexTargetBinManager Parent;
|
||||||
|
|
||||||
|
|
@ -47,15 +47,15 @@ public:
|
||||||
static const String ColorBufferName;
|
static const String ColorBufferName;
|
||||||
static const String MatInfoBufferName;
|
static const String MatInfoBufferName;
|
||||||
|
|
||||||
// Generic PrePass Render Instance Type
|
// Generic Deferred Render Instance Type
|
||||||
static const RenderInstType RIT_PrePass;
|
static const RenderInstType RIT_Deferred;
|
||||||
|
|
||||||
RenderPrePassMgr( bool gatherDepth = true,
|
RenderDeferredMgr( bool gatherDepth = true,
|
||||||
GFXFormat format = GFXFormatR16G16B16A16 );
|
GFXFormat format = GFXFormatR16G16B16A16 );
|
||||||
|
|
||||||
virtual ~RenderPrePassMgr();
|
virtual ~RenderDeferredMgr();
|
||||||
|
|
||||||
virtual void setPrePassMaterial( PrePassMatInstance *mat );
|
virtual void setDeferredMaterial( DeferredMatInstance *mat );
|
||||||
|
|
||||||
// RenderBinManager interface
|
// RenderBinManager interface
|
||||||
virtual void render(SceneRenderState * state);
|
virtual void render(SceneRenderState * state);
|
||||||
|
|
@ -64,10 +64,10 @@ public:
|
||||||
virtual void addElement( RenderInst *inst );
|
virtual void addElement( RenderInst *inst );
|
||||||
|
|
||||||
// ConsoleObject
|
// ConsoleObject
|
||||||
DECLARE_CONOBJECT(RenderPrePassMgr);
|
DECLARE_CONOBJECT(RenderDeferredMgr);
|
||||||
|
|
||||||
|
|
||||||
typedef Signal<void(const SceneRenderState*, RenderPrePassMgr*, bool)> RenderSignal;
|
typedef Signal<void(const SceneRenderState*, RenderDeferredMgr*, bool)> RenderSignal;
|
||||||
|
|
||||||
static RenderSignal& getRenderSignal();
|
static RenderSignal& getRenderSignal();
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ public:
|
||||||
|
|
||||||
virtual bool setTargetSize(const Point2I &newTargetSize);
|
virtual bool setTargetSize(const Point2I &newTargetSize);
|
||||||
|
|
||||||
inline BaseMatInstance* getPrePassMaterial( BaseMatInstance *mat );
|
inline BaseMatInstance* getDeferredMaterial( BaseMatInstance *mat );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
@ -89,12 +89,12 @@ protected:
|
||||||
/// The object render instance elements.
|
/// The object render instance elements.
|
||||||
Vector< MainSortElem > mObjectElementList;
|
Vector< MainSortElem > mObjectElementList;
|
||||||
|
|
||||||
PrePassMatInstance *mPrePassMatInstance;
|
DeferredMatInstance *mDeferredMatInstance;
|
||||||
|
|
||||||
virtual void _registerFeatures();
|
virtual void _registerFeatures();
|
||||||
virtual void _unregisterFeatures();
|
virtual void _unregisterFeatures();
|
||||||
virtual bool _updateTargets();
|
virtual bool _updateTargets();
|
||||||
virtual void _createPrePassMaterial();
|
virtual void _createDeferredMaterial();
|
||||||
|
|
||||||
bool _lightManagerActivate(bool active);
|
bool _lightManagerActivate(bool active);
|
||||||
|
|
||||||
|
|
@ -117,12 +117,12 @@ public:
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
class ProcessedPrePassMaterial : public ProcessedShaderMaterial
|
class ProcessedDeferredMaterial : public ProcessedShaderMaterial
|
||||||
{
|
{
|
||||||
typedef ProcessedShaderMaterial Parent;
|
typedef ProcessedShaderMaterial Parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProcessedPrePassMaterial(Material& mat, const RenderPrePassMgr *prePassMgr);
|
ProcessedDeferredMaterial(Material& mat, const RenderDeferredMgr *prePassMgr);
|
||||||
|
|
||||||
virtual U32 getNumStages();
|
virtual U32 getNumStages();
|
||||||
|
|
||||||
|
|
@ -131,19 +131,19 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual void _determineFeatures( U32 stageNum, MaterialFeatureData &fd, const FeatureSet &features );
|
virtual void _determineFeatures( U32 stageNum, MaterialFeatureData &fd, const FeatureSet &features );
|
||||||
|
|
||||||
const RenderPrePassMgr *mPrePassMgr;
|
const RenderDeferredMgr *mDeferredMgr;
|
||||||
bool mIsLightmappedGeometry;
|
bool mIsLightmappedGeometry;
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
class PrePassMatInstance : public MatInstance
|
class DeferredMatInstance : public MatInstance
|
||||||
{
|
{
|
||||||
typedef MatInstance Parent;
|
typedef MatInstance Parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PrePassMatInstance(MatInstance* root, const RenderPrePassMgr *prePassMgr);
|
DeferredMatInstance(MatInstance* root, const RenderDeferredMgr *prePassMgr);
|
||||||
virtual ~PrePassMatInstance();
|
virtual ~DeferredMatInstance();
|
||||||
|
|
||||||
bool init()
|
bool init()
|
||||||
{
|
{
|
||||||
|
|
@ -157,27 +157,27 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual ProcessedMaterial* getShaderMaterial();
|
virtual ProcessedMaterial* getShaderMaterial();
|
||||||
|
|
||||||
const RenderPrePassMgr *mPrePassMgr;
|
const RenderDeferredMgr *mDeferredMgr;
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
class PrePassMatInstanceHook : public MatInstanceHook
|
class DeferredMatInstanceHook : public MatInstanceHook
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PrePassMatInstanceHook(MatInstance *baseMatInst, const RenderPrePassMgr *prePassMgr);
|
DeferredMatInstanceHook(MatInstance *baseMatInst, const RenderDeferredMgr *prePassMgr);
|
||||||
virtual ~PrePassMatInstanceHook();
|
virtual ~DeferredMatInstanceHook();
|
||||||
|
|
||||||
virtual PrePassMatInstance *getPrePassMatInstance() { return mHookedPrePassMatInst; }
|
virtual DeferredMatInstance *getDeferredMatInstance() { return mHookedDeferredMatInst; }
|
||||||
|
|
||||||
virtual const MatInstanceHookType& getType() const { return Type; }
|
virtual const MatInstanceHookType& getType() const { return Type; }
|
||||||
|
|
||||||
/// The type for prepass material hooks.
|
/// The type for deferred material hooks.
|
||||||
static const MatInstanceHookType Type;
|
static const MatInstanceHookType Type;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PrePassMatInstance *mHookedPrePassMatInst;
|
DeferredMatInstance *mHookedDeferredMatInst;
|
||||||
const RenderPrePassMgr *mPrePassManager;
|
const RenderDeferredMgr *mDeferredManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
@ -208,16 +208,16 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline BaseMatInstance* RenderPrePassMgr::getPrePassMaterial( BaseMatInstance *mat )
|
inline BaseMatInstance* RenderDeferredMgr::getDeferredMaterial( BaseMatInstance *mat )
|
||||||
{
|
{
|
||||||
PrePassMatInstanceHook *hook = static_cast<PrePassMatInstanceHook*>( mat->getHook( PrePassMatInstanceHook::Type ) );
|
DeferredMatInstanceHook *hook = static_cast<DeferredMatInstanceHook*>( mat->getHook( DeferredMatInstanceHook::Type ) );
|
||||||
if ( !hook )
|
if ( !hook )
|
||||||
{
|
{
|
||||||
hook = new PrePassMatInstanceHook( static_cast<MatInstance*>( mat ), this );
|
hook = new DeferredMatInstanceHook( static_cast<MatInstance*>( mat ), this );
|
||||||
mat->addHook( hook );
|
mat->addHook( hook );
|
||||||
}
|
}
|
||||||
|
|
||||||
return hook->getPrePassMatInstance();
|
return hook->getDeferredMatInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _PREPASS_MGR_H_
|
#endif // _PREPASS_MGR_H_
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
#include "lighting/lightInfo.h"
|
#include "lighting/lightInfo.h"
|
||||||
#include "scene/sceneRenderState.h"
|
#include "scene/sceneRenderState.h"
|
||||||
#include "gfx/gfxDebugEvent.h"
|
#include "gfx/gfxDebugEvent.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
#include "gfx/gfxTransformSaver.h"
|
#include "gfx/gfxTransformSaver.h"
|
||||||
#include "console/consoleTypes.h"
|
#include "console/consoleTypes.h"
|
||||||
#include "gfx/util/screenspace.h"
|
#include "gfx/util/screenspace.h"
|
||||||
|
|
@ -70,7 +70,7 @@ RenderImposterMgr::RenderImposterMgr( F32 renderOrder, F32 processAddOrder )
|
||||||
: RenderBinManager( RIT_Imposter, renderOrder, processAddOrder )
|
: RenderBinManager( RIT_Imposter, renderOrder, processAddOrder )
|
||||||
{
|
{
|
||||||
notifyType( RIT_ImposterBatch );
|
notifyType( RIT_ImposterBatch );
|
||||||
RenderPrePassMgr::getRenderSignal().notify( this, &RenderImposterMgr::_renderPrePass );
|
RenderDeferredMgr::getRenderSignal().notify( this, &RenderImposterMgr::_renderDeferred );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderImposterMgr::initPersistFields()
|
void RenderImposterMgr::initPersistFields()
|
||||||
|
|
@ -88,7 +88,7 @@ void RenderImposterMgr::initPersistFields()
|
||||||
|
|
||||||
RenderImposterMgr::~RenderImposterMgr()
|
RenderImposterMgr::~RenderImposterMgr()
|
||||||
{
|
{
|
||||||
RenderPrePassMgr::getRenderSignal().remove( this, &RenderImposterMgr::_renderPrePass );
|
RenderDeferredMgr::getRenderSignal().remove( this, &RenderImposterMgr::_renderDeferred );
|
||||||
|
|
||||||
mIB = NULL;
|
mIB = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -119,19 +119,19 @@ bool RenderImposterMgr::_clearStats( GFXDevice::GFXDeviceEventType type )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderImposterMgr::_renderPrePass( const SceneRenderState *state, RenderPrePassMgr *prePassBin, bool startPrePass )
|
void RenderImposterMgr::_renderDeferred( const SceneRenderState *state, RenderDeferredMgr *prePassBin, bool startDeferred )
|
||||||
{
|
{
|
||||||
PROFILE_SCOPE( RenderImposterMgr_RenderPrePass );
|
PROFILE_SCOPE( RenderImposterMgr_RenderDeferred );
|
||||||
|
|
||||||
if ( !mElementList.size() || !startPrePass )
|
if ( !mElementList.size() || !startDeferred )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GFXDEBUGEVENT_SCOPE( RenderImposterMgr_RenderPrePass, ColorI::RED );
|
GFXDEBUGEVENT_SCOPE( RenderImposterMgr_RenderDeferred, ColorI::RED );
|
||||||
|
|
||||||
_innerRender( state, prePassBin );
|
_innerRender( state, prePassBin );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderImposterMgr::_innerRender( const SceneRenderState *state, RenderPrePassMgr *prePassBin )
|
void RenderImposterMgr::_innerRender( const SceneRenderState *state, RenderDeferredMgr *prePassBin )
|
||||||
{
|
{
|
||||||
PROFILE_SCOPE( RenderImposterMgr_InnerRender );
|
PROFILE_SCOPE( RenderImposterMgr_InnerRender );
|
||||||
|
|
||||||
|
|
@ -219,7 +219,7 @@ void RenderImposterMgr::_innerRender( const SceneRenderState *state, RenderPrePa
|
||||||
// list changes.
|
// list changes.
|
||||||
|
|
||||||
SceneData sgData;
|
SceneData sgData;
|
||||||
sgData.init( state, prePassBin ? SceneData::PrePassBin : SceneData::RegularBin );
|
sgData.init( state, prePassBin ? SceneData::DeferredBin : SceneData::RegularBin );
|
||||||
sgData.lights[0] = LIGHTMGR->getDefaultLight();
|
sgData.lights[0] = LIGHTMGR->getDefaultLight();
|
||||||
|
|
||||||
// TODO: I should rework this loop to generate the VB first then
|
// TODO: I should rework this loop to generate the VB first then
|
||||||
|
|
@ -232,7 +232,7 @@ void RenderImposterMgr::_innerRender( const SceneRenderState *state, RenderPrePa
|
||||||
for ( U32 i=0; i < binSize; )
|
for ( U32 i=0; i < binSize; )
|
||||||
{
|
{
|
||||||
currMat = static_cast<ImposterBaseRenderInst*>( mElementList[i].inst )->mat;
|
currMat = static_cast<ImposterBaseRenderInst*>( mElementList[i].inst )->mat;
|
||||||
setupMat = prePassBin ? prePassBin->getPrePassMaterial( currMat ) : currMat;
|
setupMat = prePassBin ? prePassBin->getDeferredMaterial( currMat ) : currMat;
|
||||||
|
|
||||||
// TODO: Fix MatInstance to take a const SceneRenderState!
|
// TODO: Fix MatInstance to take a const SceneRenderState!
|
||||||
while ( setupMat->setupPass( (SceneRenderState*)state, sgData ) )
|
while ( setupMat->setupPass( (SceneRenderState*)state, sgData ) )
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
class TSLastDetail;
|
class TSLastDetail;
|
||||||
class GFXTextureObject;
|
class GFXTextureObject;
|
||||||
class RenderPrePassMgr;
|
class RenderDeferredMgr;
|
||||||
struct ImposterRenderInst;
|
struct ImposterRenderInst;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -74,9 +74,9 @@ protected:
|
||||||
GFXPrimitiveBufferHandle mIB;
|
GFXPrimitiveBufferHandle mIB;
|
||||||
//GFXVertexBufferHandle<ImposterCorner> mCornerVB;
|
//GFXVertexBufferHandle<ImposterCorner> mCornerVB;
|
||||||
|
|
||||||
void _innerRender( const SceneRenderState *state, RenderPrePassMgr *prePassBin );
|
void _innerRender( const SceneRenderState *state, RenderDeferredMgr *prePassBin );
|
||||||
|
|
||||||
void _renderPrePass( const SceneRenderState *state, RenderPrePassMgr *prePassBin, bool startPrePass );
|
void _renderDeferred( const SceneRenderState *state, RenderDeferredMgr *prePassBin, bool startDeferred );
|
||||||
|
|
||||||
static bool _clearStats( GFXDevice::GFXDeviceEventType type );
|
static bool _clearStats( GFXDevice::GFXDeviceEventType type );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ void RenderMeshMgr::render(SceneRenderState * state)
|
||||||
// Check if bin is disabled in advanced lighting.
|
// Check if bin is disabled in advanced lighting.
|
||||||
// Allow forward rendering pass on custom materials.
|
// Allow forward rendering pass on custom materials.
|
||||||
|
|
||||||
if ( ( MATMGR->getPrePassEnabled() && mBasicOnly && !mat->isCustomMaterial() ) )
|
if ( ( MATMGR->getDeferredEnabled() && mBasicOnly && !mat->isCustomMaterial() ) )
|
||||||
{
|
{
|
||||||
j++;
|
j++;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ void RenderObjectMgr::render( SceneRenderState *state )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Check if bin is disabled in advanced lighting.
|
// Check if bin is disabled in advanced lighting.
|
||||||
if ( MATMGR->getPrePassEnabled() && mBasicOnly )
|
if ( MATMGR->getDeferredEnabled() && mBasicOnly )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for( U32 i=0; i<mElementList.size(); i++ )
|
for( U32 i=0; i<mElementList.size(); i++ )
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
#include "renderInstance/renderParticleMgr.h"
|
#include "renderInstance/renderParticleMgr.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
#include "scene/sceneManager.h"
|
#include "scene/sceneManager.h"
|
||||||
#include "scene/sceneObject.h"
|
#include "scene/sceneObject.h"
|
||||||
#include "scene/sceneRenderState.h"
|
#include "scene/sceneRenderState.h"
|
||||||
|
|
@ -512,17 +512,17 @@ void RenderParticleMgr::renderParticle(ParticleRenderInst* ri, SceneRenderState*
|
||||||
|
|
||||||
GFX->setTexture( mParticleShaderConsts.mSamplerDiffuse->getSamplerRegister(), ri->diffuseTex );
|
GFX->setTexture( mParticleShaderConsts.mSamplerDiffuse->getSamplerRegister(), ri->diffuseTex );
|
||||||
|
|
||||||
// Set up the prepass texture.
|
// Set up the deferred texture.
|
||||||
if ( mParticleShaderConsts.mPrePassTargetParamsSC->isValid() )
|
if ( mParticleShaderConsts.mDeferredTargetParamsSC->isValid() )
|
||||||
{
|
{
|
||||||
GFXTextureObject *texObject = mPrepassTarget ? mPrepassTarget->getTexture(0) : NULL;
|
GFXTextureObject *texObject = mDeferredTarget ? mDeferredTarget->getTexture(0) : NULL;
|
||||||
GFX->setTexture( mParticleShaderConsts.mSamplerPrePassTex->getSamplerRegister(), texObject );
|
GFX->setTexture( mParticleShaderConsts.mSamplerDeferredTex->getSamplerRegister(), texObject );
|
||||||
|
|
||||||
Point4F rtParams( 0.0f, 0.0f, 1.0f, 1.0f );
|
Point4F rtParams( 0.0f, 0.0f, 1.0f, 1.0f );
|
||||||
if ( texObject )
|
if ( texObject )
|
||||||
ScreenSpace::RenderTargetParameters(texObject->getSize(), mPrepassTarget->getViewport(), rtParams);
|
ScreenSpace::RenderTargetParameters(texObject->getSize(), mDeferredTarget->getViewport(), rtParams);
|
||||||
|
|
||||||
mParticleShaderConsts.mShaderConsts->set( mParticleShaderConsts.mPrePassTargetParamsSC, rtParams );
|
mParticleShaderConsts.mShaderConsts->set( mParticleShaderConsts.mDeferredTargetParamsSC, rtParams );
|
||||||
}
|
}
|
||||||
|
|
||||||
GFX->setPrimitiveBuffer( *ri->primBuff );
|
GFX->setPrimitiveBuffer( *ri->primBuff );
|
||||||
|
|
@ -538,8 +538,8 @@ bool RenderParticleMgr::_initShader()
|
||||||
|
|
||||||
// Need depth from pre-pass, so get the macros
|
// Need depth from pre-pass, so get the macros
|
||||||
Vector<GFXShaderMacro> macros;
|
Vector<GFXShaderMacro> macros;
|
||||||
if ( mPrepassTarget )
|
if ( mDeferredTarget )
|
||||||
mPrepassTarget->getShaderMacros( ¯os );
|
mDeferredTarget->getShaderMacros( ¯os );
|
||||||
|
|
||||||
// Create particle shader
|
// Create particle shader
|
||||||
if ( !Sim::findObject( "ParticlesShaderData", shaderData ) || !shaderData )
|
if ( !Sim::findObject( "ParticlesShaderData", shaderData ) || !shaderData )
|
||||||
|
|
@ -557,11 +557,11 @@ bool RenderParticleMgr::_initShader()
|
||||||
mParticleShaderConsts.mAlphaFactorSC = mParticleShader->getShaderConstHandle( "$alphaFactor" );
|
mParticleShaderConsts.mAlphaFactorSC = mParticleShader->getShaderConstHandle( "$alphaFactor" );
|
||||||
mParticleShaderConsts.mAlphaScaleSC = mParticleShader->getShaderConstHandle( "$alphaScale" );
|
mParticleShaderConsts.mAlphaScaleSC = mParticleShader->getShaderConstHandle( "$alphaScale" );
|
||||||
mParticleShaderConsts.mFSModelViewProjSC = mParticleShader->getShaderConstHandle( "$fsModelViewProj" );
|
mParticleShaderConsts.mFSModelViewProjSC = mParticleShader->getShaderConstHandle( "$fsModelViewProj" );
|
||||||
mParticleShaderConsts.mPrePassTargetParamsSC = mParticleShader->getShaderConstHandle( "$prePassTargetParams" );
|
mParticleShaderConsts.mDeferredTargetParamsSC = mParticleShader->getShaderConstHandle( "$prePassTargetParams" );
|
||||||
|
|
||||||
//samplers
|
//samplers
|
||||||
mParticleShaderConsts.mSamplerDiffuse = mParticleShader->getShaderConstHandle("$diffuseMap");
|
mParticleShaderConsts.mSamplerDiffuse = mParticleShader->getShaderConstHandle("$diffuseMap");
|
||||||
mParticleShaderConsts.mSamplerPrePassTex = mParticleShader->getShaderConstHandle("$prepassTex");
|
mParticleShaderConsts.mSamplerDeferredTex = mParticleShader->getShaderConstHandle("$deferredTex");
|
||||||
mParticleShaderConsts.mSamplerParaboloidLightMap = mParticleShader->getShaderConstHandle("$paraboloidLightMap");
|
mParticleShaderConsts.mSamplerParaboloidLightMap = mParticleShader->getShaderConstHandle("$paraboloidLightMap");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -596,18 +596,18 @@ void RenderParticleMgr::_onLMActivate( const char*, bool activate )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Hunt for the pre-pass manager/target
|
// Hunt for the pre-pass manager/target
|
||||||
RenderPrePassMgr *prePassBin = NULL;
|
RenderDeferredMgr *prePassBin = NULL;
|
||||||
for( U32 i = 0; i < rpm->getManagerCount(); i++ )
|
for( U32 i = 0; i < rpm->getManagerCount(); i++ )
|
||||||
{
|
{
|
||||||
RenderBinManager *bin = rpm->getManager(i);
|
RenderBinManager *bin = rpm->getManager(i);
|
||||||
if( bin->getRenderInstType() == RenderPrePassMgr::RIT_PrePass )
|
if( bin->getRenderInstType() == RenderDeferredMgr::RIT_Deferred )
|
||||||
{
|
{
|
||||||
prePassBin = (RenderPrePassMgr*)bin;
|
prePassBin = (RenderDeferredMgr*)bin;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we found the prepass bin, set this bin to render very shortly afterwards
|
// If we found the deferred bin, set this bin to render very shortly afterwards
|
||||||
// and re-add this render-manager. If there is no pre-pass bin, or it doesn't
|
// and re-add this render-manager. If there is no pre-pass bin, or it doesn't
|
||||||
// have a depth-texture, we can't render offscreen.
|
// have a depth-texture, we can't render offscreen.
|
||||||
mOffscreenRenderEnabled = prePassBin && (prePassBin->getTargetChainLength() > 0);
|
mOffscreenRenderEnabled = prePassBin && (prePassBin->getTargetChainLength() > 0);
|
||||||
|
|
@ -619,7 +619,7 @@ void RenderParticleMgr::_onLMActivate( const char*, bool activate )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the targets we use
|
// Find the targets we use
|
||||||
mPrepassTarget = NamedTexTarget::find( "prepass" );
|
mDeferredTarget = NamedTexTarget::find( "deferred" );
|
||||||
mEdgeTarget = NamedTexTarget::find( "edge" );
|
mEdgeTarget = NamedTexTarget::find( "edge" );
|
||||||
|
|
||||||
// Setup the shader
|
// Setup the shader
|
||||||
|
|
@ -668,7 +668,7 @@ GFXStateBlockRef RenderParticleMgr::_getOffscreenStateBlock(ParticleRenderInst *
|
||||||
d.samplers[0].alphaArg1 = GFXTATexture;
|
d.samplers[0].alphaArg1 = GFXTATexture;
|
||||||
d.samplers[0].alphaArg2 = GFXTADiffuse;
|
d.samplers[0].alphaArg2 = GFXTADiffuse;
|
||||||
|
|
||||||
// Prepass sampler
|
// Deferred sampler
|
||||||
d.samplers[1] = GFXSamplerStateDesc::getClampPoint();
|
d.samplers[1] = GFXSamplerStateDesc::getClampPoint();
|
||||||
|
|
||||||
mOffscreenBlocks[blendStyle] = GFX->createStateBlock(d);
|
mOffscreenBlocks[blendStyle] = GFX->createStateBlock(d);
|
||||||
|
|
@ -701,7 +701,7 @@ GFXStateBlockRef RenderParticleMgr::_getHighResStateBlock(ParticleRenderInst *ri
|
||||||
d.samplers[0].alphaArg1 = GFXTATexture;
|
d.samplers[0].alphaArg1 = GFXTATexture;
|
||||||
d.samplers[0].alphaArg2 = GFXTADiffuse;
|
d.samplers[0].alphaArg2 = GFXTADiffuse;
|
||||||
|
|
||||||
// Prepass sampler
|
// Deferred sampler
|
||||||
d.samplers[1] = GFXSamplerStateDesc::getClampPoint();
|
d.samplers[1] = GFXSamplerStateDesc::getClampPoint();
|
||||||
|
|
||||||
mHighResBlocks[blendStyle] = GFX->createStateBlock(d);
|
mHighResBlocks[blendStyle] = GFX->createStateBlock(d);
|
||||||
|
|
@ -773,7 +773,7 @@ GFXStateBlockRef RenderParticleMgr::_getMixedResStateBlock(ParticleRenderInst *r
|
||||||
d.samplers[0].alphaArg1 = GFXTATexture;
|
d.samplers[0].alphaArg1 = GFXTATexture;
|
||||||
d.samplers[0].alphaArg2 = GFXTADiffuse;
|
d.samplers[0].alphaArg2 = GFXTADiffuse;
|
||||||
|
|
||||||
// Prepass sampler
|
// Deferred sampler
|
||||||
d.samplers[1] = GFXSamplerStateDesc::getClampPoint();
|
d.samplers[1] = GFXSamplerStateDesc::getClampPoint();
|
||||||
|
|
||||||
mMixedResBlocks[blendStyle] = GFX->createStateBlock(d);
|
mMixedResBlocks[blendStyle] = GFX->createStateBlock(d);
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class RenderParticleMgr : public RenderTexTargetBinManager
|
||||||
friend class RenderTranslucentMgr;
|
friend class RenderTranslucentMgr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Generic PrePass Render Instance Type
|
// Generic Deferred Render Instance Type
|
||||||
static const RenderInstType RIT_Particles;
|
static const RenderInstType RIT_Particles;
|
||||||
|
|
||||||
RenderParticleMgr();
|
RenderParticleMgr();
|
||||||
|
|
@ -82,9 +82,9 @@ public:
|
||||||
protected:
|
protected:
|
||||||
bool mOffscreenRenderEnabled;
|
bool mOffscreenRenderEnabled;
|
||||||
|
|
||||||
/// The prepass render target used for the
|
/// The deferred render target used for the
|
||||||
/// soft particle shader effect.
|
/// soft particle shader effect.
|
||||||
NamedTexTargetRef mPrepassTarget;
|
NamedTexTargetRef mDeferredTarget;
|
||||||
|
|
||||||
/// The shader used for particle rendering.
|
/// The shader used for particle rendering.
|
||||||
GFXShaderRef mParticleShader;
|
GFXShaderRef mParticleShader;
|
||||||
|
|
@ -109,11 +109,11 @@ protected:
|
||||||
GFXShaderConstHandle *mFSModelViewProjSC;
|
GFXShaderConstHandle *mFSModelViewProjSC;
|
||||||
GFXShaderConstHandle *mOneOverFarSC;
|
GFXShaderConstHandle *mOneOverFarSC;
|
||||||
GFXShaderConstHandle *mOneOverSoftnessSC;
|
GFXShaderConstHandle *mOneOverSoftnessSC;
|
||||||
GFXShaderConstHandle *mPrePassTargetParamsSC;
|
GFXShaderConstHandle *mDeferredTargetParamsSC;
|
||||||
GFXShaderConstHandle *mAlphaFactorSC;
|
GFXShaderConstHandle *mAlphaFactorSC;
|
||||||
GFXShaderConstHandle *mAlphaScaleSC;
|
GFXShaderConstHandle *mAlphaScaleSC;
|
||||||
GFXShaderConstHandle *mSamplerDiffuse;
|
GFXShaderConstHandle *mSamplerDiffuse;
|
||||||
GFXShaderConstHandle *mSamplerPrePassTex;
|
GFXShaderConstHandle *mSamplerDeferredTex;
|
||||||
GFXShaderConstHandle *mSamplerParaboloidLightMap;
|
GFXShaderConstHandle *mSamplerParaboloidLightMap;
|
||||||
|
|
||||||
} mParticleShaderConsts;
|
} mParticleShaderConsts;
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ void RenderTerrainMgr::render( SceneRenderState *state )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Check if bin is disabled in advanced lighting.
|
// Check if bin is disabled in advanced lighting.
|
||||||
if ( MATMGR->getPrePassEnabled() && mBasicOnly )
|
if ( MATMGR->getDeferredEnabled() && mBasicOnly )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PROFILE_SCOPE( RenderTerrainMgr_Render );
|
PROFILE_SCOPE( RenderTerrainMgr_Render );
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ ConsoleDocClass( RenderTexTargetBinManager,
|
||||||
"@brief An abstract base class for render bin managers that render to a named textue target.\n\n"
|
"@brief An abstract base class for render bin managers that render to a named textue target.\n\n"
|
||||||
"This bin itself doesn't do any rendering work. It offers functionality to manage "
|
"This bin itself doesn't do any rendering work. It offers functionality to manage "
|
||||||
"a texture render target which derived render bin classes can render into.\n\n"
|
"a texture render target which derived render bin classes can render into.\n\n"
|
||||||
"@see RenderPrePassMgr\n"
|
"@see RenderDeferredMgr\n"
|
||||||
"@ingroup RenderBin\n" );
|
"@ingroup RenderBin\n" );
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -365,9 +365,9 @@ ShaderFeature::Resources ParallaxFeatGLSL::getResources( const MaterialFeatureDa
|
||||||
// We add the outViewTS to the outputstructure.
|
// We add the outViewTS to the outputstructure.
|
||||||
res.numTexReg = 1;
|
res.numTexReg = 1;
|
||||||
|
|
||||||
// If this isn't a prepass then we will be
|
// If this isn't a deferred then we will be
|
||||||
// creating the normal map here.
|
// creating the normal map here.
|
||||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
if ( !fd.features.hasFeature( MFT_DeferredConditioner ) )
|
||||||
res.numTex = 1;
|
res.numTex = 1;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ void EyeSpaceDepthOutGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
|
|
||||||
// If there isn't an output conditioner for the pre-pass, than just write
|
// If there isn't an output conditioner for the pre-pass, than just write
|
||||||
// out the depth to rgba and return.
|
// out the depth to rgba and return.
|
||||||
if( !fd.features[MFT_PrePassConditioner] )
|
if( !fd.features[MFT_DeferredConditioner] )
|
||||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "float4(float3(@),1)", depthOut ), Material::None ) ) );
|
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "float4(float3(@),1)", depthOut ), Material::None ) ) );
|
||||||
|
|
||||||
output = meta;
|
output = meta;
|
||||||
|
|
|
||||||
|
|
@ -953,7 +953,7 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
// To dump out UV coords...
|
// To dump out UV coords...
|
||||||
//#define DEBUG_ATLASED_UV_COORDS
|
//#define DEBUG_ATLASED_UV_COORDS
|
||||||
#ifdef DEBUG_ATLASED_UV_COORDS
|
#ifdef DEBUG_ATLASED_UV_COORDS
|
||||||
if(!fd.features[MFT_PrePassConditioner])
|
if(!fd.features[MFT_DeferredConditioner])
|
||||||
{
|
{
|
||||||
meta->addStatement(new GenOp(" @ = vec4(@.xy, mipLod / @.w, 1.0);\r\n", new DecOp(diffColor), inTex, atParams));
|
meta->addStatement(new GenOp(" @ = vec4(@.xy, mipLod / @.w, 1.0);\r\n", new DecOp(diffColor), inTex, atParams));
|
||||||
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
||||||
|
|
@ -1269,7 +1269,7 @@ void LightmapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
bool bPreProcessedLighting = false;
|
bool bPreProcessedLighting = false;
|
||||||
AdvancedLightBinManager *lightBin;
|
AdvancedLightBinManager *lightBin;
|
||||||
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
||||||
bPreProcessedLighting = lightBin->MRTLightmapsDuringPrePass();
|
bPreProcessedLighting = lightBin->MRTLightmapsDuringDeferred();
|
||||||
|
|
||||||
// Lightmap has already been included in the advanced light bin, so
|
// Lightmap has already been included in the advanced light bin, so
|
||||||
// no need to do any sampling or anything
|
// no need to do any sampling or anything
|
||||||
|
|
@ -1394,7 +1394,7 @@ void TonemapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
bool bPreProcessedLighting = false;
|
bool bPreProcessedLighting = false;
|
||||||
AdvancedLightBinManager *lightBin;
|
AdvancedLightBinManager *lightBin;
|
||||||
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
||||||
bPreProcessedLighting = lightBin->MRTLightmapsDuringPrePass();
|
bPreProcessedLighting = lightBin->MRTLightmapsDuringDeferred();
|
||||||
|
|
||||||
// Add in the realtime lighting contribution
|
// Add in the realtime lighting contribution
|
||||||
if ( fd.features[MFT_RTLighting] )
|
if ( fd.features[MFT_RTLighting] )
|
||||||
|
|
@ -1549,7 +1549,7 @@ void VertLitGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
bool bPreProcessedLighting = false;
|
bool bPreProcessedLighting = false;
|
||||||
AdvancedLightBinManager *lightBin;
|
AdvancedLightBinManager *lightBin;
|
||||||
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
||||||
bPreProcessedLighting = lightBin->MRTLightmapsDuringPrePass();
|
bPreProcessedLighting = lightBin->MRTLightmapsDuringDeferred();
|
||||||
|
|
||||||
// Assign value in d_lightcolor to toneMapColor if it exists. This is
|
// Assign value in d_lightcolor to toneMapColor if it exists. This is
|
||||||
// the dynamic light buffer, and it already has the baked-vertex-color
|
// the dynamic light buffer, and it already has the baked-vertex-color
|
||||||
|
|
|
||||||
|
|
@ -406,9 +406,9 @@ ShaderFeature::Resources ParallaxFeatHLSL::getResources( const MaterialFeatureDa
|
||||||
// We add the outViewTS to the outputstructure.
|
// We add the outViewTS to the outputstructure.
|
||||||
res.numTexReg = 1;
|
res.numTexReg = 1;
|
||||||
|
|
||||||
// If this isn't a prepass then we will be
|
// If this isn't a deferred then we will be
|
||||||
// creating the normal map here.
|
// creating the normal map here.
|
||||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
if ( !fd.features.hasFeature( MFT_DeferredConditioner ) )
|
||||||
res.numTex = 1;
|
res.numTex = 1;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ void EyeSpaceDepthOutHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
|
|
||||||
// If there isn't an output conditioner for the pre-pass, than just write
|
// If there isn't an output conditioner for the pre-pass, than just write
|
||||||
// out the depth to rgba and return.
|
// out the depth to rgba and return.
|
||||||
if( !fd.features[MFT_PrePassConditioner] )
|
if( !fd.features[MFT_DeferredConditioner] )
|
||||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "float4(@.rrr,1)", depthOut ), Material::None ) ) );
|
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "float4(@.rrr,1)", depthOut ), Material::None ) ) );
|
||||||
|
|
||||||
output = meta;
|
output = meta;
|
||||||
|
|
|
||||||
|
|
@ -991,7 +991,7 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
// To dump out UV coords...
|
// To dump out UV coords...
|
||||||
//#define DEBUG_ATLASED_UV_COORDS
|
//#define DEBUG_ATLASED_UV_COORDS
|
||||||
#ifdef DEBUG_ATLASED_UV_COORDS
|
#ifdef DEBUG_ATLASED_UV_COORDS
|
||||||
if(!fd.features[MFT_PrePassConditioner])
|
if(!fd.features[MFT_DeferredConditioner])
|
||||||
{
|
{
|
||||||
meta->addStatement(new GenOp(" @ = float4(@.xy, mipLod / @.w, 1.0);\r\n", new DecOp(diffColor), inTex, atParams));
|
meta->addStatement(new GenOp(" @ = float4(@.xy, mipLod / @.w, 1.0);\r\n", new DecOp(diffColor), inTex, atParams));
|
||||||
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
||||||
|
|
@ -1347,7 +1347,7 @@ void LightmapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
bool bPreProcessedLighting = false;
|
bool bPreProcessedLighting = false;
|
||||||
AdvancedLightBinManager *lightBin;
|
AdvancedLightBinManager *lightBin;
|
||||||
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
||||||
bPreProcessedLighting = lightBin->MRTLightmapsDuringPrePass();
|
bPreProcessedLighting = lightBin->MRTLightmapsDuringDeferred();
|
||||||
|
|
||||||
// Lightmap has already been included in the advanced light bin, so
|
// Lightmap has already been included in the advanced light bin, so
|
||||||
// no need to do any sampling or anything
|
// no need to do any sampling or anything
|
||||||
|
|
@ -1497,7 +1497,7 @@ void TonemapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
bool bPreProcessedLighting = false;
|
bool bPreProcessedLighting = false;
|
||||||
AdvancedLightBinManager *lightBin;
|
AdvancedLightBinManager *lightBin;
|
||||||
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
||||||
bPreProcessedLighting = lightBin->MRTLightmapsDuringPrePass();
|
bPreProcessedLighting = lightBin->MRTLightmapsDuringDeferred();
|
||||||
|
|
||||||
// Add in the realtime lighting contribution
|
// Add in the realtime lighting contribution
|
||||||
if ( fd.features[MFT_RTLighting] )
|
if ( fd.features[MFT_RTLighting] )
|
||||||
|
|
@ -1652,7 +1652,7 @@ void VertLitHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
bool bPreProcessedLighting = false;
|
bool bPreProcessedLighting = false;
|
||||||
AdvancedLightBinManager *lightBin;
|
AdvancedLightBinManager *lightBin;
|
||||||
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
||||||
bPreProcessedLighting = lightBin->MRTLightmapsDuringPrePass();
|
bPreProcessedLighting = lightBin->MRTLightmapsDuringDeferred();
|
||||||
|
|
||||||
// Assign value in d_lightcolor to toneMapColor if it exists. This is
|
// Assign value in d_lightcolor to toneMapColor if it exists. This is
|
||||||
// the dynamic light buffer, and it already has the baked-vertex-color
|
// the dynamic light buffer, and it already has the baked-vertex-color
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
|
||||||
|
|
||||||
FEATUREMGR->registerFeature( MFT_ParticleNormal, new ParticleNormalFeatureHLSL );
|
FEATUREMGR->registerFeature( MFT_ParticleNormal, new ParticleNormalFeatureHLSL );
|
||||||
|
|
||||||
FEATUREMGR->registerFeature( MFT_InterlacedPrePass, new NamedFeatureHLSL( "Interlaced Pre Pass" ) );
|
FEATUREMGR->registerFeature( MFT_InterlacedDeferred, new NamedFeatureHLSL( "Interlaced Pre Pass" ) );
|
||||||
|
|
||||||
FEATUREMGR->registerFeature( MFT_ForwardShading, new NamedFeatureHLSL( "Forward Shaded Material" ) );
|
FEATUREMGR->registerFeature( MFT_ForwardShading, new NamedFeatureHLSL( "Forward Shaded Material" ) );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -911,8 +911,8 @@ U32 TerrainMacroMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) c
|
||||||
void TerrainNormalMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
void TerrainNormalMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd )
|
const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
// We only need to process normals during the prepass.
|
// We only need to process normals during the deferred.
|
||||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
if ( !fd.features.hasFeature( MFT_DeferredConditioner ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MultiLine *meta = new MultiLine;
|
MultiLine *meta = new MultiLine;
|
||||||
|
|
@ -933,7 +933,7 @@ void TerrainNormalMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
||||||
Var *viewToTangent = getInViewToTangent( componentList );
|
Var *viewToTangent = getInViewToTangent( componentList );
|
||||||
|
|
||||||
// This var is read from GBufferConditionerGLSL and
|
// This var is read from GBufferConditionerGLSL and
|
||||||
// used in the prepass output.
|
// used in the deferred output.
|
||||||
Var *gbNormal = (Var*)LangElement::find( "gbNormal" );
|
Var *gbNormal = (Var*)LangElement::find( "gbNormal" );
|
||||||
if ( !gbNormal )
|
if ( !gbNormal )
|
||||||
{
|
{
|
||||||
|
|
@ -1004,8 +1004,8 @@ ShaderFeature::Resources TerrainNormalMapFeatGLSL::getResources( const MaterialF
|
||||||
{
|
{
|
||||||
Resources res;
|
Resources res;
|
||||||
|
|
||||||
// We only need to process normals during the prepass.
|
// We only need to process normals during the deferred.
|
||||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
if ( fd.features.hasFeature( MFT_DeferredConditioner ) )
|
||||||
{
|
{
|
||||||
// If this is the first normal map and there
|
// If this is the first normal map and there
|
||||||
// are no parallax features then we will
|
// are no parallax features then we will
|
||||||
|
|
|
||||||
|
|
@ -971,8 +971,8 @@ U32 TerrainMacroMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) c
|
||||||
void TerrainNormalMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
void TerrainNormalMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd )
|
const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
// We only need to process normals during the prepass.
|
// We only need to process normals during the deferred.
|
||||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
if ( !fd.features.hasFeature( MFT_DeferredConditioner ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MultiLine *meta = new MultiLine;
|
MultiLine *meta = new MultiLine;
|
||||||
|
|
@ -993,7 +993,7 @@ void TerrainNormalMapFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
||||||
Var *viewToTangent = getInViewToTangent( componentList );
|
Var *viewToTangent = getInViewToTangent( componentList );
|
||||||
|
|
||||||
// This var is read from GBufferConditionerHLSL and
|
// This var is read from GBufferConditionerHLSL and
|
||||||
// used in the prepass output.
|
// used in the deferred output.
|
||||||
Var *gbNormal = (Var*)LangElement::find( "gbNormal" );
|
Var *gbNormal = (Var*)LangElement::find( "gbNormal" );
|
||||||
if ( !gbNormal )
|
if ( !gbNormal )
|
||||||
{
|
{
|
||||||
|
|
@ -1090,8 +1090,8 @@ ShaderFeature::Resources TerrainNormalMapFeatHLSL::getResources( const MaterialF
|
||||||
{
|
{
|
||||||
Resources res;
|
Resources res;
|
||||||
|
|
||||||
// We only need to process normals during the prepass.
|
// We only need to process normals during the deferred.
|
||||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
if ( fd.features.hasFeature( MFT_DeferredConditioner ) )
|
||||||
{
|
{
|
||||||
// If this is the first normal map and there
|
// If this is the first normal map and there
|
||||||
// are no parallax features then we will
|
// are no parallax features then we will
|
||||||
|
|
|
||||||
|
|
@ -1062,7 +1062,7 @@ void TerrCell::preloadMaterials()
|
||||||
|
|
||||||
if ( GFX->getPixelShaderVersion() > 2.0f &&
|
if ( GFX->getPixelShaderVersion() > 2.0f &&
|
||||||
dStrcmp( LIGHTMGR->getId(), "BLM" ) != 0)
|
dStrcmp( LIGHTMGR->getId(), "BLM" ) != 0)
|
||||||
material->getPrePassMat();
|
material->getDeferredMat();
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( U32 i = 0; i < 4; i++ )
|
for ( U32 i = 0; i < 4; i++ )
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
#include "materials/materialManager.h"
|
#include "materials/materialManager.h"
|
||||||
#include "terrain/terrFeatureTypes.h"
|
#include "terrain/terrFeatureTypes.h"
|
||||||
#include "terrain/terrMaterial.h"
|
#include "terrain/terrMaterial.h"
|
||||||
#include "renderInstance/renderPrePassMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
#include "shaderGen/shaderGen.h"
|
#include "shaderGen/shaderGen.h"
|
||||||
#include "shaderGen/featureMgr.h"
|
#include "shaderGen/featureMgr.h"
|
||||||
#include "scene/sceneRenderState.h"
|
#include "scene/sceneRenderState.h"
|
||||||
|
|
@ -71,7 +71,7 @@ const Vector<String> TerrainCellMaterial::mSamplerNames = _initSamplerNames();
|
||||||
TerrainCellMaterial::TerrainCellMaterial()
|
TerrainCellMaterial::TerrainCellMaterial()
|
||||||
: mTerrain( NULL ),
|
: mTerrain( NULL ),
|
||||||
mCurrPass( 0 ),
|
mCurrPass( 0 ),
|
||||||
mPrePassMat( NULL ),
|
mDeferredMat( NULL ),
|
||||||
mReflectMat( NULL )
|
mReflectMat( NULL )
|
||||||
{
|
{
|
||||||
smAllMaterials.push_back( this );
|
smAllMaterials.push_back( this );
|
||||||
|
|
@ -79,7 +79,7 @@ TerrainCellMaterial::TerrainCellMaterial()
|
||||||
|
|
||||||
TerrainCellMaterial::~TerrainCellMaterial()
|
TerrainCellMaterial::~TerrainCellMaterial()
|
||||||
{
|
{
|
||||||
SAFE_DELETE( mPrePassMat );
|
SAFE_DELETE( mDeferredMat );
|
||||||
SAFE_DELETE( mReflectMat );
|
SAFE_DELETE( mReflectMat );
|
||||||
smAllMaterials.remove( this );
|
smAllMaterials.remove( this );
|
||||||
}
|
}
|
||||||
|
|
@ -219,15 +219,15 @@ void TerrainCellMaterial::setTransformAndEye( const MatrixF &modelXfm,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TerrainCellMaterial* TerrainCellMaterial::getPrePassMat()
|
TerrainCellMaterial* TerrainCellMaterial::getDeferredMat()
|
||||||
{
|
{
|
||||||
if ( !mPrePassMat )
|
if ( !mDeferredMat )
|
||||||
{
|
{
|
||||||
mPrePassMat = new TerrainCellMaterial();
|
mDeferredMat = new TerrainCellMaterial();
|
||||||
mPrePassMat->init( mTerrain, mMaterials, true, false, mMaterials == 0 );
|
mDeferredMat->init( mTerrain, mMaterials, true, false, mMaterials == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return mPrePassMat;
|
return mDeferredMat;
|
||||||
}
|
}
|
||||||
|
|
||||||
TerrainCellMaterial* TerrainCellMaterial::getReflectMat()
|
TerrainCellMaterial* TerrainCellMaterial::getReflectMat()
|
||||||
|
|
@ -248,7 +248,7 @@ void TerrainCellMaterial::init( TerrainBlock *block,
|
||||||
bool baseOnly )
|
bool baseOnly )
|
||||||
{
|
{
|
||||||
// This isn't allowed for now.
|
// This isn't allowed for now.
|
||||||
AssertFatal( !( prePassMat && reflectMat ), "TerrainCellMaterial::init - We shouldn't get prepass and reflection in the same material!" );
|
AssertFatal( !( prePassMat && reflectMat ), "TerrainCellMaterial::init - We shouldn't get deferred and reflection in the same material!" );
|
||||||
|
|
||||||
mTerrain = block;
|
mTerrain = block;
|
||||||
mMaterials = activeMaterials;
|
mMaterials = activeMaterials;
|
||||||
|
|
@ -301,8 +301,8 @@ void TerrainCellMaterial::init( TerrainBlock *block,
|
||||||
for_each( materials.begin(), materials.end(), delete_pointer() );
|
for_each( materials.begin(), materials.end(), delete_pointer() );
|
||||||
|
|
||||||
// If we have attached mats then update them too.
|
// If we have attached mats then update them too.
|
||||||
if ( mPrePassMat )
|
if ( mDeferredMat )
|
||||||
mPrePassMat->init( mTerrain, mMaterials, true, false, baseOnly );
|
mDeferredMat->init( mTerrain, mMaterials, true, false, baseOnly );
|
||||||
if ( mReflectMat )
|
if ( mReflectMat )
|
||||||
mReflectMat->init( mTerrain, mMaterials, false, true, baseOnly );
|
mReflectMat->init( mTerrain, mMaterials, false, true, baseOnly );
|
||||||
}
|
}
|
||||||
|
|
@ -341,14 +341,14 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
||||||
const bool disableParallaxMaps = GFX->getPixelShaderVersion() < 3.0f ||
|
const bool disableParallaxMaps = GFX->getPixelShaderVersion() < 3.0f ||
|
||||||
MATMGR->getExclusionFeatures().hasFeature( MFT_Parallax );
|
MATMGR->getExclusionFeatures().hasFeature( MFT_Parallax );
|
||||||
|
|
||||||
// Has advanced lightmap support been enabled for prepass.
|
// Has advanced lightmap support been enabled for deferred.
|
||||||
bool advancedLightmapSupport = false;
|
bool advancedLightmapSupport = false;
|
||||||
if ( prePassMat )
|
if ( prePassMat )
|
||||||
{
|
{
|
||||||
// This sucks... but it works.
|
// This sucks... but it works.
|
||||||
AdvancedLightBinManager *lightBin;
|
AdvancedLightBinManager *lightBin;
|
||||||
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
if ( Sim::findObject( "AL_LightBinMgr", lightBin ) )
|
||||||
advancedLightmapSupport = lightBin->MRTLightmapsDuringPrePass();
|
advancedLightmapSupport = lightBin->MRTLightmapsDuringDeferred();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop till we create a valid shader!
|
// Loop till we create a valid shader!
|
||||||
|
|
@ -360,7 +360,7 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
||||||
if ( prePassMat )
|
if ( prePassMat )
|
||||||
{
|
{
|
||||||
features.addFeature( MFT_EyeSpaceDepthOut );
|
features.addFeature( MFT_EyeSpaceDepthOut );
|
||||||
features.addFeature( MFT_PrePassConditioner );
|
features.addFeature( MFT_DeferredConditioner );
|
||||||
features.addFeature( MFT_DeferredTerrainBaseMap );
|
features.addFeature( MFT_DeferredTerrainBaseMap );
|
||||||
features.addFeature(MFT_isDeferred);
|
features.addFeature(MFT_isDeferred);
|
||||||
|
|
||||||
|
|
@ -546,7 +546,7 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
||||||
{
|
{
|
||||||
desc.setBlend( true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha );
|
desc.setBlend( true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha );
|
||||||
|
|
||||||
// If this is the prepass then we don't want to
|
// If this is the deferred then we don't want to
|
||||||
// write to the last two color channels (where
|
// write to the last two color channels (where
|
||||||
// depth is usually encoded).
|
// depth is usually encoded).
|
||||||
//
|
//
|
||||||
|
|
@ -558,9 +558,9 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
||||||
desc.setColorWrites( true, true, true, false );
|
desc.setColorWrites( true, true, true, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// We write to the zbuffer if this is a prepass
|
// We write to the zbuffer if this is a deferred
|
||||||
// material or if the prepass is disabled.
|
// material or if the deferred is disabled.
|
||||||
desc.setZReadWrite( true, !MATMGR->getPrePassEnabled() ||
|
desc.setZReadWrite( true, !MATMGR->getDeferredEnabled() ||
|
||||||
prePassMat ||
|
prePassMat ||
|
||||||
reflectMat );
|
reflectMat );
|
||||||
|
|
||||||
|
|
@ -669,10 +669,10 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
||||||
materials->pop_front();
|
materials->pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're doing prepass it requires some
|
// If we're doing deferred it requires some
|
||||||
// special stencil settings for it to work.
|
// special stencil settings for it to work.
|
||||||
if ( prePassMat )
|
if ( prePassMat )
|
||||||
desc.addDesc( RenderPrePassMgr::getOpaqueStenciWriteDesc( false ) );
|
desc.addDesc( RenderDeferredMgr::getOpaqueStenciWriteDesc( false ) );
|
||||||
|
|
||||||
desc.setCullMode( GFXCullCCW );
|
desc.setCullMode( GFXCullCCW );
|
||||||
pass->stateBlock = GFX->createStateBlock(desc);
|
pass->stateBlock = GFX->createStateBlock(desc);
|
||||||
|
|
|
||||||
|
|
@ -153,8 +153,8 @@ protected:
|
||||||
|
|
||||||
NamedTexTargetRef mLightInfoTarget;
|
NamedTexTargetRef mLightInfoTarget;
|
||||||
|
|
||||||
/// The prepass material for this material.
|
/// The deferred material for this material.
|
||||||
TerrainCellMaterial *mPrePassMat;
|
TerrainCellMaterial *mDeferredMat;
|
||||||
|
|
||||||
/// The reflection material for this material.
|
/// The reflection material for this material.
|
||||||
TerrainCellMaterial *mReflectMat;
|
TerrainCellMaterial *mReflectMat;
|
||||||
|
|
@ -182,8 +182,8 @@ public:
|
||||||
bool reflectMat = false,
|
bool reflectMat = false,
|
||||||
bool baseOnly = false );
|
bool baseOnly = false );
|
||||||
|
|
||||||
/// Returns a prepass material from this material.
|
/// Returns a deferred material from this material.
|
||||||
TerrainCellMaterial* getPrePassMat();
|
TerrainCellMaterial* getDeferredMat();
|
||||||
|
|
||||||
/// Returns the reflection material from this material.
|
/// Returns the reflection material from this material.
|
||||||
TerrainCellMaterial* getReflectMat();
|
TerrainCellMaterial* getReflectMat();
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ singleton ShaderData( ParticlesShaderData )
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/particlesP.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/gl/particlesP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$diffuseMap";
|
samplerNames[0] = "$diffuseMap";
|
||||||
samplerNames[1] = "$prepassTex";
|
samplerNames[1] = "$deferredTex";
|
||||||
samplerNames[2] = "$paraboloidLightMap";
|
samplerNames[2] = "$paraboloidLightMap";
|
||||||
|
|
||||||
pixVersion = 2.0;
|
pixVersion = 2.0;
|
||||||
|
|
@ -103,7 +103,7 @@ new ShaderData( fxFoliageReplicatorShader )
|
||||||
pixVersion = 1.4;
|
pixVersion = 1.4;
|
||||||
};
|
};
|
||||||
|
|
||||||
singleton ShaderData( VolumetricFogPrePassShader )
|
singleton ShaderData( VolumetricFogDeferredShader )
|
||||||
{
|
{
|
||||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreV.hlsl";
|
DXVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreV.hlsl";
|
||||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreP.hlsl";
|
DXPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/VFogPreP.hlsl";
|
||||||
|
|
@ -121,7 +121,7 @@ singleton ShaderData( VolumetricFogShader )
|
||||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogV.glsl";
|
OGLVertexShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogV.glsl";
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogP.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/VolumetricFog/gl/VFogP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$prepassTex";
|
samplerNames[0] = "$deferredTex";
|
||||||
samplerNames[1] = "$depthBuffer";
|
samplerNames[1] = "$depthBuffer";
|
||||||
samplerNames[2] = "$frontBuffer";
|
samplerNames[2] = "$frontBuffer";
|
||||||
samplerNames[3] = "$density";
|
samplerNames[3] = "$density";
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ singleton ShaderData( WaterShader )
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/water/gl/waterP.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/water/gl/waterP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$bumpMap"; // noise
|
samplerNames[0] = "$bumpMap"; // noise
|
||||||
samplerNames[1] = "$prepassTex"; // #prepass
|
samplerNames[1] = "$deferredTex"; // #deferred
|
||||||
samplerNames[2] = "$reflectMap"; // $reflectbuff
|
samplerNames[2] = "$reflectMap"; // $reflectbuff
|
||||||
samplerNames[3] = "$refractBuff"; // $backbuff
|
samplerNames[3] = "$refractBuff"; // $backbuff
|
||||||
samplerNames[4] = "$skyMap"; // $cubemap
|
samplerNames[4] = "$skyMap"; // $cubemap
|
||||||
|
|
@ -61,7 +61,7 @@ singleton GFXStateBlockData( WaterStateBlock )
|
||||||
{
|
{
|
||||||
samplersDefined = true;
|
samplersDefined = true;
|
||||||
samplerStates[0] = WaterSampler; // noise
|
samplerStates[0] = WaterSampler; // noise
|
||||||
samplerStates[1] = SamplerClampPoint; // #prepass
|
samplerStates[1] = SamplerClampPoint; // #deferred
|
||||||
samplerStates[2] = SamplerClampLinear; // $reflectbuff
|
samplerStates[2] = SamplerClampLinear; // $reflectbuff
|
||||||
samplerStates[3] = SamplerClampPoint; // $backbuff
|
samplerStates[3] = SamplerClampPoint; // $backbuff
|
||||||
samplerStates[4] = SamplerWrapLinear; // $cubemap
|
samplerStates[4] = SamplerWrapLinear; // $cubemap
|
||||||
|
|
@ -78,7 +78,7 @@ singleton GFXStateBlockData( UnderWaterStateBlock : WaterStateBlock )
|
||||||
|
|
||||||
singleton CustomMaterial( WaterMat )
|
singleton CustomMaterial( WaterMat )
|
||||||
{
|
{
|
||||||
sampler["prepassTex"] = "#prepass";
|
sampler["deferredTex"] = "#deferred";
|
||||||
sampler["reflectMap"] = "$reflectbuff";
|
sampler["reflectMap"] = "$reflectbuff";
|
||||||
sampler["refractBuff"] = "$backbuff";
|
sampler["refractBuff"] = "$backbuff";
|
||||||
// These samplers are set in code not here.
|
// These samplers are set in code not here.
|
||||||
|
|
@ -115,7 +115,7 @@ singleton CustomMaterial( UnderwaterMat )
|
||||||
//sampler["bumpMap"] = "core/art/water/noise02";
|
//sampler["bumpMap"] = "core/art/water/noise02";
|
||||||
//sampler["foamMap"] = "core/art/water/foam";
|
//sampler["foamMap"] = "core/art/water/foam";
|
||||||
|
|
||||||
sampler["prepassTex"] = "#prepass";
|
sampler["deferredTex"] = "#deferred";
|
||||||
sampler["refractBuff"] = "$backbuff";
|
sampler["refractBuff"] = "$backbuff";
|
||||||
|
|
||||||
shader = UnderWaterShader;
|
shader = UnderWaterShader;
|
||||||
|
|
@ -171,7 +171,7 @@ singleton CustomMaterial( WaterBasicMat )
|
||||||
//sampler["bumpMap"] = "core/art/water/noise02";
|
//sampler["bumpMap"] = "core/art/water/noise02";
|
||||||
//sampler["skyMap"] = "$cubemap";
|
//sampler["skyMap"] = "$cubemap";
|
||||||
|
|
||||||
//sampler["prepassTex"] = "#prepass";
|
//sampler["deferredTex"] = "#deferred";
|
||||||
sampler["reflectMap"] = "$reflectbuff";
|
sampler["reflectMap"] = "$reflectbuff";
|
||||||
sampler["refractBuff"] = "$backbuff";
|
sampler["refractBuff"] = "$backbuff";
|
||||||
|
|
||||||
|
|
@ -199,7 +199,7 @@ singleton CustomMaterial( UnderwaterBasicMat )
|
||||||
//sampler["bumpMap"] = "core/art/water/noise02";
|
//sampler["bumpMap"] = "core/art/water/noise02";
|
||||||
//samplers["skyMap"] = "$cubemap";
|
//samplers["skyMap"] = "$cubemap";
|
||||||
|
|
||||||
//sampler["prepassTex"] = "#prepass";
|
//sampler["deferredTex"] = "#deferred";
|
||||||
sampler["refractBuff"] = "$backbuff";
|
sampler["refractBuff"] = "$backbuff";
|
||||||
|
|
||||||
shader = UnderWaterBasicShader;
|
shader = UnderWaterBasicShader;
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,9 @@ new ShaderData( AL_DeferredShader )
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/deferredShadingP.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/lighting/advanced/gl/deferredShadingP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "colorBufferTex";
|
samplerNames[0] = "colorBufferTex";
|
||||||
samplerNames[1] = "lightPrePassTex";
|
samplerNames[1] = "lightDeferredTex";
|
||||||
samplerNames[2] = "matInfoTex";
|
samplerNames[2] = "matInfoTex";
|
||||||
samplerNames[3] = "prepassTex";
|
samplerNames[3] = "deferredTex";
|
||||||
|
|
||||||
pixVersion = 2.0;
|
pixVersion = 2.0;
|
||||||
};
|
};
|
||||||
|
|
@ -62,7 +62,7 @@ singleton PostEffect( AL_DeferredShading )
|
||||||
texture[0] = "#color";
|
texture[0] = "#color";
|
||||||
texture[1] = "#lightinfo";
|
texture[1] = "#lightinfo";
|
||||||
texture[2] = "#matinfo";
|
texture[2] = "#matinfo";
|
||||||
texture[3] = "#prepass";
|
texture[3] = "#deferred";
|
||||||
|
|
||||||
target = "$backBuffer";
|
target = "$backBuffer";
|
||||||
renderPriority = 10000;
|
renderPriority = 10000;
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ new CustomMaterial( AL_VectorLightMaterial )
|
||||||
shader = AL_VectorLightShader;
|
shader = AL_VectorLightShader;
|
||||||
stateBlock = AL_VectorLightState;
|
stateBlock = AL_VectorLightState;
|
||||||
|
|
||||||
sampler["prePassBuffer"] = "#prepass";
|
sampler["prePassBuffer"] = "#deferred";
|
||||||
sampler["shadowMap"] = "$dynamiclight";
|
sampler["shadowMap"] = "$dynamiclight";
|
||||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||||
sampler["ssaoMask"] = "#ssaoMask";
|
sampler["ssaoMask"] = "#ssaoMask";
|
||||||
|
|
@ -160,7 +160,7 @@ new CustomMaterial( AL_PointLightMaterial )
|
||||||
shader = AL_PointLightShader;
|
shader = AL_PointLightShader;
|
||||||
stateBlock = AL_ConvexLightState;
|
stateBlock = AL_ConvexLightState;
|
||||||
|
|
||||||
sampler["prePassBuffer"] = "#prepass";
|
sampler["prePassBuffer"] = "#deferred";
|
||||||
sampler["shadowMap"] = "$dynamiclight";
|
sampler["shadowMap"] = "$dynamiclight";
|
||||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||||
sampler["cookieMap"] = "$dynamiclightmask";
|
sampler["cookieMap"] = "$dynamiclightmask";
|
||||||
|
|
@ -199,7 +199,7 @@ new CustomMaterial( AL_SpotLightMaterial )
|
||||||
shader = AL_SpotLightShader;
|
shader = AL_SpotLightShader;
|
||||||
stateBlock = AL_ConvexLightState;
|
stateBlock = AL_ConvexLightState;
|
||||||
|
|
||||||
sampler["prePassBuffer"] = "#prepass";
|
sampler["prePassBuffer"] = "#deferred";
|
||||||
sampler["shadowMap"] = "$dynamiclight";
|
sampler["shadowMap"] = "$dynamiclight";
|
||||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||||
sampler["cookieMap"] = "$dynamiclightmask";
|
sampler["cookieMap"] = "$dynamiclightmask";
|
||||||
|
|
@ -212,9 +212,9 @@ new CustomMaterial( AL_SpotLightMaterial )
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This material is used for generating prepass
|
/// This material is used for generating deferred
|
||||||
/// materials for objects that do not have materials.
|
/// materials for objects that do not have materials.
|
||||||
new Material( AL_DefaultPrePassMaterial )
|
new Material( AL_DefaultDeferredMaterial )
|
||||||
{
|
{
|
||||||
// We need something in the first pass else it
|
// We need something in the first pass else it
|
||||||
// won't create a proper material instance.
|
// won't create a proper material instance.
|
||||||
|
|
@ -269,7 +269,7 @@ new CustomMaterial( AL_ParticlePointLightMaterial )
|
||||||
shader = AL_ParticlePointLightShader;
|
shader = AL_ParticlePointLightShader;
|
||||||
stateBlock = AL_ConvexLightState;
|
stateBlock = AL_ConvexLightState;
|
||||||
|
|
||||||
sampler["prePassBuffer"] = "#prepass";
|
sampler["prePassBuffer"] = "#deferred";
|
||||||
target = "lightinfo";
|
target = "lightinfo";
|
||||||
|
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ singleton ShaderData( MLAA_EdgeDetectionShader )
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/edgeDetectionP.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/mlaa/gl/edgeDetectionP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$colorMapG";
|
samplerNames[0] = "$colorMapG";
|
||||||
samplerNames[1] = "$prepassMap";
|
samplerNames[1] = "$deferredMap";
|
||||||
|
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
};
|
};
|
||||||
|
|
@ -125,7 +125,7 @@ singleton PostEffect( MLAAFx )
|
||||||
renderTime = "PFXAfterDiffuse";
|
renderTime = "PFXAfterDiffuse";
|
||||||
|
|
||||||
texture[0] = "$backBuffer"; //colorMapG
|
texture[0] = "$backBuffer"; //colorMapG
|
||||||
texture[1] = "#prepass"; // Used for depth detection
|
texture[1] = "#deferred"; // Used for depth detection
|
||||||
|
|
||||||
target = "$outTex";
|
target = "$outTex";
|
||||||
targetClear = PFXTargetClear_OnDraw;
|
targetClear = PFXTargetClear_OnDraw;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ singleton ShaderData( PFX_MotionBlurShader )
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/motionBlurP.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/motionBlurP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$backBuffer";
|
samplerNames[0] = "$backBuffer";
|
||||||
samplerNames[1] = "$prepassTex";
|
samplerNames[1] = "$deferredTex";
|
||||||
|
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
};
|
};
|
||||||
|
|
@ -43,7 +43,7 @@ singleton PostEffect(MotionBlurFX)
|
||||||
shader = PFX_MotionBlurShader;
|
shader = PFX_MotionBlurShader;
|
||||||
stateBlock = PFX_DefaultStateBlock;
|
stateBlock = PFX_DefaultStateBlock;
|
||||||
texture[0] = "$backbuffer";
|
texture[0] = "$backbuffer";
|
||||||
texture[1] = "#prepass";
|
texture[1] = "#deferred";
|
||||||
target = "$backBuffer";
|
target = "$backBuffer";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ singleton ShaderData( PFX_CausticsShader )
|
||||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/caustics/gl/causticsP.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/caustics/gl/causticsP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$prepassTex";
|
samplerNames[0] = "$deferredTex";
|
||||||
samplerNames[1] = "$causticsTex0";
|
samplerNames[1] = "$causticsTex0";
|
||||||
samplerNames[2] = "$causticsTex1";
|
samplerNames[2] = "$causticsTex1";
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ singleton PostEffect( CausticsPFX )
|
||||||
|
|
||||||
shader = PFX_CausticsShader;
|
shader = PFX_CausticsShader;
|
||||||
stateBlock = PFX_CausticsStateBlock;
|
stateBlock = PFX_CausticsStateBlock;
|
||||||
texture[0] = "#prepass";
|
texture[0] = "#deferred";
|
||||||
texture[1] = "core/images/caustics_1";
|
texture[1] = "core/images/caustics_1";
|
||||||
texture[2] = "core/images/caustics_2";
|
texture[2] = "core/images/caustics_2";
|
||||||
target = "$backBuffer";
|
target = "$backBuffer";
|
||||||
|
|
|
||||||
|
|
@ -430,7 +430,7 @@ singleton PostEffect( DOFPostEffect )
|
||||||
shader = PFX_DOFDownSampleShader;
|
shader = PFX_DOFDownSampleShader;
|
||||||
stateBlock = PFX_DOFDownSampleStateBlock;
|
stateBlock = PFX_DOFDownSampleStateBlock;
|
||||||
texture[0] = "$backBuffer";
|
texture[0] = "$backBuffer";
|
||||||
texture[1] = "#prepass";
|
texture[1] = "#deferred";
|
||||||
target = "#shrunk";
|
target = "#shrunk";
|
||||||
targetScale = "0.25 0.25";
|
targetScale = "0.25 0.25";
|
||||||
|
|
||||||
|
|
@ -485,7 +485,7 @@ singleton PostEffect( DOFFinalPFX )
|
||||||
texture[0] = "$backBuffer";
|
texture[0] = "$backBuffer";
|
||||||
texture[1] = "$inTex";
|
texture[1] = "$inTex";
|
||||||
texture[2] = "#largeBlur";
|
texture[2] = "#largeBlur";
|
||||||
texture[3] = "#prepass";
|
texture[3] = "#deferred";
|
||||||
target = "$backBuffer";
|
target = "$backBuffer";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ singleton ShaderData( PFX_EdgeAADetectShader )
|
||||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeDetectP.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/edgeaa/gl/edgeDetectP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$prepassBuffer";
|
samplerNames[0] = "$deferredBuffer";
|
||||||
|
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
};
|
};
|
||||||
|
|
@ -81,7 +81,7 @@ singleton PostEffect( EdgeDetectPostEffect )
|
||||||
|
|
||||||
shader = PFX_EdgeAADetectShader;
|
shader = PFX_EdgeAADetectShader;
|
||||||
stateBlock = PFX_DefaultEdgeAAStateBlock;
|
stateBlock = PFX_DefaultEdgeAAStateBlock;
|
||||||
texture[0] = "#prepass";
|
texture[0] = "#deferred";
|
||||||
target = "#edge";
|
target = "#edge";
|
||||||
|
|
||||||
isEnabled = true;
|
isEnabled = true;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ singleton ShaderData( FogPassShader )
|
||||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/fogP.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/fogP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$prepassTex";
|
samplerNames[0] = "$deferredTex";
|
||||||
|
|
||||||
pixVersion = 2.0;
|
pixVersion = 2.0;
|
||||||
};
|
};
|
||||||
|
|
@ -58,7 +58,7 @@ singleton PostEffect( FogPostFx )
|
||||||
|
|
||||||
shader = FogPassShader;
|
shader = FogPassShader;
|
||||||
stateBlock = FogPassStateBlock;
|
stateBlock = FogPassStateBlock;
|
||||||
texture[0] = "#prepass";
|
texture[0] = "#deferred";
|
||||||
|
|
||||||
renderPriority = 5;
|
renderPriority = 5;
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ singleton ShaderData( UnderwaterFogPassShader )
|
||||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/underwaterFogP.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/gl/underwaterFogP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$prepassTex";
|
samplerNames[0] = "$deferredTex";
|
||||||
samplerNames[1] = "$backbuffer";
|
samplerNames[1] = "$backbuffer";
|
||||||
samplerNames[2] = "$waterDepthGradMap";
|
samplerNames[2] = "$waterDepthGradMap";
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ singleton PostEffect( UnderwaterFogPostFx )
|
||||||
|
|
||||||
shader = UnderwaterFogPassShader;
|
shader = UnderwaterFogPassShader;
|
||||||
stateBlock = UnderwaterFogPassStateBlock;
|
stateBlock = UnderwaterFogPassStateBlock;
|
||||||
texture[0] = "#prepass";
|
texture[0] = "#deferred";
|
||||||
texture[1] = "$backBuffer";
|
texture[1] = "$backBuffer";
|
||||||
texture[2] = "#waterDepthGradMap";
|
texture[2] = "#waterDepthGradMap";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ singleton ShaderData( HDR_CombineShader )
|
||||||
samplerNames[1] = "$luminanceTex";
|
samplerNames[1] = "$luminanceTex";
|
||||||
samplerNames[2] = "$bloomTex";
|
samplerNames[2] = "$bloomTex";
|
||||||
samplerNames[3] = "$colorCorrectionTex";
|
samplerNames[3] = "$colorCorrectionTex";
|
||||||
samplerNames[4] = "prepassTex";
|
samplerNames[4] = "deferredTex";
|
||||||
|
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ singleton ShaderData( LightRayOccludeShader )
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/lightRay/gl/lightRayOccludeP.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/lightRay/gl/lightRayOccludeP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$backBuffer";
|
samplerNames[0] = "$backBuffer";
|
||||||
samplerNames[1] = "$prepassTex";
|
samplerNames[1] = "$deferredTex";
|
||||||
|
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
};
|
};
|
||||||
|
|
@ -77,7 +77,7 @@ singleton PostEffect( LightRayPostFX )
|
||||||
shader = LightRayOccludeShader;
|
shader = LightRayOccludeShader;
|
||||||
stateBlock = LightRayStateBlock;
|
stateBlock = LightRayStateBlock;
|
||||||
texture[0] = "$backBuffer";
|
texture[0] = "$backBuffer";
|
||||||
texture[1] = "#prepass";
|
texture[1] = "#deferred";
|
||||||
target = "$outTex";
|
target = "$outTex";
|
||||||
targetFormat = "GFXFormatR16G16B16A16F";
|
targetFormat = "GFXFormatR16G16B16A16F";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ singleton ShaderData( SSAOShader )
|
||||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_P.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_P.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$prepassMap";
|
samplerNames[0] = "$deferredMap";
|
||||||
samplerNames[1] = "$randNormalTex";
|
samplerNames[1] = "$randNormalTex";
|
||||||
samplerNames[2] = "$powTable";
|
samplerNames[2] = "$powTable";
|
||||||
|
|
||||||
|
|
@ -172,7 +172,7 @@ singleton ShaderData( SSAOBlurYShader )
|
||||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_Blur_P.glsl";
|
OGLPixelShaderFile = $Core::CommonShaderPath @ "/postFX/ssao/gl/SSAO_Blur_P.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$occludeMap";
|
samplerNames[0] = "$occludeMap";
|
||||||
samplerNames[1] = "$prepassMap";
|
samplerNames[1] = "$deferredMap";
|
||||||
|
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
|
|
||||||
|
|
@ -199,7 +199,7 @@ singleton PostEffect( SSAOPostFx )
|
||||||
shader = SSAOShader;
|
shader = SSAOShader;
|
||||||
stateBlock = SSAOStateBlock;
|
stateBlock = SSAOStateBlock;
|
||||||
|
|
||||||
texture[0] = "#prepass";
|
texture[0] = "#deferred";
|
||||||
texture[1] = "core/images/noise.png";
|
texture[1] = "core/images/noise.png";
|
||||||
texture[2] = "#ssao_pow_table";
|
texture[2] = "#ssao_pow_table";
|
||||||
|
|
||||||
|
|
@ -215,7 +215,7 @@ singleton PostEffect( SSAOPostFx )
|
||||||
stateBlock = SSAOBlurStateBlock;
|
stateBlock = SSAOBlurStateBlock;
|
||||||
|
|
||||||
texture[0] = "$inTex";
|
texture[0] = "$inTex";
|
||||||
texture[1] = "#prepass";
|
texture[1] = "#deferred";
|
||||||
|
|
||||||
target = "$outTex";
|
target = "$outTex";
|
||||||
};
|
};
|
||||||
|
|
@ -228,7 +228,7 @@ singleton PostEffect( SSAOPostFx )
|
||||||
stateBlock = SSAOBlurStateBlock;
|
stateBlock = SSAOBlurStateBlock;
|
||||||
|
|
||||||
texture[0] = "$inTex";
|
texture[0] = "$inTex";
|
||||||
texture[1] = "#prepass";
|
texture[1] = "#deferred";
|
||||||
|
|
||||||
target = "$outTex";
|
target = "$outTex";
|
||||||
};
|
};
|
||||||
|
|
@ -241,7 +241,7 @@ singleton PostEffect( SSAOPostFx )
|
||||||
stateBlock = SSAOBlurStateBlock;
|
stateBlock = SSAOBlurStateBlock;
|
||||||
|
|
||||||
texture[0] = "$inTex";
|
texture[0] = "$inTex";
|
||||||
texture[1] = "#prepass";
|
texture[1] = "#deferred";
|
||||||
|
|
||||||
target = "$outTex";
|
target = "$outTex";
|
||||||
};
|
};
|
||||||
|
|
@ -254,7 +254,7 @@ singleton PostEffect( SSAOPostFx )
|
||||||
stateBlock = SSAOBlurStateBlock;
|
stateBlock = SSAOBlurStateBlock;
|
||||||
|
|
||||||
texture[0] = "$inTex";
|
texture[0] = "$inTex";
|
||||||
texture[1] = "#prepass";
|
texture[1] = "#deferred";
|
||||||
|
|
||||||
// We write to a mask texture which is then
|
// We write to a mask texture which is then
|
||||||
// read by the lighting shaders to mask ambient.
|
// read by the lighting shaders to mask ambient.
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include "../shaderModelAutoGen.hlsl"
|
#include "../shaderModelAutoGen.hlsl"
|
||||||
#include "../torque.hlsl"
|
#include "../torque.hlsl"
|
||||||
|
|
||||||
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 0);
|
TORQUE_UNIFORM_SAMPLER2D(deferredTex, 0);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(depthBuffer, 1);
|
TORQUE_UNIFORM_SAMPLER2D(depthBuffer, 1);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(frontBuffer, 2);
|
TORQUE_UNIFORM_SAMPLER2D(frontBuffer, 2);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(density, 3);
|
TORQUE_UNIFORM_SAMPLER2D(density, 3);
|
||||||
|
|
@ -56,7 +56,7 @@ float4 main( ConnectData IN ) : TORQUE_TARGET0
|
||||||
float2 uvscreen=((IN.htpos.xy/IN.htpos.w) + 1.0 ) / 2.0;
|
float2 uvscreen=((IN.htpos.xy/IN.htpos.w) + 1.0 ) / 2.0;
|
||||||
uvscreen.y = 1.0 - uvscreen.y;
|
uvscreen.y = 1.0 - uvscreen.y;
|
||||||
|
|
||||||
float obj_test = TORQUE_PREPASS_UNCONDITION(prepassTex, uvscreen).w * preBias;
|
float obj_test = TORQUE_PREPASS_UNCONDITION(deferredTex, uvscreen).w * preBias;
|
||||||
float depth = TORQUE_TEX2D(depthBuffer, uvscreen).r;
|
float depth = TORQUE_TEX2D(depthBuffer, uvscreen).r;
|
||||||
float front = TORQUE_TEX2D(frontBuffer, uvscreen).r;
|
float front = TORQUE_TEX2D(frontBuffer, uvscreen).r;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Volumetric Fog prepass pixel shader V1.00
|
// Volumetric Fog deferred pixel shader V1.00
|
||||||
#include "../shaderModel.hlsl"
|
#include "../shaderModel.hlsl"
|
||||||
|
|
||||||
struct ConnectData
|
struct ConnectData
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
// IN THE SOFTWARE.
|
// IN THE SOFTWARE.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Volumetric Fog prepass vertex shader V1.00
|
// Volumetric Fog deferred vertex shader V1.00
|
||||||
|
|
||||||
#include "../shaderModel.hlsl"
|
#include "../shaderModel.hlsl"
|
||||||
#include "../hlslStructs.hlsl"
|
#include "../hlslStructs.hlsl"
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include "shadergen:/autogenConditioners.h"
|
#include "shadergen:/autogenConditioners.h"
|
||||||
#include "../../gl/torque.glsl"
|
#include "../../gl/torque.glsl"
|
||||||
|
|
||||||
uniform sampler2D prepassTex;
|
uniform sampler2D deferredTex;
|
||||||
uniform sampler2D depthBuffer;
|
uniform sampler2D depthBuffer;
|
||||||
uniform sampler2D frontBuffer;
|
uniform sampler2D frontBuffer;
|
||||||
uniform sampler2D density;
|
uniform sampler2D density;
|
||||||
|
|
@ -52,7 +52,7 @@ void main()
|
||||||
vec2 uvscreen=((IN_hpos.xy/IN_hpos.w) + 1.0 ) / 2.0;
|
vec2 uvscreen=((IN_hpos.xy/IN_hpos.w) + 1.0 ) / 2.0;
|
||||||
uvscreen.y = 1.0 - uvscreen.y;
|
uvscreen.y = 1.0 - uvscreen.y;
|
||||||
|
|
||||||
float obj_test = prepassUncondition( prepassTex, uvscreen).w * preBias;
|
float obj_test = deferredUncondition( deferredTex, uvscreen).w * preBias;
|
||||||
float depth = tex2D(depthBuffer,uvscreen).r;
|
float depth = tex2D(depthBuffer,uvscreen).r;
|
||||||
float front = tex2D(frontBuffer,uvscreen).r;
|
float front = tex2D(frontBuffer,uvscreen).r;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
uniform float oneOverSoftness;
|
uniform float oneOverSoftness;
|
||||||
uniform float oneOverFar;
|
uniform float oneOverFar;
|
||||||
uniform sampler2D prepassTex;
|
uniform sampler2D deferredTex;
|
||||||
//uniform vec3 vEye;
|
//uniform vec3 vEye;
|
||||||
uniform vec4 prePassTargetParams;
|
uniform vec4 prePassTargetParams;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -88,7 +88,7 @@ void main()
|
||||||
vec2 tc = IN_pos.xy * vec2(1.0, -1.0) / IN_pos.w;
|
vec2 tc = IN_pos.xy * vec2(1.0, -1.0) / IN_pos.w;
|
||||||
tc = viewportCoordToRenderTarget(saturate( ( tc + 1.0 ) * 0.5 ), prePassTargetParams);
|
tc = viewportCoordToRenderTarget(saturate( ( tc + 1.0 ) * 0.5 ), prePassTargetParams);
|
||||||
|
|
||||||
float sceneDepth = prepassUncondition( prepassTex, tc ).w;
|
float sceneDepth = deferredUncondition( deferredTex, tc ).w;
|
||||||
float depth = IN_pos.w * oneOverFar;
|
float depth = IN_pos.w * oneOverFar;
|
||||||
float diff = sceneDepth - depth;
|
float diff = sceneDepth - depth;
|
||||||
#ifdef CLIP_Z
|
#ifdef CLIP_Z
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ Fragout main( Conn IN )
|
||||||
{
|
{
|
||||||
Fragout OUT;
|
Fragout OUT;
|
||||||
|
|
||||||
// Clear Prepass Buffer ( Normals/Depth );
|
// Clear Deferred Buffer ( Normals/Depth );
|
||||||
OUT.col = float4(1.0, 1.0, 1.0, 1.0);
|
OUT.col = float4(1.0, 1.0, 1.0, 1.0);
|
||||||
|
|
||||||
// Clear Color Buffer.
|
// Clear Color Buffer.
|
||||||
|
|
|
||||||
|
|
@ -25,17 +25,17 @@
|
||||||
#include "../../torque.hlsl"
|
#include "../../torque.hlsl"
|
||||||
|
|
||||||
TORQUE_UNIFORM_SAMPLER2D(colorBufferTex,0);
|
TORQUE_UNIFORM_SAMPLER2D(colorBufferTex,0);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(lightPrePassTex,1);
|
TORQUE_UNIFORM_SAMPLER2D(lightDeferredTex,1);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(matInfoTex,2);
|
TORQUE_UNIFORM_SAMPLER2D(matInfoTex,2);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(prepassTex,3);
|
TORQUE_UNIFORM_SAMPLER2D(deferredTex,3);
|
||||||
|
|
||||||
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||||
{
|
{
|
||||||
float4 lightBuffer = TORQUE_TEX2D( lightPrePassTex, IN.uv0 );
|
float4 lightBuffer = TORQUE_TEX2D( lightDeferredTex, IN.uv0 );
|
||||||
float4 colorBuffer = TORQUE_TEX2D( colorBufferTex, IN.uv0 );
|
float4 colorBuffer = TORQUE_TEX2D( colorBufferTex, IN.uv0 );
|
||||||
float4 matInfo = TORQUE_TEX2D( matInfoTex, IN.uv0 );
|
float4 matInfo = TORQUE_TEX2D( matInfoTex, IN.uv0 );
|
||||||
float specular = saturate(lightBuffer.a);
|
float specular = saturate(lightBuffer.a);
|
||||||
float depth = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).w;
|
float depth = TORQUE_PREPASS_UNCONDITION( deferredTex, IN.uv0 ).w;
|
||||||
|
|
||||||
if (depth>0.9999)
|
if (depth>0.9999)
|
||||||
return float4(0,0,0,0);
|
return float4(0,0,0,0);
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ out vec4 OUT_col2;
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
// Clear Prepass Buffer ( Normals/Depth );
|
// Clear Deferred Buffer ( Normals/Depth );
|
||||||
OUT_col = vec4(1.0, 1.0, 1.0, 1.0);
|
OUT_col = vec4(1.0, 1.0, 1.0, 1.0);
|
||||||
|
|
||||||
// Clear Color Buffer.
|
// Clear Color Buffer.
|
||||||
|
|
|
||||||
|
|
@ -26,21 +26,21 @@
|
||||||
#include "../../../gl/torque.glsl"
|
#include "../../../gl/torque.glsl"
|
||||||
|
|
||||||
uniform sampler2D colorBufferTex;
|
uniform sampler2D colorBufferTex;
|
||||||
uniform sampler2D lightPrePassTex;
|
uniform sampler2D lightDeferredTex;
|
||||||
uniform sampler2D matInfoTex;
|
uniform sampler2D matInfoTex;
|
||||||
uniform sampler2D prepassTex;
|
uniform sampler2D deferredTex;
|
||||||
|
|
||||||
out vec4 OUT_col;
|
out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
float depth = prepassUncondition( prepassTex, uv0 ).w;
|
float depth = deferredUncondition( deferredTex, uv0 ).w;
|
||||||
if (depth>0.9999)
|
if (depth>0.9999)
|
||||||
{
|
{
|
||||||
OUT_col = vec4(0.0);
|
OUT_col = vec4(0.0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vec4 lightBuffer = texture( lightPrePassTex, uv0 );
|
vec4 lightBuffer = texture( lightDeferredTex, uv0 );
|
||||||
vec4 colorBuffer = texture( colorBufferTex, uv0 );
|
vec4 colorBuffer = texture( colorBufferTex, uv0 );
|
||||||
vec4 matInfo = texture( matInfoTex, uv0 );
|
vec4 matInfo = texture( matInfoTex, uv0 );
|
||||||
float specular = clamp(lightBuffer.a,0.0,1.0);
|
float specular = clamp(lightBuffer.a,0.0,1.0);
|
||||||
|
|
|
||||||
|
|
@ -159,9 +159,9 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
vec4 deferredSample = deferredUncondition( prePassBuffer, uvScene );
|
||||||
vec3 normal = prepassSample.rgb;
|
vec3 normal = deferredSample.rgb;
|
||||||
float depth = prepassSample.a;
|
float depth = deferredSample.a;
|
||||||
|
|
||||||
// Eye ray - Eye -> Pixel
|
// Eye ray - Eye -> Pixel
|
||||||
vec3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, vsEyeDir.xyz, vsFarPlane );
|
vec3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, vsEyeDir.xyz, vsFarPlane );
|
||||||
|
|
|
||||||
|
|
@ -101,9 +101,9 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
vec4 deferredSample = deferredUncondition( prePassBuffer, uvScene );
|
||||||
vec3 normal = prepassSample.rgb;
|
vec3 normal = deferredSample.rgb;
|
||||||
float depth = prepassSample.a;
|
float depth = deferredSample.a;
|
||||||
|
|
||||||
// Eye ray - Eye -> Pixel
|
// Eye ray - Eye -> Pixel
|
||||||
vec3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN_vsEyeDir.xyz, vsFarPlane );
|
vec3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN_vsEyeDir.xyz, vsFarPlane );
|
||||||
|
|
|
||||||
|
|
@ -214,9 +214,9 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uv0 );
|
vec4 deferredSample = deferredUncondition( prePassBuffer, uv0 );
|
||||||
vec3 normal = prepassSample.rgb;
|
vec3 normal = deferredSample.rgb;
|
||||||
float depth = prepassSample.a;
|
float depth = deferredSample.a;
|
||||||
|
|
||||||
// Use eye ray to get ws pos
|
// Use eye ray to get ws pos
|
||||||
vec4 worldPos = vec4(eyePosWorld + wsEyeRay * depth, 1.0f);
|
vec4 worldPos = vec4(eyePosWorld + wsEyeRay * depth, 1.0f);
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,9 @@ float4 main( ConvexConnectP IN ) : TORQUE_TARGET0
|
||||||
float2 uvScene = getUVFromSSPos(ssPos, rtParams0);
|
float2 uvScene = getUVFromSSPos(ssPos, rtParams0);
|
||||||
|
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
float4 prepassSample = TORQUE_PREPASS_UNCONDITION(prePassBuffer, uvScene);
|
float4 deferredSample = TORQUE_PREPASS_UNCONDITION(prePassBuffer, uvScene);
|
||||||
float3 normal = prepassSample.rgb;
|
float3 normal = deferredSample.rgb;
|
||||||
float depth = prepassSample.a;
|
float depth = deferredSample.a;
|
||||||
|
|
||||||
// Eye ray - Eye -> Pixel
|
// Eye ray - Eye -> Pixel
|
||||||
float3 eyeRay = getDistanceVectorToPlane(-vsFarPlane.w, IN.vsEyeDir, vsFarPlane);
|
float3 eyeRay = getDistanceVectorToPlane(-vsFarPlane.w, IN.vsEyeDir, vsFarPlane);
|
||||||
|
|
|
||||||
|
|
@ -161,9 +161,9 @@ float4 main( ConvexConnectP IN ) : TORQUE_TARGET0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
float4 prepassSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, uvScene );
|
float4 deferredSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, uvScene );
|
||||||
float3 normal = prepassSample.rgb;
|
float3 normal = deferredSample.rgb;
|
||||||
float depth = prepassSample.a;
|
float depth = deferredSample.a;
|
||||||
|
|
||||||
// Eye ray - Eye -> Pixel
|
// Eye ray - Eye -> Pixel
|
||||||
float3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane );
|
float3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane );
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,9 @@ float4 main( ConvexConnectP IN ) : TORQUE_TARGET0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
float4 prepassSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, uvScene );
|
float4 deferredSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, uvScene );
|
||||||
float3 normal = prepassSample.rgb;
|
float3 normal = deferredSample.rgb;
|
||||||
float depth = prepassSample.a;
|
float depth = deferredSample.a;
|
||||||
|
|
||||||
// Eye ray - Eye -> Pixel
|
// Eye ray - Eye -> Pixel
|
||||||
float3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane );
|
float3 eyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane );
|
||||||
|
|
|
||||||
|
|
@ -213,9 +213,9 @@ float4 main( FarFrustumQuadConnectP IN ) : TORQUE_TARGET0
|
||||||
subsurface = float3(0.337255, 0.772549, 0.262745);
|
subsurface = float3(0.337255, 0.772549, 0.262745);
|
||||||
}
|
}
|
||||||
// Sample/unpack the normal/z data
|
// Sample/unpack the normal/z data
|
||||||
float4 prepassSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, IN.uv0 );
|
float4 deferredSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, IN.uv0 );
|
||||||
float3 normal = prepassSample.rgb;
|
float3 normal = deferredSample.rgb;
|
||||||
float depth = prepassSample.a;
|
float depth = deferredSample.a;
|
||||||
|
|
||||||
// Use eye ray to get ws pos
|
// Use eye ray to get ws pos
|
||||||
float4 worldPos = float4(eyePosWorld + IN.wsEyeRay * depth, 1.0f);
|
float4 worldPos = float4(eyePosWorld + IN.wsEyeRay * depth, 1.0f);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
uniform float oneOverSoftness;
|
uniform float oneOverSoftness;
|
||||||
uniform float oneOverFar;
|
uniform float oneOverFar;
|
||||||
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 1);
|
TORQUE_UNIFORM_SAMPLER2D(deferredTex, 1);
|
||||||
//uniform float3 vEye;
|
//uniform float3 vEye;
|
||||||
uniform float4 prePassTargetParams;
|
uniform float4 prePassTargetParams;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -84,7 +84,7 @@ float4 main( Conn IN ) : TORQUE_TARGET0
|
||||||
float2 tc = IN.pos.xy * float2(1.0, -1.0) / IN.pos.w;
|
float2 tc = IN.pos.xy * float2(1.0, -1.0) / IN.pos.w;
|
||||||
tc = viewportCoordToRenderTarget(saturate( ( tc + 1.0 ) * 0.5 ), prePassTargetParams);
|
tc = viewportCoordToRenderTarget(saturate( ( tc + 1.0 ) * 0.5 ), prePassTargetParams);
|
||||||
|
|
||||||
float sceneDepth = TORQUE_PREPASS_UNCONDITION(prepassTex, tc).w;
|
float sceneDepth = TORQUE_PREPASS_UNCONDITION(deferredTex, tc).w;
|
||||||
float depth = IN.pos.w * oneOverFar;
|
float depth = IN.pos.w * oneOverFar;
|
||||||
float diff = sceneDepth - depth;
|
float diff = sceneDepth - depth;
|
||||||
#ifdef CLIP_Z
|
#ifdef CLIP_Z
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ uniform float3 eyePosWorld;
|
||||||
uniform float4 rtParams0;
|
uniform float4 rtParams0;
|
||||||
uniform float4 waterFogPlane;
|
uniform float4 waterFogPlane;
|
||||||
|
|
||||||
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 0);
|
TORQUE_UNIFORM_SAMPLER2D(deferredTex, 0);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(causticsTex0, 1);
|
TORQUE_UNIFORM_SAMPLER2D(causticsTex0, 1);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(causticsTex1, 2);
|
TORQUE_UNIFORM_SAMPLER2D(causticsTex1, 2);
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ float distanceToPlane(float4 plane, float3 pos)
|
||||||
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||||
{
|
{
|
||||||
//Sample the pre-pass
|
//Sample the pre-pass
|
||||||
float4 prePass = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 );
|
float4 prePass = TORQUE_PREPASS_UNCONDITION( deferredTex, IN.uv0 );
|
||||||
|
|
||||||
//Get depth
|
//Get depth
|
||||||
float depth = prePass.w;
|
float depth = prePass.w;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ uniform vec4 rtParams0;
|
||||||
uniform vec4 waterFogPlane;
|
uniform vec4 waterFogPlane;
|
||||||
uniform float accumTime;
|
uniform float accumTime;
|
||||||
|
|
||||||
uniform sampler2D prepassTex;
|
uniform sampler2D deferredTex;
|
||||||
uniform sampler2D causticsTex0;
|
uniform sampler2D causticsTex0;
|
||||||
uniform sampler2D causticsTex1;
|
uniform sampler2D causticsTex1;
|
||||||
uniform vec2 targetSize;
|
uniform vec2 targetSize;
|
||||||
|
|
@ -44,7 +44,7 @@ float distanceToPlane(vec4 plane, vec3 pos)
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
//Sample the pre-pass
|
//Sample the pre-pass
|
||||||
vec4 prePass = prepassUncondition( prepassTex, IN_uv0 );
|
vec4 prePass = deferredUncondition( deferredTex, IN_uv0 );
|
||||||
|
|
||||||
//Get depth
|
//Get depth
|
||||||
float depth = prePass.w;
|
float depth = prePass.w;
|
||||||
|
|
|
||||||
|
|
@ -87,10 +87,10 @@ void main()
|
||||||
coc = half4(0);
|
coc = half4(0);
|
||||||
for ( int i = 0; i < 4; i++ )
|
for ( int i = 0; i < 4; i++ )
|
||||||
{
|
{
|
||||||
depth[0] = prepassUncondition( depthSampler, ( IN_tcDepth0.xy + rowOfs[i] ) ).w;
|
depth[0] = deferredUncondition( depthSampler, ( IN_tcDepth0.xy + rowOfs[i] ) ).w;
|
||||||
depth[1] = prepassUncondition( depthSampler, ( IN_tcDepth1.xy + rowOfs[i] ) ).w;
|
depth[1] = deferredUncondition( depthSampler, ( IN_tcDepth1.xy + rowOfs[i] ) ).w;
|
||||||
depth[2] = prepassUncondition( depthSampler, ( IN_tcDepth2.xy + rowOfs[i] ) ).w;
|
depth[2] = deferredUncondition( depthSampler, ( IN_tcDepth2.xy + rowOfs[i] ) ).w;
|
||||||
depth[3] = prepassUncondition( depthSampler, ( IN_tcDepth3.xy + rowOfs[i] ) ).w;
|
depth[3] = deferredUncondition( depthSampler, ( IN_tcDepth3.xy + rowOfs[i] ) ).w;
|
||||||
|
|
||||||
// @todo OPENGL INTEL need review
|
// @todo OPENGL INTEL need review
|
||||||
coc = max( coc, clamp( half4(dofEqWorld.x) * depth + half4(dofEqWorld.y), half4(0.0), half4(maxWorldCoC) ) );
|
coc = max( coc, clamp( half4(dofEqWorld.x) * depth + half4(dofEqWorld.y), half4(0.0), half4(maxWorldCoC) ) );
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ void main()
|
||||||
//med.rgb = large;
|
//med.rgb = large;
|
||||||
|
|
||||||
//nearCoc = 0;
|
//nearCoc = 0;
|
||||||
depth = prepassUncondition( depthSampler, IN_uv3 ).w;
|
depth = deferredUncondition( depthSampler, IN_uv3 ).w;
|
||||||
//return half4(depth.rrr,1);
|
//return half4(depth.rrr,1);
|
||||||
//return half4(nearCoc.rrr,1.0);
|
//return half4(nearCoc.rrr,1.0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
#include "../postFx.hlsl"
|
#include "../postFx.hlsl"
|
||||||
#include "../../shaderModelAutoGen.hlsl"
|
#include "../../shaderModelAutoGen.hlsl"
|
||||||
|
|
||||||
TORQUE_UNIFORM_SAMPLER2D(prepassBuffer,0);
|
TORQUE_UNIFORM_SAMPLER2D(deferredBuffer,0);
|
||||||
|
|
||||||
// GPU Gems 3, pg 443-444
|
// GPU Gems 3, pg 443-444
|
||||||
float GetEdgeWeight(float2 uv0, in float2 targetSize)
|
float GetEdgeWeight(float2 uv0, in float2 targetSize)
|
||||||
|
|
@ -50,7 +50,7 @@ float GetEdgeWeight(float2 uv0, in float2 targetSize)
|
||||||
for(int i = 0; i < 9; i++)
|
for(int i = 0; i < 9; i++)
|
||||||
{
|
{
|
||||||
float2 uv = uv0 + offsets[i] * PixelSize;
|
float2 uv = uv0 + offsets[i] * PixelSize;
|
||||||
float4 gbSample = TORQUE_PREPASS_UNCONDITION( prepassBuffer, uv );
|
float4 gbSample = TORQUE_PREPASS_UNCONDITION( deferredBuffer, uv );
|
||||||
Depth[i] = gbSample.a;
|
Depth[i] = gbSample.a;
|
||||||
Normal[i] = gbSample.rgb;
|
Normal[i] = gbSample.rgb;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include "shadergen:/autogenConditioners.h"
|
#include "shadergen:/autogenConditioners.h"
|
||||||
|
|
||||||
// GPU Gems 3, pg 443-444
|
// GPU Gems 3, pg 443-444
|
||||||
float GetEdgeWeight(vec2 uv0, in sampler2D prepassBuffer, in vec2 targetSize)
|
float GetEdgeWeight(vec2 uv0, in sampler2D deferredBuffer, in vec2 targetSize)
|
||||||
{
|
{
|
||||||
vec2 offsets[9] = vec2[](
|
vec2 offsets[9] = vec2[](
|
||||||
vec2( 0.0, 0.0),
|
vec2( 0.0, 0.0),
|
||||||
|
|
@ -47,7 +47,7 @@ float GetEdgeWeight(vec2 uv0, in sampler2D prepassBuffer, in vec2 targetSize)
|
||||||
for(int i = 0; i < 9; i++)
|
for(int i = 0; i < 9; i++)
|
||||||
{
|
{
|
||||||
vec2 uv = uv0 + offsets[i] * PixelSize;
|
vec2 uv = uv0 + offsets[i] * PixelSize;
|
||||||
vec4 gbSample = prepassUncondition( prepassBuffer, uv );
|
vec4 gbSample = deferredUncondition( deferredBuffer, uv );
|
||||||
Depth[i] = gbSample.a;
|
Depth[i] = gbSample.a;
|
||||||
Normal[i] = gbSample.rgb;
|
Normal[i] = gbSample.rgb;
|
||||||
}
|
}
|
||||||
|
|
@ -85,12 +85,12 @@ float GetEdgeWeight(vec2 uv0, in sampler2D prepassBuffer, in vec2 targetSize)
|
||||||
in vec2 uv0;
|
in vec2 uv0;
|
||||||
#define IN_uv0 uv0
|
#define IN_uv0 uv0
|
||||||
|
|
||||||
uniform sampler2D prepassBuffer;
|
uniform sampler2D deferredBuffer;
|
||||||
uniform vec2 targetSize;
|
uniform vec2 targetSize;
|
||||||
|
|
||||||
out vec4 OUT_col;
|
out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
OUT_col = vec4( GetEdgeWeight(IN_uv0, prepassBuffer, targetSize ) );//rtWidthHeightInvWidthNegHeight.zw);
|
OUT_col = vec4( GetEdgeWeight(IN_uv0, deferredBuffer, targetSize ) );//rtWidthHeightInvWidthNegHeight.zw);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include "./../torque.hlsl"
|
#include "./../torque.hlsl"
|
||||||
#include "./../shaderModelAutoGen.hlsl"
|
#include "./../shaderModelAutoGen.hlsl"
|
||||||
|
|
||||||
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 0);
|
TORQUE_UNIFORM_SAMPLER2D(deferredTex, 0);
|
||||||
uniform float3 eyePosWorld;
|
uniform float3 eyePosWorld;
|
||||||
uniform float4 fogColor;
|
uniform float4 fogColor;
|
||||||
uniform float3 fogData;
|
uniform float3 fogData;
|
||||||
|
|
@ -33,8 +33,8 @@ uniform float4 rtParams0;
|
||||||
|
|
||||||
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||||
{
|
{
|
||||||
//float2 prepassCoord = ( IN.uv0.xy * rtParams0.zw ) + rtParams0.xy;
|
//float2 deferredCoord = ( IN.uv0.xy * rtParams0.zw ) + rtParams0.xy;
|
||||||
float depth = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).w;
|
float depth = TORQUE_PREPASS_UNCONDITION( deferredTex, IN.uv0 ).w;
|
||||||
//return float4( depth, 0, 0, 0.7 );
|
//return float4( depth, 0, 0, 0.7 );
|
||||||
|
|
||||||
float factor = computeSceneFog( eyePosWorld,
|
float factor = computeSceneFog( eyePosWorld,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include "shadergen:/autogenConditioners.h"
|
#include "shadergen:/autogenConditioners.h"
|
||||||
#include "../../gl/torque.glsl"
|
#include "../../gl/torque.glsl"
|
||||||
|
|
||||||
uniform sampler2D prepassTex ;
|
uniform sampler2D deferredTex ;
|
||||||
uniform vec3 eyePosWorld;
|
uniform vec3 eyePosWorld;
|
||||||
uniform vec4 fogColor;
|
uniform vec4 fogColor;
|
||||||
uniform vec3 fogData;
|
uniform vec3 fogData;
|
||||||
|
|
@ -38,8 +38,8 @@ out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
//vec2 prepassCoord = ( uv0.xy * rtParams0.zw ) + rtParams0.xy;
|
//vec2 deferredCoord = ( uv0.xy * rtParams0.zw ) + rtParams0.xy;
|
||||||
float depth = prepassUncondition( prepassTex, uv0 ).w;
|
float depth = deferredUncondition( deferredTex, uv0 ).w;
|
||||||
//return vec4( depth, 0, 0, 0.7 );
|
//return vec4( depth, 0, 0, 0.7 );
|
||||||
|
|
||||||
float factor = computeSceneFog( eyePosWorld,
|
float factor = computeSceneFog( eyePosWorld,
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ uniform mat4 matWorldToScreen;
|
||||||
uniform float velocityMultiplier;
|
uniform float velocityMultiplier;
|
||||||
|
|
||||||
uniform sampler2D backBuffer;
|
uniform sampler2D backBuffer;
|
||||||
uniform sampler2D prepassTex;
|
uniform sampler2D deferredTex;
|
||||||
|
|
||||||
out vec4 OUT_col;
|
out vec4 OUT_col;
|
||||||
|
|
||||||
|
|
@ -44,11 +44,11 @@ void main()
|
||||||
vec2 IN_uv0 = _IN_uv0;
|
vec2 IN_uv0 = _IN_uv0;
|
||||||
float samples = 5;
|
float samples = 5;
|
||||||
|
|
||||||
// First get the prepass texture for uv channel 0
|
// First get the deferred texture for uv channel 0
|
||||||
vec4 prepass = prepassUncondition( prepassTex, IN_uv0 );
|
vec4 deferred = deferredUncondition( deferredTex, IN_uv0 );
|
||||||
|
|
||||||
// Next extract the depth
|
// Next extract the depth
|
||||||
float depth = prepass.a;
|
float depth = deferred.a;
|
||||||
|
|
||||||
// Create the screen position
|
// Create the screen position
|
||||||
vec4 screenPos = vec4(IN_uv0.x*2-1, IN_uv0.y*2-1, depth*2-1, 1);
|
vec4 screenPos = vec4(IN_uv0.x*2-1, IN_uv0.y*2-1, depth*2-1, 1);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
// Uniforms
|
// Uniforms
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
uniform sampler2D prepassTex ;
|
uniform sampler2D deferredTex ;
|
||||||
uniform sampler2D backbuffer ;
|
uniform sampler2D backbuffer ;
|
||||||
uniform sampler1D waterDepthGradMap;
|
uniform sampler1D waterDepthGradMap;
|
||||||
uniform vec3 eyePosWorld;
|
uniform vec3 eyePosWorld;
|
||||||
|
|
@ -55,9 +55,9 @@ out vec4 OUT_col;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
//vec2 prepassCoord = IN_uv0;
|
//vec2 deferredCoord = IN_uv0;
|
||||||
//IN_uv0 = ( IN_uv0.xy * rtParams0.zw ) + rtParams0.xy;
|
//IN_uv0 = ( IN_uv0.xy * rtParams0.zw ) + rtParams0.xy;
|
||||||
float depth = prepassUncondition( prepassTex, IN_uv0 ).w;
|
float depth = deferredUncondition( deferredTex, IN_uv0 ).w;
|
||||||
//return vec4( depth.rrr, 1 );
|
//return vec4( depth.rrr, 1 );
|
||||||
|
|
||||||
// Skip fogging the extreme far plane so that
|
// Skip fogging the extreme far plane so that
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include "../../gl/postFX.glsl"
|
#include "../../gl/postFX.glsl"
|
||||||
|
|
||||||
uniform sampler2D backBuffer; // The original backbuffer.
|
uniform sampler2D backBuffer; // The original backbuffer.
|
||||||
uniform sampler2D prepassTex; // The pre-pass depth and normals.
|
uniform sampler2D deferredTex; // The pre-pass depth and normals.
|
||||||
|
|
||||||
uniform float brightScalar;
|
uniform float brightScalar;
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ void main()
|
||||||
vec4 col = vec4( 0, 0, 0, 1 );
|
vec4 col = vec4( 0, 0, 0, 1 );
|
||||||
|
|
||||||
// Get the depth at this pixel.
|
// Get the depth at this pixel.
|
||||||
float depth = prepassUncondition( prepassTex, IN_uv0 ).w;
|
float depth = deferredUncondition( deferredTex, IN_uv0 ).w;
|
||||||
|
|
||||||
// If the depth is equal to 1.0, read from the backbuffer
|
// If the depth is equal to 1.0, read from the backbuffer
|
||||||
// and perform the exposure calculation on the result.
|
// and perform the exposure calculation on the result.
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include "../postFx.hlsl"
|
#include "../postFx.hlsl"
|
||||||
|
|
||||||
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
|
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 1);
|
TORQUE_UNIFORM_SAMPLER2D(deferredTex, 1);
|
||||||
|
|
||||||
uniform float brightScalar;
|
uniform float brightScalar;
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||||
float4 col = float4( 0, 0, 0, 1 );
|
float4 col = float4( 0, 0, 0, 1 );
|
||||||
|
|
||||||
// Get the depth at this pixel.
|
// Get the depth at this pixel.
|
||||||
float depth = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).w;
|
float depth = TORQUE_PREPASS_UNCONDITION( deferredTex, IN.uv0 ).w;
|
||||||
|
|
||||||
// If the depth is equal to 1.0, read from the backbuffer
|
// If the depth is equal to 1.0, read from the backbuffer
|
||||||
// and perform the exposure calculation on the result.
|
// and perform the exposure calculation on the result.
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue