Inconsistent color space baking to float and byte images #94446
Labels
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#94446
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Windows-10-10.0.17763-SP0 64 Bits
Graphics card: AMD Radeon(TM) Vega 8 Graphics ATI Technologies Inc. 4.5.14742 Core Profile Context 21.8.2 27.20.22025.1006
Blender Version
Broken: version: 2.93.6, branch: master, commit date: 2021-11-16 14:54, hash:
c842a90e2f
Worked: ---
Short description of error
In blender we can create an image with 32 bit resolution (See image):
The new 32bit image can be used for baking in order to obtain a normal map.
This map works perfectly until saved in PNG (16bit or 8bit).
Interestingly you can bake directly on a 16bit image and the resulting image works even if it is saved in 8bit.
Here is a file where I put different pixel resolution combinations on textures saved in PNG:
TesteNormal.blend
Exact steps for others to reproduce the error
1 - Bake a normal map image with 32 bit option enabled. (see the pic "sample3.jpg")
2 - Save the image as PNG in 8 bit or 16 bit.
3 - Create a material and connect the saved baked normal map image to the normal map node.
4 - Observe the object becomes dark in rendered mode in Eevee or Cycles.
Teste_Normal_Textures.blend
Added subscriber: @CristianoSimao
32 Bit Nomal Map Generated inside Blender produces Dark materials.to 32 Bit Normal Map Generated inside Blender produces Dark materials.Added subscriber: @mano-wii
Changed status from 'Needs Triage' to: 'Needs User Info'
I can't replicate from scratch.
Could you test baking with the latest daily build? https://builder.blender.org/download/daily/
Also, could you test with an image format that supports 32bit (like OpenEXR Float Full)?
So we can define if the problem is in the baking system or in the PNG image codec.
Thanks Germano for your response.
In Blender 2.93.6 the normal map image baked and saved as 32 bit OpenEXR with Float Full work Ok. (see the pic)
In Blender 3.0 the same problem occurs, EXR 32 bit OK and PNG bad.
In Blender 2.93.8 the same thing.
The problem seems to be in the code of writing PNG image.
Apparently it doesn't correctly convert a 32-bit image to 16-bit.
But I'm not sure if this is a Blender issue or a Format limitation.
I've found a ToDo comment code that seems to be related. https://developer.blender.org/diffusion/B/browse/master/source/blender/imbuf/intern/png.c$23
Could you provide the OpenEXR image? So I can edit the description of the report and simplify the steps to reproduce the problem.
Yes here are the OpenEXR image.
And here the bad PNG.
32 bit saved as 16 bit PNG
And here 32 bit saved as 8 bit PNG
I saved the exr image to PNG (16 bit) format, the resulting image worked (I haven't been able to replicate the problem yet).
Does the OpenEXR to PNG conversion work?
I am not saying anything about saved images converted inside Blender.
I am saying the problem is in the first internal image generated in Blender with the 32bit checkbox marked when you bake the normal map, when you will save and select PNG format, the resulting image is saved probably with some error in format and when you open this image the color result is dark (wrong)
Steps.
1 - Generate any normal map with 32 bit checkbox enabled. (No need any detail in the model, a simple cube can be used)
2 - Click in the image menu, select "save as"
3 - Choose PNG file format.
4 - Click save.
5 - Create a new blender file or other model or other material and try use this saved PNG image in your material in normal map node.
6 - Result is a dark material.
Changed status from 'Needs User Info' to: 'Needs Triage'
Added subscriber: @lichtwerk
Changed status from 'Needs Triage' to: 'Needs User Info'
This should not be the case if you do the following (and to me it is not clear if you did that prior to baking):
For the selected Image Texture node that should be baked to:
Image Texture
node, changeColor Space
fromLinear
(default) toNon-Color
(this is where I am not sure if you did that)Non-Color
colorspace as normal map, these seem to work fine, no?See #52334 (32 bit Float normal map are baked in sRGB instead of Linear) /
e786ea6419
@CristianoSimao: please let us know if this works for you.
Hello Philipp.
I have changed the Color space to Non-Color only after the image is saved, as you can see in my first post in the step 3. And the problem appears.
Now following your steps I changed the color space to Non-Color before the image is saved, and then I saved as 16 bit PNG and all work OK, no more problem with this shadow colors.
But this is strange, for the other image formats this step is not necessary as you can see in my other posts.
Now I think you discover the place in the code where conversion formats uses wrong parameters.
Obs: I tested this in Blender 2.93.6
Changed status from 'Needs User Info' to: 'Archived'
Good!
With "image formats" you mean starting off with o non-32bit generated image?
If you havent touched the colorspace prior to baking there (these default to sRGB) and saving these happens to sRGB as well, there is no colorspace conversion, which I assume makes this unnecessary in your case.
I would assume if non-32bit generated images are set to anything else than sRGB prior to baking, similar issues (unwanted colorspace conversion) would take place there as well.
When saving to EXR, this saves in linear (same as the default for 32bit generated images, so also no colorspace conversion there).
So to avoid any colorspace conversion when saving baked normalmaps in 32bit generated images to lower bitdepths, the solution is to set colorspace to
Non-Color
prior to baking.This does not look like a bug to me, will archive (but of course feel free to comment again if issues persist or if this is a misunderstanding on my side).
Yes.
I think this is a bug, because if changing to Non-Color before baking is the right way this should be a obligatory step also for non 32 bit normal maps also.
If you will archive this post I can not do anything, but some other day other people will see this and report as a bug exactly because no one expect a simple thing that work will need a different pipeline only for changing a image file format.
Changed status from 'Archived' to: 'Needs Developer To Reproduce'
Added subscribers: @Sergey, @brecht
@Sergey, @brecht, since you worked on #52334 (32 bit Float normal map are baked in sRGB instead of Linear) /
e786ea6419
(and I am a bit on shaky ground), can you confirm my findings?It's a known issue in the design. We don't apply any color space transform for baking.
We may change this at some point along with bigger changes to the baking workflow, but for now it can break existing scripts or workflows.
32 Bit Normal Map Generated inside Blender produces Dark materials.to Inconsistent color space baking to float and byte imagesChanged status from 'Needs Developer To Reproduce' to: 'Confirmed'
Added subscriber: @1029910278
found this problem when creating my own baking script. Among the bake addon I brought, I find out that most of them didn't know and fix this problem when bake 32bit and export to png.
This should be mention to the float_buffer property's tip or fix