Mittwoch, 29. Januar 2014

Geometry Clipmaps Terrain Rendering Tutorial Source Code

Today I completed the ClipMap rendering by adding culling to the terrain chunks.
The speed is at 1000-2000 fps now. The source is a bit longer but stayed around 200 lines for the main algo, which is easy to overview.

You can fetch the source code and executables here:
[-Download-ZIP-] (Textured Version older shader support, 32/64 bit) (Newest)
[-Mirror-] (Gamedev)
[-Google-Code-]

License is MIT

Key settings:
Space : wireframe view
Enter : Top-down view

Since there are many libs out there that have a completely bloated and unusable source code, I think its useful for everybody wanting to get started with terrain.









Sonntag, 26. Januar 2014

Basic Geometry Clipmaps

Basic Geometry ClipMaps.
The implementation went faster and with with less code than expected
( 2 days / 120 lines for the C++ terrain code ).



Donnerstag, 23. Januar 2014

Fast Approximate Erosions ( 1-2 seconds on CPU )

The erosion computation used for the image below takes about 1-2 seconds using CPU.
The erosion is not physically correct, but gives the look of an eroded terrain.
The eroded terrain is on top, the medium eroded terrain is in the middle, the original is at the thrid.

The bottom-most is the result from computing a 2048x2048 map.

The method simulates 10k raindrops and tracks them down the valley. The result is then augmented to achieve the final height-map. Other than with hydraulic erosion, no sediment map or velocity map are used here, so the computation much faster.

The code for the entire terrain computation (DLA, Perlin noise, Erosion and obj file export) is surprisingly short. Just about 400 lines of code.

Update: using stacked blur, the complete terrain with DLA, perlin & erosion can be computed in 4 seconds (1024x1024) on the CPU (single threaded).







Montag, 20. Januar 2014

DLA Terrain blended with Perlin Noise

Today's version is with Perlin Noise to get details for closeup views.
The image below already includes a first and very simple erosion.


Donnerstag, 9. Januar 2014

Procedural Terrain Heightmap Generation using DLA (Diffusion Limited Aggregation)

In the past days I have worked on improving the terrain generation function. The basic 3D perlin noise works well to generate a generic terrain, but to get more appealing mountains, different approaches are necessary. For height maps, perlin noise can be used too, but does not look as appealing as erosion based terrain.

To achieve similar looking structures, Diffusion-limited_aggregation (DLA) is the solution. The initial result looks as the upper left image. Using gaussian smoothing, the final height image, lower right, can be obtained. The final rendering of the 3D image follows on the lower left.

The algorithm requires three steps:
  • Create the DLA image. When attaching a new point, draw a line to the referring point and add random midpoint displacement to the line to make it more interesting.
  • Create multiple copies of the DLA image and apply gaussian smoothing. The smoothing radius is increased exponentially from one image to the next.
  • Sum up all copies weighted and normalize the result.
DLA cannot easily create an infinite procedural heightmap, but using a sparse set of points, its possible to cover a quite large area and refine the DLA once you get closer. Due to the smoothing radius of 1..256 here, one pixel is influenced by an area of 512x512 pixels around the target pixel.

I have searched to find a reference for this algorithm, but so far I could not find one yet. If you find a good reference, you can post it in the comments.

The uppermost Heightmap can be downloaded as OBJ format here. (viewable with MeshLab e.g.)

Below more examples. The corresponding heighmaps are:
Heightmap1 Heightmap2 Heightmap3
You can use the GeoGen Studio to view the results.

The original heightmap data is float, but the images are limited to 256 steps.
The computation time is about 1min for 1024x1024.

















Sonntag, 5. Januar 2014

CodeFlash - Code Templates for Any Editor in Windows

In the past weeks I have been working on a small tool to accelerate code writing. The result is CodeFlash.net.

How does it work ? Type f i 5 10 + CAPSLOCK and the result is a complete for-loop: for (int i=5;i<10;i++){} , which saves a lot of coding time. It provides many other macros as well as support for multiple programming languages. The macros are stored as txt and can be edited by the user.

It works under Windows with Visual Studio, CodeBlocks, Eclipse, notepad++, IntelliJ IDEA, EditpadPro and many others as it is a stand-alone application.

Example