Discrepancy in Cycles rendering result appears when "Pack Resources" on tga file #99565

Closed
opened 2022-07-09 06:53:37 +02:00 by Stay_Here · 15 comments

System Information
Operating system: Windows-10-10.0.19043-SP0 64 Bits
Graphics card: Quadro RTX 3000 with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.25

Blender Version
Broken: version: 3.3.0 Alpha, branch: master, commit date: 2022-07-08 16:07, hash: 2ee6891728
Worked: 3.2.1 release

Short description of error
shine.jpg
The 3.3 Alpha version has a trouble to correctly render the tga texture, unless it is packed into the blend file.

not shine.jpg
After packing the external tga file, the rendering result becomes correct (see above).

Exact steps for others to reproduce the error
1, Open the sample file and load the tga texture;
2, File -> External Data -> Pack Resources;
3, File -> Save as;
4, Open the new saved file

The tga file and the sample Blender file are included.
piece.tga
Should not shine_3.blend

**System Information** Operating system: Windows-10-10.0.19043-SP0 64 Bits Graphics card: Quadro RTX 3000 with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.25 **Blender Version** Broken: version: 3.3.0 Alpha, branch: master, commit date: 2022-07-08 16:07, hash: `2ee6891728` Worked: 3.2.1 release **Short description of error** ![shine.jpg](https://archive.blender.org/developer/F13277668/shine.jpg) The 3.3 Alpha version has a trouble to correctly render the tga texture, unless it is packed into the blend file. ![not shine.jpg](https://archive.blender.org/developer/F13277671/not_shine.jpg) After packing the external tga file, the rendering result becomes correct (see above). **Exact steps for others to reproduce the error** 1, Open the sample file and load the tga texture; 2, File -> External Data -> Pack Resources; 3, File -> Save as; 4, Open the new saved file The tga file and the sample Blender file are included. ![piece.tga](https://archive.blender.org/developer/F13277655/piece.tga) [Should not shine_3.blend](https://archive.blender.org/developer/F13277659/Should_not_shine_3.blend)
Author

Added subscriber: @Stay_Here

Added subscriber: @Stay_Here

#101810 was marked as duplicate of this issue

#101810 was marked as duplicate of this issue
Stay_Here changed title from Discrepancy appears when "Pack Resources" on tga file to Discrepancy in Cycles rendering result appears when "Pack Resources" on tga file 2022-07-09 07:11:36 +02:00
Member

Added subscriber: @EAW

Added subscriber: @EAW
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

I can confirm that the issue occurs in 3.3 master hash: 443690604f
3.2.1 is ok.
Packed vs unpacked.png
Packed on the left, not packed on the right.

I can confirm that the issue occurs in 3.3 master hash: 443690604f4e 3.2.1 is ok. ![Packed vs unpacked.png](https://archive.blender.org/developer/F13283000/Packed_vs_unpacked.png) Packed on the left, not packed on the right.
Member

Added subscriber: @LukasStockner

Added subscriber: @LukasStockner
Lukas Stockner self-assigned this 2022-08-21 20:15:33 +02:00
Member

Caused by 33f5e8f239.

Caused by 33f5e8f239.
Member

Added subscriber: @brecht

Added subscriber: @brecht
Member

This is due to how OIIO's Targa loader is implemented.

In particular, it has an internal "alpha type" that it tries to read from the file. OIIO's internal alpha conversion logic applies whenever the file is 32bpp, it is not explicitly deactivated, and the file's alpha type is not explicitly set to "premultiplied". All three used to be the case for this file, until the commit linked above disabled OIIO conversion.

Instead, Cycles checks the oiio:UnassociatedAlpha spec return from OIIO now. Unfortunately, the Targa loader only sets this if the file is 32bpp and the alpha type is set to "useful". So, if the alpha type is neither "premultiplied" nor "useful", there is a change in behavior - the OIIO-internal conversion would have taken place, but the Cycles-side conversion won't.

See https:*github.com/OpenImageIO/oiio/blob/c2ed61bb853b4a446f74321c2fe4d665c01ef316/src/targa.imageio/targainput.cpp#L274 vs. https:*github.com/OpenImageIO/oiio/blob/c2ed61bb853b4a446f74321c2fe4d665c01ef316/src/targa.imageio/targainput.cpp#L837.

Apparently, the oiio:UnassociatedAlpha logic was changed here , but not the internal logic.

@brecht, since I see that you worked on that logic in the past - would you consider this an OIIO bug?

This is due to how OIIO's Targa loader is implemented. In particular, it has an internal "alpha type" that it tries to read from the file. OIIO's internal alpha conversion logic applies whenever the file is 32bpp, it is not explicitly deactivated, and the file's alpha type is not explicitly set to "premultiplied". All three used to be the case for this file, until the commit linked above disabled OIIO conversion. Instead, Cycles checks the `oiio:UnassociatedAlpha` spec return from OIIO now. Unfortunately, the Targa loader only sets this if the file is 32bpp and the alpha type is set to "useful". So, if the alpha type is neither "premultiplied" nor "useful", there is a change in behavior - the OIIO-internal conversion would have taken place, but the Cycles-side conversion won't. See https:*github.com/OpenImageIO/oiio/blob/c2ed61bb853b4a446f74321c2fe4d665c01ef316/src/targa.imageio/targainput.cpp#L274 vs. https:*github.com/OpenImageIO/oiio/blob/c2ed61bb853b4a446f74321c2fe4d665c01ef316/src/targa.imageio/targainput.cpp#L837. Apparently, the `oiio:UnassociatedAlpha` logic [was changed here ](https://github.com/OpenImageIO/oiio/commit/2086ed228bc265272988d61710f109191db7ca52), but not the internal logic. @brecht, since I see that you worked on that logic in the past - would you consider this an OIIO bug?

This looks like an OIIO bug to me, I would expect the internal logic and oiio:UnassociatedAlpha to match.

This looks like an OIIO bug to me, I would expect the internal logic and `oiio:UnassociatedAlpha` to match.
Member

Added subscribers: @MeshVoid, @mano-wii

Added subscribers: @MeshVoid, @mano-wii

This issue was referenced by 94ec66c2f2

This issue was referenced by 94ec66c2f2859c717789a41cd5b8f0af0d7ec379

This issue was referenced by 0a35afbf86

This issue was referenced by 0a35afbf86c86963ebb638f0804a706d17df5b50

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'

I committed a workaround, though would still like to have a fix upstream as well. The issue is that it seems seems to have been an intentional change. Probably for files with the same alpha metadata as the files reported here, but different contents, and there may not be a single solution that handles all files correctly.

At least for us consistency with Blender image loading is most important.

I committed a workaround, though would still like to have a fix upstream as well. The issue is that it seems seems to have been an intentional change. Probably for files with the same alpha metadata as the files reported here, but different contents, and there may not be a single solution that handles all files correctly. At least for us consistency with Blender image loading is most important.
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
5 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#99565
No description provided.