MCPcopy Create free account
hub / github.com/OGRECave/ogre / applyShadowType

Method applyShadowType

Samples/ShaderSystem/src/ShaderSystem.cpp:847–939  ·  view source on GitHub ↗

-----------------------------------------------------------------------

Source from the content-addressed store, hash-verified

845
846//-----------------------------------------------------------------------
847void Sample_ShaderSystem::applyShadowType(int menuIndex)
848{
849 // Grab the scheme render state.
850 Ogre::RTShader::RenderState* schemRenderState = mShaderGenerator->getRenderState(Ogre::MSN_SHADERGEN);
851
852
853 // No shadow
854 if (menuIndex == 0)
855 {
856 mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);
857
858#ifdef RTSHADER_SYSTEM_BUILD_EXT_SHADERS
859 if (auto srs = schemRenderState->getSubRenderState(SRS_SHADOW_MAPPING))
860 {
861 schemRenderState->removeSubRenderState(srs);
862 }
863#endif
864
865 mTrayMgr->moveWidgetToTray(mDirLightCheckBox, TL_TOPLEFT, 1);
866 mTrayMgr->moveWidgetToTray(mPointLightCheckBox, TL_TOPLEFT, 2);
867 mTrayMgr->moveWidgetToTray(mSpotLightCheckBox, TL_TOPLEFT, 3);
868
869 mDirLightCheckBox->show();
870 mPointLightCheckBox->show();
871 mSpotLightCheckBox->show();
872
873 }
874
875#ifdef RTSHADER_SYSTEM_BUILD_EXT_SHADERS
876 // Integrated shadow PSSM with 3 splits.
877 else if (menuIndex >= 1)
878 {
879 auto casterMat = MaterialManager::getSingleton().getByName("PSSM/shadow_caster");
880 mSceneMgr->setShadowTextureCasterMaterial(casterMat);
881 mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED);
882 mSceneMgr->setShadowFarDistance(3000);
883
884 // 3 textures per directional light
885 mSceneMgr->setShadowTextureCountPerLightType(Ogre::Light::LT_DIRECTIONAL, 3);
886 mSceneMgr->setShadowTextureSettings(512, 3, PF_DEPTH16);
887 mSceneMgr->setShadowTextureSelfShadow(true);
888
889 // Leave only directional light.
890 mDirLightCheckBox->setChecked(true);
891 mPointLightCheckBox->setChecked(false);
892 mSpotLightCheckBox->setChecked(false);
893
894 mTrayMgr->removeWidgetFromTray(mDirLightCheckBox);
895 mDirLightCheckBox->hide();
896
897 // shadow camera setup
898 PSSMShadowCameraSetup* pssmSetup = new PSSMShadowCameraSetup();
899 pssmSetup->calculateSplitPoints(3, mCamera->getNearClipDistance(), mSceneMgr->getShadowFarDistance());
900 pssmSetup->setSplitPadding(mCamera->getNearClipDistance()*2);
901 pssmSetup->setOptimalAdjustFactor(0, 2);
902 pssmSetup->setOptimalAdjustFactor(1, 1);
903 pssmSetup->setOptimalAdjustFactor(2, 0.5);
904

Callers

nothing calls this directly

Calls 15

getRenderStateMethod · 0.80
getSubRenderStateMethod · 0.80
removeSubRenderStateMethod · 0.80
moveWidgetToTrayMethod · 0.80
showMethod · 0.80
setCheckedMethod · 0.80
hideMethod · 0.80
getShadowFarDistanceMethod · 0.80
setSplitPaddingMethod · 0.80

Tested by

no test coverage detected