Subscribe to:

The Kiwi's TaleWitchBlasterDerelict Blow Stuff Up

New Monkey Demo: 3D Heightmapped terrain

New HTML5 Monkey Demo - 3D Heightmapped terrain! Try it here, use cursor keys to move, A/Z to move up and down, Plus/Minus to change detail level, and L to set the terrain as infinitely looping. The source code has already been bundled into the Earok's Monkey Demos pack.

This was a fun one to do, certainly not as painful as I had thought it was going to be. The inspiration was the "Voxel" terrain engine from the Novalogic Comanche games, though frankly I find the term "Voxel" to be misleading as it's really a raycaster. The way it works is that rays are casted from each Vertical line across the screen, detecting where the map is hit and drawing to the height of the hit part of the map. The ray travels into the distance until it either hits the maximum distance, or what's already been drawn extends past the top of the screen.

The unfortunate weakness with doing a terrain render this way is that you're limited to four degrees of freedom - meaning you can move freely forward/back, left/right and up/down, but you can only rotate left/right (pitch and roll rotations can be faked to a degree though).

I'm pretty sure that this is a first for Monkey, it may even be a first for HTML5 in general. Unfortunately the framerate slows to a crawl on the higher detail levels (It's fine in the C++ export). I think the big slow down is simply drawing the pixels to the screen, if someone can think of a way to make the demo run much faster, I'd love to hear from you!

(Edit: For bonus points - where did I get the terrain for this demo from?)

Tags:

Comments

hydra9
hydra9's picture
Offline
Joined: 05/24/2009

I love it! I'm a big fan of this style.

arran4
Offline
Joined: 05/05/2009

Where is it from? You didn't procedually generate it?

Earok
Earok's picture
Offline
Joined: 02/06/2009

@Sam cheers, it's certainly a very distinctive look the method generates. The Novalogic guys must have been geniuses, it's quite remarkable when you compare the graphics from Comanche versus comparable games of the era (such as Gunship 2000).

@arran hells no, it's a combination of a pre-existing height map and colour map from another one of my games. I'm not yet smart enough to be able to implement a terrain generation algorithm.

hydra9
hydra9's picture
Offline
Joined: 05/24/2009

I remember having loads of fun running around the voxel-based landscapes of this game, back in the day:
http://www.mobygames.com/game/dos/lords-of-midnight

And your demo reminded me of that :)

hydra9
hydra9's picture
Offline
Joined: 05/24/2009

It also reminded me of Outcast, of course.

I had a few issues with that game, but the landscapes were lovely.

arran4
Offline
Joined: 05/05/2009

Earok, tis not hard. I did it as a uni assignment. :P http://gameprogrammer.com/fractal.html Basically draw a line, split it in half, set the connection point at a random height (well that follows some parameters to keep it sane..) Rince and repeat until you get the detail you are after. Same sort of thing with 3d, but you do it in squares. :P

Earok
Earok's picture
Offline
Joined: 02/06/2009

@sam that's interesting, I wasn't aware of any voxel terrain games not by Novalogic. Cheers for that.

@arran yeah, no, I'm not going to do that =P well, maybe if one of my games actually requires it I'll look at it. Thanks for posting the link though.

arran4
Offline
Joined: 05/05/2009

Link was first google result. :P