From b30a722f2d6faecccd3b81efc1f0aa567064bb3a Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 11 Dec 2019 13:35:53 +0100 Subject: Fix T72124: LookDev Sphere Rendering Due to the refactoring of the overlay engine the draw caches were changed. The sphere batch used to have positions and normals. After the refactoring it didn't had the normals anymore. The normals are needed for shading. As they were not there the look dev spheres were rendered black. This change add the `nor` attribute to `DRW_cache_sphere_get` batch. Reviewed By: fclem Differential Revision: https://developer.blender.org/D6393 --- source/blender/draw/intern/draw_cache.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source/blender/draw/intern/draw_cache.c') diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 90b5e08f994..69135f8ade3 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -68,6 +68,12 @@ typedef struct Vert { int class; } Vert; +typedef struct VertShaded { + float pos[3]; + int class; + float nor[3]; +} VertShaded; + /* Batch's only (free'd as an array) */ static struct DRWShapeCache { GPUBatch *drw_procedural_verts; @@ -471,7 +477,7 @@ static void sphere_lat_lon_vert(GPUVertBuf *vbo, int *v_ofs, float lat, float lo float x = sinf(lat) * cosf(lon); float y = cosf(lat); float z = sinf(lat) * sinf(lon); - GPU_vertbuf_vert_set(vbo, *v_ofs, &(Vert){{x, y, z}, VCLASS_EMPTY_SCALED}); + GPU_vertbuf_vert_set(vbo, *v_ofs, &(VertShaded){{x, y, z}, VCLASS_EMPTY_SCALED, {x, y, z}}); (*v_ofs)++; } @@ -482,6 +488,8 @@ GPUBatch *DRW_cache_sphere_get(void) const int lon_res = 24; GPUVertFormat format = extra_vert_format(); + GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); int v_len = (lat_res - 1) * lon_res * 6; GPU_vertbuf_data_alloc(vbo, v_len); -- cgit v1.2.3