Author Topic: North/South face (Updated 22/5/07)  (Read 6786 times)

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
North/South face (Updated 22/5/07)
« on: May 14, 2007, 08:49:49 PM »
Playing around with functions.... 
 
4123-0

This is a very basic mask setup for only slopes facing N,E,S or W. I normally only use north/south combinations anyway, but I put the others in 'cause it was easy to do so. See the attached TGD for connections.  Input is from a compute terrain or compute normals node, output is from the bottom nodes. Tweaking (changing the width of slope to be masked) is done via the colour adjust nodes in the bottom row.

If you want to specify angles other than these get Harvey Birdman's clip  I'm leaving this here for now because this may render faster as there is less processing (yet to be confirmed one way or the other).

The zip file contains the TGD and image map used for the test image. Created 2 versions of the clip. A compact version for general use and an expanded version for those wanting to look at the inner workings.
« Last Edit: May 22, 2007, 02:47:42 AM by bigben »

Harvey Birdman

  • Guest
Re: North/South face
« Reply #1 on: May 14, 2007, 08:52:46 PM »
Hey, awesome! I was just wondering how to do this.

Offline old_blaggard

  • Member
  • *
  • Posts: 2524
    • http://sdcarpenter.free.fr/paul/
Re: North/South face
« Reply #2 on: May 14, 2007, 08:54:47 PM »
Clever!  Thanks for sharing, Ben.
http://www.terragen.org - A great Terragen resource with models, contests, galleries, and forums.

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: North/South face
« Reply #3 on: May 15, 2007, 12:00:43 AM »
Your welcome.  It turned out to be easier than expected. I wasn't sure what the numerical range of the scalar was going to be but I figured you must be able to derive the direction of the slope from the normal vector.  I have to stop uploading stuff in a hurry before going to work, as I left in the wrong vector component. I fixed this and left the old one in as well so you have a clip file that will let you generate a mask for north, south, east and west faces.  You can also do intermediate faces by multiplying two faces together.  e.g. south x east = southeast. ... or use any other masking combos.

If you're using DEMs and you want a more generalised mask you can create an extra heightfield shader, turn the fractal detail OFF and plug in the load heightfield node... feed this into a "Compute normal" and then into the Get normal of this clip file (see screengrab).

Harvey Birdman

  • Guest
Re: North/South face
« Reply #4 on: May 15, 2007, 11:41:37 AM »
I'm just getting ready to try applying this to some of the Yosemite terrain. Do you really need the extra heightfield shader and compute normal node? Couldn't you just take the output of the original compute terrain node and use that, and do the colors in the final 'tweak' color adjust shaders? Like I said, I haven't tried it yet, I'm just wondering if those will (heightfield and compute normal) will be necessary.

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: North/South face
« Reply #5 on: May 15, 2007, 10:41:58 PM »
You could do this.

What you can't see in the screen grab is that the heightfields on the left have fractal detail ON, and the ones on the right have fractal detail OFF.  This gives you a more generalise mask for the terrain that would still allow for coverage on all faces in the smaller details. Whether you use this or not depends on the effect you are trying to simulate.

With some extra tweaking it would also be possible to create a mask generator taking inputs for start and end angles, and a fuzzy zone (symmetrical or different for start and end) but I'll save this for when we can create "macros". I'm making enough clutter for now  ;)
« Last Edit: May 15, 2007, 10:46:15 PM by bigben »

Harvey Birdman

  • Guest
Re: North/South face
« Reply #6 on: May 15, 2007, 10:49:43 PM »
What you can't see in the screen grab is that the heightfields on the left have fractal detail ON, and the ones on the right have fractal detail OFF.  This gives you a more generalise mask for the terrain that would still allow for coverage on all faces in the smaller details. Whether you use this or not depends on the effect you are trying to simulate.

Ah. Very good.
 :)

Harvey Birdman

  • Guest
Re: North/South face
« Reply #7 on: May 16, 2007, 11:48:34 PM »
I have an improvement to suggest.

<edit>

Well, mabe.    ;)

</edit>

Let's say you're using the north face as shown above. The color output of the 'scalar to color 03' node will output white on the north faces, black elsewhere. This is clamped to something less than black in the 'tweak north' node, if the 'clamp to black' box is checked. Even so, though, the color output from the 'tweak north' node is white where there should be snow, and some non-white color elsewhere. This is then fed to the color function input of the north surface shader node. What happens is that the resultant surface shader output (at least the way I was trying to use it) applies a light color on the dark face where it has coverage, and a dark color on other faces where it has coverage. Coverage isn't limited to only north faces; the white portion of the shader output is, but it's output isn't always white. I admit I haven't actually tried your demo .tgd, BigBen, but I suspect that if you were to take the face mask nodes out of your layout, the north faces would get darker as the 'snow' disappeared, but all the other faces get lighter, too, as the dark 'snow', if you will, also disappears.

What I suggest is taking each 'tweak xxxx' output and connecting it not only to the color function input on the corresponding face surface shader, but connecting it to the breakup input as well (see image). I found that this would preserve the light 'snow' areas, but eliminate coverage where it wasn't white (or nearly so), allowing the underlying surface layers to show through undimmed. (As you may gather from the image, i am applying the face masks last, so the 'snow' overlays any other surface.)
« Last Edit: May 16, 2007, 11:54:20 PM by Harvey Birdman »

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: North/South face
« Reply #8 on: May 17, 2007, 02:00:58 AM »
Hi Harvey

I'll try and explain how I built this, which may help you decide what you want to do with it. I suspect that you just need to increase both the black and white levels in the "tweak" node.

As far as I could tell the colour result of the vector derived from Get normal has a value of 0 - 1, providing a deviation from the positive direction of the axis.  1 = 0 and 0 = 180, with intermediate shades representing the intermediate angles. A value of 1 in the vector corresonds to: X = East, Z = North, Y = Flat (slope)

The Colour adjust shader does (at least) three things:
  • White point: sets the maximum deviation from the axis that has 100% of the masked surface applied
  • Black point: Sets the minimum deviation from the axis that has 0% of the masked surface applied
  • Difference between Black point and White point = "Fuzzy" zone

e.g.  (using compass bearings) Z vector, white point 0.5, black point 0.333 will produce a mask providing 100% coverage of slopes facing from 270 thru 360 to 90 (180 +/- (vector x 180)) , fading off to nothing by 240 and 120 respectively.

You could also adjust the gamma to tweak the fall off of the surface in the fuzzy zone.

Connecting the tweak colour to additional shaders is technically redundant.  You could also plug it in to the child layer. Connecting it to the fractal breakup also requires changing the coverage/breakup settings.

The computer terrain (or a computer normal) should be the only input, using the outputs as mask for surfaces (connect to fractal breakup, blending shader etc...)

Hope this helps  :)
« Last Edit: May 17, 2007, 02:04:52 AM by bigben »

Harvey Birdman

  • Guest
Re: North/South face
« Reply #9 on: May 17, 2007, 02:19:45 AM »
I understand how the color adjust shader affects the distribution - no problem there. I think the confusion may stem from the fact that I'm trying to use the 'xxx Face' outputs directly as surface shaders while you're using them as masks to control another shaders output. As a mask your setup would work (I'll take your word for it  :D ). But using a 'face' output directly as a surface shader (as opposed to using it as a mask) applies both the dark areas of the 'mask' as well as the light areas. At least that's the way it seemed. I think I may actually be saving a step by using it as a shader instead of a mask. What do you think?

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: North/South face
« Reply #10 on: May 17, 2007, 02:36:44 AM »
I usually combine multiple masks together so this was originally intended as component for constructing masks more than anything else.

You could use it as a surface if you really wanted to, in which case you would want to plug it into the fractal breakup rather than the colour function.  It would also simplify things by using the invert breakup to reverse direction rather than subtracting the vector from 1.  I'll update it later.


Harvey Birdman

  • Guest
Re: North/South face
« Reply #11 on: May 17, 2007, 02:59:00 AM »
Cool. Thanks for the feedback. Setting up a generalized mask like you're doing is definitely more flexible. Maybe as I get a bit more adept at this I'll be working with more complex setups but for the moment this gives me a nice direct way of doing a normal-dependent snow (for instance) distribution. Won't be as flexible as your setup but it's not as complicated, either.

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: North/South face (Updated 20/5/07)
« Reply #12 on: May 21, 2007, 12:13:01 AM »
OK I think I got the last glitch... for the benefit of the one person who downloaded the previous version  ;)

Offline rcallicotte

  • Member
  • *
  • Posts: 9542
Re: North/South face (Updated 22/5/07)
« Reply #13 on: May 22, 2007, 01:21:15 PM »
Ben, thanks for your work (and Harvey, too).  I'm not ignoring you, but you're always two or three sectors away from my parsec.  So, I'm taking it slow, while I keep up with work and everything. 

Don't quit giving us this good stuff, though.  It's awesome.
So this is Disney World.  Can we live here?

 

anything