Marching Cubes Terrain (2)

As I described in my previous post I was working on marching cubes terrain. This time the texture stretching is fixed by generating texture coordinates from the 3D position and normal. This simply is the (y-axis is the up-vector), xz * normal.y + xy * normal.z + zy * normal.x. With 2 textures to splat this requires 6 texture look-ups.

Also I added cpu tessellation. The terrain size for this post is a bit smaller, but triangle count is far higher. Next step is to fix geomipmapping to reduce triangle count.

Here are some new screenshots. Also mind the”buggy” ones :).

Marching cubes terrain

Somehow you always come back to some standard terrain engine. Load a height map create a soup of triangles, optimize it, create more triangles, put a texture on it and… yes you have your terrain. Height map based. Kinda limited to a height map. Not something I wanted! So I want to have over hanging cliffs and tunnels. Have almost possible shape I can think of.

In the past I did some stuff that didn’t worked out as well as I hoped. I used a height map and offset the X, Y and Z via the R, G and B color channels. This way you can have over hanging cliffs, but still no tunnels (or well, you can use the right colors so that the edges of the cliffs meet in the middle…). But not really what I wanted.

So… I did some research on terrain and tried the marching cubes. From Wikipedia: Marching cubes is a computer graphics algorithm, published in the 1987 SIGGRAPH proceedings by Lorensen and Cline, for extracting a polygonal mesh of an isosurface from a three-dimensional scalar field (sometimes called voxels). An equivalent two-dimensional method is called the marching squares algorithm.

Sort: Creating a 3D polygon model from an “3D object”. In my case that’s what I need. However I don’t have a “3D object”. So I generate one! Define you “3D object” (in my case terrain) as a bunch of cubes. Say an array of 32x32x16. All cubes that have some neighbors, have some polygons as there is something at that location. (For more information I suggest Wikipedia or google).

Anyway, I use a height map (YES I DID!) to define the basics of my terrain shape. Next I start to add cubes randomly on locations where they could fit to generate a non-height map look and have some stuff “hanging over” (hangover…?). It still looks very polygonized, but when applied some textures it looked much better. I’m thinking of  adding some kind of tessellation to smooth it all out. Screenshot or it didn’t happen, so here you go:

Yeah fire!

A while ago I posted about the tool migration to Paint.NET. Yesterday I was trying to make a muzzle flash. With great success! And guess what, I’m gonna show you how you can make your own.

So what do you need? Well 2 thing: first Paint.NET and next the fire effect plugin. (There are plenty of references on the Paint.NET website how to install plugins, buts it’s basically copy-paste it to the effect directory).

So here it goes:

1) Draw some random stokes in any direction. My choice was to make a Christmas tree on its side.

2) In Paint.NET select Effect -> Blurs -> Gaussian Blur. Play around with the values until you get something that looks like this:

3) In Paint.NET select Effect -> Render -> Fire!… Again, play with the values a bit until you get something that suits your needs.

4) And now the tricky part: duplicate the layer. In the “Layers” window select the layer you want to duplicate (the layer with the fire that is) and press the Duplicate Layer button. Now double click  new layer (probably it’s named “Layer 2”) and set the mode to “Additive”. You should get something like this:

5) With the new layer still selected Effect -> Blurs -> Gaussian Blur. Again play around with the values.

That’s it! Crash course “Muzzle Flash” in a flash! Now go make your own!