From d11a87b88c4d76aff77912313752d23fffc8e65d Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 18 Dec 2020 16:06:26 +0100 Subject: DrawManager: High quality normals for non meshes This adds high quality normals for non meshes. These include * Volumetric Object Wireframe * Metaballs * Extracted Curves * Curves in edit mode This is in preparation to fix a regression in recent AMD drivers where the `GL_INT_2_10_10_10_REV` data type isn't working in Polaris cards. --- source/blender/gpu/GPU_vertex_format.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source/blender/gpu/GPU_vertex_format.h') diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h index 59af912ed3d..e3a566e5f21 100644 --- a/source/blender/gpu/GPU_vertex_format.h +++ b/source/blender/gpu/GPU_vertex_format.h @@ -27,6 +27,7 @@ #include "BLI_assert.h" #include "BLI_compiler_compat.h" +#include "BLI_math_geom.h" #include "GPU_common.h" #ifdef __cplusplus @@ -140,6 +141,13 @@ typedef struct GPUPackedNormal { int w : 2; /* 0 by default, can manually set to { -2, -1, 0, 1 } */ } GPUPackedNormal; +typedef struct GPUNormal { + union { + GPUPackedNormal low; + short high[3]; + }; +} GPUNormal; + /* OpenGL ES packs in a different order as desktop GL but component conversion is the same. * Of the code here, only struct GPUPackedNormal needs to change. */ @@ -195,6 +203,18 @@ BLI_INLINE GPUPackedNormal GPU_normal_convert_i10_s3(const short data[3]) return n; } +BLI_INLINE void GPU_normal_convert_v3(GPUNormal *gpu_normal, + const float data[3], + const bool do_hq_normals) +{ + if (do_hq_normals) { + normal_float_to_short_v3(gpu_normal->high, data); + } + else { + gpu_normal->low = GPU_normal_convert_i10_v3(data); + } +} + #ifdef __cplusplus } #endif -- cgit v1.2.3