Is there any way to bake a texture that I generated for Displace modifier? Or any way to recreate it one to one in the shader editor? I need to make a few fixes (to redraw it a bit) and also use it for generating my color map. Thanks T_T
I may be wrong but it looks like there's no automatic way to bake the height map of a Displace modifier.
If your object is flat with 3D relief, you can apply the Displace, give it a black and white gradient texture on the Z axis, plug it into an Emission, create a plane above and bake the Emit.
If it's a more complicated object, Ilakya gives here a method to do it, with the Multires and Shrinkwrap modifiers:
- Create your model with its Displace modifier.
- Create a second object that will contain the model as a sort of cage.
- Give this second object a Multires modifier. Give it also a Shrinkwrap modifier, Wrap Method > Project, with the model as Target. Hide the model.
- Subdivide the Multires of the second object until it looks like the model. Lower down the Level Viewport down to 0.
- Apply the Shrinkwrap modifier.
- Give your object a material, create an Image Texture, keep it selected but don't plug it for the moment, create a new image for this Image Texture.
- Go into the Render panel, choose Cycles. In the Bake panel enable Bake from Multires and Bake Type > Displacement, click on Bake, it should work.
One way to do this is with an intermediate bake. Assuming the original object is displaced by the modifier along its normals...
(Bake Type: 'Emit') Bake the positions of displaced shading-points of the modified object, in object space, by using these nodes:
Use a floating-point format, some numbers in the next step will be negative, so OpenEXR is good. I've called my image 'Displaced_P'.
Then subtract the surface-positions of the unmodified object from 'Displaced_P', and find the length of the difference along the unmodified object's normals, with this tree:
.. and bake the emitted result of that into your 'Heights' map.
The illustration above shows:
- A sphere, modifier-displaced by a procedural texture
- The results of the first tree, which you bake to 'Displaced_P'.
- The results of the second tree on the unmodified sphere, baked to 'Heights'
- The result of using the 'Heights' image to displace the sphere, in place of the procedural original.
Some of the displacements are negative, so you will have to uncheck Clamp in the 'Heights' image-texture's Texture tab > Colors panel, when you use it with the Displacement modifier.
All of this assumes the displaced object and the unmodified object share a UV map.
I haven't packed the image-textures, they're 2K, for this example.