Heightmap bake with cycles

Hi all !

It appears obvious that heightmap can be built from normalmap…

However i found no things about this and my attempts in nodes were all unsuccessfull…

Does anyone have clues on this ?
or maybe some nodes setup or tutorials ?

Thanks in advance and happy blending :slight_smile:

title changed from
//Height from bump in nodes?//
//Heightmap bake with cycles…//

Hi !

Why not using a Bump node ? It can be fed either with height map, on normal … In your case you would use your normalmap, am I right ? :slight_smile:

See you ++

hey @tricotou

sure i could ! the thing is that i only got normalmaps and need to create heights for water puddles spreading :wink:

therefore, though i use normalmaps, i also need height for knowing where the water goes ( in lower heightmap places ).

The principle is quite simple, and my only obstacle is the creation/retrieving of height from normalmap :confused:

Ah ok.

Did you try to do it with the NormalMap Plugin of Gimp ?
It has an option “Convert to height”

yes :slight_smile:

There are many tools for making heights from normals.
as an example, shadermap is just perfect :wink:

What i’d like to achieve is finding a way to get heights from normals at rendertime.

It’s not innocent :stuck_out_tongue:
I use unity and would like to retrieve heights from normals in a shader and in realtime.
It’s the same in cycles nodes even if realtime feature is not included.
and am stuck here :confused:

mebe i’m expecting something impossible ^^
ah something tells me it’s not :wink:

Although doable, it’s not recommended. You need to read a big area of the texture just for each sample. That means lots of texture nodes with different coordinates… It’s a mess to setup and modify, not to mention the slowdown all those fetches cause.

You can see the process in this SE thread :https://blender.stackexchange.com/questions/89278/how-to-get-a-smooth-curvature-map-from-a-normal-map/90311

1 Like

gave the python script in that SE answer a shot. Way too slow. I gave up an went to bed. When it was done, the resulting 2048 wasn’t bad, but areas that should have been nearly flat had a slight bulge. AwesomeBump was much faster with a slightly better result.

Trouble is, neither is a great result. Perhaps if the original normal was 32-bit full float? Then again, if it takes going to bed for it to finish an 8-bit png, you might have to go on vacation for it to do a source quality tangent normal…

Yeah, I know it’s slow. I only posted the link to show how the process works. The script can still have some great improvements. Changing the python lists to Numpy arrays could make it faster. Also, this kind of computation can be done using OpenGL, which can make it even faster.

Still, the main problem is that normal maps were invented to speed up render times by reducing height to slope. Inverting the process requires much more computation as we need to sum all slopes, find minimum and maximal values, and rescale the results (and even doing so might not give back the original height information).

1 Like

yes… revive :stuck_out_tongue:

and i’ll pin the topic as it’s mandatory for me ( when i forget the how-to )…

Cycles lacks height bake ( yes it knows about normals but height bake is stored in the terminator bug features :stuck_out_tongue: )

I finally found the way to bake pretty simply depths…
I got no time for explaining it atm and will be off for the next week but…

here’s a quick screenshot of my ( abusively ) simple setup for height bake:

( sorry for the pic size but it’s my whole desktop… )

This works like a charm in blender !

I’ll post ( shitty ) things coming from gimp normal map plugin and shadermap results…

Blender is the way to go :wink:

happy blending !

Back there with some more info about this impossible thing to do: height bake in cycles…

My 1st tries were aiming at normal maps baking:

All of you know the way:
A high-poly mesh and a plane in front of it; bake with ‘selected to active’ ON…
Here’s the result:

quite nice result and i still wonder why it’s kinda impossible to reconstruct heights from its derivated surface…
Here’s the result that Shadermap4 gives:

Looks like the mean surface tends towards zero, more than a real heightmap.

The Gimp addon gives just ‘lol’ results…

but now that blender allows this, all those 3rd party tools are useless…

For save and share purpose here’s the blend:
height_bake.blend (4.2 MB)

Happy blending !

1 Like

Some more info on the method:


What i mean by ‘stacked’ is when a mesh have crossing submeshes.

Here’s a non stacked clean mesh:

Here’s a stacked dirty mesh: ( some submesh crosses are circled in red )

The problen with baking Y info on stacked meshes is that you cannot choose the order blender bakes its faces and in the target texture ( the baked result ) you can only see the later baked face. This means that when a face behind another on is baked last you’ll see it in the result ( it’s just like some kind of Z-buffer f*ck-up in 3D realtime renderings ).

Therefore the solution is ( and hopefully there’s one ) to bake all ( diffuse and height maps ) with the
‘selected to active’ option.

For the diffuse just set the diffuse material on the object to bake
and for the heightmap just set the height material to bake.
Here’s the nodes for the height material:

And that’s all :slight_smile:

Happy blending !

later info: here are some results :slight_smile:

Left & middle are 4100 triangles meshes and right is only 71 triangles with bump…

Hope you like it !

Happy blending !