Baking tearing normals (Both cycles and BI) #43696

Closed
opened 2015-02-16 21:55:57 +01:00 by Andrej Ivanis · 20 comments

There seams to be a bug that normal are teared sometimes this happens with both Cycles (with or without cage) and BI.
Here is the scene setup: bake_bug.blend
This is tangent normal map I got by baking in Cycles with cage, you can see that middle row of bolts is teared sometimes:
bake_2_copy.png
bake_2.png
I thought there might be a problem with my geometry, but I checked in xNormal it doesn't happen:
bla_normals.png

There seams to be a bug that normal are teared sometimes this happens with both Cycles (with or without cage) and BI. Here is the scene setup: [bake_bug.blend](https://archive.blender.org/developer/F143853/bake_bug.blend) This is tangent normal map I got by baking in Cycles with cage, you can see that middle row of bolts is teared sometimes: ![bake_2_copy.png](https://archive.blender.org/developer/F143850/bake_2_copy.png) ![bake_2.png](https://archive.blender.org/developer/F143854/bake_2.png) I thought there might be a problem with my geometry, but I checked in xNormal it doesn't happen: ![bla_normals.png](https://archive.blender.org/developer/F143857/bla_normals.png)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @aivanis

Added subscriber: @aivanis

Added subscriber: @Sergey

Added subscriber: @Sergey
Member

Added subscriber: @JulianEisel

Added subscriber: @JulianEisel
Member

Tried to recreate but getting an error: Error: Uninitialized image "test" from object "fence2_LOD0.008_Circle.009". I'm a noob when it comes to baking, but seems like you didn't pack some images?
Also, could you test if the issue still appears in the latest buildbot builds? Some information about your OS and graphics card might be interesting as well.

Tried to recreate but getting an error: `Error: Uninitialized image "test" from object "fence2_LOD0.008_Circle.009"`. I'm a noob when it comes to baking, but seems like you didn't pack some images? Also, could you test if the issue still appears in the latest buildbot builds? Some information about your OS and graphics card might be interesting as well.
Author

Hi,
I just tested with 2.73.8 version (I downloaded few days ago) and it still appears. Sorry about the error either change image source to generated or here is fixed file bake_bug.blend , just open it and press bake.

OS is Mac OS 10.9.5, graphic card NVIDIA GeForce GT 650M 1024 MB

I get tearing when I bake with either CPU or GPU and also it doesn't appear just on normal map, but on other maps too.

Hi, I just tested with 2.73.8 version (I downloaded few days ago) and it still appears. Sorry about the error either change image source to generated or here is fixed file [bake_bug.blend](https://archive.blender.org/developer/F144852/bake_bug.blend) , just open it and press bake. OS is Mac OS 10.9.5, graphic card NVIDIA GeForce GT 650M 1024 MB I get tearing when I bake with either CPU or GPU and also it doesn't appear just on normal map, but on other maps too.
Member

Added subscriber: @dfelinto

Added subscriber: @dfelinto
Member

Need @dfelinto's brain here! Maybe there's something wrong in the file?

Need @dfelinto's brain here! Maybe there's something wrong in the file?

Added subscriber: @AndyDavies-3

Added subscriber: @AndyDavies-3

@AndyDavies-3 I haven't tested/checked the file, but if BI has this issue as well I think you could possibly help with other tests (xnormal, ...). Thanks ;)

@AndyDavies-3 I haven't tested/checked the file, but if BI has this issue as well I think you could possibly help with other tests (xnormal, ...). Thanks ;)

Interesting. I will take a look tomorrow

Interesting. I will take a look tomorrow

Added subscriber: @MarcClintDion

Added subscriber: @MarcClintDion

From an artists perspective this is easy enough to deal with until a code solution presents itself.

Add some control loops so the geometry is not as long and thin.

loops.png

To delete the loops afterwards:

(i) Select them all,

(ii) Use 'x' then 'g' to remove them.

Keeping the quads closer to being square shaped also helps to eliminate the oval shaped stretching that can be seen on the end bolts.

You should rebuild the cage since it looks like adding loops can invalidate the cage. Maybe indices are no longer in the proper order?

From an artists perspective this is easy enough to deal with until a code solution presents itself. Add some control loops so the geometry is not as long and thin. ![loops.png](https://archive.blender.org/developer/F149976/loops.png) To delete the loops afterwards: (i) Select them all, (ii) Use 'x' then 'g' to remove them. Keeping the quads closer to being square shaped also helps to eliminate the oval shaped stretching that can be seen on the end bolts. You should rebuild the cage since it looks like adding loops can invalidate the cage. Maybe indices are no longer in the proper order?

Forgot to check this. Sorry!

Marc is correct that adding extra loops can control the projection of the bake, though I must say that tearing is a very unusual symptom as normally the geometry skews when the rays are averaged across the surface.
In addition the centre of an object is usually projected correctly with the ends skewing, so the tearing is quite worrying as is definitely a bug. The tearing doesn't appear in xNormal using unmodified geometry.

46_Skewing.jpg
xNormal_normals.png

I just wanted to point out that while Marc is totally correct about the add/remove loops trick, it should be noted that people shouldn't really be doing it when baking directly to tangent space maps. It's an extremely destructive process and will break your normal map as it encodes data based on the geometry present at the time of the bake and once that geometry is gone it will still try to compensate for it resulting in broken shading.
You can however add extra loops, bake to an object space normal map, remove the loops and then convert back to tangent space without such worries (following Marc's steps)

Forgot to check this. Sorry! Marc is correct that adding extra loops can control the projection of the bake, though I must say that tearing is a very unusual symptom as normally the geometry skews when the rays are averaged across the surface. In addition the centre of an object is usually projected correctly with the ends skewing, so the tearing is quite worrying as is definitely a bug. The tearing doesn't appear in xNormal using unmodified geometry. ![46_Skewing.jpg](https://archive.blender.org/developer/F150003/46_Skewing.jpg) ![xNormal_normals.png](https://archive.blender.org/developer/F149998/xNormal_normals.png) I just wanted to point out that while Marc is totally correct about the add/remove loops trick, it should be noted that people shouldn't really be doing it when baking directly to tangent space maps. It's an extremely destructive process and will break your normal map as it encodes data based on the geometry present at the time of the bake and once that geometry is gone it will still try to compensate for it resulting in broken shading. You can however add extra loops, bake to an object space normal map, remove the loops and then convert back to tangent space without such worries (following Marc's steps)

Andy makes a good point about baking to Object Space maps first.

Here's more detail on how to prepare a model for texture baking when using Blender's Selected to Active Tool. I posted it to B-Stack Exchange since it's more user-help then debugging. ;)

http://blender.stackexchange.com/questions/27042/how-can-i-bake-textures-without-artifacts-until-the-time-that-the-following-baki/27043#27043

Andy, feel free to comment on any mistakes or omissions I may have made in that post so they can be corrected.


I think it's often better to work with geometry that is made up of proportional, evenly spaced quads just as we'd do for curved animation models in regards to polygon flow.

It seems as if evenly spaced and proportional geometry is able to guide the rays in a way that reduces floating precision errors.

  • We can see a weird little unit-circle 'math black hole' in action by squaring a series of numbers when their values are greater than 1.0; then comparing the results against what happens when that series of numbers is then squared using their less than 1.0 counterparts. (x > 1.0 versus x < 1.0)

an example:
- 5.0 x 5.0 = 25.0 <-this moves away from 0.0 (and is 5 times larger)

- 0.5 x 0.5 =   0.25 <-this moves towards 0.0  (and is 50% smaller)

(i) Small numbers collapse down to zero when multiplied against other small numbers, the smaller they are, the faster it happens.

(ii) Large numbers can cause the small decimal numbers to become truncated because of floating point round-off which is biased towards preserving the larger numbers. The larger the spread between the high and low values, the worse it gets.

(iii) Multiplying large numbers against small numbers exaggerates the problem further because the very small numbers can quickly collapse the large numbers down to near zero.

unitCircle_float_Trig_precision.png

DSCF1768.png

If barycentric coordinates are being used to map ray/position hits over to the UV coordinates; long thin triangles may prove to be especially susceptible to floating point round-off errors along one axis more than the other.

DSCF1770.png

I have no idea if that's the case here, and no solid idea how to fix it even if this is part of the problem. :(

Andy makes a good point about baking to Object Space maps first. Here's more detail on how to prepare a model for texture baking when using Blender's Selected to Active Tool. I posted it to B-Stack Exchange since it's more user-help then debugging. ;) http://blender.stackexchange.com/questions/27042/how-can-i-bake-textures-without-artifacts-until-the-time-that-the-following-baki/27043#27043 Andy, feel free to comment on any mistakes or omissions I may have made in that post so they can be corrected. ------ I think it's often better to work with geometry that is made up of proportional, evenly spaced quads just as we'd do for curved animation models in regards to polygon flow. It seems as if evenly spaced and proportional geometry is able to guide the rays in a way that reduces floating precision errors. - We can see a weird little unit-circle 'math black hole' in action by squaring a series of numbers when their values are greater than 1.0; then comparing the results against what happens when that series of numbers is then squared using their less than 1.0 counterparts. (x > 1.0 versus x < 1.0) ------- an example: - 5.0 x 5.0 = 25.0 <-this moves away from 0.0 (and is 5 times larger) - 0.5 x 0.5 = 0.25 <-this moves towards 0.0 (and is 50% smaller) ------- (i) Small numbers collapse down to zero when multiplied against other small numbers, the smaller they are, the faster it happens. (ii) Large numbers can cause the small decimal numbers to become truncated because of floating point round-off which is biased towards preserving the larger numbers. The larger the spread between the high and low values, the worse it gets. (iii) Multiplying large numbers against small numbers exaggerates the problem further because the very small numbers can quickly collapse the large numbers down to near zero. ![unitCircle_float_Trig_precision.png](https://archive.blender.org/developer/F150194/unitCircle_float_Trig_precision.png) ![DSCF1768.png](https://archive.blender.org/developer/F150196/DSCF1768.png) If barycentric coordinates are being used to map ray/position hits over to the UV coordinates; long thin triangles may prove to be especially susceptible to floating point round-off errors along one axis more than the other. ![DSCF1770.png](https://archive.blender.org/developer/F150207/DSCF1770.png) I have no idea if that's the case here, and no solid idea how to fix it even if this is part of the problem. :(

Added subscriber: @chrisr

Added subscriber: @chrisr

Hey guys, @MarcClintDion was partly right (it's about floating point precision). Took a while to find and fix it though... I hope I've done it right (D1207) :) Any idea who could do review??

Hey guys, @MarcClintDion was partly right (it's about floating point precision). Took a while to find and fix it though... I hope I've done it right ([D1207](https://archive.blender.org/developer/D1207)) :) Any idea who could do review??

This issue was referenced by 8cc475c40b

This issue was referenced by 8cc475c40b8e0b316430b536dac7ca0251994124

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit 8cc475c40b.

Closed by commit 8cc475c40b.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
9 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#43696
No description provided.