Project

General

Profile

SO3Engine
SO3Shadow.cpp
Go to the documentation of this file.
1
10
11#ifdef SO3_BUILD_DEFERRED
13#endif
14
15#include "SO3Renderer/SO3Root.h"
19
20namespace SO3
21{
22
23 SShadow::SShadow() : SData("")
24 {
25 }
26
27 SShadow::SShadow(SShadowManager* sManager, const std::string& shadowTechniqueName, const SShadowManager::ShadowType& shadowType) : SData(shadowTechniqueName)
28 {
29 shadowManager = sManager;
30 currentScene = sManager->GetParentScene();
32 type = shadowType;
33
34 mFadeStart = 0.6f;
35 mFadeEnd = 0.98f;
36
37 // Initialise to null.
38 cameraSetup.reset();
39
40#if SO3_ENABLE_DEFERRED_CUSTOM_SHADOWS == 1
41 // Configure deferred shadows
43#endif
44 }
45
47 {
48#if SO3_ENABLE_DEFERRED_CUSTOM_SHADOWS == 1
49 // Configure deferred shadows
51#endif
52
53 ogreScene->setShadowTechnique(Ogre::SHADOWTYPE_NONE);
54 cameraSetup.reset();
55 }
56
57 void SShadow::SetCameraSetup(Ogre::ShadowCameraSetupPtr shadowCameraSetup)
58 {
59 assert(!cameraSetup);
60 cameraSetup = shadowCameraSetup;
61 ogreScene->setShadowCameraSetup(cameraSetup);
62 }
63
64 Ogre::ShadowCameraSetupPtr SShadow::GetCameraSetup()
65 {
66 return cameraSetup;
67 }
68
73
78
82
83 void SShadow::UpdateShadowMaterial(Ogre::Technique* tech)
84 {
85 }
86
87 void SShadow::RemoveMaterialPass(Ogre::Technique* tech)
88 {
89 }
90
91 bool SShadow::IsShadowMaterialPass(Ogre::Pass* pass)
92 {
93 return false;
94 }
95
96 /*
97 Shadows viewport
98 */
99 SShadowViewport::SShadowViewport(Ogre::Viewport* viewport)
100 {
101 targetViewport = viewport;
102 }
103
107
108
109 void SShadowViewport::UpdateCamera(Ogre::Camera* cam)
110 {
111 }
112
113 /*
114 compositor pass hack for shadows
115 */
116
117 //compositor pass
118 ShadowCompositorRenderOperation::ShadowCompositorRenderOperation(Ogre::CompositorInstance* instance, const Ogre::CompositionPass* pass)
119 {
120 mCompInstance = instance;
121 }
122
126
127 void ShadowCompositorRenderOperation::execute(Ogre::SceneManager* sm, Ogre::RenderSystem* rs)
128 {
129 // Get the active camera
130 if (mCompInstance->getEnabled() && (sm->getShadowTechnique() != Ogre::SHADOWTYPE_NONE))
131 {
132 Ogre::Viewport* viewport = mCompInstance->getChain()->getViewport();
133 Ogre::Camera* cam = viewport->getCamera();
134
135 //Update shadow texture
136 Ogre::SceneManager::RenderContext* context = sm->_pauseRendering();
137 //sm->_suppressShadows(false);
138 sm->prepareShadowTextures(cam, viewport);
139 //sm->_suppressShadows(true);
140 sm->_resumeRendering(context);
141 }
142 }
143
144 Ogre::CompositorInstance::RenderSystemOperation* ShadowCompositorPass::createOperation(Ogre::CompositorInstance* instance, const Ogre::CompositionPass* pass)
145 {
146 return OGRE_NEW ShadowCompositorRenderOperation(instance, pass);
147 }
148}
void RegisterSceneManager(Ogre::SceneManager *targetScene)
static SDeferredShadowManager & getSingleton()
void UnregisterSceneManager(Ogre::SceneManager *existingScene)
Ogre::SceneManager * GetOgreScenePointer()
Definition SO3Scene.cpp:449
virtual void UpdateShadowTechnique()=0
Definition SO3Shadow.cpp:79
Ogre::ShadowCameraSetupPtr GetCameraSetup()
Definition SO3Shadow.cpp:64
Ogre::Real mFadeStart
Definition SO3Shadow.h:80
Ogre::Real mFadeEnd
Definition SO3Shadow.h:81
SShadowManager * shadowManager
Definition SO3Shadow.h:75
Ogre::ShadowCameraSetupPtr cameraSetup
Definition SO3Shadow.h:76
Ogre::SceneManager * ogreScene
Definition SO3Shadow.h:74
virtual void UpdateShadowMaterial(Ogre::Technique *tech)
Definition SO3Shadow.cpp:83
virtual void RemoveMaterialPass(Ogre::Technique *tech)
Definition SO3Shadow.cpp:87
virtual ~SShadow()
Definition SO3Shadow.cpp:46
void SetCameraSetup(Ogre::ShadowCameraSetupPtr shadowCameraSetup)
Definition SO3Shadow.cpp:57
SShadowManager * GetShadowManager()
Definition SO3Shadow.cpp:74
SShadowManager::ShadowType GetShadowType()
Definition SO3Shadow.cpp:69
virtual bool IsShadowMaterialPass(Ogre::Pass *pass)
Definition SO3Shadow.cpp:91
SScene * currentScene
Definition SO3Shadow.h:73
virtual ~SShadowViewport()
virtual void UpdateCamera(Ogre::Camera *cam)
Ogre::Viewport * targetViewport
Definition SO3Shadow.h:49
SShadowViewport(Ogre::Viewport *viewport)
Definition SO3Shadow.cpp:99
virtual Ogre::CompositorInstance::RenderSystemOperation * createOperation(Ogre::CompositorInstance *instance, const Ogre::CompositionPass *pass)
virtual void execute(Ogre::SceneManager *sm, Ogre::RenderSystem *rs)
ShadowCompositorRenderOperation(Ogre::CompositorInstance *instance, const Ogre::CompositionPass *pass)