Thursday, May 12, 2016

Sheathed in Shadow

First off, let's start with a fun fact: humans don't perceive lighting detail in a linear scale; it's actually a scale of 1/2.2, instead of 1/1. What's a girl to do? One can actually change the color by a power of 1/2.2 to apply gamma correction to provide much more detail in darkened areas:


As for the big stuff today, that was shadow mapping. When actually detailing shadows, one must figure where the area is not directly "seen" by the light, thus draped in shadow. By using a render-to-texture depthmap (hello framebuffer) that colors the closest depths into a 2D texture, one can provide a directional shadow map:


Ew, gross. That's something called shadow acne, where fragments hit in the depth map actually take similar values, providing an ugly pattern. By decreasing the depth by a certain bias, one can reduce this pattern. However, this also produces "Peter Panning" of shadows, in which they depart from their objects. By rendering the back faces in the depth map (Face culling!), one can produce proper shadows like these:


However, much like aliasing, the shadows themselves need some sampling, or in this case percentage closer filtering, in order to get smoother values. Here is a simple version for now:


These are all fine and dandy techniques, but how are they applied to a point light, as opposed to a directional light? Omnidirectional shadow maps! Well, they're more like six-sided, cubemap shadow maps. By using a cubemap and creating the depthmap in six direction faces (with a little extra help from geometry shaders), one can create shadows that can be attributed to a single point, rather than a direction of light:


Phew! We'll get cooking with some other maps tomorrow.

No comments:

Post a Comment