Re-saving 16bit PNG image with straight alpha multiple times corrupts the image #99701
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#99701
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
Graphics card: AMD
Blender Version
Broken: 3.2.1
Worked: ?
Short description of error
Re-saving 16bit PNG image with straight alpha multiple times corrupts the image.
As far as I can tell it's broken only for 16/32bit images and works for 8bit
Exact steps for others to reproduce the error
Texture.zip
Added subscriber: @Quver
Added subscriber: @Memento
Added subscriber: @OmarEmaraDev
Changed status from 'Needs Triage' to: 'Needs User Info'
Testing a 32-bit OpenEXR image, it seems the difference is just alpha premultiplication, which seems to the expected behavior. Is this the difference you are experiencing or is there something else?
@OmarEmaraDev you're right the issue is only with alpha channel, colors seems intact. I'm sorry I did not specify a format to export because my blender is configured to save as 16bit png RGBA by default (I think?) so I assumed your export will be in png too. No need to choose any other format to reproduce this. Just open the file and press alt+s, alt+r multiple times. The original file is 16bit png RGBA as well so I expect it to look the same without any changes, but in result the alpha channel seems wrong as you mentioned. Same thing when export to exr.
I think this is still a bug.
If you save the file as 8bit png there are no issues. If I paint something on that texture and want to export it back there are no ways to do this without converting it to 8bit so it looks the same as in blender. Or at least I couldn't find a way to do so. Maybe I'm missing something?
A video just in case
1.mp4
Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'
I see. You mentioned 32bit so I assumed you were talking about EXR images.
I can reproduce the issue, and it doesn't seem to be normal alpha premultiplication and I can see the option being set to Straight Alpha.
But I also don't understand the behavior, so tagging the module for more information.
Might be related to #99186.
"Save image" weird color managementto Re-saving 16bit PNG image with straight alpha multiple times corrupts the imageAdded subscriber: @Vyach
This comment was removed by @Vyach
This comment was removed by @Vyach
Added subscriber: @crantisz
This is not a color management issue. This is an Issue related to alpha pre-multiplication.
Here is the case. I saved one render in EXR PNG and PNG16.
EXR is good for image compositing, so that we know that it has pre-multiplied alpha. If we load it into compositor, it shows correct results, and we can note that alpha setting in image node is premultiplied by default.
But we can say what image is straight, so that Blender multiply RGB channels by alpha:
PNG16 we know has straight alpha. Blender indicates that and set alpha setting to straight by default. So that we lost glowing effect, as expected.
We can force image to be pre-multiplied by switching the setting. And in this case we can see the white border around cubes as an artifact of, shall we say, "de-premultiplication" as expected:
Now load PNG8. It loads as premultiplied even alpha setting is straight by default:
So we know that PNG8 has straight alpha. And Blender shows it as straight alpha correctly. But what is incorrect, the image itself. In fact, Blender makes "de-premultiplication" under the hood and PNG8 with alpha set to straight displays as pre-multiplied. And we can be convinced of that by changing alpha to premultiplied revealing double "de-premultiplication" (One from loading image and one because of PNG specification) or double dividing original pixels by alpha:
So in order to get correct representation of PNG8 we need to add additional alpha convert step:
So looks like this hidden "de-premultiplication" process is made for image texturing. I don't know that's happening under the hood, but it looks like that in texturing PNG's functions as straight, even then the whole "pipeline" uses pre-multiplied. So somewhere in the past someone decided to make PNG8 for texturing and PNG16 for compositing by doing this weird thing under the hood, and making this headache for future us, so that we struggle with different PNG's in one application.
Images:
image with straight alpha, it have very different alpha and color channel, but it loaded as premultiplied
png8 wrong reading.blend