Planetside Software Forums

General => Terragen Discussion => Topic started by: Dune on December 04, 2015, 03:14:45 AM

Title: soft maximum/minimum
Post by: Dune on December 04, 2015, 03:14:45 AM
I can't get these to work for me, so is there anyone who can explain? I am hoping to make the hard clamped colors of a PF into a 'soft-clamped' version.
Title: Re: soft maximum/minimum
Post by: WAS on December 04, 2015, 01:54:22 PM
Quote from: Dune on December 04, 2015, 03:14:45 AM
I can't get these to work for me, so is there anyone who can explain? I am hoping to make the hard clamped colors of a PF into a 'soft-clamped' version.

I think Chris can help with this, he's actually helped me (http://www.planetside.co.uk/forums/index.php/topic,20791.msg207202.html#msg207202) with understanding them more, and I do use them so soften things up a bit. Just haven't been able to achieve a true soft effect.
Title: Re: soft maximum/minimum
Post by: AP on December 04, 2015, 11:09:42 PM
It is for a Power fractal though, what i used were noise functions. The Power fractal noise needs to be converted into something that those functions can read but i tried and nothing so far.
Title: Re: soft maximum/minimum
Post by: bobbystahr on December 05, 2015, 12:21:06 AM
We need an all purpose Gaussian Blur shader......just stick it in the stack and adjust....
Title: Re: soft maximum/minimum
Post by: AP on December 05, 2015, 01:27:28 AM
http://www.planetside.co.uk/forums/index.php/topic,20215.msg199801.html#msg199801

http://www.planetside.co.uk/forums/index.php/topic,20791.msg207119.html#msg207119

http://www.planetside.co.uk/forums/index.php/topic,15702.msg152686.html#msg152686
Title: Re: soft maximum/minimum
Post by: bobbystahr on December 05, 2015, 01:53:05 AM
Quote from: Chris on December 05, 2015, 01:27:28 AM
http://www.planetside.co.uk/forums/index.php/topic,20215.msg199801.html#msg199801

http://www.planetside.co.uk/forums/index.php/topic,20791.msg207119.html#msg207119

http://www.planetside.co.uk/forums/index.php/topic,15702.msg152686.html#msg152686

D'oh..and I actually read those when they were current...pot heimers is takin it's toll, heh heh
Title: Re: soft maximum/minimum
Post by: AP on December 05, 2015, 02:19:06 AM
Perhaps someday some programming genius will come along and solve this. It happened to erosion.
Title: Re: soft maximum/minimum
Post by: Dune on December 05, 2015, 02:42:57 AM
Thanks guys. I got it working somehow, but probably not what it's meant for and how it's supposed to be. Seems like the input gets a constant, the softness too, and the input 2 is for a PF. And if you apply a soft max, strangely the minimum is softened, and vice versa, and the whole terrain is raised. Strange.
Title: Re: soft maximum/minimum
Post by: bobbystahr on December 05, 2015, 11:55:29 AM
Quote from: Dune on December 05, 2015, 02:42:57 AM
Thanks guys. I got it working somehow, but probably not what it's meant for and how it's supposed to be. Seems like the input gets a constant, the softness too, and the input 2 is for a PF. And if you apply a soft max, strangely the minimum is softened, and vice versa, and the whole terrain is raised. Strange.

node network screen grab please and thank you.
Title: Re: soft maximum/minimum
Post by: WAS on December 05, 2015, 02:46:15 PM
Quote from: Chris on December 05, 2015, 02:19:06 AM
Perhaps someday some programming genius will come along and solve this. It happened to erosion.

I feel as though if there is a Motion Blur function, we can utilize that as a Blur Function for a texture. For example. 3D Studio Max allows you to blot motion on a object that isn't actually moving, and blur it. If we could utilize similar on a function, blurring it or w/e so only said object/surface is blurred.

(http://richardfrazer.com/wp-content/uploads/2014/07/CG_vector_blur02_595px.jpg)

There is no actual motion there.

Another example of vectoring being blurred in a non-roster environment. This method is a trick and just multiplying and dimming the edges. Called false-colour on logarithmic scale or FDTD. Which is used in Radio imagining and Astronomy devices to obtain clearer images, or softer images of the cosmos from IR/Radiation data.

(http://www.nature.com/ncomms/2015/150204/ncomms7187/images_article/ncomms7187-f3.jpg)

So it's very possible and done in a lot of programs already, it's just a matter of someone knowing how to do it for TG.

There is even another method based on FDTD which is called Log Scale Matplotlib PatchCollection Colors someone is trying in Python.

It's basically a edge filter, multiplying and fading the edge colour and blending. But not going to lie it looks like the most complex math ever and probably why NASA and stuff uses it.
Title: Re: soft maximum/minimum
Post by: Dune on December 06, 2015, 02:20:14 AM
Interesting. No doubt Matt can think of something (in due time)  ;) In the image map shader you can choose for smooth interpretation, but that's pixels, turning off breakup in a surface shader make the edges of fractals smoother also.
Here you go, Bobby. The start terrain is a colored fractal.
Title: Re: soft maximum/minimum
Post by: WAS on December 06, 2015, 03:50:09 AM
Quote from: Dune on December 06, 2015, 02:20:14 AM
Interesting. No doubt Matt can think of something (in due time)  ;) In the image map shader you can choose for smooth interpretation, but that's pixels, turning off breakup in a surface shader make the edges of fractals smoother also.
Here you go, Bobby. The start terrain is a colored fractal.

I forgot about that, and that will help my.coastal scene so much. Was trying to colums and it just wasn't working right
Title: Re: soft maximum/minimum
Post by: bobbystahr on December 06, 2015, 10:34:34 AM
Quote from: Dune on December 06, 2015, 02:20:14 AM
Interesting. No doubt Matt can think of something (in due time)  ;) In the image map shader you can choose for smooth interpretation, but that's pixels, turning off breakup in a surface shader make the edges of fractals smoother also.
Here you go, Bobby. The start terrain is a colored fractal.

Wild, although I can rarely grok them I periodically get inspiration from these spidery networks..thanks for posting it mate.
Title: Re: soft maximum/minimum
Post by: Matt on December 08, 2015, 04:20:06 AM
Soft Maximum is based on the soft maximum described by John D. Cook:

http://www.johndcook.com/blog/2010/01/13/soft-maximum/

However, Cook's soft maximum uses a parameter called 'k' which can be interpreted as the 'hardness'. For Terragen I wanted this to be a 'softness' parameter instead. For those interested in the math, softness = 1/k. Thinking in terms of softness is more intuitive when working with displacements, because you can consider the 'softness' to be in the same units as the displacement, i.e. metres.

And of course Soft Minimum works in a similar way but upside down.

Quote from: Dune on December 05, 2015, 02:42:57 AM
Thanks guys. I got it working somehow, but probably not what it's meant for and how it's supposed to be. Seems like the input gets a constant, the softness too, and the input 2 is for a PF.

The first two inputs are interchangeable. But when the node is disabled, the main input ("input node") is the pass-through just like every other node in Terragen, so that might affect which one you decide should be the main input.

They don't need to be constants. You could input two fractals, for example. Even the softness could be a fractal.

Quote
And if you apply a soft max, strangely the minimum is softened, and vice versa, and the whole terrain is raised. Strange.

Max and Soft Maximum are supposed to return the maximum of two values. I know that it seems counter-intuitive if you think of it as a clamping function (and I used to have the same feeling when I started coding graphics), but hopefully it makes sense when you think of it as "the greater of A and B".

Matt
Title: Re: soft maximum/minimum
Post by: Dune on December 08, 2015, 10:06:18 AM
Thanks for your explanation, Matt. I have to dive into it again. I assume the fractal softness needs to have a minimum of a value above black for the least bit of softness, 1 being max? And I also assume the fractal sizes then vary this over space. Some experiments will be enlightening, no doubt.

Or... is it too much to ask for a quick and simple setup of its workings? I was just trying to get it to work (smoothing the lowest areas of a fractal terrain into a valley), but the terrain only doubled in height  :(
Title: Re: soft maximum/minimum
Post by: j meyer on December 08, 2015, 12:42:26 PM
Yes,please,a working example would be very helpful.
Title: Re: soft maximum/minimum
Post by: bobbystahr on December 08, 2015, 01:31:04 PM
Quote from: j meyer on December 08, 2015, 12:42:26 PM
Yes,please,a working example would be very helpful.

echo
Title: Re: soft maximum/minimum
Post by: Matt on December 08, 2015, 03:21:19 PM
Quote from: Dune on December 08, 2015, 10:06:18 AM
I assume the fractal softness needs to have a minimum of a value above black for the least bit of softness

It's OK for the softness to be 0. Then it just gives the (hard) maximum.

Quote
1 being max?

There is no upper limit on the softness you can use. If you are calculating the soft maximum of functions that produce very large values, then you probably want to use large softness values.

By the way, you can leave the softness input empty. It defaults to softness 1.

Quote
I was just trying to get it to work (smoothing the lowest areas of a fractal terrain into a valley), but the terrain only doubled in height  :(

That could happen if the softness value is too large for the functions you're working with. If you have colours that range from 0 to 1, you want a softness value much lower than 1. Perhaps start with 0.1.

I've attached an example project that shows how to use Soft Maximum to merge a terrain displacement with a constant to create a plain that smoothly transitions into the original terrain.

Matt
Title: Re: soft maximum/minimum
Post by: bobbystahr on December 08, 2015, 03:26:42 PM
Thanks very much Matt...will dig into this when my Swamp Test with the Ulco cypress' finishes test rendering....
Title: Re: soft maximum/minimum
Post by: AP on December 08, 2015, 03:41:20 PM
A better understanding certainly helps as this is what i'm currently experimenting with trying to make V and U shaped valleys, i might be missing some other functions for such features. Even larger valleys for softer transitions. I was using large values for the mountain ranges i'm working on so it is interesting to see the results of what those higher value capabilities are.

I'm thinking for U shaped valleys, more of a bell curve-like profile is needed.
Title: Re: soft maximum/minimum
Post by: fleetwood on December 08, 2015, 03:47:41 PM
Thanks Matt
Title: Re: soft maximum/minimum
Post by: Dune on December 09, 2015, 02:03:36 AM
Great, Matt, thanks very much.
Title: Re: soft maximum/minimum
Post by: AP on December 09, 2015, 02:29:16 AM
Oh and yes, much appreciative.
Title: Re: soft maximum/minimum
Post by: Tangled-Universe on December 09, 2015, 03:36:51 AM
I used the regular clamp before to create a flat bottom for a canyon, but it gives artefacts at the intersections.
This new clamp function does it in a much nicer way.

Matt's example also demonstrates nicely that you can create large shallow mountain lakes, where you can see stones being refracted in the water :)
Title: Re: soft maximum/minimum
Post by: j meyer on December 09, 2015, 12:21:24 PM
Thanks Matt  :) !
Title: Re: soft maximum/minimum
Post by: WAS on December 09, 2015, 02:04:31 PM
I'm going to have this another go. I wonder if you could achieve a softer look by stepping a function with transform input and using soft maximum/minimum to create a soft "gradient" of the terrain. I am focused on nothing but blurring right now as I've now been in several vector based programs that can do it. Even WM2 can blur your vector-based drawing.
Title: Re: soft maximum/minimum
Post by: Kadri on December 09, 2015, 03:04:36 PM

Sometimes there are topics i can not understand.Like this blurring problem (not directly about the question in this thread).

We don't have a gradient kind of feature but you can use other ways to archive some similar things.
Just when you open the default scene and use the "Simple shape shader" and use the "Edge profile" option with a "Edge width" of your desire and play with the main color what you get is a blurring (technically correct or not i don't know) of the fractal terrain by masking.

And isn't playing with the "Displacement roughness" and "Displacement spike limit" actually the same as blurring the Fractal terrain node output too?

If you use those things together with nodes like "Merge" and-or surface restrictions,image masks etc.you could archive many things.

As i said i don't see the exact problem. I will be happy if you show me what i don't understand guys (no sarcasm)?



Title: Re: soft maximum/minimum
Post by: Oshyan on December 09, 2015, 07:01:05 PM
WASasquatch, applying a gradient to the edge of a vector is not the same as "blurring". And if it's really "blurring", then it must be a raster function in WM (WM is fundamentally a raster-oriented app, even though it has vector/spline functions). If you're seeing a true, *generalized* "procedural blur" capability somewhere I'd certainly be interested in seeing it. Things like particular settings of a procedural function that create blur-like effects are really just *capabilities* of that particular shader and function. The thing about blurring is ideally it *should not care about what the input data is or where it came from*, it should just be able to blur it, globally and uniformly. If it can't do that, I wouldn't really call it "blur" but "blur-like", and likely very context-specific (which, of course, greatly limits its usefulness).

- Oshyan
Title: Re: soft maximum/minimum
Post by: WAS on December 09, 2015, 08:15:49 PM
Quote from: Kadri on December 09, 2015, 03:04:36 PM

Sometimes there are topics i can not understand.Like this blurring problem (not directly about the question in this thread).

We don't have a gradient kind of feature but you can use other ways to archive some similar things.
Just when you open the default scene and use the "Simple shape shader" and use the "Edge profile" option with a "Edge width" of your desire and play with the main color what you get is a blurring (technically correct or not i don't know) of the fractal terrain by masking.

And isn't playing with the "Displacement roughness" and "Displacement spike limit" actually the same as blurring the Fractal terrain node output too?

If you use those things together with nodes like "Merge" and-or surface restrictions,image masks etc.you could archive many things.

As i said i don't see the exact problem. I will be happy if you show me what i don't understand guys (no sarcasm)?

The SSS approach can create a "Intensity" gradient, but isn't actually smoothing/blurring anything.

The roughness is only the detail on top of the main displacement, so without it, you can plainly see the vector peaks/angles.

I'm not sure how it would be done in TG but from all I'm seeing in other programs and threads about the topic, it's basically a combination of gradienting the edges, as well as transforming the input to manually blur.

This could possibly be done with TG3 as is now by stepping and scaling the border and it's intensity (colour) and tons of Merge Shaders. But I'm not sure where to begin with that. From what I can tell, this would be done manually without extensive knowledge of functions. And by doing so you need a 0 - 1 range and every 0.001 (or so) range in between for softness on every scale step. Not sure, but that seems like over 1000+ nodes.


___


Here is a small testing jumping by 0.1 scale on softness and size scale. Need to compensate for radial effect with translation I believe but it does make for a softer look then the default softness of the PF. Merge shaders set to subtract Input - A.

(http://i.imgur.com/1mYvDJi.png)

Besides the radial issue and finding correct translation settings, it does make for a soft final power fractal with absolutely NO hard angles/edges. This version has 6 total phases with multiplication of -0.1 on each step to a total of  -0.6 translation, 1.6 scale and 0.6 softness.

(http://i.imgur.com/8JZC0p6.png)

So it seems possible to blur further, this method, however is more of a radial blur, unfortunately.
Title: Re: soft maximum/minimum
Post by: Dune on December 10, 2015, 03:10:34 AM
No hard edges in this extremely basic setup, so I don't understand what you're after either.
Title: Re: soft maximum/minimum
Post by: WAS on December 10, 2015, 05:03:40 AM
Quote from: Dune on December 10, 2015, 03:10:34 AM
No hard edges in this extremely basic setup, so I don't understand what you're after either.

If you switch to voronoi based, or a function, I want to remove creases
Title: Re: soft maximum/minimum
Post by: AP on December 10, 2015, 06:11:06 AM
If i understand you correctly you want to soften the edges and tops of a Voronoi noise function? I did this some time ago.
Title: Re: soft maximum/minimum
Post by: WAS on December 10, 2015, 03:48:16 PM
Quote from: Chris on December 10, 2015, 06:11:06 AM
If i understand you correctly you want to soften the edges and tops of a Voronoi noise function? I did this some time ago.

Yeah basically like that, but with more complex shapes. For example, just a basic voronoi diff scaller, or any other vector based shapes with PF noise. From my understanding, a Power Fractal Shader, while it can use a  voronoi setup, it's again, just the base altitutde/shape, while the PF noise creates the actual detail, which is not vector based. The only way to achieve that is as I been saying, a new function, or stepping the scale and dimming said step color and merging with original. Hundreds of times. Until you have a manual blur. But So far I can only achieve a radial setup

(http://www.nature.com/ncomms/2015/150204/ncomms7187/images_article/ncomms7187-f3.jpg)

Same setup, in another program. Also limited to radial blur.
Title: Re: soft maximum/minimum
Post by: Oshyan on December 10, 2015, 03:53:20 PM
Quote from: WASasquatch on December 10, 2015, 03:48:16 PM
From my understanding, a Power Fractal Shader, while it can use a  voronoi setup, it's again, just the base altitutde/shape, while the PF noise creates the actual detail, which is not vector based.

Whatnow?

- Oshyan
Title: Re: soft maximum/minimum
Post by: Kadri on December 10, 2015, 04:22:41 PM
Quote from: WASasquatch on December 10, 2015, 05:03:40 AM
...
If you switch to voronoi based, or a function, I want to remove creases

I think i see what you want. I tried some setups but no success.
I used to try harder in the past but now i would just use a blurred voronoi texture probably if i needed it.
Title: Re: soft maximum/minimum
Post by: WAS on December 10, 2015, 04:31:34 PM
Quote from: Oshyan on December 10, 2015, 03:53:20 PM
Quote from: WASasquatch on December 10, 2015, 03:48:16 PM
From my understanding, a Power Fractal Shader, while it can use a  voronoi setup, it's again, just the base altitutde/shape, while the PF noise creates the actual detail, which is not vector based.

Whatnow?

- Oshyan

Switch to Voronoi, anything (billows, ridges). Remove all detail. Observe form. Add detail. Observe Power Fractal Noise make up detail on it's surface, following the voronoi settings. If the noise was vector based then that means we already have a blur function cause that's some soft noise that isn't vector.

Or, remove all displacement and observe the Perlin noise.

Here is a Diff Scalar being blurred. Radial of course but yeah. Needs a lot closer steps too, and more iterations. And need to figure out how to position each step correctly. I probably shouldn't merge with original via merge shader so it doesn't show through.

(http://i.imgur.com/aYfudZO.png)

Now if I scale up, and scale back, while trying to maintain position, and then translate away from the radial center (where things are pinches) we can see there is a very noticeable blur on one plain. Now just to get it on all plains.

(http://i.imgur.com/VXpfcYe.png)

Even further iterations.

(http://i.imgur.com/NUMVqhj.png)

Creases are still present, as it's really hard to position correctly, and also scale the iterations thousands of times right next to another crease. That would need to be done by a script, which I am planning on writing in PHP.
Title: Re: soft maximum/minimum
Post by: Volker Harun on January 08, 2016, 12:08:49 PM
My very first thought to achieve this is to use two soft step scalars.