SO3Engine
|
SO3ShadowCSM.cpp
Go to the documentation of this file.
29 const Ogre::RenderSystemCapabilities* caps = SRoot::getSingleton().GetOgreRenderSystem()->getCapabilities();
53 SShadowCSM::SShadowCSM(SShadowManager* sManager) : SShadow(sManager, "CSM", SShadowManager::SO3_SHADOWS_CSM)
56 ogreScene->setShadowTechnique(static_cast <Ogre::ShadowTechnique> (Ogre::SHADOWDETAILTYPE_TEXTURE | Ogre::SHADOWDETAILTYPE_INTEGRATED | shadowManager->GetLightingTechnique()));
59 unsigned int textureCount = (quality <= SShadowManager::SO3_SHADOWS_QUALITY_MEDIUM) ? 2 : (quality == SShadowManager::SO3_SHADOWS_QUALITY_HIGH) ? 3 : 4;
69 Ogre::MaterialPtr mcaster = Ogre::MaterialManager::getSingleton().getByName("SO3/CSM/ShadowCaster");
91 ogreScene->setShadowTextureConfig(2, (unsigned short)(quality * 0.75f), (unsigned short)(quality * 0.75f), mRttFormat);
96 StableCSMShadowCameraSetup* shadowCameraSetup = new StableCSMShadowCameraSetup(ogreScene, CSMGpuConstants::getSingletonPtr());
133 ogreScene->setShadowTechnique(static_cast <Ogre::ShadowTechnique> (Ogre::SHADOWDETAILTYPE_TEXTURE | Ogre::SHADOWDETAILTYPE_INTEGRATED | shadowManager->GetLightingTechnique()));
167 if (!tech || (tech->getParent()->getName() == "Ogre/Debug/LinesMat") /*|| ((tech->getSchemeName() != Ogre::MSN_SHADERGEN) &&
176 if (tech->hasColourWriteDisabled() || (!tech->getParent()->getReceiveShadows()) || (tech->getSchemeName() == "SO3/LIGHTSHAFT"))
240 if (oPass && !oPass->getPolygonModeOverrideable() && (oPass->getPolygonMode() == Ogre::PM_POINTS))
249 nPass->setAlphaRejectSettings(oPass->getAlphaRejectFunction(), oPass->getAlphaRejectValue(), oPass->isAlphaToCoverageEnabled());
257 Ogre::TextureUnitState* nTunitState = nPass->getTextureUnitState((nbshadow <= 2) ? 3 : (nbshadow == 3) ? 4 : 5);
268 mcaster = Ogre::MaterialManager::getSingleton().getByName("SO3/CSM/ShadowCaster")->clone("SO3/CSM/ShadowCaster" + tech->getParent()->getName(), tech->getParent()->getGroup());
272 mcaster = Ogre::MaterialManager::getSingleton().getByName("SO3/CSM/ShadowCaster" + tech->getParent()->getName());
279 mcaster = Ogre::MaterialManager::getSingleton().getByName("SO3/CSM/ShadowCaster/Alpha")->clone("SO3/CSM/ShadowCaster/Alpha" + tech->getParent()->getName(), tech->getParent()->getGroup());
283 mcaster = Ogre::MaterialManager::getSingleton().getByName("SO3/CSM/ShadowCaster/Alpha" + tech->getParent()->getName());
312 //nPass->setFog(true, Ogre::FOG_LINEAR, Ogre::ColourValue::White, 0, shadowEnd * mFadeStart, shadowEnd * mFadeEnd);
318 sparams->setNamedConstant("fogParams", Ogre::Vector4(0.0f, dstart, dend, 1.0f / (dend - dstart)));
321 //float bias = (quality <= SShadowManager::SO3_SHADOWS_QUALITY_LOW) ? 0.1f : (quality <= SShadowManager::SO3_SHADOWS_QUALITY_MEDIUM) ? 0.05f : (quality > SShadowManager::SO3_SHADOWS_QUALITY_HIGH) ? 0.002f : 0.01f;
352 Ogre::MaterialPtr caster = Ogre::MaterialManager::getSingleton().getByName("SO3/CSM/ShadowCaster");
353 if (caster && (caster->getNumTechniques() > 0) && (caster->getTechnique(0)->getNumPasses() > 0) && (caster->getTechnique(0)->getPass(0)->getNumTextureUnitStates() > 0))
386 StableCSMShadowCameraSetup::StableCSMShadowCameraSetup(Ogre::SceneManager* ogreScene, CSMGpuConstants* constants) :
397 void StableCSMShadowCameraSetup::calculateSplitPoints(size_t cascadeCount, Ogre::Real firstSplitDist, Ogre::Real farDist, Ogre::Real lambda)
400 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Cannot specify less than 2 cascades", "StableCSMShadowCameraSetup::calculateSplitPoints");
428 void StableCSMShadowCameraSetup::getShadowCamera(const Ogre::SceneManager *sm, const Ogre::Camera *cam,
429 const Ogre::Viewport *vp, const Ogre::Light *light, Ogre::Camera *texCam, size_t iteration) const
452 void StableCSMShadowCameraSetup::getShadowCameraForCascade(const Ogre::SceneManager *sm, const Ogre::Camera *cam,
523 float dist = (topLeftFar.squaredLength() - bottomRightNear.squaredLength()) / (2 * (topLeftFar.z - bottomRightNear.z));
528 Ogre::Vector3 localPos(0, 0, -dist); // we have now found the point along frustum center which is equi-distant to the opposing corner positions
533 diameter *= (Ogre::Real)1.01; // allow some boundary pixels for filtering etc. TODO - make this a user constant
601 mParamsScaleBias = Ogre::GpuProgramManager::getSingletonPtr()->createSharedParameters("params_shadowMatrixScaleBias");
649 float depthRange = Ogre::Math::Abs(rs->getMinimumDepthInputValue() - rs->getMaximumDepthInputValue());
Definition SO3ShadowCSM.h:43
static CSMGpuConstants & getSingleton()
Definition SO3ShadowCSM.cpp:590
static CSMGpuConstants * getSingletonPtr()
Definition SO3ShadowCSM.cpp:582
void updateCascade(const Ogre::Camera &texCam, size_t index)
Definition SO3ShadowCSM.cpp:625
bool GetRttPixelFormat(Ogre::PixelFormat &format, bool alpha=false, bool floattex=false)
Definition SO3Root.cpp:650
void RemoveGeneratedMaterial(Ogre::Material *mat)
Definition SO3Root.cpp:2343
const SMaterialMap * GetMaterials(const std::string &groupName)
Definition SO3Scene.cpp:1147
virtual void RemoveMaterialPass(Ogre::Technique *tech)
Definition SO3ShadowCSM.cpp:144
static bool CheckSystemCompatibility()
Definition SO3ShadowCSM.cpp:22
virtual bool IsShadowMaterialPass(Ogre::Pass *pass)
Definition SO3ShadowCSM.cpp:136
virtual void UpdateShadowMaterial(Ogre::Technique *tech)
Definition SO3ShadowCSM.cpp:165
virtual void UpdateShadowTechnique()
Definition SO3ShadowCSM.cpp:131
Definition SO3Shadow.h:70
void SetCameraSetup(Ogre::ShadowCameraSetupPtr shadowCameraSetup)
Definition SO3Shadow.cpp:57
Definition SO3ShadowManager.h:43
ShadowLightingType GetLightingTechnique()
Definition SO3ShadowManager.cpp:76
ShadowQuality GetShadowQuality()
Definition SO3ShadowManager.cpp:232
@ SO3_SHADOWS_QUALITY_MEDIUM
Definition SO3ShadowManager.h:62
@ SO3_SHADOWS_QUALITY_HIGH
Definition SO3ShadowManager.h:63
void calculateSplitPoints(size_t cascadeCount, Ogre::Real firstSplitDist, Ogre::Real farDist, Ogre::Real lambda=0.95)
Definition SO3ShadowCSM.cpp:397
virtual void getShadowCamera(const Ogre::SceneManager *sm, const Ogre::Camera *cam, const Ogre::Viewport *vp, const Ogre::Light *light, Ogre::Camera *texCam, size_t iteration) const
Returns a stable CSM shadow camera for the given iteration.
Definition SO3ShadowCSM.cpp:428
void setSplitPadding(Ogre::Real pad)
Definition SO3ShadowCSM.h:96
void setSplitPoints(const SplitPointList &newSplitPoints)
Definition SO3ShadowCSM.cpp:419
~StableCSMShadowCameraSetup()
Definition SO3ShadowCSM.cpp:393
void getShadowCameraForCascade(const Ogre::SceneManager *sm, const Ogre::Camera *cam, const Ogre::Viewport *vp, const Ogre::Light *light, Ogre::Camera *texCam, size_t iteration, Ogre::Real nearSplit, Ogre::Real farSplit) const
Definition SO3ShadowCSM.cpp:452
StableCSMShadowCameraSetup(Ogre::SceneManager *ogreScene, CSMGpuConstants *constants)
Definition SO3ShadowCSM.cpp:386
size_t mCurrentIteration
Definition SO3ShadowCSM.h:123
const SplitPointList & getSplitPoints() const
Returns the calculated split points.
Definition SO3ShadowCSM.h:110
SplitPointList mSplitPoints
Definition SO3ShadowCSM.h:120
std::vector< Ogre::Real > SplitPointList
Definition SO3ShadowCSM.h:74
Definition OgreNewt_Debugger.h:21
Definition SO3DataScol.h:38
std::unordered_map< std::string, SMaterial * > SMaterialMap
Definition SO3Prerequisites.h:269
std::unordered_map< std::string, SMaterialMap * > SGroupMaterialMap
Definition SO3Prerequisites.h:270
Generated by 1.9.8