[2.1] flickering bad shadows on model

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


User avatar
Thyrion
Goblin
Posts: 224
Joined: Wed Jul 31, 2013 1:58 pm
Location: germany
x 8

[2.1] flickering bad shadows on model

Post by Thyrion »

Hi,

just started to use shadows. What can i do against this bad looking,flickering shadows?
I'm currently using just one directional light.
I'm using this function to set the shadows: http://www.ogre3d.org/forums/viewtopic. ... 34#p522394
I'm using the following settings:
numShadowCastingLights = 1
resolution = 2048
usePssm = true
numPssmSplits = 3,
shadowFilter = Ogre::HlmsPbs::PCF_3x3
crapShadows.png
If i don't use the function, the shadows on the model are looking good, but the model doesn't 'cast' shadows on the floor -_-
You do not have the required permissions to view the files attached to this post.
User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 51

Re: [2.1] flickering bad shadows on model

Post by SolarPortal »

How far does your directional shadow cast? 250 is a nice number with good quality.

This can also happen when the light is just grazing off the model. Try rotating the light to see if the same quality is all the way around.

Hope this helps :)
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 169

Re: [2.1] flickering bad shadows on model

Post by xrgo »

The second picture you posted has no shadows at all, those "shadows" you see are just dark faces of the mesh because light can't reach (aka NdotL=0) and you have no ambient light so it looks very dark.
So lets talk about the first picture, with the ugly shadows. the main problem I see is peter panning, you'll need to adjust mShadowConstantBias just so you don't get shadow acne, and that's very hard. Increasing shadow resolution helps a lot. There are a few techniques to help with that (reduce peter panning without introducing acne), like slope scale bias but I tried to implement them once and I couldn't (too noob).
And about the flickering, something I've always wanted is Stable Shadows http://www.garagegames.com/community/blogs/view/21284 but I tried to implement them once and I couldn't (again... too noob). This would solve 99% of that issue

sorry for not being too helpful :P
User avatar
Thyrion
Goblin
Posts: 224
Joined: Wed Jul 31, 2013 1:58 pm
Location: germany
x 8

Re: [2.1] flickering bad shadows on model

Post by Thyrion »

SolarPortal wrote:How far does your directional shadow cast? 250 is a nice number with good quality.
This can also happen when the light is just grazing off the model. Try rotating the light to see if the same quality is all the way around.
Hope this helps :)
Do you mean this?:

Code: Select all

//Set sane defaults for proper shadow mapping
			mOgreSceneMgrPtr->setShadowDirectionalLightExtrusionDistance(500.0f);
			mOgreSceneMgrPtr->setShadowFarDistance(500.0f);
Should the rotation change the quality of the shadows? tried it but it's the same in every direction.
Did you get the shadows work properly, without any problems? (screens? Did you customize something?)
xrgo wrote:The second picture you posted has no shadows at all, those "shadows" you see are just dark faces of the mesh because light can't reach (aka NdotL=0) and you have no ambient light so it looks very dark.
Well, now as you say it. :)
xrgo wrote: So lets talk about the first picture, with the ugly shadows. the main problem I see is peter panning, you'll need to adjust mShadowConstantBias just so you don't get shadow acne, and that's very hard. Increasing shadow resolution helps a lot. There are a few techniques to help with that (reduce peter panning without introducing acne), like slope scale bias but I tried to implement them once and I couldn't (too noob).
And about the flickering, something I've always wanted is Stable Shadows http://www.garagegames.com/community/blogs/view/21284 but I tried to implement them once and I couldn't (again... too noob). This would solve 99% of that issue

sorry for not being too helpful :P
You shocked me! I don't want to implement that, nor i'm able to do that :(

So my only option to fix that, is playing around with:
4. The default shadow bias for every material is 0.01f. Perhaps this is too much/little for you? Adjust it via HlmsDatablock::mShadowConstantBias.

Will try it (How stupid from me. Expecting that shadows would work out of the box -_- ).
User avatar
Thyrion
Goblin
Posts: 224
Joined: Wed Jul 31, 2013 1:58 pm
Location: germany
x 8

Re: [2.1] flickering bad shadows on model

Post by Thyrion »

Well, values from 0 to 1 for mShadowConstantBias doesn't help.
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 169

Re: [2.1] flickering bad shadows on model

Post by xrgo »

Thyrion wrote:Well, values from 0 to 1 for mShadowConstantBias doesn't help.
but you do see a difference? more/less acne less/more peterpanning (if not you must be doing something wrong), its very hard to find the perfect value and sometimes its impossible, in my case I just live with a little of both, and 4k shadowmaps and 4x4 pcf, looks good enough =).
You can play with the lambda too so near shadowmaps looks higher res.
Thyrion wrote:Expecting that shadows would work out of the box -_- )
they mostly do, its just impossible to have default values to fit every scene configuration.
User avatar
Thyrion
Goblin
Posts: 224
Joined: Wed Jul 31, 2013 1:58 pm
Location: germany
x 8

Re: [2.1] flickering bad shadows on model

Post by Thyrion »

xrgo wrote:its very hard to find the perfect value and sometimes its impossible, in my case I just live with a little of both, and 4k shadowmaps and 4x4 pcf, looks good enough =).
You can play with the lambda too so near shadowmaps looks higher res.
Yes i tried resolution 4096 and PCF_4x4. The flickering is gone and the shadows are looking good, except those white spaces!
I already noticed them in the 2.1 Samples and in the upcomming wild west shooter.
whitespace.png
whitespace.png
whitespace.png
xrgo wrote:they mostly do, its just impossible to have default values to fit every scene configuration.
in UE4 it "just" works. -_-
You do not have the required permissions to view the files attached to this post.
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 169

Re: [2.1] flickering bad shadows on model

Post by xrgo »

Thyrion wrote:The flickering is gone and the shadows are looking good
good! I hope you didn't get too much performance loss :P
Also you could try root->getHlmsManager()->setShadowMappingUseBackFaces(false); but you'll need to play with the bias again.
Thyrion wrote:in UE4 it "just" works. -_-
maybe the defaults just happened to fit the scene you tried =), I have seen myself this problems in UE4, it might be less common because maybe they implemented those features I mentioned, but its definitely there, its a well known problem with shadow mapping :P
https://forums.unrealengine.com/showthr ... b8d4d9007c
User avatar
GlowingPotato
Goblin
Posts: 211
Joined: Wed May 08, 2013 2:58 pm
x 10

Re: [2.1] flickering bad shadows on model

Post by GlowingPotato »

Yeah, shadows is a pain in the a** to get it working right.

I can't get the bias low enough, bugs starts to appear if u use anything below 0.5.
And the current implementation have a lot of precision problems.

In Sunset Ranges(the wild west shooter), we have multiple shadow presets like this:

Code: Select all

ompositor_node_shadow LowShadowNode {
	technique pssm

	num_splits 3
	pssm_lambda 0.85
	shadow_map 0 512 512 PF_D32_FLOAT light 0 split 0
	shadow_map 1 1024 1024 PF_D32_FLOAT light 0 split 1
	shadow_map 2 2048 2048 PF_D32_FLOAT light 0 split 2
	
	shadow_map 0 1 2 {
		pass clear {
			colour_value 1 1 1 1
		}        
		pass render_scene {}
	}
}

compositor_node_shadow MediumShadowNode {
	technique pssm

	num_splits 3
	pssm_lambda 0.85
	shadow_map 0 1024 1024 PF_D32_FLOAT light 0 split 0
	shadow_map 1 2048 2048 PF_D32_FLOAT light 0 split 1
	shadow_map 2 2048 2048 PF_D32_FLOAT light 0 split 2
	
	shadow_map 0 1 2 {
		pass clear {
			colour_value 1 1 1 1
		}        
		pass render_scene {}
	}
}

compositor_node_shadow HighShadowNode {
	technique pssm

	num_splits 3
	pssm_lambda 0.85
	shadow_map 0 2048 2048 PF_D32_FLOAT light 0 split 0
	shadow_map 1 2048 2048 PF_D32_FLOAT light 0 split 1
	shadow_map 2 4096 4096 PF_D32_FLOAT light 0 split 2
	
	shadow_map 0 1 2 {
		pass clear {
			colour_value 1 1 1 1
		}        
		pass render_scene {}
	}
}

compositor_node_shadow VeryHighShadowNode {
	technique pssm

	num_splits 3
	pssm_lambda 0.85
	shadow_map 0 2048 2048 PF_D32_FLOAT light 0 split 0
	shadow_map 1 4096 4096 PF_D32_FLOAT light 0 split 1
	shadow_map 2 4096 4096 PF_D32_FLOAT light 0 split 2
	
	shadow_map 0 1 2 {
		pass clear {
			colour_value 1 1 1 1
		}        
		pass render_scene {}
	}
}

More than 3 shadow cascades is a HUGE performance bottle neck for us.

The very high preset have two 4k maps. Is very resource hungry, the high preset is good enough. Bias still present in any preset.
Those settings will vary from project to project.

Regarding Unreal, they have mages and wizards working on that shi*. Its just unreal.
User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 51

Re: [2.1] flickering bad shadows on model

Post by SolarPortal »

Should the rotation change the quality of the shadows? tried it but it's the same in every direction.
Sorry, i was not meaning this. But rotating the light or model to get the head in full shadow to see the quality is what i meant. It was to see if the same lines existed while fully shadowed.

We use a similar technique to GlowingPotato and have multiple shadow qualities which could be controlled from the end game.
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk