Author Topic: question about mask  (Read 752 times)

Offline micvswind

  • Member
  • *
  • Posts: 21
question about mask
« on: August 17, 2017, 04:40:44 AM »
hi guys.
here is a question,i calculate this mask form terrain,then i mask a flat surface with it,why it is so different.

Offline micvswind

  • Member
  • *
  • Posts: 21
Re: question about mask
« Reply #1 on: August 17, 2017, 05:13:57 AM »
and now the question become that how change a 3dimension mask to 2dimension mask.

Offline micvswind

  • Member
  • *
  • Posts: 21
Re: question about mask
« Reply #2 on: August 17, 2017, 05:48:03 AM »
here is the tgd.

Online bobbystahr

  • Member
  • *
  • Posts: 8087
  • Turn, and face the Strange Ch Ch Changes...D Bowie
Re: question about mask
« Reply #3 on: August 17, 2017, 05:55:29 AM »
what's the point of the Merge shader that goes nowhere?
something borrowed,
something Blue.
Ring out the Old.
Bring in the New

bobbystahr

Offline Dune

  • Member
  • *
  • Posts: 12738
  • Corkscrew Bird
    • www.ulco-art.nl
Re: question about mask
« Reply #4 on: August 17, 2017, 06:39:19 AM »
What do you want to achieve with this? The masking follows the contours of the terrain allright (though I stretched the Y of the terrain to 10000, which allows for better masking).
In case you still haven't seen enough of my work: www.ulco-art.nl

Offline micvswind

  • Member
  • *
  • Posts: 21
Re: question about mask
« Reply #5 on: August 17, 2017, 07:09:47 AM »
What do you want to achieve with this? The masking follows the contours of the terrain allright (though I stretched the Y of the terrain to 10000, which allows for better masking).

i want apply the mash with shape of contour to a flat plane.

Offline Dune

  • Member
  • *
  • Posts: 12738
  • Corkscrew Bird
    • www.ulco-art.nl
Re: question about mask
« Reply #6 on: August 17, 2017, 07:31:31 AM »
It's better to use the colors/scalars from altitude to make your contours. Altitude itself doesn't work like this. See screendump. The color adjust shaders (or smooth step+ 2 constants) give you some altitude, which you can add and subtract, etc, until you have the desired contours.
In case you still haven't seen enough of my work: www.ulco-art.nl

Offline treddie

  • Member
  • *
  • Posts: 156
Re: question about mask
« Reply #7 on: October 10, 2017, 09:00:56 PM »
I hope I am not barging in here, but I have been having this same problem.  I tried your example here, Dune but could not get it to work outright, so it must be a settings issue.

In an attempt to understand exactly what the shaders are doing, I tried this test without regard to anything but getting a halo on a big disk object, where the disk meets the terrain.
It seems that the previews are telling me I have a good mask, but it just does not do what it appears it should do when applied to the surface layer.

Note:  The "stray" Color Adjust shader is not connected to anything, because it was nothing more than a reverse image of the Adjust shader that I have hooked up.  It was used for testing purposes.

76602-0
« Last Edit: October 10, 2017, 09:07:25 PM by treddie »

Offline Dune

  • Member
  • *
  • Posts: 12738
  • Corkscrew Bird
    • www.ulco-art.nl
Re: question about mask
« Reply #8 on: October 11, 2017, 07:31:57 AM »
This doesn't work obviously.
1. I would suggest merging the two large displacements (mainland and island) before the compute terrain (faster to render, because you have one less compute terrain), and also stretch the Y of both fractals X100 or so. You could also use just one fractal warp after that merge. Then add a blue node 'displacement to scalar' as a sideline, then add a color adjust. Attach the color adjust to the lake surface shader, and start by setting the white and black color to altitudes around the water level. That should give you a nice white 'surf' band around the landmasses.
In case you still haven't seen enough of my work: www.ulco-art.nl

Offline mogn

  • Member
  • *
  • Posts: 443
Re: question about mask
« Reply #9 on: October 11, 2017, 12:42:30 PM »
Using blue nodes only makes it simple.
The fractal terrain is from the default scene.

Offline treddie

  • Member
  • *
  • Posts: 156
Re: question about mask
« Reply #10 on: October 11, 2017, 07:51:11 PM »
Ok, I got both of your examples to work, and thank you for the guidance.  But I still do not understand WHY mine does not.  If I pass a mask (that its preview says is valid) to a shader, the shader should honor the mask, no?  Obviously, something is wrong in my setup, and I do not feel much closer in understanding what the various shaders are meant to accomplish.  They seem counter-intuitive.

Offline Oshyan

  • Planetside Staff
  • *
  • Posts: 11752
  • Holy snagging ducks!
Re: question about mask
« Reply #11 on: October 11, 2017, 08:06:18 PM »
It's hard to say for sure what's going on without seeing your TGD. But one thought that comes to mind is that having Mask As Coverage enabled might give you different results than you expect.

- Oshyan

Offline treddie

  • Member
  • *
  • Posts: 156
Re: question about mask
« Reply #12 on: October 11, 2017, 11:04:10 PM »
Hi Oshyan!

I had fiddled with mask as coverage, but found that either way, it usually did not change things much.

Here is my tgd.  For the life of me, I cannot see why it won't work as set up.  I am fine with the help people have offered with their own solutions, but if I cannot see why a particular approach won't work, then all I will ever end up doing is reusing other people's stuff with no understanding of what any node is doing.  Especially when you get into the functions (blue nodes).

* Mask Test (Simple).tgd (33.79 kB - downloaded 32 times.)

« Last Edit: October 11, 2017, 11:07:02 PM by treddie »

Offline Dune

  • Member
  • *
  • Posts: 12738
  • Corkscrew Bird
    • www.ulco-art.nl
Re: question about mask
« Reply #13 on: October 12, 2017, 06:11:46 AM »
It's quite logical why your setup won't work; the distribution shader calculates altitudes from a surface that is flat (ocean). No matter if you attach the terrain into input of it. It works independently.
In case you still haven't seen enough of my work: www.ulco-art.nl

Offline Matt

  • Planetside Staff
  • *
  • Posts: 2849
  • I'm the crazy one
Re: question about mask
« Reply #14 on: October 13, 2017, 08:26:47 AM »
In Terragen the displacement pipeline and the colour/shading pipeline are processed at different times. First, all of the shaders are used to displace the surface of the object so that the final displacement is known. Then all of the shaders are used to calculate colour and shading according to the final displacement. In your setup the Distribution Shader won't see any displacement because it's applied to an object that has no displacement (intentionally, I assume). It doesn't matter that its input can generate displacement, because displacement isn't automatically calculated when a shader is used as a mask; the mask shader only generates colour.

A different method is needed, and this is where Dune's method is useful. The terrain needs to be converted to a value using "Displacement to Scalar" node. This node requests displacement from its input during the colour/shading pipeline and converts it to a value that can be used as a scalar or a greyscale colour. This then can be used as a mask, but you'll want to remap the values to a range between 0 and 1 using a Colour Adjust Shader, or Smooth Step Scalar, or something like that.

Another thing to remember: Although data usually seems to flow from top to bottom (from a shader's output to the input port of another node), things are really calculated in reverse. An object or shader requests data from its input(s). Therefore the values generated by a shader depend on the context in which they are requested.

Matt
« Last Edit: October 13, 2017, 08:46:09 AM by Matt »
Just because milk is white doesn't mean that clouds are made of milk.