Fix #98654: GPUOffScreen example has wrong color management

This was because the display shader never did the correct
color transformation.

This is a risky fix as it expects all input texture to be in
the correct colorspace (srgb). If they aren't this will
produce darker result.

If this is a huge issue we can introduce a global setting
(like line width) to set if the attached texture is
in srgb space or linear. This would avoid to change the
drawing code all over the place.

Pull Request: https://projects.blender.org/blender/blender/pulls/141237
This commit is contained in:
Clément Foucault
2025-07-03 14:07:58 +02:00
committed by Clément Foucault
parent e442c16fef
commit 644fb2b679
5 changed files with 15 additions and 0 deletions

View File

@@ -6,7 +6,10 @@
FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_image_rect_color)
#include "gpu_shader_colorspace_lib.glsl"
void main()
{
fragColor = texture(image, texCoord_interp) * color;
fragColor = blender_srgb_to_framebuffer_space(fragColor);
}

View File

@@ -6,7 +6,10 @@
FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_image_common)
#include "gpu_shader_colorspace_lib.glsl"
void main()
{
fragColor = texture(image, texCoord_interp);
fragColor = blender_srgb_to_framebuffer_space(fragColor);
}

View File

@@ -11,6 +11,8 @@
# include "gpu_glsl_cpp_stubs.hh"
# include "GPU_shader_shared.hh"
# include "gpu_srgb_to_framebuffer_space_info.hh"
#endif
#include "gpu_interface_info.hh"
@@ -24,4 +26,5 @@ FRAGMENT_OUT(0, float4, fragColor)
PUSH_CONSTANT(float4x4, ModelViewProjectionMatrix)
SAMPLER(0, sampler2D, image)
VERTEX_SOURCE("gpu_shader_2D_image_vert.glsl")
ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space)
GPU_SHADER_CREATE_END()

View File

@@ -11,6 +11,8 @@
# include "gpu_glsl_cpp_stubs.hh"
# include "GPU_shader_shared.hh"
# include "gpu_srgb_to_framebuffer_space_info.hh"
#endif
#include "gpu_interface_info.hh"
@@ -26,5 +28,6 @@ PUSH_CONSTANT(float4, rect_geom)
SAMPLER(0, sampler2D, image)
VERTEX_SOURCE("gpu_shader_2D_image_rect_vert.glsl")
FRAGMENT_SOURCE("gpu_shader_image_color_frag.glsl")
ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space)
DO_STATIC_COMPILATION()
GPU_SHADER_CREATE_END()

View File

@@ -11,6 +11,8 @@
# include "gpu_glsl_cpp_stubs.hh"
# include "GPU_shader_shared.hh"
# include "gpu_srgb_to_framebuffer_space_info.hh"
#endif
#include "gpu_interface_info.hh"
@@ -24,6 +26,7 @@ FRAGMENT_OUT(0, float4, fragColor)
PUSH_CONSTANT(float4x4, ModelViewProjectionMatrix)
SAMPLER(0, sampler2D, image)
VERTEX_SOURCE("gpu_shader_3D_image_vert.glsl")
ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space)
GPU_SHADER_CREATE_END()
GPU_SHADER_CREATE_INFO(gpu_shader_3D_image)