Fractal procedural erosion shader public beta

Started by Daniil, November 15, 2015, 01:49:40 PM

Previous topic - Next topic

Daniil

I am pleased to present the beta version of fractal procedural erosion shader for Terragen. It is developed using Terragen SDK.

At the present it works on Windows only, no OS X version yet.

And yes, it's free.

Shader process it's input and outputs eroded landscape. But may be it is better to interpret it as eroded landscape synthesizer which is basing on uneroded input landscape.

Achieving good-looking results highly depends on how the unprocessed terrain was designed. Original landscape doesn't need to have many small-sized details, they can sometimes confuse the algorithm. Moreother, usually small details are shaved off completely and algorithm generates its own details. So you can generate original landscape using lesser number of octaves, also it is faster.

Currently shader doesn't process truly infinite area, as one can expect from procedural algorithm. Actually it handles the square area of size approx. (1000 * Erosion scale)^2 (1000 km * 1000 km for default settings) centered at (0, 0). The support of much bigger sizes is planned in the future.

Shader uses extensive RAM caching during its work, and can hog up to several gigabytes. You can control the amount of RAM which shader can use, but actually the more RAM you have, the faster plugin works, especially during the animation rendering.

To evaluate a single point algorithm has to evaluate context area around: to sample original area and to build drainage network; it results in a noticeable delay before actual render or even just preview starts updating. But all data is being cached, so evaluating of a point next to first takes much less time. The less distance between points, the less new data has to be evaluated. So after initial delay rendering is speeding up. And if you render the animation, subsequent frames are rendered faster than the first. But if the erosion cache grows too large (bigger than limit) it is being flushed, and shader has to rebuild some data again.

To install just extract the dkerosion.tgp into "Plugins" subfolder in your main Terragen folder. There are two builds, 32 and 64 bit, you need to install just one of course. Then you can find the erosion shader in the Displacement Shader section of shaders.

Terragen 3.3 or higher required.

Some images:
[attach=1][attach=2][attach=3][attach=4]

By Ulco Glimmerveen (Dune):
[attach=5][attach=6][attach=7][attach=8]

By Martin Huisman (Tangled-Universe):
[attach=9]

Version 0.4.0 beta.
[attachurl=10]

Daniil.

Daniil

#1
Parameters guide:

Scale tab:

Scale (in meters). Sets the size of biggest erosion features, this is the average distance between biggest ridges. In overall, the more the scale, the more eroded is the terrain. For big mountain ranges you can try the values of 2k or higher.
Scale = 400
[attach=1]
Scale = 1000
[attach=2]
Scale = 2000
[attach=3]

Large-scale attenuation. Attenuates the first and slightly the second octaves, working somewhat similar to Feature scale parameter in Power. Can be useful to making largest valleys less prominent.
Large-scale attenuation = 0.0
[attach=4]
Large-scale attenuation = 0.7
[attach=5]

Octaves - sets the number of Fractal octaves.

Dynamically reduce the number of octaves - allows algorithm to calculate less octaves if higher octaves are too small and invisible – for example, at distant view. Greatly speeds up the rendering.
Technically this parameter is needed if you want to stack multiple erosion plugins serially. In this case you need to set it off for all instances except last.

Non-rendering octaves. This is abridgement of "Non-rendering context octaves". The number of octaves used for populations.
As was written, usually it is beter to enable "Dynamically reduce number of octaves" option for better performance. In this case distant area will be evaluated using lesser number of octaves, so actual number of rendered octaves depends on the camera position. This will work wrong if populations used, so Erosion shader ignore this option and "Octaves" parameter and will use "Non-rendering octaves instead. Using usual "Octaves" parameter can be very slow process, imagine populating area of 10x10 km using Scale = 1000 m and 16 octaves - it forces the shader to evaluate the whole square of 10x10 km with 3 cm resolution. So I recommend to set "Non-rendering octaves" to a values lesser than "Octaves". You can try various values and find a good compromise between populating process speed and populating accuracy.

Parameters tab:

Hardness and Rock removal: affect the profile of gullies. Hardness controls the slopes of gully (and partly depth), and Rock removal controls overall erosion effect, changing depth and width of gullies.
Hardness = 0.3, Rock removal = 1.0
[attach=2]

Hardness = 0.8
[attach=6]

Rock removal = 0.4
[attach=7]

Illustration of effect of these parameters on gully profile:
[attach=8]

Deposition amount controls the sedimentation. Can be set to the values higher than 1.0. Rivers example from the first post used Deposition amount set to 1.5
Deposition amount = 0.5
[attach=2]

Deposition amount = 0.8
[attach=9]

Deposition floor creates global layer of sediment which covers all places with altitude lower than Deposition floor value.

Smooth ridges. Generates rounded ridges instead sharp, but its effect reduced by further generating of higher octaves.

Limited gullies length - limits the length of gullies so they won't form long structures

Gullies sharpening – sets the amount of sharpening the gullies at beginning.

Smooth surface – smoothes surface, can be useful if it is need to generate a limited octaves picture.

Maps tab.

Erosion shader can generate not only displacement, but also color 2D-images, which can be used for masking other shaders. These images called maps.

To use maps, you need to turn on "Enable maps" parameter. Basically that's all – you can link Erosion shader to Mask input of other shader. Default map to output is Deposition map.

In this example I want to shade deposition layer, so I added Surface layer and linked Erosion shader to Surface layer's Mask input.
[attach=10]

You can see that deposition map has smooth cloudy edges, it is rarely useful (but can display thickness of deposited sediment), so I added Colour adjust shader and set White point to 0.01 – it is enough for sharp edges.

Also I want to add a second map to display erosive flows. Erosion shader able to output up to three maps in the same time, it uses color coding for that. Using "Red", "Green" and "Blue" parameters you can select desired map, and it will be output using that color component.

To extract needed map from complex output you need to use "Red to scalar", "Green to scalar" or "Blue to scalar" functions in the "Function->Convert" section of shaders.

So I used Green and Blue components for Deposition Map and Flow Map A.
[attach=11]

There are two flow maps in the shader – A and B. You can use first map for shading, and second to generate displacement based on flows – it is useful for creating river channels (you need to link this map into Displacement Function input of a shader which generates disoplacement, for example, Displacement shader or Surface shader, and set Displacement amplitude to negative value). Flow map B has important hardcoded property for rivers: lesser flows are scaled to have lesser depth. Flow map A use equal intensity for all flows.

You can limit the number of octaves for both flow maps (usually it is enough 1...3 octaves for rivers) using map octaves parameters, and set smoothing for flow maps using smoothing parameters (useful for smoother river channels).

Mask tab.

Erosion shader can be masked by other shaders, it can be useful for limiting the erosion effect.

There are usual Mask by shader and Invert mask parameters, and also three masking modes.

This is original terrain and also fully processed by erosion:
[attach=12][attach=13]

Masked terrain with all modes off:
[attach=14]

Limit erosion to mask. This mode tries to keep erosion inside mask without sharp transitions at the edges of mask even if mask is just black and white colors. Erosion effect can go out of mask a little.
[attach=15]

Mask as blend - common blending mode, multiplies erosion effect by mask (attenuating displacement by grey colors).
[attach=16]

Mask as rock removal - mode which keeps the slopes, often looks more natural than Mask as blend mode.
[attach=17]

You can combine the modes.

Daniil.

Rumburak

Great. Thanks a lot for developing this shader!

archonforest

Dell T5500 with Dual Hexa Xeon CPU 3Ghz, 32Gb ram, GTX 1080
Amiga 1200 8Mb ram, 8Gb ssd

j meyer

Thank you very much! Especially for sharing it for free with the community.
Much appreciated!

archonforest

I wanted to try on the pc at work...hehe..simple dual core not really running it well... :D
Dell T5500 with Dual Hexa Xeon CPU 3Ghz, 32Gb ram, GTX 1080
Amiga 1200 8Mb ram, 8Gb ssd

WAS

Couple questions, my friend here has Terragen 2.2 and wants to know if it is compatible? I am wondering what the System Requirements may be. You mention "Gigabytes" of RAM, that could cause crashes on systems with 2-4GB RAM, no?

AP

Thank you for all of the effort put forth for such a paradigm shift within computer generated terrain generation.


Dune

#9
And this may be good to know; the first rendering takes longer than after that, as it needs to build up a memory of the erosion. The lower the octaves the faster.

I was about to write something about masking, but won't until you have, Daniil.

mhaze

Just seen this.  So happy and could not come at a better time for me. Thank you for all the hard work I shall go away and play.

mhaze

This is amazing and much faster than I was expecting!

Tangled-Universe

Absolutely great work Daniil!
As you can see we all really appreciate your efforts on this! :)

Thanks a lot!

Daniil

#13
Quote from: WASasquatch on November 15, 2015, 03:14:27 PM
Couple questions, my friend here has Terragen 2.2 and wants to know if it is compatible? I am wondering what the System Requirements may be. You mention "Gigabytes" of RAM, that could cause crashes on systems with 2-4GB RAM, no?
No, it isn't compatible with TG2. It even won't wotk with earlier versions of TG3. As for RAM, you can set the erosion cache size to 1 GB, but expect the great slowdown due to frequent cache flushes. You can also keep low RAM usage by limiting the octaves (5-6), it is often enough for a good picture. You can get additional details then by using usual noise fractal shaders.

Quote from: archonforest on November 15, 2015, 03:02:27 PM
I wanted to try on the pc at work...hehe..simple dual core not really running it well... :D
There is some initial delay in the rendering process, as Ulco mentioned. I also edited the first post and added additional information about this delay. You can also limit the number of octaves in the erosion shader and also in fractal(s) forming the original terrain.

Quote from: Dune on November 16, 2015, 02:38:39 AM
I was about to write something about masking, but won't until you have, Daniil.
Feel free to be first, Ulco. :) I don't have enough time at the moment, but still hope to write about it today or tomorrow.

Daniil.

Dune

OK. Masking then, short and simple for the time being;

It is paramount to add some blue nodes to begin with; convert--- blue to scalar, green to scalar, red to scalar. Attach these to the output of the erosion shader, check mapping, and if using a mask like s simple shape or distance shader, check mask ánd check mask as blend (at least that's what I did). Feed the outputs of the blue nodes into the masking input of three successive test surface shaders with distinct colors. Then adjust settings and see what happens.
You can adjust the outputs with color adjust shaders to make areas more or less pronounced, mask them by power fractals or whatever (height, slope...) or combine them using merge shaders. Something like the 1 octave flow map can be used for rivers running down the lowest areas, and that can be warped (whicjh I find very useful).
And then of course use each of these surface shaders to add specific texturing.
At least you can get on your way now  ;)