(Note- before you read… this guy is way ahead of me… http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/HiRISE_DTM_from_PDS_IMG )
Here is a little intro to making a 3d terrain from the latest and greatest data collected by our robots orbiting Mars (as of 2015).
There have been many many Mars robots collecting terrain data over the years, but the Mars Reconnaisance Orbiter has probably one of the best cameras ever, the HiRISE camera, taking alot of photos. Sometimes, it even takes two photos of the same terrain from different angles…. then the geniuses at University of Arizona / HiRISE / NASA figure out how to stitch the photos together into elevation data, so they can figure out how tall the various features are on the surface of the planet. Just from two photos.
They call it “Digital Terrain Models”, DTM, and you can read about it here, all the nitty gritty details:
Can we put this into a video game? Well…. the first step I guess would be getting this data into some kinda 3d format. How?
Let’s try it out on a crater:
Credit: NASA/JPL/University of Arizona/USGS
Now, that is a nice picture. But it’s not what we need. Notice how you can see the Sun’s shadows? The Sun is at left – so the left side of the crater walls are brightened, and the right sides are darkened. This picture, therefore, does not represent pure elevation data. This picture has colors representing elevation (blue is lowest, then green, then yellow, then red, then white as highest), but the colors are blended with shadows. It is a “shaded relief map” as they say, where the ‘relief’ are the colors showing the topographical data (the elevations).
I need a pure elevation map (heightmap). Where the color only links to elevation, and there are no shadows. I needed to explore HiRISE’s website and see if there was one.
There are a lot of images listed there. I only want the small stuff.. my machine cannot handle a 250 megabyte JPEG2 image (and jpeg2 is not a very standard format in the open source world, you need a special OpenJPEG library tool to open it). What I wanted were the smaller JPEG samples.
After a bit of poking around I finally found what I wanted.
Notice how it’s a heightmap? You can tell because it’s all funky looking — there are no shadows from an ordinary sun on the crater. The entire crater floor has the same color – meaning it’s all at the same altitude. The entire rim is also nearly white. This map is showing us pure altitude – with black as the lowest, and white as the highest points. The shades of gray in between indicate how high above ‘black’ the land is at a given point.
Now… that image is roughly 1000×3300 pixels… still too big. So I opened up Kolourpaint and cropped it down to just the crater. Remember this is just an experiment, need to keep things kinda simple.
This is my heightmap! You can see much better here how the heightmap coloration is working to tell us about the elevation of points on the crater. Definitely no shadows. Just pure elevation data? Now…. how to get that heightmap into some 3d format? After all, this heightmap is still just a 2d image file.
Well, there are tons of ways. But there is a really popular free program called Blender, that, while notoriously difficult for newbies like myself, was, well, already installed on my system so I decided to try it. I found this nice tutorial by John Flower,
and in a few minutes I had a basic heightmap converted to 3d:
Now… what about Unity? That’s a nice game engine… easier than Blender for most people… but… well… it doesn’t exist on Linux yet and I’m using Linux. But I hope this little write-up will give an idea of… possibilities. Heightmaps are pretty popular in game development circles so a lot of tools will have ways to convert a heightmap image to a 3d format. So for now, we will leave it here.
Oh.. but PostScript! Fun facts regarding Stereo Photogrammetry:
How did the HiRISE folks make this heightmap? Well, poking around the HiRISE website a little bit tells us some of the answer. Pasted below are the two original images they combined – just ordinary photos with the Sun’s shadows clearly showing. Notice how one image is slightly off from the other? They were taken by the Mars Reconaissance Orbiter robot from different positions in space….
I am assuming these images should also be credited to one or more of NASA/JPL/University of Arizona/US Gelogical Survey (they were taken from the same website).
The HiRISE crew was able to combine these two into a single heightmap image as shown above. I think some people in the image processing business might call this “Stereo Photogrammetry”. Nice!!!