mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
Merge branch 'GarageGames/master' into ueberengine-dev
Conflicts: Engine/source/T3D/fps/guiCrossHairHud.cpp
This commit is contained in:
commit
81750f3deb
2827 changed files with 315755 additions and 121398 deletions
1319
Engine/source/environment/VolumetricFog.cpp
Normal file
1319
Engine/source/environment/VolumetricFog.cpp
Normal file
File diff suppressed because it is too large
Load diff
243
Engine/source/environment/VolumetricFog.h
Normal file
243
Engine/source/environment/VolumetricFog.h
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _VolumetricFog_H_
|
||||
#define _VolumetricFog_H_
|
||||
|
||||
#ifndef _SCENEOBJECT_H_
|
||||
#include "scene/sceneObject.h"
|
||||
#endif
|
||||
#ifndef _MATTEXTURETARGET_H_
|
||||
#include "materials/matTextureTarget.h"
|
||||
#endif
|
||||
#ifndef _GFXSHADER_H_
|
||||
#include "gfx/gfxShader.h"
|
||||
#endif
|
||||
#ifndef _GFXTARGET_H_
|
||||
#include "gfx/gfxTarget.h"
|
||||
#endif
|
||||
#ifndef _GFXVERTEXBUFFER_H_
|
||||
#include "gfx/gfxVertexBuffer.h"
|
||||
#endif
|
||||
#ifndef _TSSHAPE_H_
|
||||
#include "ts/tsShape.h"
|
||||
#endif
|
||||
#ifndef _POST_EFFECT_H_
|
||||
#include "postFx/postEffect.h"
|
||||
#endif
|
||||
|
||||
#include "gui/core/guiCanvas.h"
|
||||
|
||||
class VolumetricFogRTManager;
|
||||
|
||||
class VolumetricFog : public SceneObject
|
||||
{
|
||||
typedef SceneObject Parent;
|
||||
|
||||
// Maskbits for updating
|
||||
enum
|
||||
{
|
||||
VolumetricFogMask = Parent::NextFreeMask,
|
||||
FogColorMask = Parent::NextFreeMask << 1,
|
||||
FogDensityMask = Parent::NextFreeMask << 2,
|
||||
FogModulationMask = Parent::NextFreeMask << 3,
|
||||
FogPostFXMask = Parent::NextFreeMask << 4,
|
||||
FogShapeMask = Parent::NextFreeMask << 5,
|
||||
NextFreeMask = Parent::NextFreeMask << 6
|
||||
};
|
||||
|
||||
// Struct which holds the shape details
|
||||
struct meshes
|
||||
{
|
||||
F32 det_size;
|
||||
S32 sub_shape;
|
||||
S32 obj_det;
|
||||
U32 num_verts;
|
||||
GFXVertexPNTT *verts;
|
||||
Vector <GFXPrimitive> *piArray;
|
||||
Vector <U32> *indices;
|
||||
};
|
||||
|
||||
protected:
|
||||
// Rendertargets;
|
||||
GFXTextureTargetRef z_buf;
|
||||
NamedTexTargetRef mPrepassTarget;
|
||||
NamedTexTargetRef mDepthBufferTarget;
|
||||
NamedTexTargetRef mFrontBufferTarget;
|
||||
|
||||
// Fog Modulation texture
|
||||
GFXTexHandle mTexture;
|
||||
|
||||
// Shaders
|
||||
GFXShaderRef mShader;
|
||||
GFXShaderRef mPrePassShader;
|
||||
GFXShaderRef mReflectionShader;
|
||||
|
||||
// Stateblocks
|
||||
GFXStateBlockDesc descD;
|
||||
GFXStateBlockDesc descF;
|
||||
GFXStateBlockDesc desc_preD;
|
||||
GFXStateBlockDesc desc_preF;
|
||||
GFXStateBlockDesc desc_refl;
|
||||
|
||||
GFXStateBlockRef mStateblockD;
|
||||
GFXStateBlockRef mStateblockF;
|
||||
GFXStateBlockRef mStateblock_preD;
|
||||
GFXStateBlockRef mStateblock_preF;
|
||||
GFXStateBlockRef mStateblock_refl;
|
||||
|
||||
// Shaderconstants
|
||||
GFXShaderConstBufferRef mShaderConsts;
|
||||
GFXShaderConstHandle *mModelViewProjSC;
|
||||
GFXShaderConstHandle *mFadeSizeSC;
|
||||
GFXShaderConstHandle *mFogColorSC;
|
||||
GFXShaderConstHandle *mFogDensitySC;
|
||||
GFXShaderConstHandle *mPreBias;
|
||||
GFXShaderConstHandle *mAccumTime;
|
||||
GFXShaderConstHandle *mIsTexturedSC;
|
||||
GFXShaderConstHandle *mModSpeedSC;
|
||||
GFXShaderConstHandle *mModStrengthSC;
|
||||
GFXShaderConstHandle *mViewPointSC;
|
||||
GFXShaderConstHandle *mTexScaleSC;
|
||||
GFXShaderConstHandle *mTexTilesSC;
|
||||
|
||||
GFXShaderConstBufferRef mPPShaderConsts;
|
||||
GFXShaderConstHandle *mPPModelViewProjSC;
|
||||
|
||||
GFXShaderConstHandle *mAmbientColorSC;
|
||||
|
||||
GFXShaderConstBufferRef mReflShaderConsts;
|
||||
GFXShaderConstHandle *mReflModelViewProjSC;
|
||||
GFXShaderConstHandle *mReflFogColorSC;
|
||||
GFXShaderConstHandle *mReflFogDensitySC;
|
||||
GFXShaderConstHandle *mReflFogStrengthSC;
|
||||
|
||||
// Vertex and Prim. Buffer
|
||||
GFXVertexBufferHandle<GFXVertexPNTT> mVB;
|
||||
GFXPrimitiveBufferHandle mPB;
|
||||
|
||||
// Fog volume data;
|
||||
StringTableEntry mShapeName;
|
||||
ColorI mFogColor;
|
||||
F32 mFogDensity;
|
||||
bool mIgnoreWater;
|
||||
bool mReflect;
|
||||
Vector<meshes> det_size;
|
||||
bool mShapeLoaded;
|
||||
F32 mPixelSize;
|
||||
F32 mFadeSize;
|
||||
U32 mCurDetailLevel;
|
||||
U32 mNumDetailLevels;
|
||||
F32 mObjSize;
|
||||
F32 mRadius;
|
||||
OrientedBox3F ColBox;
|
||||
VectorF mObjScale;
|
||||
F32 mMinDisplaySize;
|
||||
F32 mInvScale;
|
||||
|
||||
// Fog Modulation data
|
||||
String mTextureName;
|
||||
bool mIsTextured;
|
||||
F32 mTexTiles;
|
||||
F32 mStrength;
|
||||
Point2F mSpeed1;
|
||||
Point2F mSpeed2;
|
||||
Point4F mSpeed;
|
||||
Point2F mTexScale;
|
||||
|
||||
// Fog Rendering data
|
||||
Point3F camPos;
|
||||
Point2F mViewPoint;
|
||||
F32 mFOV;
|
||||
F32 viewDist;
|
||||
bool mIsVBDirty;
|
||||
bool mIsPBDirty;
|
||||
bool mCamInFog;
|
||||
bool mResizing;
|
||||
PlatformWindow *mPlatformWindow;
|
||||
|
||||
// Reflections
|
||||
F32 mFogReflStrength;
|
||||
|
||||
// PostFX
|
||||
PostEffect *glowFX;
|
||||
bool mUseGlow;
|
||||
F32 mGlowStrength;
|
||||
U8 mGlowing;
|
||||
F32 mCurGlow;
|
||||
|
||||
bool mModifLightRays;
|
||||
F32 mLightRayMod;
|
||||
F32 mOldLightRayStrength;
|
||||
|
||||
GameConnection* conn;
|
||||
U32 mCounter;
|
||||
|
||||
void ResizeRT(PlatformWindow *win, bool resize);
|
||||
|
||||
protected:
|
||||
// Protected methods
|
||||
bool onAdd();
|
||||
void onRemove();
|
||||
void handleResize(VolumetricFogRTManager *RTM, bool resize);
|
||||
void handleCanvasResize(GuiCanvas* canvas);
|
||||
|
||||
bool LoadShape();
|
||||
bool setupRenderer();
|
||||
void InitTexture();
|
||||
bool UpdateBuffers(U32 dl,bool force=true);
|
||||
|
||||
void processTick(const Move *move);
|
||||
void _enterFog(ShapeBase *control);
|
||||
void _leaveFog(ShapeBase *control);
|
||||
|
||||
public:
|
||||
// Public methods
|
||||
VolumetricFog();
|
||||
~VolumetricFog();
|
||||
|
||||
static void initPersistFields();
|
||||
virtual void inspectPostApply();
|
||||
|
||||
U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
|
||||
void unpackUpdate(NetConnection *conn, BitStream *stream);
|
||||
|
||||
void prepRenderImage(SceneRenderState* state);
|
||||
void render(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat);
|
||||
void reflect_render(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat);
|
||||
|
||||
// Methods for modifying & networking various fog elements
|
||||
// Used in script
|
||||
void setFogColor(ColorF color);
|
||||
void setFogColor(ColorI color);
|
||||
void setFogDensity(F32 density);
|
||||
void setFogModulation(F32 strength, Point2F speed1, Point2F speed2);
|
||||
void setFogGlow(bool on_off, F32 strength);
|
||||
void setFogLightray(bool on_off, F32 strength);
|
||||
bool isInsideFog();
|
||||
|
||||
DECLARE_CONOBJECT(VolumetricFog);
|
||||
|
||||
DECLARE_CALLBACK(void, onEnterFog, (SimObjectId obj));
|
||||
DECLARE_CALLBACK(void, onLeaveFog, (SimObjectId obj));
|
||||
};
|
||||
#endif
|
||||
293
Engine/source/environment/VolumetricFogRTManager.cpp
Normal file
293
Engine/source/environment/VolumetricFogRTManager.cpp
Normal file
|
|
@ -0,0 +1,293 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Volumetric Fog Rendertarget Manager
|
||||
//
|
||||
// Creates and maintains one set of rendertargets to be used by every
|
||||
// VolumetricFog object in the scene.
|
||||
//
|
||||
// Will be loaded at startup end removed when ending game.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "VolumetricFogRTManager.h"
|
||||
#include "core/module.h"
|
||||
#include "scene/sceneManager.h"
|
||||
#include "windowManager/platformWindowMgr.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "gui/core/guiCanvas.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
|
||||
MODULE_BEGIN(VolumetricFogRTManager)
|
||||
|
||||
MODULE_INIT_AFTER(Scene)
|
||||
MODULE_SHUTDOWN_BEFORE(Scene)
|
||||
|
||||
MODULE_INIT
|
||||
{
|
||||
gVolumetricFogRTManager = new VolumetricFogRTManager;
|
||||
gClientSceneGraph->addObjectToScene(gVolumetricFogRTManager);
|
||||
}
|
||||
|
||||
MODULE_SHUTDOWN
|
||||
{
|
||||
gClientSceneGraph->removeObjectFromScene(gVolumetricFogRTManager);
|
||||
SAFE_DELETE(gVolumetricFogRTManager);
|
||||
}
|
||||
|
||||
MODULE_END;
|
||||
|
||||
ConsoleDocClass( VolumetricFogRTManager,
|
||||
"@brief Creates and maintains one set of rendertargets to be used by every\n"
|
||||
"VolumetricFog object in the scene.\n\n"
|
||||
"Will be loaded at startup end removed when ending game.\n\n"
|
||||
"Methods:\n"
|
||||
" get() returns the currently loaded VolumetricFogRTManager, also accessible\n"
|
||||
" through VFRTM define.\n"
|
||||
" Init() Initializes the rendertargets, called when a VolumetricFog object is\n"
|
||||
" added to the scene.\n"
|
||||
" isInitialed() returns true if Rendertargets are present, false if not, then\n"
|
||||
" Init() should be called to create the rendertargets.\n"
|
||||
" setQuality(U32 Quality) Normally a rendertarget has the same size as the view,\n"
|
||||
" with this method you can scale down the size of it.\n"
|
||||
" Be aware that scaling down will introduce renderartefacts.\n"
|
||||
"@ingroup Atmosphere"
|
||||
);
|
||||
|
||||
VolumetricFogRTMResizeSignal VolumetricFogRTManager::smVolumetricFogRTMResizeSignal;
|
||||
|
||||
VolumetricFogRTManager *gVolumetricFogRTManager = NULL;
|
||||
|
||||
S32 VolumetricFogRTManager::mTargetScale = 1;
|
||||
|
||||
IMPLEMENT_CONOBJECT(VolumetricFogRTManager);
|
||||
|
||||
VolumetricFogRTManager::VolumetricFogRTManager()
|
||||
{
|
||||
setGlobalBounds();
|
||||
mTypeMask |= EnvironmentObjectType;
|
||||
mNetFlags.set(IsGhost);
|
||||
mIsInitialized = false;
|
||||
mNumFogObjects = 0;
|
||||
}
|
||||
|
||||
VolumetricFogRTManager::~VolumetricFogRTManager()
|
||||
{
|
||||
if (mFrontTarget.isRegistered())
|
||||
mFrontTarget.unregister();
|
||||
|
||||
if (mDepthTarget.isRegistered())
|
||||
mDepthTarget.unregister();
|
||||
|
||||
if (mDepthBuffer.isValid())
|
||||
mDepthBuffer->kill();
|
||||
|
||||
if (mFrontBuffer.isValid())
|
||||
mFrontBuffer->kill();
|
||||
}
|
||||
|
||||
void VolumetricFogRTManager::onSceneRemove()
|
||||
{
|
||||
if (mIsInitialized)
|
||||
mPlatformWindow->getScreenResChangeSignal().remove(this, &VolumetricFogRTManager::ResizeRT);
|
||||
}
|
||||
|
||||
void VolumetricFogRTManager::onRemove()
|
||||
{
|
||||
removeFromScene();
|
||||
Parent::onRemove();
|
||||
}
|
||||
|
||||
void VolumetricFogRTManager::consoleInit()
|
||||
{
|
||||
Con::addVariable("$pref::VolumetricFog::Quality", TypeS32, &mTargetScale,
|
||||
"The scale of the rendertargets.\n"
|
||||
"@ingroup Rendering\n");
|
||||
}
|
||||
|
||||
bool VolumetricFogRTManager::Init()
|
||||
{
|
||||
if (mIsInitialized)
|
||||
{
|
||||
Con::errorf("VolumetricFogRTManager allready initialized!!");
|
||||
return true;
|
||||
}
|
||||
|
||||
GuiCanvas* cv = dynamic_cast<GuiCanvas*>(Sim::findObject("Canvas"));
|
||||
if (cv == NULL)
|
||||
{
|
||||
Con::errorf("VolumetricFogRTManager::Init() - Canvas not found!!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mPlatformWindow = cv->getPlatformWindow();
|
||||
mPlatformWindow->getScreenResChangeSignal().notify(this,&VolumetricFogRTManager::ResizeRT);
|
||||
|
||||
if (mTargetScale < 1 || GFX->getAdapterType() == Direct3D11)
|
||||
mTargetScale = 1;
|
||||
|
||||
mWidth = mFloor(mPlatformWindow->getClientExtent().x / mTargetScale);
|
||||
mHeight = mFloor(mPlatformWindow->getClientExtent().y / mTargetScale);
|
||||
|
||||
mDepthBuffer = GFXTexHandle(mWidth, mHeight, GFXFormatR32F,
|
||||
&GFXDefaultRenderTargetProfile, avar("%s() - mDepthBuffer (line %d)", __FUNCTION__, __LINE__));
|
||||
if (!mDepthBuffer.isValid())
|
||||
{
|
||||
Con::errorf("VolumetricFogRTManager Fatal Error: Unable to create Depthbuffer");
|
||||
return false;
|
||||
}
|
||||
if (!mDepthTarget.registerWithName("volfogdepth"))
|
||||
{
|
||||
Con::errorf("VolumetricFogRTManager Fatal Error : Unable to register Depthbuffer");
|
||||
return false;
|
||||
}
|
||||
mDepthTarget.setTexture(mDepthBuffer);
|
||||
|
||||
mFrontBuffer = GFXTexHandle(mWidth, mHeight, GFXFormatR32F,
|
||||
&GFXDefaultRenderTargetProfile, avar("%s() - mFrontBuffer (line %d)", __FUNCTION__, __LINE__));
|
||||
if (!mFrontBuffer.isValid())
|
||||
{
|
||||
Con::errorf("VolumetricFogRTManager Fatal Error: Unable to create front buffer");
|
||||
return false;
|
||||
}
|
||||
if (!mFrontTarget.registerWithName("volfogfront"))
|
||||
{
|
||||
Con::errorf("VolumetricFogRTManager Fatal Error : Unable to register Frontbuffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
mFrontTarget.setTexture(mFrontBuffer);
|
||||
|
||||
Con::setVariable("$VolumetricFog::density", "0.0");
|
||||
|
||||
mIsInitialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
U32 VolumetricFogRTManager::IncFogObjects()
|
||||
{
|
||||
mNumFogObjects++;
|
||||
return mNumFogObjects;
|
||||
}
|
||||
|
||||
U32 VolumetricFogRTManager::DecFogObjects()
|
||||
{
|
||||
if (mNumFogObjects > 0)
|
||||
mNumFogObjects--;
|
||||
return mNumFogObjects;
|
||||
}
|
||||
|
||||
void VolumetricFogRTManager::ResizeRT(PlatformWindow* win,bool resize)
|
||||
{
|
||||
mFogHasAnswered = 0;
|
||||
smVolumetricFogRTMResizeSignal.trigger(this, true);
|
||||
}
|
||||
|
||||
void VolumetricFogRTManager::FogAnswered()
|
||||
{
|
||||
mFogHasAnswered++;
|
||||
if (mFogHasAnswered == mNumFogObjects)
|
||||
{
|
||||
if (Resize())
|
||||
smVolumetricFogRTMResizeSignal.trigger(this, false);
|
||||
else
|
||||
Con::errorf("VolumetricFogRTManager::FogAnswered - Error resizing rendertargets!");
|
||||
}
|
||||
}
|
||||
|
||||
bool VolumetricFogRTManager::Resize()
|
||||
{
|
||||
if (mTargetScale < 1 || GFX->getAdapterType() == Direct3D11)
|
||||
mTargetScale = 1;
|
||||
|
||||
mWidth = mFloor(mPlatformWindow->getClientExtent().x / mTargetScale);
|
||||
mHeight = mFloor(mPlatformWindow->getClientExtent().y / mTargetScale);
|
||||
|
||||
if (mWidth < 16 || mHeight < 16)
|
||||
return false;
|
||||
|
||||
if (mFrontTarget.isRegistered())
|
||||
mFrontTarget.setTexture(NULL);
|
||||
|
||||
if (mDepthTarget.isRegistered())
|
||||
mDepthTarget.setTexture(NULL);
|
||||
|
||||
if (mDepthBuffer.isValid())
|
||||
mDepthBuffer->kill();
|
||||
|
||||
if (mFrontBuffer.isValid())
|
||||
mFrontBuffer->kill();
|
||||
|
||||
mFrontBuffer = GFXTexHandle(mWidth, mHeight, GFXFormatR32F,
|
||||
&GFXDefaultRenderTargetProfile, avar("%s() - mFrontBuffer (line %d)", __FUNCTION__, __LINE__));
|
||||
if (!mFrontBuffer.isValid())
|
||||
{
|
||||
Con::errorf("VolumetricFogRTManager::Resize() Fatal Error: Unable to create front buffer");
|
||||
return false;
|
||||
}
|
||||
mFrontTarget.setTexture(mFrontBuffer);
|
||||
|
||||
mDepthBuffer = GFXTexHandle(mWidth, mHeight, GFXFormatR32F,
|
||||
&GFXDefaultRenderTargetProfile, avar("%s() - mDepthBuffer (line %d)", __FUNCTION__, __LINE__));
|
||||
if (!mDepthBuffer.isValid())
|
||||
{
|
||||
Con::errorf("VolumetricFogRTManager::Resize() Fatal Error: Unable to create Depthbuffer");
|
||||
return false;
|
||||
}
|
||||
mDepthTarget.setTexture(mDepthBuffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
S32 VolumetricFogRTManager::setQuality(U32 Quality)
|
||||
{
|
||||
if (!mIsInitialized)
|
||||
return (mTargetScale = Quality);
|
||||
|
||||
if (Quality < 1)
|
||||
Quality = 1;
|
||||
|
||||
if (Quality == mTargetScale)
|
||||
return mTargetScale;
|
||||
|
||||
mTargetScale = Quality;
|
||||
|
||||
mFogHasAnswered = 0;
|
||||
smVolumetricFogRTMResizeSignal.trigger(this, true);
|
||||
|
||||
return mTargetScale;
|
||||
}
|
||||
|
||||
VolumetricFogRTManager* VolumetricFogRTManager::get()
|
||||
{
|
||||
return gVolumetricFogRTManager;
|
||||
}
|
||||
|
||||
DefineConsoleFunction(SetFogVolumeQuality, S32, (U32 new_quality), ,
|
||||
"@brief Resizes the rendertargets of the Volumetric Fog object.\n"
|
||||
"@params new_quality new quality for the rendertargets 1 = full size, 2 = halfsize, 3 = 1/3, 4 = 1/4 ...")
|
||||
{
|
||||
if (VFRTM == NULL)
|
||||
return -1;
|
||||
return VFRTM->setQuality(new_quality);
|
||||
}
|
||||
91
Engine/source/environment/VolumetricFogRTManager.h
Normal file
91
Engine/source/environment/VolumetricFogRTManager.h
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _VolumetricFogRTManager_H_
|
||||
#define _VolumetricFogRTManager_H_
|
||||
|
||||
#ifndef _SCENEOBJECT_H_
|
||||
#include "scene/sceneObject.h"
|
||||
#endif
|
||||
#ifndef _MATTEXTURETARGET_H_
|
||||
#include "materials/matTextureTarget.h"
|
||||
#endif
|
||||
#ifndef _GFXTARGET_H_
|
||||
#include "gfx/gfxTarget.h"
|
||||
#endif
|
||||
#ifndef _SIGNAL_H_
|
||||
#include "core/util/tSignal.h"
|
||||
#endif
|
||||
|
||||
class VolumetricFogRTManager;
|
||||
|
||||
typedef Signal<void(VolumetricFogRTManager *VolumetricFogRTManager, bool resize)> VolumetricFogRTMResizeSignal;
|
||||
|
||||
#define VFRTM VolumetricFogRTManager::get()
|
||||
|
||||
class VolumetricFogRTManager : public SceneObject
|
||||
{
|
||||
public:
|
||||
typedef SceneObject Parent;
|
||||
|
||||
protected:
|
||||
GFXTexHandle mDepthBuffer;
|
||||
GFXTexHandle mFrontBuffer;
|
||||
|
||||
NamedTexTarget mDepthTarget;
|
||||
NamedTexTarget mFrontTarget;
|
||||
|
||||
PlatformWindow* mPlatformWindow;
|
||||
|
||||
static S32 mTargetScale;
|
||||
bool mIsInitialized;
|
||||
U32 mNumFogObjects;
|
||||
U32 mFogHasAnswered;
|
||||
U32 mWidth;
|
||||
U32 mHeight;
|
||||
|
||||
void onRemove();
|
||||
void onSceneRemove();
|
||||
void ResizeRT(PlatformWindow *win, bool resize);
|
||||
|
||||
static VolumetricFogRTMResizeSignal smVolumetricFogRTMResizeSignal;
|
||||
|
||||
public:
|
||||
VolumetricFogRTManager();
|
||||
~VolumetricFogRTManager();
|
||||
static VolumetricFogRTManager *get();
|
||||
bool Init();
|
||||
bool IsInitialized() { return mIsInitialized; }
|
||||
static void consoleInit();
|
||||
static VolumetricFogRTMResizeSignal& getVolumetricFogRTMResizeSignal() { return smVolumetricFogRTMResizeSignal; }
|
||||
void FogAnswered();
|
||||
S32 setQuality(U32 Quality);
|
||||
bool Resize();
|
||||
U32 IncFogObjects();
|
||||
U32 DecFogObjects();
|
||||
|
||||
DECLARE_CONOBJECT(VolumetricFogRTManager);
|
||||
};
|
||||
|
||||
extern VolumetricFogRTManager* gVolumetricFogRTManager;
|
||||
|
||||
#endif
|
||||
|
|
@ -141,7 +141,7 @@ bool BasicClouds::onAdd()
|
|||
GFXStateBlockDesc desc;
|
||||
desc.setCullMode( GFXCullNone );
|
||||
desc.setBlend( true );
|
||||
desc.setZReadWrite( false, false );
|
||||
desc.setZReadWrite( true, false );
|
||||
desc.samplersDefined = true;
|
||||
desc.samplers[0].addressModeU = GFXAddressWrap;
|
||||
desc.samplers[0].addressModeV = GFXAddressWrap;
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ bool CloudLayer::onAdd()
|
|||
GFXStateBlockDesc desc;
|
||||
desc.setCullMode( GFXCullNone );
|
||||
desc.setBlend( true );
|
||||
desc.setZReadWrite( false, false );
|
||||
desc.setZReadWrite( true, false );
|
||||
desc.samplersDefined = true;
|
||||
desc.samplers[0].addressModeU = GFXAddressWrap;
|
||||
desc.samplers[0].addressModeV = GFXAddressWrap;
|
||||
|
|
|
|||
|
|
@ -732,7 +732,7 @@ void DecalRoad::prepRenderImage( SceneRenderState* state )
|
|||
MathUtils::getZBiasProjectionMatrix( gDecalBias, frustum, tempMat );
|
||||
coreRI.projection = tempMat;
|
||||
|
||||
coreRI.type = RenderPassManager::RIT_Decal;
|
||||
coreRI.type = RenderPassManager::RIT_DecalRoad;
|
||||
coreRI.vertBuff = &mVB;
|
||||
coreRI.primBuff = &mPB;
|
||||
coreRI.matInst = matInst;
|
||||
|
|
|
|||
|
|
@ -1248,7 +1248,7 @@ DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodeNormal, void, (Point3F normal
|
|||
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, setSelectedRoad, void, (const char * objName), (""), "" )
|
||||
{
|
||||
if ( dStrIsEmpty(objName) )
|
||||
if ( String::isEmpty(objName) )
|
||||
object->setSelectedRoad(NULL);
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1552,7 +1552,7 @@ bool MeshRoad::castRay( const Point3F &s, const Point3F &e, RayInfo *info )
|
|||
info->point.interpolate(start, end, out);
|
||||
info->face = -1;
|
||||
info->object = this;
|
||||
|
||||
info->material = this->mMatInst[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,13 +81,6 @@ const F32 ScatterSky::smEarthRadius = (6378.0f * 1000.0f);
|
|||
const F32 ScatterSky::smAtmosphereRadius = 200000.0f;
|
||||
const F32 ScatterSky::smViewerHeight = 1.0f;
|
||||
|
||||
GFXImplementVertexFormat( ScatterSkyVertex )
|
||||
{
|
||||
addElement( "POSITION", GFXDeclType_Float3 );
|
||||
addElement( "NORMAL", GFXDeclType_Float3 );
|
||||
addElement( "COLOR", GFXDeclType_Color );
|
||||
}
|
||||
|
||||
ScatterSky::ScatterSky()
|
||||
{
|
||||
mPrimCount = 0;
|
||||
|
|
@ -150,6 +143,8 @@ ScatterSky::ScatterSky()
|
|||
mBrightness = 1.0f;
|
||||
|
||||
mCastShadows = true;
|
||||
mStaticRefreshFreq = 8;
|
||||
mDynamicRefreshFreq = 8;
|
||||
mDirty = true;
|
||||
|
||||
mLight = LightManager::createLightInfo();
|
||||
|
|
@ -270,6 +265,8 @@ void ScatterSky::_conformLights()
|
|||
mLight->setAmbient( mAmbientColor );
|
||||
mLight->setColor( mSunColor );
|
||||
mLight->setCastShadows( mCastShadows );
|
||||
mLight->setStaticRefreshFreq(mStaticRefreshFreq);
|
||||
mLight->setDynamicRefreshFreq(mDynamicRefreshFreq);
|
||||
|
||||
FogData fog = getSceneManager()->getFogData();
|
||||
fog.color = mFogColor;
|
||||
|
|
@ -380,6 +377,9 @@ void ScatterSky::initPersistFields()
|
|||
addField( "castShadows", TypeBool, Offset( mCastShadows, ScatterSky ),
|
||||
"Enables/disables shadows cast by objects due to ScatterSky light." );
|
||||
|
||||
addField("staticRefreshFreq", TypeS32, Offset(mStaticRefreshFreq, ScatterSky), "static shadow refresh rate (milliseconds)");
|
||||
addField("dynamicRefreshFreq", TypeS32, Offset(mDynamicRefreshFreq, ScatterSky), "dynamic shadow refresh rate (milliseconds)");
|
||||
|
||||
addField( "brightness", TypeF32, Offset( mBrightness, ScatterSky ),
|
||||
"The brightness of the ScatterSky's light object." );
|
||||
|
||||
|
|
@ -486,6 +486,8 @@ U32 ScatterSky::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
|||
stream->write( mBrightness );
|
||||
|
||||
stream->writeFlag( mCastShadows );
|
||||
stream->write(mStaticRefreshFreq);
|
||||
stream->write(mDynamicRefreshFreq);
|
||||
|
||||
stream->write( mFlareScale );
|
||||
|
||||
|
|
@ -587,6 +589,8 @@ void ScatterSky::unpackUpdate(NetConnection *con, BitStream *stream)
|
|||
stream->read( &mBrightness );
|
||||
|
||||
mCastShadows = stream->readFlag();
|
||||
stream->read(&mStaticRefreshFreq);
|
||||
stream->read(&mDynamicRefreshFreq);
|
||||
|
||||
stream->read( &mFlareScale );
|
||||
|
||||
|
|
@ -760,7 +764,7 @@ void ScatterSky::_initVBIB()
|
|||
F32 zOffset = -( mCos( mSqrt( 1.0f ) ) + 0.01f );
|
||||
|
||||
mVB.set( GFX, mVertCount, GFXBufferTypeStatic );
|
||||
ScatterSkyVertex *pVert = mVB.lock();
|
||||
GFXVertexP *pVert = mVB.lock();
|
||||
if(!pVert) return;
|
||||
|
||||
for ( U32 y = 0; y < vertStride; y++ )
|
||||
|
|
@ -950,12 +954,21 @@ void ScatterSky::_render( ObjectRenderInst *ri, SceneRenderState *state, BaseMat
|
|||
|
||||
Point3F camPos2 = state->getCameraPosition();
|
||||
MatrixF xfm(true);
|
||||
xfm.setPosition(camPos2 - Point3F( 0, 0, mZOffset));
|
||||
|
||||
GFX->multWorld(xfm);
|
||||
MatrixF xform(proj);//GFX->getProjectionMatrix());
|
||||
xform *= GFX->getViewMatrix();
|
||||
xform *= GFX->getWorldMatrix();
|
||||
|
||||
if(state->isReflectPass())
|
||||
{
|
||||
static MatrixF rotMat(EulerF(0.0, 0.0, M_PI_F));
|
||||
xform.mul(rotMat);
|
||||
rotMat.set(EulerF(M_PI_F, 0.0, 0.0));
|
||||
xform.mul(rotMat);
|
||||
}
|
||||
xform.setPosition(xform.getPosition() - Point3F(0, 0, mZOffset));
|
||||
|
||||
mShaderConsts->setSafe( mModelViewProjSC, xform );
|
||||
mShaderConsts->setSafe( mMiscSC, miscParams );
|
||||
mShaderConsts->setSafe( mSphereRadiiSC, sphereRadii );
|
||||
|
|
@ -1053,17 +1066,17 @@ void ScatterSky::_renderMoon( ObjectRenderInst *ri, SceneRenderState *state, Bas
|
|||
|
||||
// Initialize points with basic info
|
||||
Point3F points[4];
|
||||
points[0] = Point3F(-BBRadius, 0.0, -BBRadius);
|
||||
points[0] = Point3F( -BBRadius, 0.0, -BBRadius);
|
||||
points[1] = Point3F( -BBRadius, 0.0, BBRadius);
|
||||
points[2] = Point3F( BBRadius, 0.0, BBRadius);
|
||||
points[3] = Point3F( BBRadius, 0.0, -BBRadius);
|
||||
points[2] = Point3F( BBRadius, 0.0, -BBRadius);
|
||||
points[3] = Point3F( BBRadius, 0.0, BBRadius);
|
||||
|
||||
static const Point2F sCoords[4] =
|
||||
{
|
||||
Point2F( 0.0f, 0.0f ),
|
||||
Point2F( 0.0f, 1.0f ),
|
||||
Point2F( 1.0f, 1.0f ),
|
||||
Point2F( 1.0f, 0.0f )
|
||||
Point2F( 1.0f, 0.0f ),
|
||||
Point2F( 1.0f, 1.0f )
|
||||
};
|
||||
|
||||
// Get info we need to adjust points
|
||||
|
|
@ -1112,7 +1125,7 @@ void ScatterSky::_renderMoon( ObjectRenderInst *ri, SceneRenderState *state, Bas
|
|||
mMoonMatInst->setSceneInfo( state, sgData );
|
||||
|
||||
GFX->setVertexBuffer( vb );
|
||||
GFX->drawPrimitive( GFXTriangleFan, 0, 2 );
|
||||
GFX->drawPrimitive( GFXTriangleStrip, 0, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1437,4 +1450,4 @@ DefineEngineMethod( ScatterSky, applyChanges, void, (),,
|
|||
)
|
||||
{
|
||||
object->inspectPostApply();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,14 +57,6 @@ class TimeOfDay;
|
|||
class CubemapData;
|
||||
class MatrixSet;
|
||||
|
||||
|
||||
GFXDeclareVertexFormat( ScatterSkyVertex )
|
||||
{
|
||||
Point3F point;
|
||||
VectorF normal;
|
||||
GFXVertexColor color;
|
||||
};
|
||||
|
||||
class ScatterSky : public SceneObject, public ISceneLight
|
||||
{
|
||||
typedef SceneObject Parent;
|
||||
|
|
@ -207,6 +199,8 @@ protected:
|
|||
LightInfo *mLight;
|
||||
|
||||
bool mCastShadows;
|
||||
S32 mStaticRefreshFreq;
|
||||
S32 mDynamicRefreshFreq;
|
||||
bool mDirty;
|
||||
|
||||
LightFlareData *mFlareData;
|
||||
|
|
@ -228,7 +222,7 @@ protected:
|
|||
|
||||
// Prim buffer, vertex buffer and shader for rendering.
|
||||
GFXPrimitiveBufferHandle mPrimBuffer;
|
||||
GFXVertexBufferHandle<ScatterSkyVertex> mVB;
|
||||
GFXVertexBufferHandle<GFXVertexP> mVB;
|
||||
GFXShaderRef mShader;
|
||||
|
||||
GFXStateBlockRef mStateBlock;
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ void SkyBox::_renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseM
|
|||
|
||||
void SkyBox::_initRender()
|
||||
{
|
||||
GFXVertexPNTT *tmpVerts = NULL;
|
||||
GFXVertexPNT *tmpVerts = NULL;
|
||||
|
||||
U32 vertCount = 36;
|
||||
|
||||
|
|
@ -264,7 +264,7 @@ void SkyBox::_initRender()
|
|||
// Create temp vertex pointer
|
||||
// so we can read from it
|
||||
// for generating the normals below.
|
||||
tmpVerts = new GFXVertexPNTT[vertCount];
|
||||
tmpVerts = new GFXVertexPNT[vertCount];
|
||||
|
||||
// We don't bother sharing
|
||||
// vertices here, in order to
|
||||
|
|
@ -400,14 +400,14 @@ void SkyBox::_initRender()
|
|||
mIsVBDirty = false;
|
||||
}
|
||||
|
||||
GFXVertexPNTT *vertPtr = mVB.lock();
|
||||
GFXVertexPNT *vertPtr = mVB.lock();
|
||||
if (!vertPtr)
|
||||
{
|
||||
delete[] tmpVerts;
|
||||
return;
|
||||
}
|
||||
|
||||
dMemcpy( vertPtr, tmpVerts, sizeof ( GFXVertexPNTT ) * vertCount );
|
||||
dMemcpy(vertPtr, tmpVerts, sizeof( GFXVertexPNT) * vertCount);
|
||||
|
||||
mVB.unlock();
|
||||
|
||||
|
|
@ -599,7 +599,8 @@ void SkyBox::_initMaterial()
|
|||
|
||||
// We want to disable culling and z write.
|
||||
GFXStateBlockDesc desc;
|
||||
desc.setCullMode( GFXCullCW );
|
||||
desc.setCullMode( GFXCullNone );
|
||||
desc.setBlend( true );
|
||||
desc.setZReadWrite( true, false );
|
||||
mMatInstance->addStateBlockDesc( desc );
|
||||
|
||||
|
|
@ -607,9 +608,10 @@ void SkyBox::_initMaterial()
|
|||
FeatureSet features = MATMGR->getDefaultFeatures();
|
||||
features.removeFeature( MFT_RTLighting );
|
||||
features.removeFeature( MFT_Visibility );
|
||||
features.addFeature(MFT_SkyBox);
|
||||
|
||||
// Now initialize the material.
|
||||
mMatInstance->init( features, getGFXVertexFormat<GFXVertexPNTT>() );
|
||||
mMatInstance->init(features, getGFXVertexFormat<GFXVertexPNT>());
|
||||
}
|
||||
|
||||
void SkyBox::_updateMaterial()
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ protected:
|
|||
|
||||
SimObjectPtr<Material> mMaterial;
|
||||
|
||||
GFXVertexBufferHandle<GFXVertexPNTT> mVB;
|
||||
GFXVertexBufferHandle<GFXVertexPNT> mVB;
|
||||
|
||||
GFXVertexBufferHandle<GFXVertexPC> mFogBandVB;
|
||||
Material *mFogBandMat;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ Sun::Sun()
|
|||
mSunAzimuth = 0.0f;
|
||||
mSunElevation = 35.0f;
|
||||
mCastShadows = true;
|
||||
mStaticRefreshFreq = 250;
|
||||
mDynamicRefreshFreq = 8;
|
||||
|
||||
mAnimateSun = false;
|
||||
mTotalTime = 0.0f;
|
||||
|
|
@ -163,7 +165,10 @@ void Sun::initPersistFields()
|
|||
"Adjust the Sun's global contrast/intensity");
|
||||
|
||||
addField( "castShadows", TypeBool, Offset( mCastShadows, Sun ),
|
||||
"Enables/disables shadows cast by objects due to Sun light");
|
||||
"Enables/disables shadows cast by objects due to Sun light");
|
||||
|
||||
addField("staticRefreshFreq", TypeS32, Offset(mStaticRefreshFreq, Sun), "static shadow refresh rate (milliseconds)");
|
||||
addField("dynamicRefreshFreq", TypeS32, Offset(mDynamicRefreshFreq, Sun), "dynamic shadow refresh rate (milliseconds)");
|
||||
|
||||
endGroup( "Lighting" );
|
||||
|
||||
|
|
@ -220,7 +225,9 @@ U32 Sun::packUpdate(NetConnection *conn, U32 mask, BitStream *stream )
|
|||
stream->write( mLightColor );
|
||||
stream->write( mLightAmbient );
|
||||
stream->write( mBrightness );
|
||||
stream->writeFlag( mCastShadows );
|
||||
stream->writeFlag( mCastShadows );
|
||||
stream->write(mStaticRefreshFreq);
|
||||
stream->write(mDynamicRefreshFreq);
|
||||
stream->write( mFlareScale );
|
||||
|
||||
if ( stream->writeFlag( mFlareData ) )
|
||||
|
|
@ -254,6 +261,8 @@ void Sun::unpackUpdate( NetConnection *conn, BitStream *stream )
|
|||
stream->read( &mLightAmbient );
|
||||
stream->read( &mBrightness );
|
||||
mCastShadows = stream->readFlag();
|
||||
stream->read(&mStaticRefreshFreq);
|
||||
stream->read(&mDynamicRefreshFreq);
|
||||
stream->read( &mFlareScale );
|
||||
|
||||
if ( stream->readFlag() )
|
||||
|
|
@ -426,6 +435,8 @@ void Sun::_conformLights()
|
|||
// directional color are the same.
|
||||
bool castShadows = mLightColor != mLightAmbient && mCastShadows;
|
||||
mLight->setCastShadows( castShadows );
|
||||
mLight->setStaticRefreshFreq(mStaticRefreshFreq);
|
||||
mLight->setDynamicRefreshFreq(mDynamicRefreshFreq);
|
||||
}
|
||||
|
||||
void Sun::_initCorona()
|
||||
|
|
@ -456,15 +467,15 @@ void Sun::_renderCorona( ObjectRenderInst *ri, SceneRenderState *state, BaseMatI
|
|||
Point3F points[4];
|
||||
points[0] = Point3F(-BBRadius, 0.0, -BBRadius);
|
||||
points[1] = Point3F( -BBRadius, 0.0, BBRadius);
|
||||
points[2] = Point3F( BBRadius, 0.0, BBRadius);
|
||||
points[3] = Point3F( BBRadius, 0.0, -BBRadius);
|
||||
points[2] = Point3F( BBRadius, 0.0, -BBRadius);
|
||||
points[3] = Point3F(BBRadius, 0.0, BBRadius);
|
||||
|
||||
static const Point2F sCoords[4] =
|
||||
{
|
||||
Point2F( 0.0f, 0.0f ),
|
||||
Point2F( 0.0f, 1.0f ),
|
||||
Point2F( 1.0f, 1.0f ),
|
||||
Point2F( 1.0f, 0.0f )
|
||||
Point2F( 1.0f, 0.0f ),
|
||||
Point2F(1.0f, 1.0f)
|
||||
};
|
||||
|
||||
// Get info we need to adjust points
|
||||
|
|
@ -514,7 +525,7 @@ void Sun::_renderCorona( ObjectRenderInst *ri, SceneRenderState *state, BaseMatI
|
|||
mCoronaMatInst->setSceneInfo( state, sgData );
|
||||
|
||||
GFX->setVertexBuffer( vb );
|
||||
GFX->drawPrimitive( GFXTriangleFan, 0, 2 );
|
||||
GFX->drawPrimitive( GFXTriangleStrip, 0, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ protected:
|
|||
F32 mEndElevation;
|
||||
|
||||
bool mCastShadows;
|
||||
S32 mStaticRefreshFreq;
|
||||
S32 mDynamicRefreshFreq;
|
||||
|
||||
LightInfo *mLight;
|
||||
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ void TimeOfDay::_getSunColor( ColorF *outColor ) const
|
|||
//simple check
|
||||
if ( mColorTargets[0].elevation != 0.0f )
|
||||
{
|
||||
AssertFatal(0, "TimeOfDay::GetColor() - First elevation must be 0.0 radians")
|
||||
AssertFatal(0, "TimeOfDay::GetColor() - First elevation must be 0.0 radians");
|
||||
outColor->set(1.0f, 1.0f, 1.0f);
|
||||
//mBandMod = 1.0f;
|
||||
//mCurrentBandColor = color;
|
||||
|
|
@ -411,7 +411,7 @@ void TimeOfDay::_getSunColor( ColorF *outColor ) const
|
|||
|
||||
if ( mColorTargets[mColorTargets.size()-1].elevation != M_PI_F )
|
||||
{
|
||||
AssertFatal(0, "Celestails::GetColor() - Last elevation must be PI")
|
||||
AssertFatal(0, "Celestails::GetColor() - Last elevation must be PI");
|
||||
outColor->set(1.0f, 1.0f, 1.0f);
|
||||
//mBandMod = 1.0f;
|
||||
//mCurrentBandColor = color;
|
||||
|
|
|
|||
|
|
@ -205,8 +205,6 @@ void WaterBlock::setupVertexBlock( U32 width, U32 height, U32 rowOffset )
|
|||
U32 numVerts = width * height;
|
||||
|
||||
GFXWaterVertex *verts = new GFXWaterVertex[ numVerts ];
|
||||
ColorI waterColor(31, 56, 64, 127);
|
||||
GFXVertexColor vertCol(waterColor);
|
||||
|
||||
U32 index = 0;
|
||||
for( U32 i=0; i<height; i++ )
|
||||
|
|
@ -219,7 +217,6 @@ void WaterBlock::setupVertexBlock( U32 width, U32 height, U32 rowOffset )
|
|||
vert->point.x = vertX;
|
||||
vert->point.y = vertY;
|
||||
vert->point.z = 0.0;
|
||||
vert->color = vertCol;
|
||||
vert->normal.set(0,0,1);
|
||||
vert->undulateData.set( vertX, vertY );
|
||||
vert->horizonFactor.set( 0, 0, 0, 0 );
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ GFXImplementVertexFormat( GFXWaterVertex )
|
|||
{
|
||||
addElement( "POSITION", GFXDeclType_Float3 );
|
||||
addElement( "NORMAL", GFXDeclType_Float3 );
|
||||
addElement( "COLOR", GFXDeclType_Color );
|
||||
addElement( "TEXCOORD", GFXDeclType_Float2, 0 );
|
||||
addElement( "TEXCOORD", GFXDeclType_Float4, 1 );
|
||||
}
|
||||
|
|
@ -207,7 +206,7 @@ WaterObject::WaterObject()
|
|||
mEmissive( false ),
|
||||
mUnderwaterColor(9, 6, 5, 240)
|
||||
{
|
||||
mTypeMask = WaterObjectType | StaticObjectType;
|
||||
mTypeMask = WaterObjectType;
|
||||
|
||||
for( U32 i=0; i < MAX_WAVES; i++ )
|
||||
{
|
||||
|
|
@ -827,25 +826,25 @@ void WaterObject::drawUnderwaterFilter( SceneRenderState *state )
|
|||
// draw quad
|
||||
|
||||
|
||||
GFXVertexBufferHandle<GFXVertexPC> verts( GFX, 4, GFXBufferTypeVolatile );
|
||||
GFXVertexBufferHandle<GFXVertexPCT> verts( GFX, 4, GFXBufferTypeVolatile );
|
||||
verts.lock();
|
||||
|
||||
verts[0].point.set( -1.0 - copyOffsetX, -1.0 + copyOffsetY, 0.0 );
|
||||
verts[0].point.set(1.0 - copyOffsetX, -1.0 + copyOffsetY, 0.0);
|
||||
verts[0].color = mUnderwaterColor;
|
||||
|
||||
verts[1].point.set( -1.0 - copyOffsetX, 1.0 + copyOffsetY, 0.0 );
|
||||
verts[1].point.set(1.0 - copyOffsetX, 1.0 + copyOffsetY, 0.0);
|
||||
verts[1].color = mUnderwaterColor;
|
||||
|
||||
verts[2].point.set( 1.0 - copyOffsetX, 1.0 + copyOffsetY, 0.0 );
|
||||
verts[2].point.set(-1.0 - copyOffsetX, -1.0 + copyOffsetY, 0.0);
|
||||
verts[2].color = mUnderwaterColor;
|
||||
|
||||
verts[3].point.set( 1.0 - copyOffsetX, -1.0 + copyOffsetY, 0.0 );
|
||||
verts[3].point.set(-1.0 - copyOffsetX, 1.0 + copyOffsetY, 0.0);
|
||||
verts[3].color = mUnderwaterColor;
|
||||
|
||||
verts.unlock();
|
||||
|
||||
GFX->setVertexBuffer( verts );
|
||||
GFX->drawPrimitive( GFXTriangleFan, 0, 2 );
|
||||
GFX->drawPrimitive( GFXTriangleStrip, 0, 2 );
|
||||
|
||||
// reset states / transforms
|
||||
GFX->setProjectionMatrix( proj );
|
||||
|
|
@ -1142,7 +1141,7 @@ bool WaterObject::initMaterial( S32 idx )
|
|||
else
|
||||
mat = MATMGR->createMatInstance( mSurfMatName[idx] );
|
||||
|
||||
const GFXVertexFormat *flags = getGFXVertexFormat<GFXVertexPC>();
|
||||
const GFXVertexFormat *flags = getGFXVertexFormat<GFXVertexPCT>();
|
||||
|
||||
if ( mat && mat->init( MATMGR->getDefaultFeatures(), flags ) )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ GFXDeclareVertexFormat( GFXWaterVertex )
|
|||
{
|
||||
Point3F point;
|
||||
Point3F normal;
|
||||
GFXVertexColor color;
|
||||
Point2F undulateData;
|
||||
Point4F horizonFactor;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -175,9 +175,6 @@ void WaterPlane::setupVBIB( SceneRenderState *state )
|
|||
{
|
||||
const Frustum &frustum = state->getCullingFrustum();
|
||||
|
||||
// Water base-color, assigned as color for all verts.
|
||||
const GFXVertexColor vertCol(mWaterFogData.color);
|
||||
|
||||
// World-Up vector, assigned as normal for all verts.
|
||||
const Point3F worldUp( 0.0f, 0.0f, 1.0f );
|
||||
|
||||
|
|
@ -250,7 +247,6 @@ void WaterPlane::setupVBIB( SceneRenderState *state )
|
|||
xVal = cornerPosition.x + (F32)( j * squareSize );
|
||||
|
||||
vertPtr->point.set( xVal, yVal, 0.0f );
|
||||
vertPtr->color = vertCol;
|
||||
vertPtr->normal = worldUp;
|
||||
vertPtr->undulateData.set( xVal, yVal );
|
||||
vertPtr->horizonFactor.set( 0, 0, 0, 0 );
|
||||
|
|
@ -404,7 +400,6 @@ void WaterPlane::setupVBIB( SceneRenderState *state )
|
|||
vertPtr->point.set( pos.x, pos.y, 0.0f );
|
||||
vertPtr->undulateData.set( pos.x, pos.y );
|
||||
vertPtr->horizonFactor.set( 0, 0, 0, 0 );
|
||||
vertPtr->color = vertCol;
|
||||
vertPtr->normal = worldUp;
|
||||
vertPtr++;
|
||||
}
|
||||
|
|
@ -427,7 +422,6 @@ void WaterPlane::setupVBIB( SceneRenderState *state )
|
|||
vertPtr->point.set( pos.x, pos.y, 50.0f );
|
||||
vertPtr->undulateData.set( pos.x, pos.y );
|
||||
vertPtr->horizonFactor.set( 1, 0, 0, 0 );
|
||||
vertPtr->color = vertCol;
|
||||
vertPtr->normal = worldUp;
|
||||
vertPtr++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue