[METAL] Texture Paint Color Picker picks wrong colors #106103

Closed
opened 2023-03-24 13:25:05 +01:00 by Helge Maus · 12 comments

System Information
Operating system: macOS-13.2.1-x86_64-i386-64bit 64 Bits
Graphics card: Metal API AMD Radeon Pro 580 1.2

Blender Version
Broken: version: 3.5.0 Release Candidate, branch: blender-v3.5-release, commit date: 2023-03-24 01:57, hash: 6caccf6b9f20
Worked: It worked correctly in Blender 3.4.1 for me

Short description of error
If I hold down the S Key for sampling a color in 3d view, it picks most of the time the background color of a textture and not the color under the Mouse Pointer.
Look into the screenshot onto the palette. These "colors" I pickes over the blue area in 3D View. They should be blue and not white.

You see it also while drawing with pressed S key in the color wheel in the picker on the right side. It samples blue, all values between and while, while I'm over the blue area. Shading is set to flat ...

In 2D-View it works as expected.

Exact steps for others to reproduce the error

  • Open attached .blend file or
    • Take a default cube,
    • switch to texture painting
    • add a texture
  • paint an area blue.
  • Hold down the s-key and start sampling the colors from the cube.

Depending on the sampling point you should get the correct color, I don't

**System Information** Operating system: macOS-13.2.1-x86_64-i386-64bit 64 Bits Graphics card: Metal API AMD Radeon Pro 580 1.2 **Blender Version** Broken: version: 3.5.0 Release Candidate, branch: blender-v3.5-release, commit date: 2023-03-24 01:57, hash: `6caccf6b9f20` Worked: It worked correctly in Blender 3.4.1 for me **Short description of error** If I hold down the S Key for sampling a color in 3d view, it picks most of the time the background color of a textture and not the color under the Mouse Pointer. Look into the screenshot onto the palette. These "colors" I pickes over the blue area in 3D View. They should be blue and not white. You see it also while drawing with pressed S key in the color wheel in the picker on the right side. It samples blue, all values between and while, while I'm over the blue area. Shading is set to flat ... In 2D-View it works as expected. **Exact steps for others to reproduce the error** - Open attached .blend file or - Take a default cube, - switch to texture painting - add a texture - paint an area blue. - Hold down the s-key and start sampling the colors from the cube. Depending on the sampling point you should get the correct color, I don't
Helge Maus added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-03-24 13:25:06 +01:00
Member

Unable to reproduce this on linux & nvidia hardware. Likely to be a metal-related issue.

Unable to reproduce this on linux & nvidia hardware. Likely to be a metal-related issue.
Author

Good point, will test.
Yes, works uner OpenGL.
Seems to happen only in METAL.

Good point, will test. Yes, works uner OpenGL. Seems to happen only in METAL.
Helge Maus changed title from Texture Paint Color Picker picks wrong colors to [METAL] Texture Paint Color Picker picks wrong colors 2023-03-27 16:44:37 +02:00
Member

@mano-wii , can you replicate the issue?

@mano-wii , can you replicate the issue?
Pratik Borhade added the
Platform
macOS
Interest
Metal
labels 2023-03-28 08:04:15 +02:00

I can confirm the problem.
My impression is that the color Picker reads the object as if it had a different UV.

I can confirm the problem. My impression is that the color Picker reads the object as if it had a different UV.
Clément Foucault added this to the EEVEE & Viewport project 2023-03-28 16:30:50 +02:00
Clément Foucault added this to the 3.6 LTS milestone 2023-03-29 16:32:40 +02:00

@Michael-Parkin-White-Apple Here is one for you.

@Michael-Parkin-White-Apple Here is one for you.

Thanks for the report, i'll look into this.

Thanks for the report, i'll look into this.

I'm getting a separate assertion failure in GPU_select_buffer_stride_realign and also in the area size check in MTLFramebuffer::read if you hold down S and whizz the cursor around the view.

When a fix is found, can hopefully also patch up any undefined paths.

I'm getting a separate assertion failure in `GPU_select_buffer_stride_realign` and also in the area size check in MTLFramebuffer::read if you hold down S and whizz the cursor around the view. When a fix is found, can hopefully also patch up any undefined paths.

if a quick fix is needed, skipping the data fetch from the paint and going straight to sampling the viewport framebuffer works fine in Metal

Skipping this check in source/blender/editors/sculpt_paint/paint_utils.c :: paint_sample_color
if (v3d && texpaint_proj) {

GPU_backend_get_type() != GPU_BACKEND_METAL

and using the GPU_frontbuffer_read_pixels based fallback can work.

Let me know if this is viable for a PR. I'll investigate a proper solution, but not too familiar with texture painting feature.

if a quick fix is needed, skipping the data fetch from the paint and going straight to sampling the viewport framebuffer works fine in Metal Skipping this check in `source/blender/editors/sculpt_paint/paint_utils.c :: paint_sample_color` `if (v3d && texpaint_proj) {` `GPU_backend_get_type() != GPU_BACKEND_METAL` and using the `GPU_frontbuffer_read_pixels` based fallback can work. Let me know if this is viable for a PR. I'll investigate a proper solution, but not too familiar with texture painting feature.

If I remember correctly, GPU_select_buffer_stride_realign was created because GPU_framebuffer_read_color crashed on some older GPUs if it was required to read regions outside the framebuffer boundary.
So a rect_clamp and the buffer needed to be corrected to match the original rect.

The downside of using GPU_frontbuffer_read_pixels is that it returns the shaded image value. The user usually wants the original texture or colordata value. That's why a selection is made first to identify the polygon and thus read its data.

As today has been set as the Blender 3.5 Release day (https://projects.blender.org/milestones), I'm not sure how this bug should be handled. @ThomasDinges should know?

If I remember correctly, `GPU_select_buffer_stride_realign` was created because `GPU_framebuffer_read_color` crashed on some older GPUs if it was required to read regions outside the framebuffer boundary. So a `rect_clamp` and the buffer needed to be corrected to match the original `rect`. The downside of using `GPU_frontbuffer_read_pixels` is that it returns the shaded image value. The user usually wants the original texture or colordata value. That's why a selection is made first to identify the polygon and thus read its data. As today has been set as the Blender 3.5 Release day (https://projects.blender.org/milestones), I'm not sure how this bug should be handled. @ThomasDinges should know?

Once this report is fixed in main, it can be backported for a 3.5.1 bugfix release.

The usual procedure applies @mano-wii :) For future issues on release day, please notify me on the chat.

Once this report is fixed in main, it can be backported for a 3.5.1 bugfix release. The usual procedure applies @mano-wii :) For future issues on release day, please notify me on the chat.

Looks like this is a bug with GPU_viewport_size_get_i not correctly returning the contextual viewport size in Metal.

Viewport returned by OpenGL: VIEWPORT: 1219 41 1279 1548

Returned by Metal: VIEWPORT: 0 0 3024 1694 (Which is the native backbuffer res).

Likely a state issue of which current viewport is active at the time of sampling. Will submit a patch.

Looks like this is a bug with `GPU_viewport_size_get_i` not correctly returning the contextual viewport size in Metal. Viewport returned by OpenGL: `VIEWPORT: 1219 41 1279 1548` Returned by Metal: `VIEWPORT: 0 0 3024 1694` (Which is the native backbuffer res). Likely a state issue of which current viewport is active at the time of sampling. Will submit a patch.

EDIT: comment in wrong report

EDIT: comment in wrong report
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-04-07 13:06:05 +02:00
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 Assignees
7 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#106103
No description provided.