diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-06-13 07:20:35 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-06-13 07:20:46 +0300 |
commit | 16f5d51109bce849dff5379c60360f271622ac0f (patch) | |
tree | 99df7e9fbbeb387c53a34254ed8af1372012a6aa /source/blender | |
parent | c55dac9904d7f18189fa8335794696e49b2d3875 (diff) |
Fix T98735: GPU subdiv displays normals for all elements
The normals flags were not setup properly which made normals for all
elements (vertices, faces) to be drawn when using the normals overlay.
Also remove usage of uints for the flag in the APIs.
Diffstat (limited to 'source/blender')
4 files changed, 23 insertions, 15 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index e7726ff55ca..2b0953b0b9b 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -1837,6 +1837,7 @@ void draw_subdiv_build_lnor_buffer(const DRWSubdivCache *cache, GPU_vertbuf_bind_as_ssbo(cache->subdiv_polygon_offset_buffer, binding_point++); GPU_vertbuf_bind_as_ssbo(pos_nor, binding_point++); GPU_vertbuf_bind_as_ssbo(cache->extra_coarse_face_data, binding_point++); + GPU_vertbuf_bind_as_ssbo(cache->verts_orig_index, binding_point++); /* Outputs */ GPU_vertbuf_bind_as_ssbo(lnor, binding_point++); diff --git a/source/blender/draw/intern/shaders/common_subdiv_lib.glsl b/source/blender/draw/intern/shaders/common_subdiv_lib.glsl index 55e4ac20271..d76a7369f79 100644 --- a/source/blender/draw/intern/shaders/common_subdiv_lib.glsl +++ b/source/blender/draw/intern/shaders/common_subdiv_lib.glsl @@ -139,20 +139,20 @@ void set_vertex_pos(inout PosNorLoop vertex_data, vec3 pos) vertex_data.z = pos.z; } -void set_vertex_nor(inout PosNorLoop vertex_data, vec3 nor, uint flag) +/* Set the vertex normal but preserve the existing flag. This is for when we compute manually the + * vertex normals when we cannot use the limit surface, in which case the flag and the normal are + * set by two separate compute pass. */ +void set_vertex_nor(inout PosNorLoop vertex_data, vec3 nor) { vertex_data.nx = nor.x; vertex_data.ny = nor.y; vertex_data.nz = nor.z; - vertex_data.flag = float(flag); } -/* Set the vertex normal but preserve the existing flag. This is for when we compute manually the - * vertex normals when we cannot use the limit surface, in which case the flag and the normal are - * set by two separate compute pass. */ -void set_vertex_nor(inout PosNorLoop vertex_data, vec3 nor) +void set_vertex_nor(inout PosNorLoop vertex_data, vec3 nor, float flag) { - set_vertex_nor(vertex_data, nor, 0); + set_vertex_nor(vertex_data, nor); + vertex_data.flag = flag; } void add_newell_cross_v3_v3v3(inout vec3 n, vec3 v_prev, vec3 v_curr) diff --git a/source/blender/draw/intern/shaders/common_subdiv_patch_evaluation_comp.glsl b/source/blender/draw/intern/shaders/common_subdiv_patch_evaluation_comp.glsl index 0ffb216fc6f..e146ccb343a 100644 --- a/source/blender/draw/intern/shaders/common_subdiv_patch_evaluation_comp.glsl +++ b/source/blender/draw/intern/shaders/common_subdiv_patch_evaluation_comp.glsl @@ -459,9 +459,9 @@ void main() vec3 nor = vec3(0.0); int origindex = input_vert_origindex[loop_index]; - uint flag = 0; + float flag = 0.0; if (origindex == -1) { - flag = -1; + flag = -1.0; } PosNorLoop vertex_data; diff --git a/source/blender/draw/intern/shaders/common_subdiv_vbo_lnor_comp.glsl b/source/blender/draw/intern/shaders/common_subdiv_vbo_lnor_comp.glsl index b7bcfd2d369..f5c4c7895aa 100644 --- a/source/blender/draw/intern/shaders/common_subdiv_vbo_lnor_comp.glsl +++ b/source/blender/draw/intern/shaders/common_subdiv_vbo_lnor_comp.glsl @@ -11,7 +11,12 @@ layout(std430, binding = 2) readonly buffer extraCoarseFaceData uint extra_coarse_face_data[]; }; -layout(std430, binding = 3) writeonly buffer outputLoopNormals +layout(std430, binding = 3) readonly buffer inputVertOrigIndices +{ + int input_vert_origindex[]; +}; + +layout(std430, binding = 4) writeonly buffer outputLoopNormals { LoopNormal output_lnor[]; }; @@ -60,13 +65,15 @@ void main() loop_normal.nx = face_normal.x; loop_normal.ny = face_normal.y; loop_normal.nz = face_normal.z; - loop_normal.flag = 0.0; - - if (is_face_selected(coarse_quad_index)) { - loop_normal.flag = 1.0; - } for (int i = 0; i < 4; i++) { + int origindex = input_vert_origindex[start_loop_index + i]; + float flag = 0.0; + if (origindex == -1) { + flag = -1.0; + } + loop_normal.flag = flag; + output_lnor[start_loop_index + i] = loop_normal; } } |