Horde3D

Next-Generation Graphics Engine
It is currently 18.05.2024, 14:03

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Shadow Bias
PostPosted: 06.10.2008, 08:39 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
Good morning. Quick question on the shadow bias settings, with a large scenes im finding it virtually impossible to have a shadow bias suitable for all items based from one global value. Would it not be better (if its possible) to have it defined on a per object bases rather than per light?

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
 Post subject: Re: Shadow Bias
PostPosted: 06.10.2008, 10:13 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Good question. I never saw the bias on a per-object basis. The bias depends among other factors on the curvature of the surface, the size of the projected texels and also the radius of the light source (depth range). So I think it is not possible to find a global per-object bias that would work with all lights. But what I have been thinking about is having a different bias for each shadow map split (for the cascaded SMs).

We had the same problem as you back in the University days with our huge city scene. We found a solution that clearly reduces the biasing problem but requires ShaderModel 3 hardware. It is just a single line; it is already in the shaders but commented out. Look at the SHADOWMAP contexts.

Code:
// Clearly better bias but requires SM 3.0
gl_FragDepth =  dist + abs( dFdx( dist ) ) + abs( dFdy( dist ) ) + shadowBias;

In case you wonder about the dFdx/dFdy functions: They describe the rate of change of a value relative to the neighboring pixels. So this method better takes into account the curvature of surfaces.


Top
 Profile  
Reply with quote  
 Post subject: Re: Shadow Bias
PostPosted: 06.10.2008, 16:48 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
marciano wrote:
Code:
// Clearly better bias but requires SM 3.0
gl_FragDepth =  dist + abs( dFdx( dist ) ) + abs( dFdy( dist ) ) + shadowBias;
In case you wonder about the dFdx/dFdy functions: They describe the rate of change of a value relative to the neighboring pixels. So this method better takes into account the curvature of surfaces.
Just to warn you, dFdx/dFdy can be very expensive operations on early SM 3.0 hardware. Newer hardware will do fine though.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
 Post subject: Re: Shadow Bias
PostPosted: 06.10.2008, 17:09 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
Thanks for the replies. I will give it ago and see what happens, running a Geforce 8800GT.

I know Tor. Advanced Engine does lighting based on a per object bias, but that's probably a completely different system from Horde's. Its an interesting problem.

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group