About making 3D ray-traced model of the Moon, in Python, using real measurements.

1. Traveling Moon.

This summer a giant, 7m-diameter Moon installation by Luke Jerram traveled around European cities. It also visited Poland, where it was presented outdoor at the Copernicus Science Centre in Warsaw. The event had a great atmosphere, with people relaxing around, meeting friends, and taking photos. I also was there to explore lunar craters. The detail level of this 7m-tall construction means that 5km of the real Moon surface is projected on one centimeter of the model. When I approached it closely, I had the impression that below the centimeter scale, there are not many details, although it looked great from a distance. The installation made me curious about what data is available to make the Moon model of this size. I decided to make a data-viz project at RnD Team Studio and share results here and on Behance.

Here is what I have found: publicly available resources, from NASA obviously, are incredibly detailed. The elevation map highest resolution is 59 meters! Also, the actual colors of the surface are available at the high resolution of 480m. Shadows of the surface features are removed there, and the brightness is corrected for the inclination with respect to the light (Sun) direction. So, this is all you need to make a stunning 3D model for yourself. Actually, you should worry if this is not too much.

In this tutorial, I am going to make the Moon model using these public domain data and a few Python packages: Numpy for basic data preprocessing, OpenCV for 2D image scaling, Matplotlib for displaying images, and PlotOptiX for ray-tracing in 3D. Code presented in this tutorial is available on GitHub, in Jupyter notebooks. You can run notebooks on your local computer, or remotely, e.g. on the Google Cloud Platform for which I’ll give installation instructions on GitHub.

The tutorial aims to let you create as detailed Moon as your hardware can stand.

First, I made the Moon from a standard triangular mesh with nodes at positions corresponding to the sphere surface modified according to the elevation data. This approach turned out to be memory consuming, and I was not satisfied with the close-ups made of heavily downscaled data. Therefore I tried another way and used the elevation map to determine the sphere surface displacement on the fly, while the image is computed. This worked perfectly. In the tutorial, I’ll show both approaches, and explain differences in the algorithms used behind the scenes.