diff options
author | Jeroen Bakker <jeroen@blender.org> | 2019-12-11 15:35:53 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2019-12-18 12:56:26 +0300 |
commit | b30a722f2d6faecccd3b81efc1f0aa567064bb3a (patch) | |
tree | c44c5a7c41482c97cfa62d24867a2b7bc7a42c2c /source/blender | |
parent | a6b1c158c99b3538921a4f9dd435b18a8093a400 (diff) |
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
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 10 |
1 files changed, 9 insertions, 1 deletions
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); |