Shadow problem

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
kowinis
Gnoblar
Posts: 7
Joined: Fri Mar 20, 2015 10:39 pm

Shadow problem

Post by kowinis »

hi,

i`m having hard time trying shadows to get going, i tried implementing few shader programs i found on ogre forums:
http://www.ogre3d.org/forums/viewtopic.php?f=1&t=46819
http://www.ogre3d.org/forums/viewtopic.php?f=11&t=52354

but i always encounter the same froblem , shadows seem to flcker/disapear at some angles of camera like in this video:
[youtube]https://www.youtube.com/watch?v=kq-_TubF1fQ[/youtube]

i have the same problem with directional, post, and point lights, and if i add multiple lights ( same or diferent types) it gets even worse,
thres nothing special how i setup my scene, i use simple BasicApplication code and just add the code provided with the shader from threads above.

any help would be appreciated,
R
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: Shadow problem

Post by areay »

I have had that exact problem many times with PSSM. What you need to do is adjust your optimal adjust values. Invest a little time to make a debug gui widget with sliders to adjust each of those values, one per split. You should also play with the 'optimal adjust' boolean and shadow biasing. I have a gui widget that lets me adjust all of these things and updates my shaders in real time. It takes ages to get it all looking correct.

Here's my example config that I use after playing around with the widget, it's not Ogre code, just values that I read from my config file when the game starts. These values won't work for you because it's all scene dependent, how big it is, what your shadow distance is, near clip distance etc etc.

I render front faces, not back

Code: Select all

ShadowCasterBias = 0.00
ShadowFixedBias =  0.00000036
ShadowSampleOffset = 0.25
ShadowGradientClamp = 0.0 // I don't use this anymore
ShadowGradientScaleBias = 0.0 // I don't use this anymore
ShadowOptimalAdjust1 = 3
ShadowOptimalAdjust2 = 2.25
ShadowOptimalAdjust3 = 0
ShadowSplitPaddingMultiplier = 2
ShadowSimpleAdjust = false
Here's some actual setup, note that I skew the distribution of splits as an additional parameter to 'calculateSplitPoints'

Code: Select all

	m_pSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED);
	m_pSceneMgr->setShadowFarDistance(600);
	m_pSceneMgr->setShadowTextureCount(3);
	m_pSceneMgr->setShadowTexturePixelFormat(Ogre::PF_FLOAT32_R);

	m_pSceneMgr->setShadowTextureCountPerLightType(Ogre::Light::LT_DIRECTIONAL, 3);

	// shadow camera setup
	m_pPSSM = new Ogre::PSSMShadowCameraSetup();

	m_pSceneMgr->setShadowTextureConfig(0, 1024, 1024, Ogre::PF_FLOAT32_R, 0, 50);
	m_pSceneMgr->setShadowTextureConfig(1, 1024, 1024, Ogre::PF_FLOAT32_R, 0, 50);
	m_pSceneMgr->setShadowTextureConfig(2, 1024, 1024, Ogre::PF_FLOAT32_R, 0, 50);

	m_pPSSM->calculateSplitPoints(3, m_pCamera->getNearClipDistance(), m_pSceneMgr->getShadowFarDistance(), 0.85f); 

	m_pPSSM->setUseAggressiveFocusRegion(true);
	m_pPSSM->setCameraLightDirectionThreshold(Ogre::Degree(15.0));

        m_pPSSM->setUseSimpleOptimalAdjust(false);
	m_pSceneMgr->setShadowTextureSelfShadow(false);
	m_pSceneMgr->setShadowCasterRenderBackFaces(false);
	m_pSceneMgr->setShadowTextureCasterMaterial("PSSM/shadow_caster");
	m_pSceneMgr->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(m_pPSSM));

And here's my texture material for the shadow maps

Code: Select all

abstract texture_unit texture_units/shadow_tex
{
	content_type shadow
	tex_address_mode border
	tex_border_colour 1.0 1.0 1.0 1.0
	
	 filtering anisotropic anisotropic none
}
Despite all this I still get jitter and blockiness at certain angles, like where the dir light is parallel with the camera's direction. Good luck kowinis, I'm more than happy to swap notes about this.
kowinis
Gnoblar
Posts: 7
Joined: Fri Mar 20, 2015 10:39 pm

Re: Shadow problem

Post by kowinis »

hi areay,

thnx for reply, for the moment unfortunately my laptop(wich i use for my project) broke down :/ i have all the files and etc. , but for now is all i`m left with is this wooden pc, and my wifes laptop, wich was forged in middleages, both cant even handle shadows...so for next few weeks i`ll have to work on other parts of the project, but as soon as i`ll get my hands on my laptop, i`ll try your suggestions, i am new to shaders ( and programing in general ),i wanted to find "out of the box solution" but seeing i`m gonna have to get my hands dirty - ill try to implement it with tutorial depth shadow maping first ,since shader codes i found on forum would be too complex for me to crack...
I`ll update you with my progress, thnx again :)
Max98
Gnoblar
Posts: 11
Joined: Sun Feb 22, 2015 1:10 pm
x 1

Re: Shadow problem

Post by Max98 »

Any solution found yet? I have the exact same problem, shadows get screwed up depending on the angle of the camera. The more it's parallel to the light's direction, the more it gets blurry.
kowinis
Gnoblar
Posts: 7
Joined: Fri Mar 20, 2015 10:39 pm

Re: Shadow problem

Post by kowinis »

didnt foundt any solution myself just downloaded nullsquareds soft shadows demo , and it worked for me, athough its hard to find a working link to that demo but is out there somwhere..:D pm me if you want i can email .zip of it to you ^^ its not the best solution but ill do for now:)
Max98
Gnoblar
Posts: 11
Joined: Sun Feb 22, 2015 1:10 pm
x 1

Re: Shadow problem

Post by Max98 »

With some testing, I believe the flickering can be caused by a bad tuned shadowFarDistance (try to increase it) or a bad tuned SplitPadding.
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: Shadow problem

Post by areay »

I think that the flickering can be improved but that it's inherent with LiPSM (which PSSM and PSVSM use). When you get your padding, near/far distances, optimal adjust values and offsets setup well for your scene you don't notice flickering very much and users don't notice at all. I think half the problem is that most of us have never paid as much attention to shadows in other games as we have our own :D
Post Reply