question about mask

Started by micvswind, August 17, 2017, 12:40:44 AM

Previous topic - Next topic

micvswind

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.

micvswind

and now the question become that how change a 3dimension mask to 2dimension mask.

micvswind

here is the tgd.

bobbystahr

what's the point of the Merge shader that goes nowhere?
something borrowed,
something Blue.
Ring out the Old.
Bring in the New
Bobby Stahr, Paracosmologist

Dune

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).

micvswind

Quote from: Dune on August 17, 2017, 02: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).

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

Dune

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.

treddie

#7
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.

[attach=1]

Dune

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.

mogn

Using blue nodes only makes it simple.
The fractal terrain is from the default scene.

treddie

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.

Oshyan

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

treddie

#12
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).

[attach=1]


Dune

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.

Matt

#14
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
Just because milk is white doesn't mean that clouds are made of milk.