Implementation of reflection and skylight probes.

Moves lighting math to the diffuse/specular two-channel logic.
This commit is contained in:
Areloch 2018-09-16 22:15:07 -05:00
parent 83dd55e851
commit 2be32ad737
102 changed files with 12346 additions and 1911 deletions

View file

@ -40,9 +40,10 @@
#include "gfx/gfxDebugEvent.h"
#include "math/util/matrixSet.h"
#include "console/consoleTypes.h"
#include "gfx/gfxTextureManager.h"
const RenderInstType AdvancedLightBinManager::RIT_LightInfo( "directLighting" );
const String AdvancedLightBinManager::smBufferName( "directLighting" );
const RenderInstType AdvancedLightBinManager::RIT_LightInfo( "specularLighting" );
const String AdvancedLightBinManager::smBufferName( "specularLighting" );
ShadowFilterMode AdvancedLightBinManager::smShadowFilterMode = ShadowFilterMode_SoftShadowHighQuality;
bool AdvancedLightBinManager::smPSSMDebugRender = false;
@ -180,6 +181,26 @@ bool AdvancedLightBinManager::setTargetSize(const Point2I &newTargetSize)
return ret;
}
bool AdvancedLightBinManager::_updateTargets()
{
PROFILE_SCOPE(AdvancedLightBinManager_updateTargets);
bool ret = Parent::_updateTargets();
mDiffuseLightingTarget = NamedTexTarget::find("diffuseLighting");
if (mDiffuseLightingTarget.isValid())
{
mDiffuseLightingTex = mDiffuseLightingTarget->getTexture();
for (U32 i = 0; i < mTargetChainLength; i++)
mTargetChain[i]->attachTexture(GFXTextureTarget::Color1, mDiffuseLightingTex);
}
GFX->finalizeReset();
return ret;
}
void AdvancedLightBinManager::addLight( LightInfo *light )
{
// Get the light type.

View file

@ -90,6 +90,9 @@ public:
// registered buffer name
static const String smBufferName;
NamedTexTargetRef mDiffuseLightingTarget;
GFXTexHandle mDiffuseLightingTex;
/// The shadow filter mode to use on shadowed light materials.
static ShadowFilterMode smShadowFilterMode;
@ -128,6 +131,7 @@ public:
bool MRTLightmapsDuringDeferred() const { return mMRTLightmapsDuringDeferred; }
void MRTLightmapsDuringDeferred(bool val);
bool _updateTargets();
typedef Signal<void(SceneRenderState *, AdvancedLightBinManager *)> RenderSignal;
static RenderSignal &getRenderSignal();

View file

@ -63,6 +63,7 @@ void AdvancedLightingFeatures::registerFeatures( const GFXFormat &deferredTarget
FEATUREMGR->registerFeature(MFT_PixSpecular, new DeferredPixelSpecularGLSL());
FEATUREMGR->registerFeature(MFT_MinnaertShading, new DeferredMinnaertGLSL());
FEATUREMGR->registerFeature(MFT_SubSurface, new DeferredSubSurfaceGLSL());
FEATUREMGR->registerFeature(MFT_ReflectionProbes, new ReflectionProbeFeatGLSL);
#endif
}
else
@ -75,6 +76,7 @@ void AdvancedLightingFeatures::registerFeatures( const GFXFormat &deferredTarget
FEATUREMGR->registerFeature(MFT_PixSpecular, new DeferredPixelSpecularHLSL());
FEATUREMGR->registerFeature(MFT_MinnaertShading, new DeferredMinnaertHLSL());
FEATUREMGR->registerFeature(MFT_SubSurface, new DeferredSubSurfaceHLSL());
FEATUREMGR->registerFeature(MFT_ReflectionProbes, new ReflectionProbeFeatHLSL);
#endif
}

View file

@ -98,7 +98,7 @@ void DeferredRTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &component
uvScene->setName( "uvScene" );
LangElement *uvSceneDecl = new DecOp( uvScene );
String rtParamName = String::ToString( "rtParams%s", "directLightingBuffer" );
String rtParamName = String::ToString( "rtParams%s", "diffuseLightingBuffer" );
Var *rtParams = (Var*) LangElement::find( rtParamName );
if( !rtParams )
{
@ -121,7 +121,7 @@ void DeferredRTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &component
// create texture var
Var *lightInfoBuffer = new Var;
lightInfoBuffer->setType( "sampler2D" );
lightInfoBuffer->setName( "directLightingBuffer" );
lightInfoBuffer->setName( "diffuseLightingBuffer" );
lightInfoBuffer->uniform = true;
lightInfoBuffer->sampler = true;
lightInfoBuffer->constNum = Var::getTexUnitNum(); // used as texture unit num here
@ -207,7 +207,7 @@ void DeferredRTLightingFeatGLSL::setTexData( Material::StageData &stageDat,
mLastTexIndex = texIndex;
passData.mTexType[ texIndex ] = Material::TexTarget;
passData.mSamplerNames[ texIndex ]= "directLightingBuffer";
passData.mSamplerNames[ texIndex ]= "diffuseLightingBuffer";
passData.mTexSlot[ texIndex++ ].texTarget = texTarget;
}
}

View file

@ -99,7 +99,7 @@ void DeferredRTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &component
uvScene->setName("uvScene");
LangElement *uvSceneDecl = new DecOp(uvScene);
String rtParamName = String::ToString("rtParams%s", "directLightingBuffer");
String rtParamName = String::ToString("rtParams%s", "diffuseLightingBuffer");
Var *rtParams = (Var*)LangElement::find(rtParamName);
if (!rtParams)
{
@ -215,7 +215,7 @@ void DeferredRTLightingFeatHLSL::setTexData( Material::StageData &stageDat,
mLastTexIndex = texIndex;
passData.mTexType[ texIndex ] = Material::TexTarget;
passData.mSamplerNames[ texIndex ]= "directLightingBuffer";
passData.mSamplerNames[ texIndex ]= "diffuseLightingBuffer";
passData.mTexSlot[ texIndex++ ].texTarget = texTarget;
}
}