[Solved]Shadow oddities

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


Sweenie
Silver Sponsor
Silver Sponsor
Posts: 92
Joined: Wed Mar 23, 2005 3:29 pm
Location: Sweden
x 1

[Solved]Shadow oddities

Post by Sweenie »

Hi.

I'm getting some annoying shadow artifacts from the directional light that I assumed was shadow acne, but no matter what I set the bias to, it won't go away.

I'm using OgreNext 2.2.0 fresh clone from today. I've had these artifacts for some time though so it's not something that happened recently but now I have given up trying to figure it out on my own. :oops:

Setting bias to 0.01

Code: Select all

mRoot->getHlmsManager()->getHlms(HLMS_PBS)->getDefaultDatablock()->mShadowConstantBias = 0.01f;
Image
Image

Setting bias to 1.00, expected the acne to go away and some "peter panning" to occur, but nothing seems to happen.

Code: Select all

mRoot->getHlmsManager()->getHlms(HLMS_PBS)->getDefaultDatablock()->mShadowConstantBias = 1.00f;
Image

I'm setting the bias constant right before the rendering loop, but could something be overriding my bias constant? I searched through the media files but nothing seems to set the bias there.
Changing the light direction doesn't make a difference either.

Code: Select all

	mSceneManager->setShadowDirectionalLightExtrusionDistance(500.0f);
	mSceneManager->setShadowFarDistance(500.0f);

Code: Select all

	texture atlas		2048 7168 PFG_D32_FLOAT
	texture tmpCubemap	1024 1024 PFG_R32_FLOAT cubemap depth_format PFG_D32_FLOAT

	num_splits		3
	pssm_lambda		0.85
	shadow_map 0 atlas uv 0.0 0.000000000000000 1.0 0.285714285714286 light 0 split 0
	shadow_map 1 atlas uv 0.0 0.285714285714286 0.5 0.142857142857143 light 0 split 1
	shadow_map 2 atlas uv 0.5 0.285714285714286 0.5 0.142857142857143 light 0 split 2
Last edited by Sweenie on Wed Nov 13, 2019 11:42 am, edited 1 time in total.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5511
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1379

Re: Shadow oddities

Post by dark_sylinc »

Hi!

The default datablock is used as fallback when a material couldn't be found or had errors, not as default settings.

Thus unless the object is actually using the default datablock, changing its mShadowConstantBias won't actually do anything to your scene.

Change your datablock's via:

Code: Select all

for( size_t i=0u; i<item->getNumSubItems(); ++ )
    item->getSubItem( i )->getDatablock()->mShadowConstantBias = 1.0f;
Also remember negative values are valid too.
Sweenie
Silver Sponsor
Silver Sponsor
Posts: 92
Joined: Wed Mar 23, 2005 3:29 pm
Location: Sweden
x 1

Re: Shadow oddities

Post by Sweenie »

aha, that explains it. Thank you.

Now i actually see a difference, though I'm still having a hard time getting the shadows right. I would settle with pretty ok, but right now i only get two variants of pretty bad.

Bias = 0.01 , Black zig-zags on seams of lit surfaces, and some bright pixels on surfaces that should be completely in shadow.
Image

Bias = 2.5, Now the panning is almost gone and the bright pixels are almost gone as well but the black zig-zags are even worse.
Image

Bias = -3.0, Here the zig-zags are mostly gone at close distance but the panning is pretty bad and the bright pixels are back with a vengeance. :lol:
Image

It feels like i'm doing something wrong because other users seems to get this right.

The geometry are a bunch of stacked boxes(1x1x1 meter), a bit like minecraft(not doing a "voxel" or minecraft game).
Sweenie
Silver Sponsor
Silver Sponsor
Posts: 92
Joined: Wed Mar 23, 2005 3:29 pm
Location: Sweden
x 1

Re: Shadow oddities

Post by Sweenie »

I found the problem. I'm an idiot.

Disabling backfaces with setShadowMappingUseBackFaces(false) and a bias of -3 did the trick. :D
Image.

My ground(big white plane) got big acne problems after that but I only disabled castShadows to fix that.
There is just a little bit of panning at the top but that is totally acceptable and can probably be reduced with a bit more tuning.