diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-02-25 19:55:02 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-02-25 23:25:13 +0300 |
commit | 118a219e9dcec433902b228dc8d029e7458e6976 (patch) | |
tree | 8c8e6c2fa2fa9834b96c9c00b0958ac4d8141332 /source/blender/draw/intern/mesh_extractors | |
parent | 4896e72a4d9d4fc65aae15a5120ce9f1b53482f7 (diff) |
Fix different shading between CPU and GPU subdivision
Reuse the same vertex normals calculation as for the GPU code, by
weighing each vertex normals by the angle of the edges incident to the
vertex on the face.
Additionally, remove limit normals, as the CPU code does not use them
either, and would also cause different shading issues when limit surface
is used.
Fixes T95242: shade smooth artifacts with edge crease and limit surface
Fixes T94919: subdivision, different shading between CPU and GPU
Diffstat (limited to 'source/blender/draw/intern/mesh_extractors')
-rw-r--r-- | source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc index ef88a34021e..0645683d58b 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc @@ -233,14 +233,12 @@ static void extract_pos_nor_init_subdiv(const DRWSubdivCache *subdiv_cache, void *UNUSED(data)) { GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buffer); - const bool do_limit_normals = subdiv_cache->do_limit_normals && - !subdiv_cache->use_custom_loop_normals; /* Initialize the vertex buffer, it was already allocated. */ GPU_vertbuf_init_build_on_device( vbo, get_pos_nor_format(), subdiv_cache->num_subdiv_loops + mr->loop_loose_len); - draw_subdiv_extract_pos_nor(subdiv_cache, vbo, do_limit_normals); + draw_subdiv_extract_pos_nor(subdiv_cache, vbo); if (subdiv_cache->use_custom_loop_normals) { Mesh *coarse_mesh = subdiv_cache->mesh; @@ -266,7 +264,7 @@ static void extract_pos_nor_init_subdiv(const DRWSubdivCache *subdiv_cache, GPU_vertbuf_discard(src_custom_normals); GPU_vertbuf_discard(dst_custom_normals); } - else if (!do_limit_normals) { + else { /* We cannot evaluate vertex normals using the limit surface, so compute them manually. */ GPUVertBuf *subdiv_loop_subdiv_vert_index = draw_subdiv_build_origindex_buffer( subdiv_cache->subdiv_loop_subdiv_vert_index, subdiv_cache->num_subdiv_loops); @@ -279,6 +277,7 @@ static void extract_pos_nor_init_subdiv(const DRWSubdivCache *subdiv_cache, vbo, subdiv_cache->subdiv_vertex_face_adjacency_offsets, subdiv_cache->subdiv_vertex_face_adjacency, + subdiv_loop_subdiv_vert_index, vertex_normals); draw_subdiv_finalize_normals(subdiv_cache, vertex_normals, subdiv_loop_subdiv_vert_index, vbo); |