From 85c3e1204991d5ce1e89eb6201727d82eb32be50 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 4 Jul 2019 08:27:17 +0200 Subject: Fix T66100: WorkBench Banding Issues Color banding issues can appear, as result of the 8 bitdepth RGBA that is used in the viewport. This change will use `GPU_RGBA16F` for final renderings and for drawing textures. This allows displaying HDRI textures. Vertex Colors uses `GPU_RGBA16` to resolve color banding issues. All other modes use `GPU_RGBA8` to reduce bandwidth and gpu memory. Reviewed By: fclem, brecht Differential Revision: https://developer.blender.org/D5179 --- .../draw/engines/workbench/workbench_private.h | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source/blender/draw/engines/workbench/workbench_private.h') diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 17144c4dc10..cb9a97878e2 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -381,6 +381,30 @@ BLI_INLINE bool workbench_is_matdata_pass_enabled(WORKBENCH_PrivateData *wpd) workbench_is_in_texture_paint_mode(); } +/** + * Get the default texture format to be used by the color and history buffers. + * + * Use GPU_RGBA16F for final renderings and for drawing textures. This + * allows displaying HDRI textures. Vertex Colors uses GPU_RGBA16 to resolve + * color banding issues (T66100). All other modes use GPU_RGBA8 to reduce + * bandwidth and gpu memory. + */ +BLI_INLINE const eGPUTextureFormat workbench_color_texture_format(const WORKBENCH_PrivateData *wpd) +{ + eGPUTextureFormat result; + if (DRW_state_is_image_render() || workbench_is_in_texture_paint_mode() || + TEXTURE_DRAWING_ENABLED(wpd)) { + result = GPU_RGBA16F; + } + else if (VERTEX_COLORS_ENABLED(wpd)) { + result = GPU_RGBA16; + } + else { + result = GPU_RGBA8; + } + return result; +} + /* workbench_deferred.c */ void workbench_deferred_engine_init(WORKBENCH_Data *vedata); void workbench_deferred_engine_free(void); -- cgit v1.2.3