Interior Mapping Shader

A fast shader for quickly approximating building geometry

I spent some time in 2011 studying OpenGL and GLSL shader techniques for a class on computer graphics. During this course I came across the technique known as “interior mapping”, described by Joost van Dongen (creator of the gorgeous independent racing game Proun) in this paper.

The technique describes how one can use a fragment shader to approximate the position of evenly-spaced internal planes cast perpendicular to each other throughout a 3D model. By using very simple math, you can estimate which plane is closest to the camera and use it to draw what the “interior” of the model would look like. While this is of little to no use for organic shapes, it can be used as a component of a structure shader to create a pretty convincing estimation of a building’s interior for only a constant cost per pixel, perfect for flight simulators and other real-time rendering projects that require an efficient way to add depth to a large cityscape. Indeed, a more elaborate version of this technique is visibly used in Insomniac Games’ 2018 Spider-Man game for PS4.