We have been working to create a height map output with the shader editor. We have a plane that has been sculpted into a terrain.

enter image description here

We have applied a material with the following node setup to get the correct white to black shading according to height:

texture coordinate, separate xyz, color ramp, output

The middle color stop in the color ramp has its color set to HSV and the H is 0, S is 0, and V is 0.5.

The shading this applies to the object is then recorded by a camera directly above it, with all rotation axes set to 0. Under the camera tab, its lens type is set to orthographic and the scale was set up so it would frame the object correctly.

shader result on object, camera settings

However, when I import the height map this makes into Godot and set it up, there is a crease where the grayscale has changed color way too quickly, and the high points of the map are squished down.

What else needs to be adjusted here in order for this to work?

  • 3
    $\begingroup$ HSV is non-linear.. see for example this recent Q&A .. make sure you're in linear space all the way through .. a Mist pass may also be an option .. P.S.. do you need a color-ramp at all? $\endgroup$ – Robin Betts Oct 7 '19 at 22:16
  • 1
    $\begingroup$ This likely cause by using HSV. See: blender.stackexchange.com/questions/154163/… $\endgroup$ – Robert Gützkow Oct 7 '19 at 22:19
  • $\begingroup$ @RobinBetts was a bit faster. I agree with him, the mist pass would be exactly what you need. It's essentially a depth pass normalized to the [0.0-1.0] range. $\endgroup$ – Robert Gützkow Oct 7 '19 at 22:23
  • $\begingroup$ You are right, getting rid of the color ramp makes no apparent difference. How do i set up a mist pass? $\endgroup$ – kim holder Oct 7 '19 at 23:22
  • 2
    $\begingroup$ In Cycles View Layers tab, enable Mist Pass - then the settings are available in the World tab beneath Ambient Occlusion. Right-click dragging over a color render will give you a report about each pixel in the lower left including Z-depth. Use that info to adjust Mist distances optimally. Save a high-quality 16-bit png. Anything less also compresses grays and limits darks exaggerating brights. $\endgroup$ – HelloHiHola Oct 8 '19 at 1:10

I've just looked into your way of making a height map, which seems a bit snappier than a Mist pass for something like this - I'd never thought of doing it this way...

So long as you keep the color-space linear all the way through, it works fine, as far as I can see.

enter image description here

In the Render > Color Management panel, set the View Transform to 'Raw'... Using EEVEE, here, but Cycles would work, too.. image saved as 16-bit RGB PNG. When used as a texture in a Displacement modifier, the Color Space in the texture must be set to 'Linear', too.

enter image description here

I didn't make a fuss about smoothing and subdivision, but the results seem accurate. Original on the left, displacement with EEVEE image & displacement with Cycles image on the right, with the Displacement modifier set to a Strength of the Z dimension of the original object.

  • 1
    $\begingroup$ Funky, why does the right geometry look so noise from above? $\endgroup$ – Leander Oct 8 '19 at 10:49
  • $\begingroup$ @Leander, thanks for that.. couldn't track the fault down or even get it to go linear for a while .. a fresh .blend fixed it.. one of those strange ones.. all the settings seemed fine. Ironic.. it was supposed to be a quick method.... :( $\endgroup$ – Robin Betts Oct 8 '19 at 14:37
  • 1
    $\begingroup$ Sorry, I didn't want to cause more work. I was just interested. $\endgroup$ – Leander Oct 8 '19 at 14:38
  • $\begingroup$ @Leander No problem at all, you were absolutely right.. just wish I'd solved the mystery... $\endgroup$ – Robin Betts Oct 8 '19 at 21:09
  • $\begingroup$ That 'Raw' part is what we were still missing after the comments under the question. Thanks. $\endgroup$ – kim holder Oct 11 '19 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.