Problem with masks or just a newbie's error

Started by Oysterman, May 19, 2014, 08:49:32 AM

Previous topic - Next topic

Oysterman

Hi,

I'm trying to understand how masks work and for a moment I thought I did but then I got what can be seen in the image with small lakes and trees. Trees in the water!

I'm using a grey scale image made in Photoshop as terrain (image map based) and the same image, but inverted, to mask a shader.

Connected to the masked shader are a few populations of vegetation. To my surprise the populations populate the water areas which shouldn't happen since that is masked as a black area.

Advice on what I'm doing wrong is greatly appreciated.

Thanks

Dune

#1
I don't even have to look at your file; it's probably caused by the fractal warp shader, which changes the terrain, so the image map is also changed, while it is not in the lower end of the shaders line. See what happens if you take that out.

Or, like I did here, add the same fractal warp between image map and distribution shader.

Something else; there was someone else just a few days ago who used the end of the line also for distribution of populations. That is not the good way; you should use a separate distribution shader. Shouldn't be connected to the line of nodes at all. You can set heights (like minimum water height) or mask it by whatever you like; image map, power fractal, simple shape...
Probably, if you set minimum water height in the distribution shader that should be enough for your populations, no need for the image map there.


bigben

#2
There are a couple of things potentially going on here.
Firstly, as Dune alluded to, you should have your lake displacement last (just before the Compute Terrain).
If you want to rough up the shape of the image map, you should do this before connecting it to the displacement shader.
The reason for these two requirements is that you want to use your displacement function as a mask for your population density.

Another problem is that you've connected the surface shader to the population density NOT the image map. What you have is a population density based on the colour of the terrain. (You don't need the second image for the surface shader mask, you can just use the first and invert the mask.)

For your population density shader then, add a colour adjust shader and connect the input to your displacement function into this. Set the black value of the colour adjust shader to 1. TG smooths images, so even if your mask had only black and white, the anti-aliasing on the image would give you a smooth border.  This colour adjustment ensures you don't get trees in the shallow parts of the lake.  Use this colour adjust node as the population density.

Haven't changed the order of nodes, but try this.

[edit] An altitude restriction above your lake level may be enough as Dune mentioned, but it is possible to have multiple lakes at different altitudes, not to mention adding variation to the population density using a power fractal for the population density. In those cases I multiply any additional masks by the image map mask.

You can also reduce the amount of water rendered by masking the lake object.
http://forums.planetside.co.uk/index.php?topic=4459.msg49935#msg49935

Oysterman

Many thanks to both Dune and Big Ben.

I appreciate the extremely quick replies and I'm grateful for the two tgd files. Yes, I downloaded both.

Now I have to check them and re-think, which in this case is a good thing since I really failed before.

Maybe if I use masks a hundred times I get it :-)

Thank you