Sunday, February 26, 2012

Fake Parallax

Offsetting texture UVs via the camera normal


A good example of this shader is to imagine a building with a window cut into it, allowing the viewer to see through into the room beyond. Instead of modeling out the interior (which can be prohibitive in computer game environments where this trick is often applied) we can use a texture of the room instead, aligned roughly to the outside wall, with an offset to give the viewer a parallax cue in order to make it appear as though the room has some sort of three dimensional depth.

This is easier to understand when we can see things in motion - here's a quick setup scene to help illustrate.




Obviously this technique has some limitations, but when used in mid to background elements in shots where the camera motion isn't too extreme, it may be just the thing needed to help add some quick depth to a 3D scene, cutting down on the time spent modeling, texturing and lighting an interior.

So let's look at how we can go about setting up a shader which can recreate this parallax effect in Maya...