Fix: Targa with Palette Shows Grayscale in Viewport. #106047

Merged
Jeroen Bakker merged 3 commits from Jeroen-Bakker/blender:image-target-draws-grayscale into main 2023-03-24 07:46:44 +01:00
Member

Viewport assumes that when the number of planes of the image
buffer is less or equal to 8 it is a gray scale image. In that
case it will optimize the texture to be stored as a grayscale
image on the GPU.

When using a targa file with a palette, the bitplanes were not
extracted from the actual colors, but from the number of colors
that were present in the palette.

Image buffers don't support palettes so that doesn't make sense.
This PR uses the bitdepth of the actual colors inside the palette
to identify the number of planes to use in the image buffer.

Fix: #105976

Viewport assumes that when the number of planes of the image buffer is less or equal to 8 it is a gray scale image. In that case it will optimize the texture to be stored as a grayscale image on the GPU. When using a targa file with a palette, the bitplanes were not extracted from the actual colors, but from the number of colors that were present in the palette. Image buffers don't support palettes so that doesn't make sense. This PR uses the bitdepth of the actual colors inside the palette to identify the number of planes to use in the image buffer. Fix: #105976
Jeroen Bakker added 1 commit 2023-03-23 15:36:12 +01:00
454030f542 Fix: Targa using a palette can display as grayscale in Viewport.
Viewport assumes that when the number of planes of the image
buffer is less or equal to 8 it is a gray scale image. In that
case it will optimize the texture to be stored as a grayscale
image on the GPU.

When using a targa file with a palette, the bitplanes were not
extracted from the actual colors, but from the number of colors
that were present in the palette.

Image buffers don't support palettes so that doesn't make sense.
This PR uses the bitdepth of the actual colors inside the palette
to identify the number of planes to use in the image buffer.

Fix: #105976
Jeroen Bakker added 1 commit 2023-03-23 15:36:51 +01:00
Jeroen Bakker requested review from Sergey Sharybin 2023-03-23 15:36:58 +01:00
Jeroen Bakker added the
Interest
Images & Movies
label 2023-03-23 15:37:03 +01:00
Jeroen Bakker added this to the 3.6 LTS milestone 2023-03-23 15:37:09 +01:00
Jeroen Bakker added this to the EEVEE & Viewport project 2023-03-23 15:37:14 +01:00
Jeroen Bakker modified the project from EEVEE & Viewport to Core 2023-03-23 15:38:23 +01:00
Jeroen Bakker self-assigned this 2023-03-23 15:38:29 +01:00
Jeroen Bakker changed title from Fix: Targa using a palette can display as grayscale in Viewport. to Fix: Targa with Palette Shows Grayscale in Viewport. 2023-03-23 15:39:55 +01:00
Sergey Sharybin approved these changes 2023-03-23 16:40:17 +01:00
Sergey Sharybin left a comment
Owner

On a code side this seems reasonable, but see the comment about, well, comment :) I'd leave it out. But not really strongly opinionated about it.

What I'm curious is how easy it would be to integrate the test to the bl_imbuf_load.py so that the case which is explicitly fixed does not get re-introduced with the new image IO library?

On a code side this seems reasonable, but see the comment about, well, comment :) I'd leave it out. But not really strongly opinionated about it. What I'm curious is how easy it would be to integrate the test to the `bl_imbuf_load.py` so that the case which is explicitly fixed does not get re-introduced with the new image IO library?
@ -681,3 +679,1 @@
size++;
}
ibuf->planes = size;
/* Set the planes based on the number of planes of the palette. Planes are

Not sure the comment is that useful. It is not the only place where the assignment to the planes happens, and the GPU sides optimizations might change in the future.

To me the ibuf->places = tga.mapbits seems clear by itself.

Not sure the comment is that useful. It is not the only place where the assignment to the planes happens, and the GPU sides optimizations might change in the future. To me the `ibuf->places = tga.mapbits` seems clear by itself.

Indeed, this problem will be fixed once #105785 lands. Attached is what the file looks like on my branch.

Indeed, this problem will be fixed once #105785 lands. Attached is what the file looks like on my branch.
Jeroen Bakker added 1 commit 2023-03-24 07:45:48 +01:00
Jeroen Bakker merged commit 1588f57602 into main 2023-03-24 07:46:44 +01:00
Jeroen Bakker deleted branch image-target-draws-grayscale 2023-03-24 07:46:47 +01:00
Bastien Montagne removed this from the Core project 2023-07-03 12:47:18 +02:00
Sign in to join this conversation.
No reviewers
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
3 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#106047
No description provided.