toggleCompositors command useful for debugging

This commit is contained in:
scrawl 2012-04-29 03:33:10 +02:00
parent 5d4d35a02c
commit 11ebae3be2
8 changed files with 64 additions and 37 deletions

View file

@ -16,6 +16,7 @@ source_group(game FILES ${GAME} ${GAME_HEADER})
add_openmw_dir (mwrender
renderingmanager debugging sky player animation npcanimation creatureanimation actors objects
renderinginterface localmap occlusionquery terrain terrainmaterial water shadows shaderhelper
compositors
)
add_openmw_dir (mwinput

View file

@ -18,6 +18,7 @@
#include "shaderhelper.hpp"
#include "localmap.hpp"
#include "water.hpp"
#include "compositors.hpp"
using namespace MWRender;
using namespace Ogre;
@ -29,6 +30,8 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
{
mRendering.createScene("PlayerCam", Settings::Manager::getFloat("field of view", "General"), 5);
mCompositors = new Compositors(mRendering.getViewport());
mWater = 0;
//The fog type must be set before any terrain objects are created as if the
@ -67,15 +70,15 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
// note that the order is important here
if (useMRT())
{
CompositorManager::getSingleton().addCompositor(mRendering.getViewport(), "gbuffer");
CompositorManager::getSingleton().setCompositorEnabled(mRendering.getViewport(), "gbuffer", true);
CompositorManager::getSingleton().addCompositor(mRendering.getViewport(), "Underwater");
CompositorManager::getSingleton().addCompositor(mRendering.getViewport(), "gbufferFinalizer");
CompositorManager::getSingleton().setCompositorEnabled(mRendering.getViewport(), "gbufferFinalizer", true);
mCompositors->addCompositor("gbuffer", 0);
mCompositors->setCompositorEnabled("gbuffer", true);
mCompositors->addCompositor("Underwater", 1);
mCompositors->addCompositor("gbufferFinalizer", 2);
mCompositors->setCompositorEnabled("gbufferFinalizer", true);
}
else
{
CompositorManager::getSingleton().addCompositor(mRendering.getViewport(), "UnderwaterNoMRT");
mCompositors->addCompositor("UnderwaterNoMRT", 0);
}
// Turn the entire scene (represented by the 'root' node) -90
@ -120,6 +123,7 @@ RenderingManager::~RenderingManager ()
delete mTerrainManager;
delete mLocalMap;
delete mOcclusionQuery;
delete mCompositors;
}
MWRender::SkyManager* RenderingManager::getSkyManager()
@ -231,7 +235,7 @@ void RenderingManager::update (float duration){
void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){
if(store->cell->data.flags & store->cell->HasWater){
if(mWater == 0)
mWater = new MWRender::Water(mRendering.getCamera(), mSkyManager, store->cell);
mWater = new MWRender::Water(mRendering.getCamera(), this, store->cell);
else
mWater->changeCell(store->cell);
mWater->setActive(true);
@ -292,35 +296,29 @@ void RenderingManager::skySetMoonColour (bool red){
bool RenderingManager::toggleRenderMode(int mode)
{
if (mode != MWWorld::World::Render_Wireframe)
if (mode == MWWorld::World::Render_CollisionDebug || mode == MWWorld::World::Render_Pathgrid)
return mDebugging->toggleRenderMode(mode);
else // if (mode == MWWorld::World::Render_Wireframe)
else if (mode == MWWorld::World::Render_Wireframe)
{
if (mRendering.getCamera()->getPolygonMode() == PM_SOLID)
{
// disable compositors
if (useMRT())
{
CompositorManager::getSingleton().setCompositorEnabled(mRendering.getViewport(), "gbuffer", false);
CompositorManager::getSingleton().setCompositorEnabled(mRendering.getViewport(), "gbufferFinalizer", false);
}
mCompositors->setEnabled(false);
mRendering.getCamera()->setPolygonMode(PM_WIREFRAME);
return true;
}
else
{
// re-enable compositors
if (useMRT())
{
CompositorManager::getSingleton().setCompositorEnabled(mRendering.getViewport(), "gbuffer", true);
CompositorManager::getSingleton().setCompositorEnabled(mRendering.getViewport(), "gbufferFinalizer", true);
}
mCompositors->setEnabled(true);
mRendering.getCamera()->setPolygonMode(PM_SOLID);
return false;
}
}
else //if (mode == MWWorld::World::Render_Compositors)
{
return mCompositors->toggle();
}
}
void RenderingManager::configureFog(ESMS::CellStore<MWWorld::RefData> &mCell)
@ -518,4 +516,9 @@ void RenderingManager::switchToExterior()
mRendering.getScene()->setCameraRelativeRendering(true);
}
Compositors* RenderingManager::getCompositors()
{
return mCompositors;
}
} // namespace

View file

@ -47,6 +47,7 @@ namespace MWRender
class ShaderHelper;
class LocalMap;
class Water;
class Compositors;
class RenderingManager: private RenderingInterface {
@ -67,6 +68,7 @@ class RenderingManager: private RenderingInterface {
/// to internal details of the rendering system anymore
SkyManager* getSkyManager();
Compositors* getCompositors();
void toggleLight();
bool toggleRenderMode(int mode);
@ -157,6 +159,8 @@ class RenderingManager: private RenderingInterface {
bool mSunEnabled;
bool mCompositorsEnabled;
SkyManager* mSkyManager;
OcclusionQuery* mOcclusionQuery;
@ -192,6 +196,8 @@ class RenderingManager: private RenderingInterface {
MWRender::Shadows* mShadows;
MWRender::ShaderHelper* mShaderHelper;
MWRender::Compositors* mCompositors;
};
}

View file

@ -2,24 +2,20 @@
#include <components/settings/settings.hpp>
#include "sky.hpp"
#include "renderingmanager.hpp"
#include "compositors.hpp"
using namespace Ogre;
namespace MWRender
{
Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) :
Water::Water (Ogre::Camera *camera, RenderingManager* rend, const ESM::Cell* cell) :
mCamera (camera), mViewport (camera->getViewport()), mSceneManager (camera->getSceneManager()),
mIsUnderwater(false), mVisibilityFlags(0),
mReflectionTarget(0), mActive(1), mToggled(1),
mReflectionRenderActive(false)
mReflectionRenderActive(false), mRendering(rend)
{
mSky = sky;
try
{
CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false);
} catch(...) {}
mSky = rend->getSkyManager();
mTop = cell->water;
@ -147,8 +143,6 @@ Water::~Water()
mWaterNode->detachObject(mWater);
mSceneManager->destroyEntity(mWater);
mSceneManager->destroySceneNode(mWaterNode);
CompositorManager::getSingleton().removeCompositorChain(mViewport);
}
void Water::changeCell(const ESM::Cell* cell)
@ -178,13 +172,13 @@ void Water::checkUnderwater(float y)
{
if (!mActive)
{
CompositorManager::getSingleton().setCompositorEnabled(mViewport, mCompositorName, false);
mRendering->getCompositors()->setCompositorEnabled(mCompositorName, false);
return;
}
if ((mIsUnderwater && y > mTop) || !mWater->isVisible() || mCamera->getPolygonMode() != Ogre::PM_SOLID)
{
CompositorManager::getSingleton().setCompositorEnabled(mViewport, mCompositorName, false);
mRendering->getCompositors()->setCompositorEnabled(mCompositorName, false);
// tell the shader we are not underwater
Ogre::Pass* pass = mMaterial->getTechnique(0)->getPass(0);
@ -199,7 +193,7 @@ void Water::checkUnderwater(float y)
if (!mIsUnderwater && y < mTop && mWater->isVisible() && mCamera->getPolygonMode() == Ogre::PM_SOLID)
{
if (mUnderwaterEffect)
CompositorManager::getSingleton().setCompositorEnabled(mViewport, mCompositorName, true);
mRendering->getCompositors()->setCompositorEnabled(mCompositorName, true);
// tell the shader we are underwater
Ogre::Pass* pass = mMaterial->getTechnique(0)->getPass(0);

View file

@ -9,6 +9,7 @@
namespace MWRender {
class SkyManager;
class RenderingManager;
/// Water rendering
class Water : public Ogre::RenderTargetListener, public Ogre::RenderQueueListener
@ -40,6 +41,7 @@ namespace MWRender {
void updateVisible();
RenderingManager* mRendering;
SkyManager* mSky;
std::string mCompositorName;
@ -55,7 +57,7 @@ namespace MWRender {
int mVisibilityFlags;
public:
Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell);
Water (Ogre::Camera *camera, RenderingManager* rend, const ESM::Cell* cell);
~Water();
void setActive(bool active);

View file

@ -144,4 +144,5 @@ op 0x200014d: ModDisposition
op 0x200014e: ModDisposition, explicit reference
op 0x200014f: ForceGreeting
op 0x2000150: ForceGreeting, explicit reference
opcodes 0x2000151-0x3ffffff unused
op 0x2000152: ToggleCompositors
opcodes 0x2000153-0x3ffffff unused

View file

@ -194,6 +194,22 @@ namespace MWScript
}
};
class OpToggleCompositors : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext());
bool enabled = MWBase::Environment::get().getWorld()->toggleRenderMode(MWWorld::World::Render_Compositors);
context.report (enabled ?
"Compositors -> On" : "Compositors -> Off");
}
};
const int opcodeXBox = 0x200000c;
const int opcodeOnActivate = 0x200000d;
const int opcodeActivate = 0x2000075;
@ -208,6 +224,7 @@ namespace MWScript
const int opcodeFadeTo = 0x200013e;
const int opcodeToggleWater = 0x2000144;
const int opcodeTogglePathgrid = 0x2000146;
const int opcodeToggleCompositors = 0x2000152;
void registerExtensions (Compiler::Extensions& extensions)
{
@ -229,6 +246,7 @@ namespace MWScript
extensions.registerInstruction ("twa", "", opcodeToggleWater);
extensions.registerInstruction ("togglepathgrid", "", opcodeTogglePathgrid);
extensions.registerInstruction ("tpg", "", opcodeTogglePathgrid);
extensions.registerInstruction ("togglecompositors", "", opcodeToggleCompositors);
}
void installOpcodes (Interpreter::Interpreter& interpreter)
@ -247,6 +265,7 @@ namespace MWScript
interpreter.installSegment5 (opcodeFadeTo, new OpFadeTo);
interpreter.installSegment5 (opcodeTogglePathgrid, new OpTogglePathgrid);
interpreter.installSegment5 (opcodeToggleWater, new OpToggleWater);
interpreter.installSegment5 (opcodeToggleCompositors, new OpToggleCompositors);
}
}
}

View file

@ -63,7 +63,8 @@ namespace MWWorld
{
Render_CollisionDebug,
Render_Wireframe,
Render_Pathgrid
Render_Pathgrid,
Render_Compositors
};
private: