sunBokeh feature added

This commit is contained in:
Duion 2016-06-02 20:52:46 +02:00
parent 5d52864c9f
commit 637a804fd7
6 changed files with 29 additions and 1 deletions

View file

@ -44,6 +44,7 @@
#include "materials/shaderData.h"
#include "postFx/postEffectManager.h"
#include "postFx/postEffectVis.h"
#include "environment/scatterSky.h" //sunBokeh feature
using namespace Torque;
@ -303,6 +304,7 @@ PostEffect::PostEffect()
mScreenSunPosSC( NULL ),
mLightDirectionSC( NULL ),
mCameraForwardSC( NULL ),
mSunVisibilitySC( NULL ), //sunBokeh feature
mAccumTimeSC( NULL ),
mDeltaTimeSC( NULL ),
mInvCameraMatSC( NULL )
@ -602,6 +604,7 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
mScreenSunPosSC = mShader->getShaderConstHandle( "$screenSunPos" );
mLightDirectionSC = mShader->getShaderConstHandle( "$lightDirection" );
mCameraForwardSC = mShader->getShaderConstHandle( "$camForward" );
mSunVisibilitySC = mShader->getShaderConstHandle( "$sunVisibility" ); //sunBokeh feature
mAccumTimeSC = mShader->getShaderConstHandle( "$accumTime" );
mDeltaTimeSC = mShader->getShaderConstHandle( "$deltaTime" );
@ -849,6 +852,15 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
mat.inverse();
mShaderConsts->set( mInvCameraMatSC, mat, mInvCameraMatSC->getType() );
}
if( mSunVisibilitySC->isValid() ) //sunBokeh feature
{
ScatterSky* pSky = dynamic_cast<ScatterSky*>(Sim::findObject("Himmel"));
if(pSky)
mShaderConsts->set( mSunVisibilitySC, pSky->getSunVisibility() );
else
mShaderConsts->set( mSunVisibilitySC, 0.0f );
}
} // if ( state )