Gpu shaders color from 3.1 do not match those in 3.0 #95341

Closed
opened 2022-01-30 22:58:10 +01:00 by Adrian Rutkowski · 12 comments

System Information
Operating system: windows
Graphics card: RTX 2080 super

Blender Version
Broken: 3.1 and 3.2
Worked: 3.0.1

Short description of error
shaders color from 3.1 do not match those in 3.0

Exact steps for others to reproduce the error

here is how the drawing looks in 3.0
blender_Boj7x0kn60.png

here is how the drawing looks in 3.1
blender_WS8C9HsQs7.png

import bpy
import gpu
from gpu_extras.batch import batch_for_shader

vertices = (
    (100, 100), (700, 100),
    (100, 700), (700, 700))

indices = (
    (0, 1, 2), (2, 1, 3))


shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices)


def draw():
    shader.bind()
    shader.uniform_float("color", (0, 0.5, 0.5, 1.0))
    batch.draw(shader)


bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')
**System Information** Operating system: windows Graphics card: RTX 2080 super **Blender Version** Broken: 3.1 and 3.2 Worked: 3.0.1 **Short description of error** shaders color from 3.1 do not match those in 3.0 **Exact steps for others to reproduce the error** here is how the drawing looks in 3.0 ![blender_Boj7x0kn60.png](https://archive.blender.org/developer/F12836136/blender_Boj7x0kn60.png) here is how the drawing looks in 3.1 ![blender_WS8C9HsQs7.png](https://archive.blender.org/developer/F12836138/blender_WS8C9HsQs7.png) ``` import bpy import gpu from gpu_extras.batch import batch_for_shader vertices = ( (100, 100), (700, 100), (100, 700), (700, 700)) indices = ( (0, 1, 2), (2, 1, 3)) shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices) def draw(): shader.bind() shader.uniform_float("color", (0, 0.5, 0.5, 1.0)) batch.draw(shader) bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL') ```

Added subscriber: @niewinny

Added subscriber: @niewinny
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Hi, thanks for the report. I am not sure if this is a bug.
RGBA values are calculated correctly in recent versions.

(Check with color picker from materials tab, G and B values are ~0.5 in 3.2v where it shows ~0.2 in previous versions)
To make sure I will see where exactly it changed.

Hi, thanks for the report. I am not sure if this is a bug. RGBA values are calculated correctly in recent versions. (Check with color picker from materials tab, G and B values are ~0.5 in 3.2v where it shows ~0.2 in previous versions) To make sure I will see where exactly it changed.

you are right blender's picker shows it as 0.5
it should be the opposite though

3.1
Photoshop_3R6MDLlAwW.png

3.0
Photoshop_UrvyTQMdtL.png

you are right blender's picker shows it as 0.5 it should be the opposite though 3.1 ![Photoshop_3R6MDLlAwW.png](https://archive.blender.org/developer/F12836486/Photoshop_3R6MDLlAwW.png) 3.0 ![Photoshop_UrvyTQMdtL.png](https://archive.blender.org/developer/F12836488/Photoshop_UrvyTQMdtL.png)
Member

To make sure I will see where exactly it changed.

Cannot find the exact commit. I am getting build errors.

it should be the opposite though

You mean RGBA values passed to shader code shows correct output in pervious versions?

> To make sure I will see where exactly it changed. Cannot find the exact commit. I am getting build errors. > it should be the opposite though You mean RGBA values passed to shader code shows correct output in pervious versions?
Member

Added subscriber: @Jeroen-Bakker

Added subscriber: @Jeroen-Bakker

You mean RGBA values passed to shader code shows correct output in pervious versions?

Yes I measured RGBA of those squares in photoshop and in 3.0 G = 0.5 and in 3.1 G = 0.73

it's quite odd, looks like not everything is affected

look at gizmos in 3.1 and 3.0

3.1
blender_9esvggFHtv.png

3.0
blender_zifuN1Si1l.png

yet the grid colors draw just fine

> You mean RGBA values passed to shader code shows correct output in pervious versions? Yes I measured RGBA of those squares in photoshop and in 3.0 G = 0.5 and in 3.1 G = 0.73 it's quite odd, looks like not everything is affected look at gizmos in 3.1 and 3.0 3.1 ![blender_9esvggFHtv.png](https://archive.blender.org/developer/F12837139/blender_9esvggFHtv.png) 3.0 ![blender_zifuN1Si1l.png](https://archive.blender.org/developer/F12837141/blender_zifuN1Si1l.png) yet the grid colors draw just fine
Member

Could be due that this is an issue introduced when porting the internal shaders to use GPUShaderCreateInfo structures.
I haven't checked yet, but 8fb2ff458b might have introduced the issue and should be fixed.

The reason that the axis gizmo draws well is because their srgb and linear values are the same.

Could be due that this is an issue introduced when porting the internal shaders to use GPUShaderCreateInfo structures. I haven't checked yet, but 8fb2ff458b might have introduced the issue and should be fixed. The reason that the axis gizmo draws well is because their srgb and linear values are the same.
Jeroen Bakker self-assigned this 2022-01-31 13:52:17 +01:00
Member

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

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

Blender 3.0 sets the srgbTarget to true in the builtin shader that performs the linear to srgb conversion.
Blender 3.1/2 doesn't have the option to set the srgbTarget what is a bug.

Blender 3.0 sets the `srgbTarget` to true in the builtin shader that performs the linear to srgb conversion. Blender 3.1/2 doesn't have the option to set the `srgbTarget` what is a bug.

This issue was referenced by 9578fe3068

This issue was referenced by 9578fe30682360e7b9554afd8d23cceed55c70bd
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Thomas Dinges added this to the 3.1 milestone 2023-02-08 15:52:54 +01: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 project
No Assignees
4 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#95341
No description provided.