How can I render a matte showing vertical relative depth

Started by cyphyr, August 13, 2019, 07:04:39 am

Previous topic - Next topic

cyphyr

Huh Wha??

What I need to do is create a depth matte of a river., ie how deep the river is at any point. So this will be the height difference between the water surface (a native Terragen water disk object) and the terrain vertically below it.

If the river was completely horizontal I could do this simply with a surface layer but the river is not Horizontal. One end is 200m higher than the other. Also the river is part of a GeoTiff, so there is no way of subtracting the river element from the terrain element.

So I need to somehow measure the height of the displaced river object and subtract that from the height of the terrain where they intersect.

Ideas and suggestions ? :)
www.richardfraser.co.uk
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 3900X @3.79Ghz, 64Gb (TG4 benchmark 6:20)
i7 5930K @3.5Ghz, 32Gb (TG4 benchmark 13.44)

Dune

I'd use a displacement to scalar (2x) and subtract those.

Tangled-Universe

Quote from: Dune on August 13, 2019, 07:29:11 amI'd use a displacement to scalar (2x) and subtract those.
I was about to suggest the same, but somehow I get the feeling he already tried that since he said:
Quote from: cyphyr on August 13, 2019, 07:04:39 amAlso the river is part of a GeoTiff, so there is no way of subtracting the river element from the terrain element.
So I'm not sure, but that's definitely what I'd try first too.

Technically the network is being parsed from the bottom up, so if you have a plane/disc object for the water you should be able to use a get altitude node to sample the altitude at each shading point on the water plane/disc and indeed, subtract that from the get altitude from your terrain, however...that only works if that get altitude somehow gets down to the planet node, so we would need a work-around to get the Y scalar. If you do not do that you are basically subtracting two get altitude nodes resulting in a black mask, since downstream of the network they "end up" at the same object.

To get a Y scalar I would connect a displacement shader to vector node to the compute terrain, followed by a Y to scalar. Now you have the altitude in a scalar value. Subtract that from the get altitude from your water object and you should have a waterdepth mask.

Or not. Sometimes TG's ways are...difficult  ::)

Hetzen

The TG way is normally to smooth a version of you terrain and use that as a masked river plane. The problem with this way is that you often get a concave water surface.

A more accurate way would be to use a 3D app to create a a river plane on your geo, making sure it follows the height of the river along it's course and that the edges of the plane tuck under the sides of the river.

To get a gradient, you'll need to generate a height gradient from your river and landscape projected from the side, the river in the 3D app, the landscape in TG. Then use the difference of those two gradients.

The latter is quite a complex process as you have to match gradients but it does work and will give you the best results.

Tangled-Universe

Or use the smoothing filter shader to smooth out the river (if possible), do the subtraction and manually mask out the non-river areas.

Dune

And I don't suppose Daniil's erosion shader (water function) can be used on your geotiff?

cyphyr

Thanks for the added brain cells guys :)

Yes getting an altitude from the water disk is I think the only way and the main problem.
I shall try the y to scalar from a displacement node .
Not sure if the scalar info will translate over to a separate node network.
Hmmmm ... .. .
Quote from: Dune on August 13, 2019, 10:23:20 amAnd I don't suppose Daniil's erosion shader (water function) can be used on your geotiff?
It could of course but not usefully :)
I don't want to alter the terrain in any way just pull the info of how deep the river is (where the river plane intersects with the terrain) as a grey scale matte that can be used in Nuke to help comp a river that has been made in another program.
I already have a good mask of the river but a river deepness mask/matte will help blend the edges in (I think/hope).
www.richardfraser.co.uk
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 3900X @3.79Ghz, 64Gb (TG4 benchmark 6:20)
i7 5930K @3.5Ghz, 32Gb (TG4 benchmark 13.44)

Dune

If the river in your geotiff is a flat area (say waterlevel) then it's not to hard to use the river mask of that tiff to add a little depth, and use the altitude of the file with flat river to displace the waterplane/sphere. If it's an eroded gully it's harder, but maybe the geotiff can be copied and smoothed where the river is in PS or so. Masking out the water is easy.

cyphyr

Smoothing things or making alterations in PS won't cot it.
The output must be pixel perfect.

I think I got it now ... the water plane was a distraction ... I have two sets of displacements one for the terrain, a base geoTiff with a whole bunch of procedurals, image maps and Simple Shape displacements on top of that.
The second displacement was going into the water disk to "tilt" the water plane to match the change of altitude of the river. (approximately 200m over 4miles).

The disk is a distraction though. I know it's offset and I know it's "tilt " displacement.

In theory all I have to do is add the offset to the tilt displacement and subtract the terrain displacement ... In theory ...
www.richardfraser.co.uk
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 3900X @3.79Ghz, 64Gb (TG4 benchmark 6:20)
i7 5930K @3.5Ghz, 32Gb (TG4 benchmark 13.44)

Matt

Perhaps you could use the subsurface effect in the Water Shader, and make everything except the river invisible to camera (but visible to rays) I imagine it might work if you set reflectivity to 0 and then either (1) set a very large decay distance and use the subsurface volume colour to gradually build up a greyscale value with depth or (2) use a short decay distance, white terrain (and turn off the aforementioned volume effect), so that the edges of the river are white and the water gets darker as it gets deeper.

This wouldn't give you an exact depth map because the rays would be refracted, but I guess that may really be a good thing depending on what the map will be used for in the comp.
Just because milk is white doesn't mean that clouds are made of milk.

cyphyr

Quote from: Matt on August 13, 2019, 12:18:16 pmPerhaps you could use the subsurface effect in the Water Shader, and make everything except the river invisible to camera (but visible to rays) I imagine it might work if you set reflectivity to 0 and then either (1) set a very large decay distance and use the subsurface volume colour to gradually build up a greyscale value with depth or (2) use a short decay distance, white terrain (and turn off the aforementioned volume effect), so that the edges of the river are white and the water gets darker as it gets deeper.

This wouldn't give you an exact depth map because the rays would be refracted, but I guess that may really be a good thing depending on what the map will be used for in the comp.
I did wonder about using that method but it wouldn't be vertical depth. It would be from the cameras perspective (the camera is flying quite low along the river). Closer to the camera the distance between the river surface and the river bed would be shorter than further away from the camera ... I err *think*.
www.richardfraser.co.uk
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 3900X @3.79Ghz, 64Gb (TG4 benchmark 6:20)
i7 5930K @3.5Ghz, 32Gb (TG4 benchmark 13.44)

Matt

Quote from: cyphyr on August 13, 2019, 12:28:50 pmI did wonder about using that method but it wouldn't be vertical depth. It would be from the cameras perspective (the camera is flying quite low along the river). Closer to the camera the distance between the river surface and the river bed would be shorter than further away from the camera ... I err *think*.
It would be based on the rays refracting into the water, which are more vertical than the camera rays. But, yes, it would vary with camera angle and it would also be affected by waves, if you render them.

It could be made more vertical by using a higher index of refraction, but I'd definitely recommend disabling waves in that case.
Just because milk is white doesn't mean that clouds are made of milk.

cyphyr

Hmmm, cranking up the refraction seems to give something useful.
Thankyou
.
www.richardfraser.co.uk
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 3900X @3.79Ghz, 64Gb (TG4 benchmark 6:20)
i7 5930K @3.5Ghz, 32Gb (TG4 benchmark 13.44)

WAS

Quote from: Matt on August 13, 2019, 12:18:16 pmerhaps you could use the subsurface effect in the Water Shader, and make everything except the river invisible to camera (but visible to rays) I imagine it might work if you set reflectivity to 0 and then either (1) set a very large decay distance and use the subsurface volume colour to gradually build up a greyscale value with depth or (2) use a short decay distance, white terrain (and turn off the aforementioned volume effect), so that the edges of the river are white and the water gets darker as it gets deeper.

Would setting decay distance to the depth of the water help? I was following this and thinking of a test.

For example if the terrain floor minimum is 0 and water is 10 than decay distance 10?
Check out my Terragen Discord: https://discord.gg/Vy5FRTE

Matt

That seems like a reasonable rule of thumb, yeah. But the falloff is exponential, so don't expect it to give a full range of 0..1. There isn't a straightforward way to make the falloff linear.
Just because milk is white doesn't mean that clouds are made of milk.