Page MenuHome

Baking a tangent space normal map without using “selected to active” ignores modifiers
Closed, ResolvedPublicBUG

Description

System Information
Operating system: Linux-5.8.0-48-generic-x86_64-with-debian-bullseye-sid 64 Bits
Graphics card: GeForce GTX 1650 Ti with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 460.39

Blender Version
Broken: version: 2.92.0, branch: master, commit date: 2021-02-24 16:25, hash: rB02948a2cab44
Worked: (not sure)

Short description of error
As the issue title states, baking a tangent space normal map without using the Selected to Active option appears to ignore modifiers, producing wrong results. For example, this is the result of baking a normal map on a simple smooth-shaded cylinder with a bevel modifier applied:

Given this is a tangent space normal map with a completely uninteresting material, the normal map should be a solid color (and the cylinder in the 3D viewport should be completely black), but obviously it is not. If the bevel modifier is applied, the problem goes away.

Curiously, baking an object space normal map works fine:

This strongly suggests to me that this is, in fact, a bug, not just unexpected behavior.

Exact steps for others to reproduce the error

  1. Start from the following .blend file:

  2. Select the normal map image texture node and press Bake. Note that the baked normals are incorrect.
  3. Apply the Bevel modifier on the cylinder, then press Bake again. Note that the baked normals are now correct.

Event Timeline

Peeking through the source, this line of object_bake_api.c seems suspect:

me_nores = BKE_mesh_new_from_object(NULL, ob_low_eval, false);

Looking at what BKE_mesh_new_from_object does, it seems like maybe the third argument should be true. But I know fairly little about Blender’s internals, and I have not bothered compiling it myself to test if that fixes things.

Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Confirmed.Apr 16 2021, 6:10 AM
Germano Cavalcante (mano-wii) changed the subtype of this task from "Report" to "Bug".

I can confirm.
If you bake the normal tangent in edit mode the result is correct.