mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
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:
commit
93b0179019
2 changed files with 18 additions and 9 deletions
|
|
@ -136,6 +136,7 @@ ScatterSky::ScatterSky()
|
||||||
|
|
||||||
mExposure = 1.0f;
|
mExposure = 1.0f;
|
||||||
mNightInterpolant = 0;
|
mNightInterpolant = 0;
|
||||||
|
mZOffset = 0.0f;
|
||||||
|
|
||||||
mShader = NULL;
|
mShader = NULL;
|
||||||
|
|
||||||
|
|
@ -313,7 +314,7 @@ void ScatterSky::setElevation( F32 elevation )
|
||||||
void ScatterSky::inspectPostApply()
|
void ScatterSky::inspectPostApply()
|
||||||
{
|
{
|
||||||
mDirty = true;
|
mDirty = true;
|
||||||
setMaskBits( 0xFFFFFFFF );
|
setMaskBits( 0xFFFFFFFF );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScatterSky::initPersistFields()
|
void ScatterSky::initPersistFields()
|
||||||
|
|
@ -324,13 +325,13 @@ void ScatterSky::initPersistFields()
|
||||||
addField( "skyBrightness", TypeF32, Offset( mSkyBrightness, ScatterSky ),
|
addField( "skyBrightness", TypeF32, Offset( mSkyBrightness, ScatterSky ),
|
||||||
"Global brightness and intensity applied to the sky and objects in the level." );
|
"Global brightness and intensity applied to the sky and objects in the level." );
|
||||||
|
|
||||||
addField( "sunSize", TypeF32, Offset( mSunSize, ScatterSky ),
|
addField( "sunSize", TypeF32, Offset( mSunSize, ScatterSky ),
|
||||||
"Affects the size of the sun's disk." );
|
"Affects the size of the sun's disk." );
|
||||||
|
|
||||||
addField( "colorizeAmount", TypeF32, Offset( mColorizeAmt, ScatterSky ),
|
addField( "colorizeAmount", TypeF32, Offset( mColorizeAmt, ScatterSky ),
|
||||||
"Controls how much the the alpha component of colorize brigthens the sky. Setting to 0 returns default behavior." );
|
"Controls how much the the alpha component of colorize brigthens the sky. Setting to 0 returns default behavior." );
|
||||||
|
|
||||||
addField( "colorize", TypeColorF, Offset( mColorize, ScatterSky ),
|
addField( "colorize", TypeColorF, Offset( mColorize, ScatterSky ),
|
||||||
"Tints the sky the color specified, the alpha controls the brigthness. The brightness is multipled by the value of colorizeAmt." );
|
"Tints the sky the color specified, the alpha controls the brigthness. The brightness is multipled by the value of colorizeAmt." );
|
||||||
|
|
||||||
addField( "rayleighScattering", TypeF32, Offset( mRayleighScattering, ScatterSky ),
|
addField( "rayleighScattering", TypeF32, Offset( mRayleighScattering, ScatterSky ),
|
||||||
|
|
@ -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" );
|
||||||
|
|
@ -473,11 +477,13 @@ U32 ScatterSky::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
||||||
stream->write( mAmbientScale );
|
stream->write( mAmbientScale );
|
||||||
stream->write( mSunScale );
|
stream->write( mSunScale );
|
||||||
stream->write( mFogScale );
|
stream->write( mFogScale );
|
||||||
stream->write( mColorizeAmt );
|
stream->write( mColorizeAmt );
|
||||||
stream->write( mColorize );
|
stream->write( mColorize );
|
||||||
|
|
||||||
stream->write( mExposure );
|
stream->write( mExposure );
|
||||||
|
|
||||||
|
stream->write( mZOffset );
|
||||||
|
|
||||||
stream->write( mBrightness );
|
stream->write( mBrightness );
|
||||||
|
|
||||||
stream->writeFlag( mCastShadows );
|
stream->writeFlag( mCastShadows );
|
||||||
|
|
@ -556,7 +562,7 @@ void ScatterSky::unpackUpdate(NetConnection *con, BitStream *stream)
|
||||||
stream->read( &mAmbientScale );
|
stream->read( &mAmbientScale );
|
||||||
stream->read( &mSunScale );
|
stream->read( &mSunScale );
|
||||||
stream->read( &mFogScale );
|
stream->read( &mFogScale );
|
||||||
F32 colorizeAmt;
|
F32 colorizeAmt;
|
||||||
stream->read( &colorizeAmt );
|
stream->read( &colorizeAmt );
|
||||||
|
|
||||||
if(mColorizeAmt != colorizeAmt) {
|
if(mColorizeAmt != colorizeAmt) {
|
||||||
|
|
@ -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();
|
||||||
|
|
@ -706,7 +714,7 @@ bool ScatterSky::_initShader()
|
||||||
Con::warnf( "ScatterSky::_initShader - failed to locate ScatterSkySBData!" );
|
Con::warnf( "ScatterSky::_initShader - failed to locate ScatterSkySBData!" );
|
||||||
else
|
else
|
||||||
mStateBlock = GFX->createStateBlock( data->getState() );
|
mStateBlock = GFX->createStateBlock( data->getState() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !mStateBlock )
|
if ( !mStateBlock )
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -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();
|
||||||
|
|
@ -979,7 +987,7 @@ void ScatterSky::_render( ObjectRenderInst *ri, SceneRenderState *state, BaseMat
|
||||||
mShaderConsts->setSafe( mUseCubemapSC, 0.0f );
|
mShaderConsts->setSafe( mUseCubemapSC, 0.0f );
|
||||||
}
|
}
|
||||||
|
|
||||||
GFX->setPrimitiveBuffer( mPrimBuffer );
|
GFX->setPrimitiveBuffer( mPrimBuffer );
|
||||||
GFX->setVertexBuffer( mVB );
|
GFX->setVertexBuffer( mVB );
|
||||||
|
|
||||||
GFX->drawIndexedPrimitive( GFXTriangleList, 0, 0, mVertCount, 0, mPrimCount );
|
GFX->drawIndexedPrimitive( GFXTriangleList, 0, 0, mVertCount, 0, mPrimCount );
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,7 @@ protected:
|
||||||
|
|
||||||
F32 mExposure;
|
F32 mExposure;
|
||||||
F32 mNightInterpolant;
|
F32 mNightInterpolant;
|
||||||
|
F32 mZOffset;
|
||||||
|
|
||||||
VectorF mLightDir;
|
VectorF mLightDir;
|
||||||
VectorF mSunDir;
|
VectorF mSunDir;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue