diff options
author | Jeroen Bakker <jeroen@blender.org> | 2020-12-18 18:06:26 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-01-04 13:09:56 +0300 |
commit | d11a87b88c4d76aff77912313752d23fffc8e65d (patch) | |
tree | bd770e25985ccb82b2557790d654ea6c8fc36642 /source/blender/gpu | |
parent | 17be2149a805a3f43a10ff6f800ada429889aa6b (diff) |
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.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_vertex_format.h | 20 |
1 files changed, 20 insertions, 0 deletions
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 |