January - "2.5D"

Voxel space rendering

Map

Path

Pitch

Camera height

About this demo

This is an implementation of an old rendering technique called voxel space rendering commonly used in the 1990's

The math

color map depth map

We are given a height and color map, call it c(p)c(p) and d(p)d(p). Where p[0,1]×[0,1]p\in[0,1]\times[0,1] is the point on the map to be sampled. Suppose the camera is at some point c[0,1]×[0,1]c\in[0,1]\times[0,1], with height hh. Voxel space rendering works by scanning the view frustum in a back to front order, for each point pp on the frustum, we calculate the height of the rasterized point with the formula,

d(p)hzz=cp\frac{d(p)-h}{z}\qquad\qquad z=||c-p||

Where d(p)hd(p)-h is the height of the point relative to the camera, and zz is a scaling term used to perform perspective projection. We can adjust the pitch of the camera by adding an offset term, oo to the formula,

d(p)hz+oz=cp\frac{d(p)-h}{z}+o\qquad\qquad z=||c-p||

Effectively translating the image by a fixed value. We draw a vertical line from the bottom of the rasterized image to the calculated height with the sampled color c(p)c(p).

References

https://github.com/s-macke/VoxelSpace

© 2022 Designed & Built by Jun Lim