Merge pull request #1002 from Winterleaf/Fix-ScatterSky-Zindex

Z Offset for Scattersky to fix the rendering issue at high altitudes.
This commit is contained in:
Daniel Buckmaster 2015-01-02 13:04:24 +11:00
commit 93b0179019
2 changed files with 18 additions and 9 deletions

View file

@ -136,6 +136,7 @@ ScatterSky::ScatterSky()
mExposure = 1.0f; mExposure = 1.0f;
mNightInterpolant = 0; mNightInterpolant = 0;
mZOffset = 0.0f;
mShader = NULL; mShader = NULL;
@ -350,6 +351,9 @@ void ScatterSky::initPersistFields()
addField( "exposure", TypeF32, Offset( mExposure, ScatterSky ), addField( "exposure", TypeF32, Offset( mExposure, ScatterSky ),
"Controls the contrast of the sky and sun during daytime." ); "Controls the contrast of the sky and sun during daytime." );
addField( "zOffset", TypeF32, Offset( mZOffset, ScatterSky ),
"Offsets the scatterSky to avoid canvas rendering. Use 5000 or greater for the initial adjustment" );
endGroup( "ScatterSky" ); endGroup( "ScatterSky" );
addGroup( "Orbit" ); addGroup( "Orbit" );
@ -478,6 +482,8 @@ U32 ScatterSky::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
stream->write( mExposure ); stream->write( mExposure );
stream->write( mZOffset );
stream->write( mBrightness ); stream->write( mBrightness );
stream->writeFlag( mCastShadows ); stream->writeFlag( mCastShadows );
@ -577,6 +583,8 @@ void ScatterSky::unpackUpdate(NetConnection *con, BitStream *stream)
stream->read( &mExposure ); stream->read( &mExposure );
stream->read( &mZOffset );
stream->read( &mBrightness ); stream->read( &mBrightness );
mCastShadows = stream->readFlag(); mCastShadows = stream->readFlag();
@ -937,7 +945,7 @@ void ScatterSky::_render( ObjectRenderInst *ri, SceneRenderState *state, BaseMat
Point3F camPos2 = state->getCameraPosition(); Point3F camPos2 = state->getCameraPosition();
MatrixF xfm(true); MatrixF xfm(true);
xfm.setPosition(camPos2);//-Point3F( 0, 0, 200000.0f)); xfm.setPosition(camPos2 - Point3F( 0, 0, mZOffset));
GFX->multWorld(xfm); GFX->multWorld(xfm);
MatrixF xform(proj);//GFX->getProjectionMatrix()); MatrixF xform(proj);//GFX->getProjectionMatrix());
xform *= GFX->getViewMatrix(); xform *= GFX->getViewMatrix();

View file

@ -179,6 +179,7 @@ protected:
F32 mExposure; F32 mExposure;
F32 mNightInterpolant; F32 mNightInterpolant;
F32 mZOffset;
VectorF mLightDir; VectorF mLightDir;
VectorF mSunDir; VectorF mSunDir;