mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
sunBokeh feature added
This commit is contained in:
parent
5d52864c9f
commit
637a804fd7
|
|
@ -121,6 +121,7 @@ LightFlareData::LightFlareData()
|
|||
mElementCount( 0 ),
|
||||
mScale( 1.0f ),
|
||||
mOcclusionRadius( 0.0f ),
|
||||
mVisibility( 1.0f ), //sunBokeh feature
|
||||
mRenderReflectPass( true )
|
||||
{
|
||||
dMemset( mElementRect, 0, sizeof( RectF ) * MAX_ELEMENTS );
|
||||
|
|
@ -445,6 +446,8 @@ void LightFlareData::prepRender( SceneRenderState *state, LightFlareState *flare
|
|||
const RectI &viewport = GFX->getViewport();
|
||||
Point3F oneOverViewportExtent( 1.0f / (F32)viewport.extent.x, 1.0f / (F32)viewport.extent.y, 0.0f );
|
||||
|
||||
// Sun visibility, assume 0 at start of frame
|
||||
mVisibility = 0; //sunBokeh feature
|
||||
// Really convert it to screen space.
|
||||
lightPosSS.x -= viewport.point.x;
|
||||
lightPosSS.y -= viewport.point.y;
|
||||
|
|
@ -514,6 +517,7 @@ void LightFlareData::prepRender( SceneRenderState *state, LightFlareState *flare
|
|||
// These are the factors which affect the "alpha" of the flare effect.
|
||||
// Modulate more in as appropriate.
|
||||
ColorF baseColor = ColorF::WHITE * lightSourceBrightnessScale * occlusionFade;
|
||||
mVisibility = lightSourceBrightnessScale * fadeInOutScale * occlusionFade; //sunBokeh feature
|
||||
|
||||
// Setup the vertex buffer for the maximum flare elements.
|
||||
const U32 vertCount = 4 * mElementCount;
|
||||
|
|
|
|||
|
|
@ -94,6 +94,8 @@ public:
|
|||
|
||||
/// Submits render instances for corona and flare effects.
|
||||
void prepRender( SceneRenderState *state, LightFlareState *flareState );
|
||||
/// sunBokeh feature
|
||||
F32 getVisibility() const { return mVisibility; }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
@ -112,7 +114,7 @@ protected:
|
|||
static Point3F sBasePoints[4];
|
||||
|
||||
// Fields...
|
||||
|
||||
F32 mVisibility; //sunBokeh feature
|
||||
F32 mScale;
|
||||
bool mFlareEnabled;
|
||||
String mFlareTextureName;
|
||||
|
|
|
|||
|
|
@ -655,6 +655,11 @@ void ScatterSky::prepRenderImage( SceneRenderState *state )
|
|||
state->getRenderPass()->addInst( ri );
|
||||
}
|
||||
*/
|
||||
// Screen flare occlusion fix //sunBokeh feature
|
||||
F32 screenRadius = GFX->getViewport().extent.y * mFlareScale * 0.01f;
|
||||
Point3F lightWorldPos = state->getCameraPosition() - state->getFarPlane() * mLight->getDirection() * 0.9f;
|
||||
F32 dist = ( lightWorldPos - state->getCameraPosition() ).len();
|
||||
mFlareState.worldRadius = screenRadius * dist / state->getWorldToScreenScale().y;
|
||||
|
||||
// Light flare effect render instance.
|
||||
if ( mFlareData && mNightInterpolant != 1.0f )
|
||||
|
|
|
|||
|
|
@ -109,6 +109,10 @@ public:
|
|||
F32 getAzimuth() const { return mSunAzimuth; }
|
||||
///
|
||||
F32 getElevation() const { return mSunElevation; }
|
||||
/// sunBokeh feature
|
||||
F32 getSunVisibility() const { if (mFlareData) return mFlareData->getVisibility(); else return 0; }
|
||||
// Same method as above, but also checks if the data is valid, needs more CPU time, only use if above method fails
|
||||
//F32 getSunVisibility() const { if dynamic_cast<LightFlareData*>(mFlareData) return mFlareData->getVisibility(); else return 0; }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ protected:
|
|||
GFXShaderConstHandle *mAccumTimeSC;
|
||||
GFXShaderConstHandle *mDeltaTimeSC;
|
||||
GFXShaderConstHandle *mInvCameraMatSC;
|
||||
GFXShaderConstHandle *mSunVisibilitySC; //sunBokeh feature
|
||||
|
||||
bool mAllowReflectPass;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue