mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-20 03:45:26 +00:00
lighting single buffer
This commit is contained in:
parent
ecef09525a
commit
b0fff30d33
37 changed files with 309 additions and 813 deletions
|
|
@ -119,17 +119,8 @@ AdvancedLightBinManager::AdvancedLightBinManager( AdvancedLightManager *lm /* =
|
|||
: RenderBinManager( RIT_LightInfo, 1.0f, 1.0f ),
|
||||
mNumLightsCulled(0),
|
||||
mLightManager(lm),
|
||||
mShadowManager(sm),
|
||||
mConditioner(NULL)
|
||||
mShadowManager(sm)
|
||||
{
|
||||
// Create an RGB conditioner
|
||||
NamedTexTarget* specLightTarg = NamedTexTarget::find(RenderDeferredMgr::SpecularLightBufferName);
|
||||
|
||||
mConditioner = new AdvancedLightBufferConditioner(lightBufferFormat,
|
||||
AdvancedLightBufferConditioner::RGB );
|
||||
|
||||
specLightTarg->setConditioner( mConditioner );
|
||||
|
||||
mMRTLightmapsDuringDeferred = true;
|
||||
|
||||
Con::NotifyDelegate callback( this, &AdvancedLightBinManager::_deleteLightMaterials );
|
||||
|
|
@ -143,8 +134,6 @@ AdvancedLightBinManager::~AdvancedLightBinManager()
|
|||
{
|
||||
_deleteLightMaterials();
|
||||
|
||||
SAFE_DELETE(mConditioner);
|
||||
|
||||
Con::NotifyDelegate callback( this, &AdvancedLightBinManager::_deleteLightMaterials );
|
||||
Con::removeVariableNotify( "$pref::shadows::filterMode", callback );
|
||||
Con::removeVariableNotify( "$AL::PSSMDebugRender", callback );
|
||||
|
|
@ -274,16 +263,8 @@ void AdvancedLightBinManager::render( SceneRenderState *state )
|
|||
//if ( !_onPreRender( state ) )
|
||||
// return;
|
||||
|
||||
//GFX->clear(GFXClearTarget, ColorI(0, 0, 0, 0), 1.0f, 0);
|
||||
|
||||
NamedTexTargetRef diffuseLightingTarget = NamedTexTarget::find("diffuseLighting");
|
||||
|
||||
if (diffuseLightingTarget.isNull())
|
||||
return;
|
||||
|
||||
NamedTexTargetRef specularLightingTarget = NamedTexTarget::find("specularLighting");
|
||||
|
||||
if (specularLightingTarget.isNull())
|
||||
NamedTexTargetRef sceneColorTargetRef = NamedTexTarget::find("AL_FormatToken");
|
||||
if (sceneColorTargetRef.isNull())
|
||||
return;
|
||||
|
||||
GFXTextureTargetRef lightingTargetRef = GFX->allocRenderToTextureTarget();
|
||||
|
|
@ -294,13 +275,12 @@ void AdvancedLightBinManager::render( SceneRenderState *state )
|
|||
//Do a quick pass to update our probes if they're dirty
|
||||
PROBEMGR->updateDirtyProbes();
|
||||
|
||||
lightingTargetRef->attachTexture(GFXTextureTarget::Color0, specularLightingTarget->getTexture());
|
||||
lightingTargetRef->attachTexture(GFXTextureTarget::Color1, diffuseLightingTarget->getTexture());
|
||||
lightingTargetRef->attachTexture(GFXTextureTarget::Color0, sceneColorTargetRef->getTexture());
|
||||
|
||||
GFX->pushActiveRenderTarget();
|
||||
GFX->setActiveRenderTarget(lightingTargetRef);
|
||||
|
||||
GFX->setViewport(specularLightingTarget->getViewport());
|
||||
GFX->setViewport(sceneColorTargetRef->getViewport());
|
||||
|
||||
// Restore transforms
|
||||
MatrixSet &matrixSet = getRenderPass()->getMatrixSet();
|
||||
|
|
@ -415,7 +395,6 @@ void AdvancedLightBinManager::render( SceneRenderState *state )
|
|||
|
||||
// Finish up the rendering
|
||||
//_onPostRender();
|
||||
lightingTargetRef->resolve();
|
||||
GFX->popActiveRenderTarget();
|
||||
}
|
||||
|
||||
|
|
@ -765,9 +744,8 @@ void AdvancedLightBinManager::LightMaterialInfo::setLightParameters( const Light
|
|||
0.0f );
|
||||
|
||||
matParams->setSafe( lightSpotParams, spotParams );
|
||||
|
||||
VectorF lightDir = lightInfo->getDirection();
|
||||
matParams->setSafe( lightDirection, lightDir );
|
||||
matParams->setSafe( lightDirection, lightInfo->getDirection());
|
||||
matParams->setSafe( lightPosition, lightInfo->getPosition());
|
||||
}
|
||||
// Fall through
|
||||
|
||||
|
|
|
|||
|
|
@ -230,8 +230,6 @@ protected:
|
|||
///
|
||||
void _onShadowFilterChanged();
|
||||
|
||||
AdvancedLightBufferConditioner *mConditioner;
|
||||
|
||||
typedef GFXVertexPNTT FarFrustumQuadVert;
|
||||
GFXVertexBufferHandle<FarFrustumQuadVert> mFarFrustumQuadVerts;
|
||||
|
||||
|
|
|
|||
|
|
@ -179,3 +179,25 @@ void DeferredSpecVarsHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
meta->addStatement(new GenOp(" @.a = @;\r\n", material, metalness));
|
||||
output = meta;
|
||||
}
|
||||
|
||||
//deferred emissive
|
||||
void DeferredEmissiveHLSL::processPix(Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd)
|
||||
{
|
||||
//for now emission just uses the diffuse color, we could plug in a separate texture for emission at some stage
|
||||
Var *diffuseTargetVar = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (!diffuseTargetVar)
|
||||
return; //oh dear something is not right, maybe we should just write 0's instead
|
||||
|
||||
// search for scene color target var
|
||||
Var *sceneColorVar = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget3));
|
||||
if (!sceneColorVar)
|
||||
{
|
||||
// create scene color target var
|
||||
sceneColorVar = new Var;
|
||||
sceneColorVar->setType("fragout");
|
||||
sceneColorVar->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3));
|
||||
sceneColorVar->setStructName("OUT");
|
||||
}
|
||||
|
||||
output = new GenOp("@ = float4(@.rgb,0);", sceneColorVar, diffuseTargetVar);
|
||||
}
|
||||
|
|
@ -69,4 +69,16 @@ public:
|
|||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; }
|
||||
};
|
||||
|
||||
class DeferredEmissiveHLSL : public ShaderFeatureHLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Emissive"; }
|
||||
|
||||
virtual void processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd);
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const { return ShaderFeature::RenderTarget3; }
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue