No more LiSPSM shadows with 13.6

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
suny
Greenskin
Posts: 137
Joined: Thu Mar 12, 2020 5:53 pm
x 60

No more LiSPSM shadows with 13.6

Post by suny »

Ogre Version: :?: 13.6
Operating System: :?: windows
Render System: :?: dx9c

Hi,
I was using 13.1 and updated Ogre to 13.6 today.
I'm using LiSPSM shadows in my engine and don't have any shadows anymore. I know LiSPSM is improved with the last update but is there something I need to change to make it work again?

What I'm doing:

Code: Select all

struct shadowListener: public Ogre::ShadowTextureListener
{
    // this is a callback we'll be using to set up our shadow camera
    void shadowTextureCasterPreViewProj(Ogre::Light *light, Ogre::Camera *cam, size_t)
    {
        float range = light->getAttenuationRange();
        cam->setNearClipDistance(0.01);
        cam->setFarClipDistance(range);
    }

void shadowTexturesUpdated(size_t) {}
void shadowTextureReceiverPreViewProj(Ogre::Light*, Ogre::Frustum*) {}
void preFindVisibleObjects(Ogre::SceneManager*, Ogre::SceneManager::IlluminationRenderStage, Ogre::Viewport*) {}
void postFindVisibleObjects(Ogre::SceneManager*, Ogre::SceneManager::IlluminationRenderStage, Ogre::Viewport*) {}
} shadowCameraUpdaterPlay;

Code: Select all

void playState::initShadows()
{
    // we'll be self shadowing
    mSceneMgr->setShadowTextureSelfShadow(true);
	mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED);
	mSceneMgr->setShadowTextureCount(1);
	mSceneMgr->setShadowDirLightTextureOffset( 0.2 );
	mSceneMgr->setShadowDirectionalLightExtrusionDistance(400);
	mSceneMgr->setShadowFarDistance(200);
    	// the size, too (1024 looks good with 3x3 or more filtering)
	mSceneMgr->setShadowTextureSize(game->shadowTextureSize);

mSceneMgr->setShadowTexturePixelFormat(Ogre::PF_FLOAT32_GR);

 mSceneMgr->setShadowCasterRenderBackFaces(false);

	Ogre::TexturePtr tex = mSceneMgr->getShadowTexture(0);
	Ogre::Viewport *vpo = tex->getBuffer()->getRenderTarget()->getViewport(0);
	vpo->setBackgroundColour(Ogre::ColourValue(1, 1, 1, 1));
 vpo->setClearEveryFrame(true);

camSetup = OGRE_NEW Ogre::LiSPSMShadowCameraSetup;
camSetup->create(200, true, Ogre::Degree(5));

camSetup->setCameraLightDirectionThreshold(Ogre::Degree(5));
camSetup->setUseAggressiveFocusRegion(true);
camSetup->setOptimalAdjustFactor((Ogre::Real) 200);
mSceneMgr->setShadowFarDistance(270); //200 - bigger for 45 degrees
 mSceneMgr->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(camSetup));

	// and add the shader listener
 mSceneMgr->addShadowTextureListener(&shadowCameraUpdaterPlay);
}
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: No more LiSPSM shadows with 13.6

Post by paroj »

those magic tuning parameters like

Code: Select all

setShadowDirLightTextureOffset( 0.2 )
setShadowDirectionalLightExtrusionDistance(400)
setOptimalAdjustFactor((Ogre::Real) 200)

must be updated for 13.6. I would suggest removing all of them and see whether it works. Also try switching to FocusedShadowCameraSetup for testing.

User avatar
suny
Greenskin
Posts: 137
Joined: Thu Mar 12, 2020 5:53 pm
x 60

Re: No more LiSPSM shadows with 13.6

Post by suny »

Thanks!

I tried to remove the magic numbers but without result.
I then tried to use FocusedShadowCameraSetup, but still no shadows.

At the end, my code is:

Code: Select all

mSceneMgr->setShadowTextureSelfShadow(true);
mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED);
mSceneMgr->setShadowTextureCount(1);
mSceneMgr->setShadowTextureSize(game->shadowTextureSize);
mSceneMgr->setShadowTexturePixelFormat(Ogre::PF_FLOAT32_GR);
mSceneMgr->setShadowCasterRenderBackFaces(false);

Ogre::TexturePtr tex = mSceneMgr->getShadowTexture(0);
Ogre::Viewport *vpo = tex->getBuffer()->getRenderTarget()->getViewport(0);
vpo->setBackgroundColour(Ogre::ColourValue(1, 1, 1, 1));
vpo->setClearEveryFrame(true);
camSetup = OGRE_NEW Ogre::FocusedShadowCameraSetup;
camSetup->create();
mSceneMgr->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(camSetup));

// and add the shader listener
mSceneMgr->addShadowTextureListener(&shadowCameraUpdaterPlay);

What can I try to pinpoint the issue? I'm not sure of what could have changed between 13.1 and 13.6.
S.

paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: No more LiSPSM shadows with 13.6

Post by paroj »

well there are shadow related changes in 13.6, so try whether 13.5 works..

User avatar
suny
Greenskin
Posts: 137
Joined: Thu Mar 12, 2020 5:53 pm
x 60

Re: No more LiSPSM shadows with 13.6

Post by suny »

Tried Version 13.5.3 and I don't have shadows anymore.
S.

Post Reply