SO3Engine
SO3ShadowStencil.cpp
Go to the documentation of this file.
1
9
10namespace SO3
11{
12
13SShadowStencil::SShadowStencil() : SShadow(0, "", SShadowManager::SO3_SHADOWS_STENCIL)
14{
15}
16
17SShadowStencil::SShadowStencil(SShadowManager* sManager) : SShadow(sManager, "Stencil", SShadowManager::SO3_SHADOWS_STENCIL)
18{
19 const Ogre::RenderSystemCapabilities* caps = SRoot::getSingleton().GetOgreRenderSystem()->getCapabilities();
20 if (caps && caps->hasCapability(Ogre::RSC_HWSTENCIL))
21 {
22 //hack to be sure that ogre use the good shadow caster (ogre bug ?)
23 Ogre::MaterialPtr mcaster = Ogre::MaterialManager::getSingleton().getByName("Ogre/StencilShadowVolumes");
24 ogreScene->setShadowTextureCasterMaterial(mcaster);
25 ogreScene->setShadowTextureReceiverMaterial(mcaster);
26
27 ogreScene->setShadowTexturePixelFormat(Ogre::PF_X8R8G8B8);
28 Ogre::ShadowTechnique newTechnique = static_cast <Ogre::ShadowTechnique> (Ogre::SHADOWDETAILTYPE_STENCIL | shadowManager->GetLightingTechnique());
29 ogreScene->setShadowTechnique(newTechnique);
30 }
31}
32
34{
35 Ogre::MaterialPtr emptyMat;
36 ogreScene->setShadowTextureCasterMaterial(emptyMat);
37 ogreScene->setShadowTextureReceiverMaterial(emptyMat);
38 ogreScene->setShadowTextureCount(1);
39 ogreScene->setShadowTexturePixelFormat(Ogre::PF_X8R8G8B8);
40 ogreScene->setShadowCasterRenderBackFaces(false);
41 ogreScene->setShadowTextureSelfShadow(false);
42 ogreScene->setShadowTechnique(Ogre::SHADOWTYPE_NONE);
43}
44
46{
47 const Ogre::RenderSystemCapabilities* caps = SRoot::getSingleton().GetOgreRenderSystem()->getCapabilities();
48 if (caps && caps->hasCapability(Ogre::RSC_HWSTENCIL))
49 {
50 Ogre::ShadowTechnique newTechnique = static_cast <Ogre::ShadowTechnique> (Ogre::SHADOWDETAILTYPE_STENCIL | shadowManager->GetLightingTechnique());
51 ogreScene->setShadowTechnique(newTechnique);
52 }
53}
54
55}
Ogre::RenderSystem * GetOgreRenderSystem()
Definition SO3Root.cpp:865
static SRoot & getSingleton()
Definition SO3Root.cpp:116
SShadowManager * shadowManager
Definition SO3Shadow.h:75
Ogre::SceneManager * ogreScene
Definition SO3Shadow.h:74
ShadowLightingType GetLightingTechnique()
virtual void UpdateShadowTechnique()
Abstract class defining a shadow rendering technique. .