Author Topic: Fractal procedural erosion shader public beta  (Read 30855 times)

Offline blinkfrog

  • Member
  • *
  • Posts: 76
Fractal procedural erosion shader public beta
« on: November 15, 2015, 05:49:40 PM »
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:
60907-060909-160911-260913-3

By Ulco Glimmerveen (Dune):
60915-460917-560919-660921-7

By Martin Huisman (Tangled-Universe):
60923-8

Version 0.4.0 beta.
* erosion_0_4_0_1b.zip (148.4 kB - downloaded 819 times.)

Daniil.
« Last Edit: December 31, 2015, 07:56:43 AM by Oshyan »

Offline blinkfrog

  • Member
  • *
  • Posts: 76
Re: Fractal procedural erosion shader public beta
« Reply #1 on: November 15, 2015, 05:50:16 PM »
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
60926-0
Scale = 1000
60928-1
Scale = 2000
60930-2

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
60932-3
Large-scale attenuation = 0.7
60934-4

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
60928-5

Hardness = 0.8
60936-6

Rock removal = 0.4
60938-7

Illustration of effect of these parameters on gully profile:
60940-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
60928-9

Deposition amount = 0.8
60942-10

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.
60966-11

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.
60968-12

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:
60970-1360972-14

Masked terrain with all modes off:
60974-15

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.
60976-16

Mask as blend - common blending mode, multiplies erosion effect by mask (attenuating displacement by grey colors).
60978-17

Mask as rock removal - mode which keeps the slopes, often looks more natural than Mask as blend mode.
60980-18

You can combine the modes.

Daniil.
« Last Edit: November 18, 2015, 04:54:14 AM by blinkfrog »

Offline Rumburak

  • Member
  • *
  • Posts: 125
Re: Fractal procedural erosion shader public beta
« Reply #2 on: November 15, 2015, 06:13:36 PM »
Great. Thanks a lot for developing this shader!

Offline archonforest

  • Member
  • *
  • Posts: 3204
  • !AMIGA RULEZ!
Re: Fractal procedural erosion shader public beta
« Reply #3 on: November 15, 2015, 06:41:05 PM »
Wow this is fantastic!!!
Thank so much ;)
...many rooms to explore but the doors look the same...

Offline j meyer

  • Member
  • *
  • Posts: 2023
    • orkwarts
Re: Fractal procedural erosion shader public beta
« Reply #4 on: November 15, 2015, 06:49:48 PM »
Thank you very much! Especially for sharing it for free with the community.
Much appreciated!

Offline archonforest

  • Member
  • *
  • Posts: 3204
  • !AMIGA RULEZ!
Re: Fractal procedural erosion shader public beta
« Reply #5 on: November 15, 2015, 07:02:27 PM »
I wanted to try on the pc at work...hehe..simple dual core not really running it well... :D
...many rooms to explore but the doors look the same...

Offline WASasquatch

  • Member
  • *
  • Posts: 806
  • to = ( be ) ? be : not;
Re: Fractal procedural erosion shader public beta
« Reply #6 on: November 15, 2015, 07: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?
Art can be a window into the soul

Offline AP

  • Member
  • *
  • Posts: 2688
Re: Fractal procedural erosion shader public beta
« Reply #7 on: November 15, 2015, 07:19:45 PM »
Thank you for all of the effort put forth for such a paradigm shift within computer generated terrain generation.

Offline Kadri

  • Member
  • *
  • Posts: 7865
Re: Fractal procedural erosion shader public beta
« Reply #8 on: November 16, 2015, 12:25:14 AM »

Thank you. Nice to have another feature to play with :)

Offline Dune

  • Member
  • *
  • Posts: 12827
  • Corkscrew Bird
    • www.ulco-art.nl
Re: Fractal procedural erosion shader public beta
« Reply #9 on: November 16, 2015, 06:38:39 AM »
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.
« Last Edit: November 16, 2015, 06:41:40 AM by Dune »
In case you still haven't seen enough of my work: www.ulco-art.nl

Offline mhaze

  • Member
  • *
  • Posts: 3152
Re: Fractal procedural erosion shader public beta
« Reply #10 on: November 16, 2015, 08:15:28 AM »
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.

Offline mhaze

  • Member
  • *
  • Posts: 3152
Re: Fractal procedural erosion shader public beta
« Reply #11 on: November 16, 2015, 10:00:54 AM »
This is amazing and much faster than I was expecting!

Offline Tangled-Universe

  • Terrevangelist
  • *
  • Posts: 6075
    • CGScenery.com - Terragen Tutorials!
Re: Fractal procedural erosion shader public beta
« Reply #12 on: November 16, 2015, 10:18:54 AM »
Absolutely great work Daniil!
As you can see we all really appreciate your efforts on this! :)

Thanks a lot!

Offline blinkfrog

  • Member
  • *
  • Posts: 76
Re: Fractal procedural erosion shader public beta
« Reply #13 on: November 16, 2015, 12:04:34 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.

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.

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.
« Last Edit: November 16, 2015, 12:18:08 PM by blinkfrog »

Offline Dune

  • Member
  • *
  • Posts: 12827
  • Corkscrew Bird
    • www.ulco-art.nl
Re: Fractal procedural erosion shader public beta
« Reply #14 on: November 16, 2015, 12:21:49 PM »
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  ;)
In case you still haven't seen enough of my work: www.ulco-art.nl