# Planetside Software Forums

## General => Terragen Discussion => Topic started by: WAS on October 25, 2018, 08:38:26 pm

Title: Mutliples in Terragen?
Post by: WAS on October 25, 2018, 08:38:26 pm
Is it possible to do a conditional to check multiples? Ex ( altitude / scalar ) != 0

Additionally have it recursive for height? From like 0 - alt or alt - 0

What I was thinking of doesn't provide me anything
Title: Re: Mutliples in Terragen?
Post by: WAS on October 25, 2018, 09:01:33 pm
Also thought about the logic this way but still not able to get any result. I think the issue is I'm not sure how to loop through the available altitude (if any).

Actually, my else input just defaulted accidently to the displacement multiplier, which should be the displacement to scalar, so it is proving a else result.
Title: Re: Mutliples in Terragen?
Post by: Oshyan on October 26, 2018, 02:10:10 pm
There are no loops and, as far as I'm aware. The Conditional nodes would be an example of conditionals.

- Oshyan
Title: Re: Mutliples in Terragen?
Post by: WAS on October 26, 2018, 05:03:38 pm
Well it is a conditional. Multiples in programing.

For example, the second image shows a working method (minus defaulted else result that should be a disp scalar), just no ability to actually loop through the alt.
Title: Re: Mutliples in Terragen?
Post by: Matt on October 26, 2018, 06:33:31 pm
What do you mean by multiples? Are you looking for 'modulo' ? If so, there's a node for that, as well as rounding to the nearest integer.
Title: Re: Mutliples in Terragen?
Post by: WAS on October 26, 2018, 08:03:10 pm
Quote from: Matt on October 26, 2018, 06:33:31 pm
What do you mean by multiples? Are you looking for 'modulo' ? If so, there's a node for that, as well as rounding to the nearest integer.

I was looking to occur a result on altitude at certain multiples applying a effect if so, if not, piping original scalar.  For example 100, would be happening every 100 meters.

Think of basic programming like printing columns or rows where you want to establish a new column/row... or even more basic in old HTML/CSS styling columns with different cololours

https://ideone.com/yGYjwY

Was hoping to be able to go by altitude and thus effect terrain wherever by altitude without actually doing it by masks.
Title: Re: Mutliples in Terragen?
Post by: Matt on October 26, 2018, 10:21:28 pm
I think this is what you need:

https://planetside.co.uk/wiki/index.php?title=Modulo_Scalar

<terragen_clip>
<modulo_scalar
name = "Modulo scalar 01"
gui_use_node_pos = "1"
gui_node_pos = "-300 820 0"
gui_group = ""
enable = "1"
input_node = "Get altitude 01"
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
input_2 = "Constant scalar 01"
>
</modulo_scalar>
<get_altitude
name = "Get altitude 01"
gui_use_node_pos = "1"
gui_node_pos = "-300 960 0"
gui_group = ""
enable = "1"
input_node = ""
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
>
</get_altitude>
<constant_scalar
name = "Constant scalar 01"
gui_use_node_pos = "1"
gui_node_pos = "-100 900 0"
gui_group = ""
enable = "1"
input_node = ""
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
scalar = "100"
>
</constant_scalar>
</terragen_clip>
Title: Re: Mutliples in Terragen?
Post by: WAS on October 26, 2018, 10:57:31 pm
Quote from: Matt on October 26, 2018, 10:21:28 pm
I think this is what you need:

https://planetside.co.uk/wiki/index.php?title=Modulo_Scalar

<terragen_clip>
<modulo_scalar
name = "Modulo scalar 01"
gui_use_node_pos = "1"
gui_node_pos = "-300 820 0"
gui_group = ""
enable = "1"
input_node = "Get altitude 01"
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
input_2 = "Constant scalar 01"
>
</modulo_scalar>
<get_altitude
name = "Get altitude 01"
gui_use_node_pos = "1"
gui_node_pos = "-300 960 0"
gui_group = ""
enable = "1"
input_node = ""
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
>
</get_altitude>
<constant_scalar
name = "Constant scalar 01"
gui_use_node_pos = "1"
gui_node_pos = "-100 900 0"
gui_group = ""
enable = "1"
input_node = ""
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
scalar = "100"
>
</constant_scalar>
</terragen_clip>

I think that is pretty much what I tried to do with my first attempt at terrain stepping with modulo but wasn't sure how to use it to use it to apply to the terrain.

https://planetside.co.uk/forums/index.php/topic,25829.msg256234.html#msg256234

Let's see what else i can come up with with it.
Title: Re: Mutliples in Terragen?
Post by: WAS on October 26, 2018, 11:14:50 pm
Well, I thought about it differently and came across this lol still not what I'm after.
Title: Re: Mutliples in Terragen?
Post by: Hetzen on October 27, 2018, 08:37:04 pm
WAS, Duncan right? Sorry I'm crap with names.

Modulo is a really cool function for what you're trying to get to. I like to divide the modulo output by the modulo scaler input, that will give me a range of 0-1 for each step, rather than an output which depends on the modulo input2 amount. Then you can throw that at what you're trying to form. eg multiply by pi into a sine function which will give you half a phase of a sine wave each step, ie the positive bump every step you've set input2 to.

Conditionals are an unforgiving beast as you've found with that network. They often give harsh results, if not used properly.

I'll use them for two things; one to cut off any complicated calculation. If a simpler calculation of a mask says zero, then I don't want the extra processing in my render. ie don't bother looking at those hundreds of nodes if the mask made by a couple of nodes says zero. Can cut out a shit load of rendering time. Especially with cloud stuff.

The other is when you want to combine two scaler patterns and want the larger value through over the test. So for example, you have two PFs outputting 0-1 colour space. You plug one PF into the input. The second into the comparison. The logic then goes if Input is 'greater' than Comparison, then pass Input else show Comparison. This can give great patterns that cut over the other, a bit like the Merge function works with displacements, but you're working in colour space.
Title: Re: Mutliples in Terragen?
Post by: WAS on October 27, 2018, 09:19:45 pm
Jordan, actually. Duncan is one of my favorite characters from the Dune saga, however.

Wow, this is a lot to think about, some cool ideas you've given. I'm still not sure i understand the process of utilizing the modulo to apply exactly what I want, especially adding pi through a sine.

Mathematics and me are not friend, as much as I dabble in fields which require it I do have really bad dyscalculia which really effects my understanding and ability to perform in it.
Title: Re: Mutliples in Terragen?
Post by: Hetzen on October 27, 2018, 09:33:38 pm
Sorry Jordan. I've etched that into my brain now. I'm a big fan of Lynch's Dune.

Yeah modulo counts up to the input you give it. So, if you use Get Altitude as your main input, and you want things to happen every 100 meters, input2 on your modulo scaler is 100. But your output will be 1-100 every 100 meters. If you want that to drive things, ie a mask, a mask should only work with values 0-1, so divide your modulo output by your input (100) will give you that scale.

Trig functions work in radians, so a range of 0-1 needs to be multiplied by 2 x pi to give a full sine wave (ie positive bump to negative dip). The example I gave above only looked at the positive bump, so you only need half of it's phase, so just pi, no need for the x2.
Title: Re: Mutliples in Terragen?
Post by: WAS on October 27, 2018, 09:45:30 pm
I feel very accomplished Hetzen... Thank you a lot! It's hard to express how excited I am right now via text but I'm ecstatic.  :D :D

Now to see about testing some thing with it's use.

I won't tell you how many times I read your posts and wrote on paper...
Title: Re: Mutliples in Terragen?
Post by: Hetzen on October 27, 2018, 09:59:27 pm
Well, pleased to meet you Jordan. I'm a Jon in this fractal landscape.

If you want to recreate a simple strata function try this....

Displacement to Scaler - Modulo every 100

Displacement to Scaler subtract above result

That will give you hard steps every 100 meters when you plug that result into a Displacement node.
Title: Re: Mutliples in Terragen?
Post by: WAS on October 27, 2018, 10:21:15 pm
Oh interesting, I think that's more along the lines of what I was initially going for. I wonder if there is a way to blend the resulting scalar by original disp to scalar with some sort of constant scalar to controll the slop from hard to soft or nothing (original).
Title: Re: Mutliples in Terragen?
Post by: Hetzen on October 27, 2018, 10:37:02 pm
Yes there is. But you'll need to work out what's going on in the above and how you want to apply it.

In the above example, you're subtracting the modulo output from the displacement value. Within that you can work out how that modulo output should curve through it's range to give you less harsh steps. Nodes like Bias and Gain are useful, but they work within the 0-1 range, so the divide by modulo input2 brings you back into that, which you can then multiply back out. Then you have Linear and Smooth Step Scalers. Combinations of those will create step steepness and plateau build up.

And nothing is stopping you multiplying anything by a PF....
Title: Re: Mutliples in Terragen?
Post by: WAS on October 28, 2018, 03:42:50 am
Quote from: Hetzen on October 27, 2018, 10:37:02 pm
Nodes like Bias and Gain are useful, but they work within the 0-1 range, so the divide by modulo input2 brings you back into that, which you can then multiply back out.

Could you explain this, maybe a little more simpler? I think I got lost. I'll have a look in the morning and see if I can understand it better.

Quote from: Hetzen on October 27, 2018, 10:37:02 pm
Then you have Linear and Smooth Step Scalers. Combinations of those will create step steepness and plateau build up.

This I am also confused on, I've been told about using linear and smooth step in conjunction for this but couldn't seem to grasp it. Is it a linear step fed into a smooth step, right?
Title: Re: Mutliples in Terragen?
Post by: mhaze on October 28, 2018, 06:50:47 am
Thanks for this - however I cannot get bias/gain or smooth step to work. Probably the fact that my maths has long gone! I can get plateau build up but not control the steepness of the steps.
Title: Re: Mutliples in Terragen?
Post by: Dune on October 28, 2018, 07:02:25 am
If you have an output and put a bias scaler after that, use a constant scalar as function input, with a value between 0 and 1 to shift the grey. I usually use 0.2 or 0.8 or so to shift either side. Smooth step kind of works the same as color adjust (but differently), and you can use either small values or in case of large terrain displacements altitudes. Even PF's with ((even large) color ranges and distribution by its noise.
Title: Re: Mutliples in Terragen?
Post by: mhaze on October 28, 2018, 07:08:05 am
This is as far as I seem to be able to get.
Title: Re: Mutliples in Terragen?
Post by: Hetzen on October 28, 2018, 08:16:10 am
Here you go. :)
Title: Re: Mutliples in Terragen?
Post by: mhaze on October 28, 2018, 08:43:27 am
Thank you. Always great to learn from the masters! I've struggling all morning!
Title: Re: Mutliples in Terragen?
Post by: mhaze on October 28, 2018, 10:14:54 am
Thanks again, Hetzen, with the addition of a Y redirect this produces beautiful outcroppy landscapes.
Title: Re: Mutliples in Terragen?
Post by: Hetzen on October 28, 2018, 02:34:04 pm
Looking forward to seeing what you come up with.
Title: Re: Mutliples in Terragen?
Post by: WAS on October 28, 2018, 03:08:18 pm
Oh there has been some developments. From what I am understanding from current conversation I was trying to do things a little backwards for the edges.
Title: Re: Mutliples in Terragen?
Post by: Dune on October 29, 2018, 04:17:37 am
Here's another simple way of getting some sort of strata.
Title: Re: Mutliples in Terragen?
Post by: WAS on October 29, 2018, 04:25:34 am
Oh wow, cool Ulco. This thread is really getting informative. Haha
Title: Re: Mutliples in Terragen?
Post by: ajcgi on October 29, 2018, 08:15:26 am
The simple node layouts on this thread answer a few blue nodes questions I've had for a while.
This strikes me as being potentially faster and looser, creatively speaking, for strata.
Title: Re: Mutliples in Terragen?
Post by: mhaze on October 29, 2018, 12:29:45 pm
Title: Re: Mutliples in Terragen?
Post by: Matt on October 29, 2018, 06:46:56 pm
Ulco, have you tried using Get Altitude instead? It doesn't need an input, and this saves it from calculating the terrain twice (or 4 times in your example).
Title: Re: Mutliples in Terragen?
Post by: Dune on October 30, 2018, 02:50:41 am
No, but does that save on rendertime? It works the same way, but there's no compute terrain anyway, just the difference between get altitude and displacement to scalar....
Title: Re: Mutliples in Terragen?
Post by: mhaze on October 30, 2018, 05:47:14 am
Here's an example using get altitude, slightly easier to mask but harder to set up. I've added a redirect to add to the fun.
Title: Re: Mutliples in Terragen?
Post by: Matt on October 30, 2018, 03:23:43 pm
If you had a lot more terrain shaders in there, then yes, the number of times they are calculated substantially affects the render time (for the same reason that Compute Terrain affects render time). Moreover, someone might follow this whole setup by a Compute Terrain, so you want it to be efficient. Your Displacement to Scalar should be replaced with Get Altitude and its input disconnected. I believe it will produce the same output, but more efficiently.
Title: Re: Mutliples in Terragen?
Post by: Dune on October 31, 2018, 02:43:28 am
Thanks Matt. I wouldn't have thought the difference between get altitude (a calculation, afaik) and displacement to scalar (a calculation) would be that big, but it's good to know.
Title: Re: Mutliples in Terragen?
Post by: Oshyan on October 31, 2018, 04:53:25 pm
Different calculations have different levels of complexity and thus calculation time. This goes down to even the simplest of calculations, for example addition and subtraction are faster in CPUs than multiplication. Both are "calculations", but one takes more resources/time.

- Oshyan
Title: Re: Mutliples in Terragen?
Post by: Matt on October 31, 2018, 08:20:37 pm
Displacement to Scalar calculates the tree of nodes input to the Displacement to Scalar (i.e. the fractal in your example, which has hundreds of instructions), while Get Altitude simply reads the displacement that was already in memory and calculates its altitude (which is just one vector subtraction and one dot product).
Title: Re: Mutliples in Terragen?
Post by: Dune on November 01, 2018, 03:15:37 am
Thanks, guys. Learned something again!
Title: Re: Mutliples in Terragen?
Post by: WAS on November 01, 2018, 03:10:07 pm
Found this digging on the forums by Frank, could be of help with different types of terracing.

https://planetside.co.uk/forums/index.php/topic,13221.0.html
Title: Re: Mutliples in Terragen? (Terracing Effect Discussion)
Post by: WAS on November 02, 2018, 02:47:54 am
Quote from: WASasquatch on October 25, 2018, 08:38:26 pm
Is it possible to do a conditional to check multiples? Ex ( altitude / scalar ) != 0

Additionally have it recursive for height? From like 0 - alt or alt - 0

What I was thinking of doesn't provide me anything