Friday, May 13, 2016

Super Shiny

Today was a day to learn a couple more interesting topics (and review a few).

First off, normal mapping. Ever wonder what normal maps are for? They generally can take fragments (pixels, not vertices) and can apply a 2D texture of color values (think the colors as directions: z - blue, y - green, x - red) to the fragments to displace their normals for an incredible amount of cheap detail.

However! This assumes that the texture is always pointing toward the z direction. This won't do for lighting! We require another coordinate space specific to the texture (tangent space), with specific vectors (normal, tangent, bitangent) that form a sort of lookAt vector for that space. Combine that with the normal displacement to create a flexible form of bump mapping:


One can also do a similar thing with parallax mapping, where the view direction (the camera position) is used in relation to a provided heightmap texture (separate from the normals; we still need it for lighting) in order to actually change the texture coordinates in regards to how one looks at it. It's still a 2D texture, but it provides one heck of an optical illusion of depth.

As for improvements, clamping the border to prevent any artifacts and actually linearly interpolating between two layers of depth (one can sample extra layers to determine where to change the coordinates for parallax mapping) for this sexy brick wall here:


As for the big thing today? HDR (high dynamic range)! Usually, monitors limit color values from 0.0 to 1.0. What should be done if the ranges go above that? Using a larger framebuffer (think 16-bit, not 8-bit) and post-processing, one can actually take a 2D screen buffer containing light values higher than 1.0 and apply it as actual brightness to bright enough intensities. Combine that with an exposure (not automatic, unfortunately), and one can produce environments naturally suited to high and low light conditions. Behold!


This can prevent a bunch of white-out in bright day-time locations, but can also bring plenty of detail to low-light situations with a light-at-the-end-of-the-tunnel feel.

What's next? The end of advanced lighting! Yikes. I really liked getting back into this stuff.

No comments:

Post a Comment