[[:start|Start Page]] >> [[dragengine:modules:main|Module System]] >> [[dragengine:modules:opengl:main|OpenGL Graphic Module]] >> **Improved lighting in shadows**
Lighting in shadows is always a problem. Physically there is difference in light intensity due to light bouncing, cavities or objects orientations. In games this is usually just flat since these kinds of secondary lighting information are too complex to add especially for dynamic scenes. To help remedy this problem the OpenGL Graphic Modules uses a little hack to add more depth to areas in shadows.
The basic observation is that a user notices more the **lack of light difference in curved surfaces** in shadows than he is going to notice an **incorrect amount of lighting** used for these differences. Using this obersation the lighting formula has been slightly adjusted. For ambient lighting in shadow areas the **dot product** used for pixels outside shadows is used too but in the reversed direction. The surface orientation is used as a sort of fake ambient occlusion term. Surfaces pointing away from the light source receive less ambient light than those approaching the perpandicular orientation. With light outside shadows this is the inverse where surfaces pointing towards the light source receive higher intensities than surface approach a perpendicula orientation.
In pracise the ambient light is reduced to 25% towards surfaces pointing straight away from the light source. This produces depth in ambient areas that is looking better than doing nothing (or using broken by design techniques like SSAO). This replaces the old ambient lighting hack that messed with the dot product in an ugly way. This solution is way better looking and stable.
The image below shows a comparison between using the improved lighting in shadows and using conventional flat shading.
{{ :dragengine:modules:opengl:imprshalig.png |Comparison between improved shading in shadows and conventional flat shading}}
Comparison between improved shading in shadows and conventional flat shading. The right image has the improved lighting enabled. Surfaces with different orientations receive now different amounts of ambient light. The ground texture too is slightly improved in depth using this technique although the ambient occlusion image reduces the effect.