1
$\begingroup$

I'm using the GIS addon (https://github.com/domlysz/BlenderGIS) to import digital elevation models into blender. So far so good, it puts a regular mesh at the right coordinates at the correct scale and everyone is happy. Except... When I start shading, I'd like to use a different gradient along the objects z axis for below sea level geometry than for above sea level geometry and use vertical exaggeration (scaling along z).

In my current setup, I'm using the object coordinates from a texture mapping node, the separate xyz node to get the z component and then create masks for below 0 and above 0 using the math node. I've used the map range to convert fixed boundaries (similar to a map legend, with fixed minimum depth and maximum elevation) to 0 and 1 which seems to work ok I guess. I then use the binary land mask to mix the depth shader with the land shader. However, it feels clunky to do it like that. Also, this doesn't work when vertical exaggeration (scaling along z) is used and then applied to the object. I've attached a screenshot of my shader setup and the current shading (this is in Eevee, but it works in Cycles as well).

Result of the current setup in Eevee - Islands and seafloor use different shaders - vertical exaggeration 3 (scale z 3), but not applied! Otherwise the limits for the map range would be off.

shader configuration - using some groups, hence the 5 images. The part most related to my question is in the middle bottom one. I'm using fixed limits for the map range, so that e.g. the minimum depth is -10000 m and the maximum depth is 0 m, indifferent if this is actually in the mesh. Since I am using object coordinates, any scaling applied to the object would mix this is up - minimum would then be -30000 instead of 10000 (if scaled by 3).

As you can see, my setup is quite procedural but it cannot handle vertical exaggeration (when applied to the mesh). I'd love to somehow use the generated coordinates (since they are between 0 and 1), but then I'd need the min and max of z as well and this is where my understanding of the math nodes doe snot get me the desired results.

Any help would be appreciated!

$\endgroup$

1 Answer 1

0
$\begingroup$

To handle vertical exaggeration in conjunction with the node Map Range, you need to know the height of your mesh.

Since there seems to be no way to process the dimensions of the object in the shader in a mapping node, the following workaround might help:

  1. Create a modifier of type Geometry Nodes.

  2. Use the node Bounding Box, separate the lowest and the highest value on the Z-axis and store it in an Output Attribute.

  3. In the shader you can then read these values with the node Attribute, and use them as minimum and maximum values for your mapping in the node Map Range.

With this, the terrain should always have an even gradient from bottom to top, no matter what dimensions or scaling it has, and should be split at the zero point.

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks a bunch that's really helpful! Haven't looked into geometry nodes yet but they seem to be very powerful indeed. $\endgroup$ Commented May 6, 2022 at 20:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .