3D Terrain
















































3D Terrain
I recently made a little 3D thing and after it took off on twitter I was asked to write up how it was done.
Please note though, that this was basically my first 3d-thing, so I'm likely not using all the right words. :) I started by jamming around with Zep's 3d dot party template and ended up with the above.
Anyway, as most things - it is not as complicated as it looks. It grew quite organically, but it boils down to these steps.
First I made sure I had a working grid.
I wanted to have a height map, so I used the sprite sheet to draw a very simple repeatable map.
Every tick I look at a slightly different position in the map, giving a nice scrolling feeling.
But it looks a bit dull, so I wanted to add some movement. This was done by applying a cos and sine function over time.
As it still was a bit static I also added a slight sway to the camera.
Adding it all together ended up with this very living scrolling thing. Since the sine and cos waves doesn't have anything to do with the terrain and run on a different frequency it looks very alive and smooth.
I'm pretty sure the whole thing can be done faster and better, but hey - if it looks right on the screen... ;)
Happy to answer any questions if needed.
Cheers,
Johan