Shadows
Posted: 09 Jul 2017, 21:02
Since I won't have time to work on shadows anytime soon, I might as well post what I tried a while ago:
https://github.com/scrawl/openmw/tree/osgshadow
This was a very basic test of osgShadow's ViewDependentShadowMap (supposedly their most advanced, and full featured, shadow technique). But here's where everything went wrong (that I can remember):
- Due to a bug introduced with OSG 3.4, Drawables not attached to Geodes (such as OpenMW's) are not considered for the shadow frustum, this has been fixed in the OSG git master (and possibly a point release, can't remember).
- The ViewDependantShadowMap is, for some reason, hard coded to just 2 splits. Most games use at least 3. This may or may not turn out to be an actual issue, if the other issues can be resolved?
- The terrain's multi-pass material is not integrated properly so the terrain looks white.
- Polygons facing away from the light source display a flickering effect (this is normal, and can be resolved by using a shader so that back-facing polygons are always shadowed).
- From certain camera angles, the shadow projection goes totally wonky and all blurry. I have no idea why this is. I tracked down the change to some magic calculations with 1-letter variable names that I could make no sense of.
- Note that if you turn on shadow map debugging, the scene's shadow rendering will break; due to a bug (or missing feature?) in the debugging feature.
It's really hard to say if it's worth continuing with osgShadow or should we try making our own shadow module from scratch.
https://github.com/scrawl/openmw/tree/osgshadow
This was a very basic test of osgShadow's ViewDependentShadowMap (supposedly their most advanced, and full featured, shadow technique). But here's where everything went wrong (that I can remember):
- Due to a bug introduced with OSG 3.4, Drawables not attached to Geodes (such as OpenMW's) are not considered for the shadow frustum, this has been fixed in the OSG git master (and possibly a point release, can't remember).
- The ViewDependantShadowMap is, for some reason, hard coded to just 2 splits. Most games use at least 3. This may or may not turn out to be an actual issue, if the other issues can be resolved?
- The terrain's multi-pass material is not integrated properly so the terrain looks white.
- Polygons facing away from the light source display a flickering effect (this is normal, and can be resolved by using a shader so that back-facing polygons are always shadowed).
- From certain camera angles, the shadow projection goes totally wonky and all blurry. I have no idea why this is. I tracked down the change to some magic calculations with 1-letter variable names that I could make no sense of.
- Note that if you turn on shadow map debugging, the scene's shadow rendering will break; due to a bug (or missing feature?) in the debugging feature.
It's really hard to say if it's worth continuing with osgShadow or should we try making our own shadow module from scratch.