Any way to apply a generated terrain mask to plane object?

Started by sboerner, November 08, 2021, 01:41:19 PM

Previous topic - Next topic

sboerner

I have a heightfield with hills and a creek, with some additional displacements to adjust the level of the creek bed. Now I'd like to make a procedural mask that extends into the creek bed and use it to make an ice shelf along the margins of the creek.

No problems making the mask. But there doesn't seem to be any way to apply it to the water surface, which is a plane. Is this even possible? I'm guessing the answer is no.

I know I've seen examples of coastal water foam on this forum that might offer some clues, but can't seem to find them now.

In the meantime maybe I'll apply the mask to the base terrain, capture it with a camera and apply it as a texture map to the plane. :P

WAS

I'd imagine World Space / Final Position would work fine, but maybe I am wrong.

I'll give that a test.

WAS

Seems to work in my tests, but I don't have a river/stream heightmap to test and was too lazy to make one.

However, to simulate depth better, unless you have an extruded imported plane, you may have better results just merging between offsetted ice, and water with a merge shader on the water surface plane.

Edit: Yeah, a merge is a much better result. No issues with rays and stuff due to opacity.

sboerner

Thanks, Jordan. I see what you did here. This is a good solution for procedural rivers and I'll file it away for future reference. Using a merge shader to apply the ice shelf works really well, so I'll definitely borrow that.

What I'm really looking for, though, is building an ice shelf over a heightfield generated from a DEM. So the creek is not procedural. I'd like the ice shelf to be defined by the water depth, so the shallow areas are frozen. Most of these areas will be along the shore, but there should also be ice around sandbars and rocks in the middle of the stream.

Burning a mask texture map with an orthogonal camera seems to work. Running a test now and will post shortly.


WAS

Oh ok. Well you could probably do use the foam trick, that is using the displacement to scalar and a colour adjust or two to define your area.

Dune

Why don't you use the greys from the heightfield, either directly (if it's grey tif), or through a displacement to scalar (blue) and a color adjust?

sboerner

That's what I ended up doing, though the displacement to scalar was giving me trouble. It could see the additional displacements fine but not the underlying heightfield, which is generated from a loaded .ter file. Maybe I was doing something wrong. I used a get altitude with a color adjust instead, and that worked perfectly.

Couldn't find a way to apply the live mask to the plane object, though, which is why I ended up capturing a grayscale mask with an orthogonal camera and then applying it with an image map shader. It's a simple process and works fine.

WAS

Not even sure how a get altitude with a colour adjust works as it should have no data regarding the terrain. Just the altitude value. That's a new one.,

WAS

the heightfield shader can shade by height. Giving a colour map output.

sboerner

You mean I stumbled upon something new?  :D

The Get Altitude outputs a scalar value, correct?


Quotethe heightfield shader can shade by height. Giving a colour map output.

That might work as well.

WAS

Yeah, I mean if it works like that, all you need is the surface layer, as that's what it's using, get altitude or get altitude in texture. So you should be able to derive the ice area from the water height. Otherwise, I don't understand how this is working. xD

sboerner

Yep, I assume it's getting its altitude data from the surface layer. It took me awhile (as a longtime Maya modeler who's used to *directional* graphs) to understand that TG nodes transmit data both ways.

I tested this with landmark shaders set at various altitudes. Setting the white point of the color adjust shader to the desired altitude nails it every time.

Dune

But get altitude only works when a compute terrain is used (I think), and only in the line it's in. The only way I can think of to get an altitude of a terrain to another line is to use the blue node displacement to scalar.

sboerner

Here is what I am getting. The two networks are identical except one uses Get Altitude, and the other Displacement to Scalar. No Compute Terrain. According to the documentation, both shaders output scalar values. But apparently the scalar values they produce are very different.

Get Altitude gives me the result I would expect. Displacement to Scalar gives me . . . nothing. What am I missing here?

Either way I can't find a way to transfer the live mask to another line. Whenever the displaced state (here generated by a PF) isn't available, the mask goes away. Which makes sense.