Horde3D http://horde3d.org/forums/ |
|
[solved] Shadowmap bug? http://horde3d.org/forums/viewtopic.php?f=3&t=258 |
Page 1 of 1 |
Author: | Manny [ 20.03.2008, 11:34 ] |
Post subject: | [solved] Shadowmap bug? |
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). 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 |
Author: | marciano [ 20.03.2008, 12:36 ] |
Post subject: | |
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 ); |
Author: | Manny [ 20.03.2008, 12:52 ] |
Post subject: | |
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. |
Author: | AcidFaucet [ 20.03.2008, 15:58 ] |
Post subject: | |
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. |
Author: | Manny [ 20.03.2008, 17:46 ] |
Post subject: | |
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. |
Author: | marciano [ 20.03.2008, 20:06 ] |
Post subject: | |
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. |
Author: | DarkAngel [ 26.03.2008, 06:04 ] |
Post subject: | |
To me, this bug looks like it's caused by shadow bleeding/acne... Try playing with the light's ShadowMapBias value. |
Author: | marciano [ 29.03.2008, 22:50 ] |
Post subject: | |
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. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |