LiSPSM and directional lights

Problems building or running the engine, queries about how to use features etc.
Post Reply
foxbat
Greenskin
Posts: 131
Joined: Sun Sep 25, 2005 2:44 am
Location: Melbourne, Australia
x 20

LiSPSM and directional lights

Post by foxbat »

I was just wondering whether anyone has had any success yet in using LiSPSM with directional lights. In all my tests (including the Ogre shadow demo) the projection goes crazy when the camera is facing within about 90 degrees of the light vector. I'm using the latest 1.7 build.

Does the LiSPSM method theoretically support directional lights or is it limited to spotlights and point lights only? In the latter case it would be nice to have the engine automatically treat directional lights as spotlights just for shadow casting.
iigor
Gnome
Posts: 387
Joined: Thu May 08, 2008 3:46 pm
Location: Russia, Moscow

Post by iigor »

until 1.6 development ends there is no reason to use 1.7, because it's identical than first version of 1.6, so 1.6 now is more stable than 1.7, and 1.7 hasn't any new features than 1.6.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

It supports directional lights and I use it (as PSSM) all the time in that mode.

Just be careful about the settings you use, because there is a 'duelling frusta' problem when the camera is looking back towards the light. This is a challenge common to all shadow optimisation routines and all you can really do is try to minimise it. If you're getting a lot of distortion, play with the opt settings you're using, and consider PSSM to spread the resulting inaccuracy in a way that is less noticeable. If you're using directional lights PSSM is a better option than single-texture LiSPSM anyway; each texture uses LiSPSM but within a smaller, subdivided region.
foxbat
Greenskin
Posts: 131
Joined: Sun Sep 25, 2005 2:44 am
Location: Melbourne, Australia
x 20

Post by foxbat »

Ok I went to 1.6 RC1 and tried adjusting the following parameters:

setShadowDirLightTextureOffset
setShadowDirectionalLightExtrusionDistance
setUseAggressiveFocusRegion
setOptimalAdjustFactor


This is the best result I could come up with:

http://tinypic.com/player.php?v=2crr2i9&s=4

At the camera orientation right at the start of the video the shadows are more or less in the correct location, just really blocky and blury. At any other angles things go crazy. This is exactly how it used to be in the older Ogre builds with those Lispsm bugs.

Maybe I'm missing something?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

My guess is that your optimal adjust factor is way too low. It needs to be high for directional lights.

Here's some settings that work just fine:

Code: Select all

		mSceneMgr->setShadowTextureSize(1024);
		mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE);

		LiSPSMShadowCameraSetup* lispsmSetup = new LiSPSMShadowCameraSetup();
		lispsmSetup->setOptimalAdjustFactor(2);
		mSceneMgr->setShadowCameraSetup(ShadowCameraSetupPtr(lispsmSetup));

		mSceneMgr->setShadowFarDistance(3000);
		mSceneMgr->setShadowColour(ColourValue(0.35, 0.35, 0.35));
		mSceneMgr->setAmbientLight(ColourValue(0.3, 0.3, 0.3));

		mLight = mSceneMgr->createLight("MainLight");
		mLight->setType(Light::LT_DIRECTIONAL);
		Vector3 vec(-1,-1,0);
		vec.normalise();
		mLight->setDirection(vec);
Result:
ImageImage
foxbat
Greenskin
Posts: 131
Joined: Sun Sep 25, 2005 2:44 am
Location: Melbourne, Australia
x 20

Post by foxbat »

Changing the optimal adjust factor didn't help, but after further testing I believe the problem may be something to do with either the setup order or with switching between shadow types in the shadows demo. When I explicitly set Lispsm on scene load everything works fine. It's the process of manually selecting Lispsm in the GUI which creates problems. Exactly what the cause of this is, I don't know. Also, it appears that only directional lights are sensitive to this problem.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

The demo changes the optimal adjust factors on the fly, and it assumes spotlights. Don't use it as an example unless you're willing to change all that too. The code above proves there's nothing wrong with the LiSPSM itself here, it's just an optimal adjust setting that's throwing it out.
foxbat
Greenskin
Posts: 131
Joined: Sun Sep 25, 2005 2:44 am
Location: Melbourne, Australia
x 20

Post by foxbat »

I don't believe the problem is optimal adjust factor. I've removed all references to this in the demo and the problem still occurs.

Here are some screenshots showing what happens to the shadow projection:

After texture shadows and Lispsm is set (this works fine)
ImageImage

After switching to stencil shadows and back again to texture Lispsm:
ImageImage
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

This is probably just some bad state management. There's probably some other bug caused by changing the state which isn't being handled in the demo there. I don't see what point this serves - the issue isn't whether you can get LiSPSM to work properly with directional lights in Demo_Shadows - in a fresh app it works perfectly fine. I'm not going to go chasing ghosts in Demo_Shadows because it doesn't need to work there - I'm using LiSPSM in plenty of apps with directional shadows and the code snippet I posted above works. Is there a reason we're still talking about this that I'm missing?

Just ignore Demo_Shadows for the moment and whether it's UI can handle directional light settings, because it's not designed to. The code I posted previously works - if you have a clean case where it doesn't, please post the repro case.
Post Reply