Can't mask water shader

Started by digitalis99, January 24, 2012, 07:40:14 PM

Previous topic - Next topic

digitalis99

I hope someone can help out with a mental block I'm having.  I've tried dandelO and bigben's methods for masking water so that sub-terranean water isn't rendered, but I simply can't get it to work.  I've attached a .tgd so you can see where I'm at.  It appears that either the water is entirely present, or entirely gone.  None of the dozen combinations I've tried get the water to stay where the water is supposed to be.

Ignore the shore foam, it's a WIP.
Pixel Plow :: Render Endlessly :: http://www.pixelplow.net

dandelO

You'll need to create a mask to use as the opacity function of where you want water to show. Right now you have only a distribution shader plugged into it with altitude constraints, since the water is a sphere it's going to be the same height all round and any constraints used there are likely only to cut-off displaced areas of waves below the constraint level or, if 'Y for altitude' is used, the actual Y value right round the planet.

I'd take a paint shader, cover everywhere you see water in the preview with a pure white brush(flow=1, falloff=0) and miss out anywhere there is visible terrain. Paint a *little into the shoreline to make sure the water meets the shore all around your coast. Use that as your opacity function instead of the distribution shader.

Goms made a great extension to the method that removes the need for manually masking the water, it uses merged(raise highest) black/white versions of the terrain fractals as the opacity function, it usually works very well but I can't get it to work in your .tgd for some reason.

digitalis99

Yeah, I was trying to get goms method to work, too, but couldn't.  Too bad I have to resort to painted shaders.  Seems like you should never have to do that with all the procedural capabilities available.
Pixel Plow :: Render Endlessly :: http://www.pixelplow.net

Dune


Tangled-Universe

I use a slightly adapted version of Dandelo's workflow:

I render the image + water (often I replace the watershader with a bright surfacelayer) at half the final resolution and detail, so just a quicky.
Then I open it in Photoshop, add an empty layer and select the bright water. After expanding the selection I make it white, followed by inverting the selection and make that black.
As a last step I resize the image to the final rendersize and save it as a BMP.

In TG2 I create an imagemap shader and load the BMP. By default it is camera-projected, so I keep it completely untouched.
The imagemap shader is then being fed into the opacity function for the water.

I'm only not sure yet if I really need to resize the mask to the final render size or that a similar ratio itself is sufficient.
The camera-projection mode can be a bit iffy.

Anyway, so far this has always worked fine for me.

Dune

#5
Well, this one didn't work because D99 had the initial PF all black and no contrast in the colors. It changed that, as it has no influence on the land. Then a simple reverse and some playing with the values and you have your procedural mask.
I used the bmp method as well in one or two projects, but it is a bit more work.


digitalis99

Thanks Dune!  I particularly liked the positive offset in the surface layer just before the water sphere so you could see where the mask is cutting things off.  I knew I was missing something obvious.  One of the guys in dandelO's water masking thread set the fractal terrain to all black.  It worked for him, so that's why mine was set that way.  He used an all-white PF and a mix shader to somehow determine the mask.

Now to the interesting part: This doesn't appear to change render times in the least.

If I disable the water sphere, a crop region of just the sand bar takes 9-10seconds to render.  If I enable the water sphere without it being masked, that same crop region takes ~39seconds to render.  When I mask the water sphere and render the same crop region, it *still* takes 39seconds to render.  You can see for yourself by simply enabling the crop region I have specified in the Full Render.

When rendering with a masked sphere, you don't see the water during the render, so the mask is working to some degree.  Since we're masking by using opacity, is TG still rendering the element and then simply setting it to transparent?  I realize there will be more light bouncing around with the water sphere enabled, but surely I'd see at least a *little* reduction in rendering an almost top-down view of just the sand?
Pixel Plow :: Render Endlessly :: http://www.pixelplow.net

Tangled-Universe

and what if you disconnect the surface shader from the planet node and render again?
Then only the atmosphere and water will be rendered and you'll see if your masking did work, because it sounds you didn't set it up correctly. See?

digitalis99

Correct, I didn't have the masking setup correctly in the first place, but I do now.  Disconnecting the sand surface shader from the planet yields a render time of 25seconds and a black frame.  Here's the crop region output part-way through the render.  Clearly, TG is still computing something, even though the result is not displayed.
Pixel Plow :: Render Endlessly :: http://www.pixelplow.net

Dune

Render time also depends on the complexity of the waves, depth and murkiness, I've found. Maybe that area of water masked out isn't so heavy...

digitalis99

That certainly could be, but I would think that no matter how complex/simple the water was, the render time would be much closer to when the water sphere is disabled.  The fact that the render time is *exactly* the same masked vs. unmasked tells me that this trick just isn't doing anything at all to help render times.
Pixel Plow :: Render Endlessly :: http://www.pixelplow.net

Tangled-Universe


digitalis99

Sure, this is basically what Dune gave me with the test color turned off on the surface shader that's attached to the Sea sphere and the offset dropped to 0 to get the water to be where it's supposed to be.  I did 3 test renders of the Full crop region.  Here are the results:

Water on and unmasked: 35 seconds
Water on and masked: 34 seconds
Water off (sphere disabled): 7 seconds

I'm running another TG render in the background on my machine now, at a lower CPU priority.  That may account for the slight difference in timing between the first two.  They certainly both felt like they took the same amount of time.

BTW, ignore the errors when you open this, if you get any.  I think Dune's higher-than-2.3-version added some parameters that 2.3 doesn't understand.  It still works.
Pixel Plow :: Render Endlessly :: http://www.pixelplow.net

digitalis99

Anyone have any luck with the masking yet?  I'm going to try some other stuff.
Pixel Plow :: Render Endlessly :: http://www.pixelplow.net