Horde3D

Next-Generation Graphics Engine
It is currently 22.11.2024, 06:36

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: [solved] Shadowmap bug?
PostPosted: 20.03.2008, 11:34 
Offline

Joined: 20.12.2007, 00:18
Posts: 23
Hi!

I have a simple scene set up with some basic objects in it. If these objects overlap from the lights point of view I see some artefacts in the shadowing. It looks like the back facing polygons (that are in shadow) aren't being shadowed correctly. (So objects aren't self shadowing correctly either).

Image

This is present (but very difficult to see) in the chicago sample. Is this likely to be something setup incorrectly with the rendering, or potentially a bug in the shadowmap implementation?

Thanks


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 20.03.2008, 12:36 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
The artefact you describe comes from the lighting model implemented in the sample shaders. Currently we are using Half Lambert Lighting (default in Valve's Source Engine) which makes the lighting softer. You can easily change this to the standard model in fragLighting.glsl by replacing

Code:
// Half lambert lighting
float NdotL = dot( normal, light );
float diffuse = NdotL * 0.5 + 0.5;
diffuse = diffuse * diffuse;


with

Code:
// Standard Lambert lighting
float NdotL = dot( normal, light );
float diffuse = max( NdotL, 0.0 );


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 20.03.2008, 12:52 
Offline

Joined: 20.12.2007, 00:18
Posts: 23
I was actually referring to the shadow itself, rather than the lighting on the back of the models. It's actually the comparison here:

Code:
if( NdotL > 0.0 && att > 0.0 )


What is the purpose of the NdotL part? This is stopping back facing polys from being shadowed which I wouldn't have thought was desired behaviour.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 20.03.2008, 15:58 
Offline

Joined: 19.11.2007, 19:35
Posts: 218
NdotL is short hand for the dot product of the Normal and Lighting vector. That little spot of code makes sure that the normal is in the opposite direction of the shadow projector and therefore the reason shadows aren't being cast onto backfaces.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 20.03.2008, 17:46 
Offline

Joined: 20.12.2007, 00:18
Posts: 23
Yup, understood, although generally backface culling should be turned on so backfaces aren't rendered. Doing it like this means if you did happen to be rendering both front and back faces that not only would back faces not receive shadow (correct), but front faces facing away from the shadow projector will also not receive shadow (incorrect).

The latter effect is what I was mainly concerend with in the original image, where the pink torus is not in shadow on the faces directed away from the light source. I.e. you can see the green cyclinder casts a shadow that stops along the top of the torus.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 20.03.2008, 20:06 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
The NdotL is basically the angle between the light source and the face normal, not between the viewer and the face. Backface culling for the viewer is always enabled but for the light you need to take special care in the shaders.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 26.03.2008, 06:04 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
To me, this bug looks like it's caused by shadow bleeding/acne... Try playing with the light's ShadowMapBias value.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: 29.03.2008, 22:50 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
We have updated the lighting shaders of the samples in Horde 0.15 so that they are more suitable for general applications. The current ones are very specific to our samples. I think this will help solving your issues.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


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