Displacement baking doesn't work (and also other modes)
Closed, InvalidPublic


This bug happen since a loooong time, finally seems I managed to make a demonstration blend: simply, displacement baking of the sculpted mesh gives a black rendered texture; I tried all the possible modes with the same result. I managed to bake the AO, then I tried to bake a Full Render and again I had a black texture. The weird thing is that in the textured 3d view it was still showing the AO map on the model, even if the Full Render baking had made a totally black one.

In former Blender versions, after three or four tries, in the end and in some way you could have the displacement baked (but mainly with "Selected to active" option), now it seems impossible, it doesn't work at all.

In version 2.63a, for example, it worked at first try.

Ubuntu 10.10 64 bit, 2.64 official release.



You're misusing baking from multires option. This option is supposed to be used to bake normals/heights maps of the highest multires level against preview level of multires. In your case preview level == highest level and for sure heights maps would be all zero.
There was a bug which handled this situation wrong in 2.63 and it's correct now in 2.64.

As for AO and Full Render baking it works all right here in the file you attached here.

Hi Sergey,
ok, probably I misused the multires option, btw i tried it now setting the preview level to 0 and I got the same result (seems to work at level 1, instead).
In any case I recorded a short screencast of what's happening under my system, for a while you can download the zip from here:

You can not use multires baker to bake against level 0 as well. Strangely, there used to be a warning about this but now it doesn't seem to be showing.

From your video i could only think about you being confused by displacement baking with multires disabled. But this also not a bug. To bake displacement map you need two objects and bake from selection to active. This means you need to create (or duplicate this object) object and set it's subdivision level to value you'll be later applying heights map. select hires object, then also select lowres object (so both are selected, lores is active) and enable Selection to Active in baker settings.
This is how it worked all the time actually.

Yes, this is how I always did it BUT why is Selected to Active an option for displacement, then? The fact that it is an option made me think that it was also possible to do it on the object itself (and actually, in older version, it was), I tried and that's why I posted in the bug tracker.

And, about my video, what about the fact that the 3d textured view didn't show the newly baked map but the old one? And the colored AO (shouldn't be in grayscale)?

On a side note, I'd like to point out that the baking from multires documentation is not clear at all about the way to make it work...

On one more side note, thanks for taking the time to look in this issue. :)

It's just quite generic interface for all possible bake modes which mainly supports working with single object only. For displacement baker you really need two geometries (you need some start point to start heights from). Baker here is being quite stupid and expects user to specify such a geometry. In theory it's probably possible to make it baking against multires lvl0, but that'll be quite not so much obvious.

I'm not so much familiar with how AO baking works and used, but seems it takes diffuse color into account. This question better be aimed to Brecht.

Well, there's a post in our blog about multires baker (http://code.blender.org/index.php/2011/06/baking-from-multires-data/) which explicitly says it bakes from highest level to preview one :) Thought it was pretty much clear..

Yes, but it doesn't seems to work, that's the point (my apologies, that's probably due to my bad English understanding).

Ok, I attached a new png with three stages:
- the first image is the sculpted multires mesh; I set the multires preview to 1 and baked the displacement from multires, obtaining the horror of the second image (the same mesh with a subdivsion surface set at 1 and the displace modifier);
- in the third image, the result of the displacement baking "Selected to Active" method; this usually works, but in this case it gave me terrible artefacts.

I can't really get what I'm doing wrong, and I baked a lot with 2.49...

If you wish I can send you the file.

Enrico, i've fixed couple of issues in svn rev51310 which could potentially resolve yours.
Also discussed AO and diffuse color with Brecht and it seems it depends on how exactly you'll be using AO map you would either want or don't want to include diffuse color in it. You can use Normalize option to make AO map not affected by diffuse color.

Sergey, thanks for the tip about AO.
About displacement, I just compiled svn 51310 and tried to bake it again:
with "from multires" no difference at all (but I'm convinced that I still don't understand how bake from multires works; how can you assign a hi density displacement baked map to a mesh with just level 1 of subdivision?);
with "selected to active" even worse, that is the result you can see in the png I attached ("displ_bake3.png").

Seriously, I don't know what to do... do you think it could be something related to my hardware (graphic card failure or bad drivers, ram or whatever)?

I added my observations with r51303 using Enricos blend file. What i can directly say: It is a mess.

Displacement from Multires:
* Only works if you set Preview to 1.
* The values of Sculpt and Render don't change anything.
* Setting Preview to 0 produces a black image as expected (not supported), but the user gets no warning or something like this.
* Setting Preview to the same as the current highest level will give a black image (expected)
* Any other Preview value (2-4 in your example blend) gives wrong results.

Displacement from Multires with "Low Resolution Map" checked:
* Only creates results if Preview < Render
* Every result is wrong and gives bumpy pattern. (Flat shaded normal used instead of Smooth shaded normal?)
* Does not bake to Preview=0 at all. Thats what it actually should be doing.

Displacement Selected to Active:
* Gives mainly correct results, but creates a lot of artifacts; black dots if both meshes are very close to each other.
* Setting a small bias (0.001) fixes this issue, which is also present in normal baking.
* Enabling Normalized doesn't do anything.

Normal from Multires:
* Works exactly like "Displacement from Multires". With Preview set to 1 it gives correct results. Anything else gives artifacts, is disabled (0) or is useless (max).
* No "Low Resolution Map" option.

Normal Active from Selected:
* Same as for "Displacement Selected to Active". Small Bias is needed for very close (identical) surfaces or it will give artifacts.
* Baking to Render > 0 shows "flat shading" artifacts.

AO from Multires:
* Ignores all settings except Render.
* Render can be any value (0-max).
* AO always uses flat normals (flat shading) without interpolation
* If "Normalized" is checked it will only produce a gray tone texture. If not, then it will include the diffuse color as well.

Thanks Tobias for the testing, so it doesn't seems to be anything related to my hardware.
In my last attempt to bake "Selected to Active" I obviously did it the wrong way (tzè, Sunday morning...), I redid it but in any case the results are wrong, I try to upload the png showing the issue.

Tobias, first of all please always test most recent builds especially if somebody reports there were fixes in related areas.

All bakes with "From Multires" enabled are supposed to work with preview level >= 1. There should be warning message appear if baking is attempting to bake against level 0, but it's a bit tricky to do in a convenient way since you could bake lots of objects at once. Since this option is really for special usage only wouldn't currently consider this is a bug.

Furthermore, baking from multires would use highest multires level to generate hires mesh. It is intended and it'll be tricky to support other configurations.

I can not see issues with displacement bake from multires. Perhaps it looks wrong for you since normalization always happens when baking displacement from multires.

Displacement using low resolution mesh behaves exactly how it is expected to be -- it uses geometry and normals from low resolution mesh which produces that "bumpy" pattern.

Displacement baking from selection to active could give artifacts if meshes intersects or situates too close to each other. This is mainly a precision issue in this case it seems. Probably it could be improved, but don't think it's a bug. Not sure why normalization doesn't work tho.

I can not see how normals baking from multires are wrong. Perhaps you're using this map on something different from mesh with the same multires level as you created this map against. Also can not see flat shading on baking normals from selection to active.

AO baking is intended to take Render level into account only. Currently can not confirm flat normals only. Normalized also seems to behave exactly how it's expected.

Enrico, having sample file which behaves wrong with all notes mentioned above would help much more than screenshots.

That's ok, Sergey, do you have an address I can send you the file to (that's quite big, around 30 Mb, I cannot attach it here)?

Enrico, you can use either sergey.vfx AT gmail.com or you could use our ftp ftp://download.blender/org/ftp/incoming to upload files.

Ok, just sent you by mail. Thanks in advance.

Enrico, pardon for the delay.

Checked your file. From what i can currently see displacement map baking happens correct. The issue is, lowres mesh you're baking against is really lowpoly and it's kind of "cage', so all heights goes invards, which describes why the image is so much dark. Also, some areas of lowres mesh are actually inside hires mesh (i.e. some parts of the head are inside the sholder) and in this case heights are calculating incorrect.

I'm not sure if it's possible to make heights baking correct in this case, probably if you'll remove intersections of lowres.. But to make displacement/normals maps really nice you need to bake against subdivided lowres.

I will mail you files prepared for selection-to-active baking and for baking from multires.

Hi Sergey,
first of all thanks for the files.

Sadly, I just tried them and I had exactly the same wrong results I had before... actually, there seems to be no differences in the settings of your files from what I had done, or am I missing something?
About the intersections and the too low resolution mesh, ok, I admit I don't know enough about displacement baking to say something about it... so, basically, a workflow where you subdivide and sculpt a lowres mesh it's not possible because later you cannot bake the sculpting? What should be the minimum resolution of a base mesh, then?
I suppose a solution could be to retopologize a more dense base mesh to bake from selection to active, but this seems a bit weird to me (not to have to retopologize, that's normal procedure, but to have to use a denser mesh in any case).

Also, the problem is not a baked image too dark, it is mainly very bad artifacts clearly showing in the images I attached.

One more thing: if I bake from multires I have to set the multires preview to 1, and then assign the baked displacement to a mesh with the same resolution: how is it possible to have a displacement on a mesh at level 1 of subdivision??

Thanks for your time.

Not sure why you're considering the displacement map is not correct.

I'll try briefly describe how they're working and supposed to be used, think it'll help understanding your setup.

Basically, displacement map affects on vertices. Namely it moves vertices along their normals. Brighter colors moves vertices by longer distance along the normal. This map does not produce new geometry, meaning it can not give more details on faces.

Usecase for displacement map would be to have a simplified mesh, bake displacement map from hires onto this lores. Then you need to subdivide this lores to it'll have enough vertices to "transmit" all the details. And you apply displacement map on such mesh.
In case you're using multires, usecase is: bake displacement map map against lower level of multires, then remove higher levels of multires, add subdivision surface with as much subdivisions as it's needed to produce the same amount vertices as original hires mesh had (i.e. in your case you've got multires with total level 5, if you bake against level 3 you'll need to add subsurf with level=2 before you're applying your displacement map) .

To choose suitable subdivision level of lores you should remember, that displacement happens along normals, meaning i.e. in your case displacement can not produce nice mouth from few faces only.

Normal maps affects on normals, apparently :) Meaning they could give details on faces by affecting light, but they're not affecting on geometry at all. So here you should also have lores with enough details.

Usecase is pretty much the same -- you choose suitable lores level, bake normals on it. After this you apply normals map on this mesh, no need to subdivide mesh further.

Choosing suitable lores subdivision level is also depends on particular geometry and choosing such level you should remember geometry wouldn't be changed at all.

After all, think it's more like you're confused by usage of this maps (which indeed could be tricky) rather than bug in blender. Think discussing this in the mail would be more convenient and less distractive for other developers who're reading logs from bugtracker. Would be easy to re-open if we'll discover real issue in our discussion.

I replied to you by mail, but I'm posting again here because I think this should be reopened, actually... :)

Your description is perfectly clear; what I don't get is why you keep on saying that "it works as it should", when the results I obtain are clearly wrong (as shown in the already attached images).
BTW, I found something interesting that should be indicative that something changed in the code from earlier versions: the reason I was sure the baking on the mutant sculpted mesh should have worked was that I actually I had already did this before and it worked, then (not at the first try, I had the smoothed faces issue, but after 2 or 3 more tries it worked); for example, I modelled a very simple torax lowres mesh, I rigged it, then sculpted, baked the displacement and the result was great; today I tried to open it with the last Blender svn and it shows (wrong) as in attached image "test_displ.png".
Opening the same file in Blender 2.63a, it shows correctly: attached image"test_orig.png"!
So, something changed from 2.63a to recent svn, and it seems a regression to me.

Please provide .blend file which demonstrates the regression then.

My apologies, the baked textures was automatically set to sRGB color mode and this caused the wrong displacement; by setting it to Linear works good, the same as in 2.63a.