Project

General

Profile

SO3Engine
SO3DeferredShading.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
25#ifndef __SO3_DEFERRED_SHADING_H__
26#define __SO3_DEFERRED_SHADING_H__
27
28
30#include "SO3GBuffer.h"
45#include "OgreCompositorInstance.h"
46#include "OgreSceneManager.h"
47#include "OgreSceneNode.h"
48#include "OgreMaterial.h"
49#include "OgreRenderTargetListener.h"
50
51namespace SO3
52{
53
58class SDeferredShading : public Ogre::Singleton<SDeferredShading>
59{
60public:
73
74 // References about most of the techniques listed here can be found here: http://iryoku.com/aacourse/
76 {
78 SO3_DEFERRED_SSAA = 1, // Warning, SSAA means Screen Space AA, not Super Sampling AA (although it a super sampling derivated technique!).
79 SO3_DEFERRED_NFAA = 2, // Normal Filter AA.
80 // SO3_DEFERRED_FXAA -> http://timothylottes.blogspot.com/2011/07/fxaa-311-released.html
82 };
83
84protected:
85 typedef Ogre::CompositorInstance* GBufferCompositors[SO3_DEFERRED_COUNT];
86 typedef Ogre::CompositorInstance* AntiAliasingCompositors[SO3_DEFERRED_AA_COUNT];
94
95 typedef std::map<SViewPort*, GBufferFilters*> OgreViewportList;
98private:
99 bool newViewportAdded;
100 SDeferredShadowManager* deferredShadowManager;
101 SGBuffer* currentGBuffer;
102 typedef std::map<std::string, SGBuffer*> AvailableGBufferMap;
103 AvailableGBufferMap availableGBufferMap;
104 SDeferredCompositorGBuffer* compositorGBuffer;
105 SDeferredCompositorLighting* compositorLighting;
106 SDeferredCompositorShowDepth* compositorShowDepth;
107 SDeferredCompositorShowDiffuse* compositorShowDiffuse;
108 SDeferredCompositorShowEmissive* compositorShowEmissive;
109 SDeferredCompositorShowMaterialID* compositorShowMaterialID;
110 SDeferredCompositorShowNormal* compositorShowNormal;
111 SDeferredCompositorShowSpecular* compositorShowSpecular;
112 SDeferredCompositorShowVelocity* compositorShowVelocity;
113 SDeferredCompositorSSAO* compositorSSAO;
114 SDeferredCompositorSSAA* compositorSSAA;
115 SDeferredCompositorNFAA* compositorNFAA;
116 SDeferredLightManager* deferredLightManager;
117 Ogre::MaterialManager::Listener* gBufferSchemeHandler;
118 Ogre::MaterialManager::Listener* noGBufferSchemeHandler;
119 Ogre::CompositorLogic* ssaoCompositorLogic;
120 Ogre::CustomCompositionPass* deferredLightCompositionPass;
121 SGBufferMaterialGenerator* gbufferMaterialGenerator;
122
123public:
128
133
138
143
148 static const Ogre::uint8 PRE_GBUFFER_RENDER_QUEUE;
149
154 static const Ogre::uint8 POST_GBUFFER_RENDER_QUEUE;
155
158 void RegisterViewport(SViewPort* targetViewport);
159
162 void UnregisterViewport(SViewPort* existingViewport);
163
167
170 void SetSSAO(SViewPort* existingViewport, bool ssao);
171
174 void SetAntiAliasing(SViewPort* existingViewport, DeferredShadingAntiAliasingMode newMode);
175
179 void SetMode(DeferredShadingMode mode);
180
184
188
192protected:
193private:
194};
195
196}
197
198#endif
Ogre::CompositorInstance * AntiAliasingCompositors[SO3_DEFERRED_AA_COUNT]
static SDeferredShading * getSingletonPtr()
static const Ogre::uint8 PRE_GBUFFER_RENDER_QUEUE
void SetAntiAliasing(SViewPort *existingViewport, DeferredShadingAntiAliasingMode newMode)
void SetSSAO(SViewPort *existingViewport, bool ssao)
void UnregisterViewport(SViewPort *existingViewport)
static SDeferredShading & getSingleton()
std::map< SViewPort *, GBufferFilters * > OgreViewportList
OgreViewportList ogreViewportList
static const Ogre::uint8 POST_GBUFFER_RENDER_QUEUE
void RegisterViewport(SViewPort *targetViewport)
DeferredShadingMode currentMode
DeferredShadingMode GetMode() const
@ SO3_DEFERRED_SHOWCOLOUR
Show diffuse (for debugging)
@ SO3_DEFERRED_SHOWNORMALS
Show normals (for debugging)
@ SO3_DEFERRED_SHOWLIT
The deferred shading mode.
@ SO3_DEFERRED_SHOWEMISSIVE
Show emissive channel (for debugging)
@ SO3_DEFERRED_SHOWVELOCITY
Show velocity vector (for debugging)
@ SO3_DEFERRED_SHOWSPECULAR
Show specular channel (for debugging)
@ SO3_DEFERRED_SHOWDEPTH
Show depth channel (for debugging)
void SetMode(DeferredShadingMode mode)
SGBufferMaterialGenerator * GetGBufferMaterialGenerator()
Ogre::CompositorInstance * GBufferCompositors[SO3_DEFERRED_COUNT]
Ogre::CompositorInstance * ssaoCompositor
AntiAliasingCompositors antiAliasingCompositors
Ogre::CompositorInstance * gBufferInstance