#blending terrain graph

1 messages · Page 1 of 1 (latest)

north pollen
#

i made a thread.

#

so in my shader graph, i get the position and the normal vector. i then remap the y-position to range from -1 to 1, and get the steepness of the normal vector by getting the dot product (with a (0,1,0) vector3)

using these values, and having parameters such as maxHeight, minHeight, maxSteepness, minSteepness, i assign the proper texture.

#

which looks like this:

i have a module like this one for each of the textures.

the 4 inputs coming in from the left are the steepness i calculated (top 2 blue lines) and the normalized y-value (bottom two blue lines)

then the next textures branch output goes into this branch's "false" input, and this branch output sets the baseColor.

#

this is with all textures

dusky basin
#

Yep, so, you have hard transitions between the textures.
If you want smooth transitions, you can't use branch nodes, branches are just "on or off".

You need to calculate a "weight" for each texture, based on the height and slope. This weight should be a mask values in the [0-1] range. You then use the Lerp nodes to blend with the previous texture.

north pollen
#

this is what it looks like on my terrain. i am quite pleased with how well it works (i know, i still need to optimize it as it is WAY more expensive than it needs to be), but you can see how clear and visible the edges are between the textures

dusky basin
#

Typically, for the height portion, you would do it like this :

north pollen
#

i understand what you mean, however the first time even touching shaderGraphs was three days ago and i have no clue how i could calculate the weight....

dusky basin
#

Basically, you do a height mask, and a slope mask for each layer.
You then combine them (multiply node for example), and use it to blend with the previous layer.

#

I would probably help to isolate the layering logic in a subgraph, so it will be easier to handle any further modifications.

north pollen
#

i would need a double smoothstep though, right? if the height (grass, for example) is set to 0.3-0.8, and the slopeRange 1 (facing up) - 0.5 (a 45° slope), it should blend in and then out again, right?

and is there a way to make it "bleed" instead? so that if it is between .3-.8 and 0°-45°, it is at 100%, then drops off as it is outside of these bounds? this would ensure that at height 1 for example snow doesn't fade out, making the tips semi-snow and semi-base object color (black)

dusky basin
dusky basin
north pollen
#

no, i meant that it is lerping from 0%-100% from bottom to top, so that means the top will have rought edges, right?

dusky basin
#

Hum ... no. Lerp in a mixing operations, between A & B, based on T.
If T = 0, result is A, if T= 0.25, result is 75%A+25%B, if T=0.5 its half A + half B, if T = 1, result is B.

#

And with this setup, each layer has a starting height transition, and an ending height transition. Then higher up is the starting height transition of the nest layer, and go on.

north pollen
#

oh dang my bad, it anyway would work how it is desired to... if it blends from 0-100, then the next layer will blend from 0-100 again so even though the previous layer ended at 100% opacity (i hope i am using opacity right...), the next layer only starts blending so it anyway makes each layer look like its blending on both ends...

north pollen
#

what would be the best way to "normaalize" the height and slope values?

#

i have 6 different textures, so trying to find a balance with all the values is really tricky.... it would be much easier if the height was in a range of 0-1, no matter the size of the object, and the same for the slope...

#

and i noticed that in the layerSubGraph, when changing the heightMinMax max value to something less than 1, it doesnt change anything....

dusky basin
dusky basin
north pollen
#

in the sub graph, when i try modifying the max value of the height range to something below 1, i would expect the top part of the preview to become black, but it doesnt...

dusky basin
north pollen
#

if you change the the max height to 0.2, does it change anything?