mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-24 13:55:34 +00:00
Direct3D11 Engine/source changes
This commit is contained in:
parent
3a9b50f702
commit
41e5caf22b
81 changed files with 1291 additions and 617 deletions
|
|
@ -317,8 +317,7 @@ void VolumetricFog::handleResize(VolumetricFogRTManager *RTM, bool resize)
|
|||
{
|
||||
F32 width = (F32)mPlatformWindow->getClientExtent().x;
|
||||
F32 height = (F32)mPlatformWindow->getClientExtent().y;
|
||||
if (!mPlatformWindow->isFullscreen())
|
||||
height -= 20;//subtract caption bar from rendertarget size.
|
||||
|
||||
mTexScale.x = 2.0f - ((F32)mTexture.getWidth() / width);
|
||||
mTexScale.y = 2.0f - ((F32)mTexture.getHeight() / height);
|
||||
}
|
||||
|
|
@ -1075,7 +1074,6 @@ void VolumetricFog::render(ObjectRenderInst *ri, SceneRenderState *state, BaseMa
|
|||
|
||||
mPPShaderConsts->setSafe(mPPModelViewProjSC, xform);
|
||||
|
||||
LightInfo *lightinfo = LIGHTMGR->getSpecialLight(LightManager::slSunLightType);
|
||||
const ColorF &sunlight = state->getAmbientLightColor();
|
||||
|
||||
Point3F ambientColor(sunlight.red, sunlight.green, sunlight.blue);
|
||||
|
|
@ -1160,6 +1158,11 @@ void VolumetricFog::render(ObjectRenderInst *ri, SceneRenderState *state, BaseMa
|
|||
GFX->setStateBlock(mStateblockF);
|
||||
|
||||
GFX->drawPrimitive(0);
|
||||
|
||||
// Ensure these two textures are bound to the pixel shader input on the second run as they are used as pixel shader outputs (render targets).
|
||||
GFX->setTexture(1, NULL); //mDepthBuffer
|
||||
GFX->setTexture(2, NULL); //mFrontBuffer
|
||||
GFX->updateStates(); //update the dirty texture state we set above
|
||||
}
|
||||
|
||||
void VolumetricFog::reflect_render(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat)
|
||||
|
|
@ -1210,9 +1213,6 @@ void VolumetricFog::InitTexture()
|
|||
F32 width = (F32)mPlatformWindow->getClientExtent().x;
|
||||
F32 height = (F32)mPlatformWindow->getClientExtent().y;
|
||||
|
||||
if (!mPlatformWindow->isFullscreen())
|
||||
height -= 20;//subtract caption bar from rendertarget size.
|
||||
|
||||
mTexScale.x = 2.0f - ((F32)mTexture.getWidth() / width);
|
||||
mTexScale.y = 2.0f - ((F32)mTexture.getHeight() / height);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include "windowManager/platformWindowMgr.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "gui/core/guiCanvas.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
|
||||
MODULE_BEGIN(VolumetricFogRTManager)
|
||||
|
||||
|
|
@ -127,10 +128,10 @@ void VolumetricFogRTManager::consoleInit()
|
|||
bool VolumetricFogRTManager::Init()
|
||||
{
|
||||
if (mIsInitialized)
|
||||
{
|
||||
{
|
||||
Con::errorf("VolumetricFogRTManager allready initialized!!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
GuiCanvas* cv = dynamic_cast<GuiCanvas*>(Sim::findObject("Canvas"));
|
||||
if (cv == NULL)
|
||||
|
|
@ -142,15 +143,11 @@ bool VolumetricFogRTManager::Init()
|
|||
mPlatformWindow = cv->getPlatformWindow();
|
||||
mPlatformWindow->getScreenResChangeSignal().notify(this,&VolumetricFogRTManager::ResizeRT);
|
||||
|
||||
if (mTargetScale < 1)
|
||||
if (mTargetScale < 1 || GFX->getAdapterType() == Direct3D11)
|
||||
mTargetScale = 1;
|
||||
|
||||
mWidth = mFloor(mPlatformWindow->getClientExtent().x / mTargetScale);
|
||||
mHeight = mPlatformWindow->getClientExtent().y;
|
||||
mFullScreen = mPlatformWindow->isFullscreen();
|
||||
if (!mFullScreen)
|
||||
mHeight -= 20;//subtract caption bar from rendertarget size.
|
||||
mHeight = mFloor(mHeight / mTargetScale);
|
||||
mHeight = mFloor(mPlatformWindow->getClientExtent().y / mTargetScale);
|
||||
|
||||
mDepthBuffer = GFXTexHandle(mWidth, mHeight, GFXFormatR32F,
|
||||
&GFXDefaultRenderTargetProfile, avar("%s() - mDepthBuffer (line %d)", __FUNCTION__, __LINE__));
|
||||
|
|
@ -221,14 +218,11 @@ void VolumetricFogRTManager::FogAnswered()
|
|||
|
||||
bool VolumetricFogRTManager::Resize()
|
||||
{
|
||||
if (mTargetScale < 1)
|
||||
if (mTargetScale < 1 || GFX->getAdapterType() == Direct3D11)
|
||||
mTargetScale = 1;
|
||||
|
||||
mWidth = mFloor(mPlatformWindow->getClientExtent().x / mTargetScale);
|
||||
mHeight = mPlatformWindow->getClientExtent().y;
|
||||
|
||||
if (!mPlatformWindow->isFullscreen())
|
||||
mHeight -= 20;//subtract caption bar from rendertarget size.
|
||||
mHeight = mFloor(mHeight / mTargetScale);
|
||||
mHeight = mFloor(mPlatformWindow->getClientExtent().y / mTargetScale);
|
||||
|
||||
if (mWidth < 16 || mHeight < 16)
|
||||
return false;
|
||||
|
|
@ -248,19 +242,19 @@ bool VolumetricFogRTManager::Resize()
|
|||
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;
|
||||
}
|
||||
{
|
||||
Con::errorf("VolumetricFogRTManager::Resize() Fatal Error: Unable to create Depthbuffer");
|
||||
return false;
|
||||
}
|
||||
mDepthTarget.setTexture(mDepthBuffer);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ class VolumetricFogRTManager : public SceneObject
|
|||
U32 mFogHasAnswered;
|
||||
U32 mWidth;
|
||||
U32 mHeight;
|
||||
bool mFullScreen;
|
||||
|
||||
void onRemove();
|
||||
void onSceneRemove();
|
||||
|
|
|
|||
|
|
@ -1067,17 +1067,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
|
||||
|
|
@ -1126,7 +1126,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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -467,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
|
||||
|
|
@ -525,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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -826,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 );
|
||||
|
|
@ -1141,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 ) )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue