Planetside Software Forums

General => Terragen Discussion => Topic started by: micvswind on August 17, 2017, 12:40:44 AM

Title: question about mask
Post by: micvswind on August 17, 2017, 12: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.
Title: Re: question about mask
Post by: micvswind on August 17, 2017, 01:13:57 AM
and now the question become that how change a 3dimension mask to 2dimension mask.
Title: Re: question about mask
Post by: micvswind on August 17, 2017, 01:48:03 AM
here is the tgd.
Title: Re: question about mask
Post by: bobbystahr on August 17, 2017, 01:55:29 AM
what's the point of the Merge shader that goes nowhere?
Title: Re: question about mask
Post by: 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).
Title: Re: question about mask
Post by: micvswind on August 17, 2017, 03:09:47 AM
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.
Title: Re: question about mask
Post by: Dune on August 17, 2017, 03: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.
Title: Re: question about mask
Post by: treddie on October 10, 2017, 05: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.

[attach=1]
Title: Re: question about mask
Post by: Dune on October 11, 2017, 03: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.
Title: Re: question about mask
Post by: mogn on October 11, 2017, 08:42:30 AM
Using blue nodes only makes it simple.
The fractal terrain is from the default scene.
Title: Re: question about mask
Post by: treddie on October 11, 2017, 03: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.
Title: Re: question about mask
Post by: Oshyan on October 11, 2017, 04: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
Title: Re: question about mask
Post by: treddie on October 11, 2017, 07: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).

[attach=1]

Title: Re: question about mask
Post by: Dune on October 12, 2017, 02: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.
Title: Re: question about mask
Post by: Matt on October 13, 2017, 04: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
Title: Re: question about mask
Post by: treddie on October 20, 2017, 07:18:12 PM
Sorry for the delay in getting back.  Very busy lately.

So just because I have a high contrast preview that looks like a good mask, it's not necessarily.  It could just be altitude information?  But then I can convert that to a grayscale "bitmap" and use THAT as the mask?

But if I use a distribution shader to confine to a particular band in the terrain, why cannot that be used to tell  the displacement shader to only let displacement info through that lies in that band, and everything else is either black or pure white?  Since every point in the displacement "map" signifies precise points above the initially flat terrain surface.  Ergo, somewhere in the pipeline, those scalar displacement values are keyed to points of altitude.  No?
Title: Re: question about mask
Post by: Dune on October 21, 2017, 02:49:30 AM
QuoteBut then I can convert that to a grayscale "bitmap" and use THAT as the mask?
Yes, but that would need a render of that mask and reimport in an image map shader. You'd have to figure out the projection then.

The scond point only works if you use it in the same line to the planet input, so the main line of shaders, because that's where the band is calculated from. Not in a lake or so.
Title: Re: question about mask
Post by: micvswind on December 12, 2017, 09:46:49 PM
Quote from: Dune on October 21, 2017, 02:49:30 AM
QuoteBut then I can convert that to a grayscale "bitmap" and use THAT as the mask?
Yes, but that would need a render of that mask and reimport in an image map shader. You'd have to figure out the projection then.

The scond point only works if you use it in the same line to the planet input, so the main line of shaders, because that's where the band is calculated from. Not in a lake or so.


here again.
i am sorry for delay to back.and this problem still trouble me.
with you guys's suggestion.and i still can't resolve my problem.displacement to scalar get a mash like image A,and i get a mask with distribute like image B.i use the mask like image C to desire a mask that offset the mask image B,but i failed.
my purpose is show like image D.maybe you guys could help me again.
Title: Re: question about mask
Post by: Dune on December 13, 2017, 02:20:34 AM
You make it yourself too difficult. I made you a simple starting file. And, btw. a distribution shader needn't have an input for it to calculate slopes/altitudes.

And an example of what I made with this basic setup a few years ago.
Title: Re: question about mask
Post by: micvswind on December 13, 2017, 02:46:14 AM
Quote from: Dune on December 13, 2017, 02:20:34 AM
You make it yourself too difficult. I made you a simple starting file. And, btw. a distribution shader needn't have an input for it to calculate slopes/altitudes.

And an example of what I made with this basic setup a few years ago.

Thank you much again dune.I download you .TGD file and study it carefully.you show a way to solve the problem smartly.and i desire to get out a terrace landscape like this image bellow:
i want to offset the mask get with slopes/altitudes and displace the terrance with a scalar like -1,thus edge of every lever of the terrace is flat ,can walk people and keep water.
thank you  again.forgive me for my poor english.

regards.
Title: Re: question about mask
Post by: Dune on December 13, 2017, 12:35:17 PM
I don't quite understand what you want, but what you show with the coloured lines - some kind of inner offset, is not possible with this setup. Not to my knowledge anyway. Maybe someone else can give you a better solution....