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.
This commit is contained in:
parent
cfc6eb7391
commit
8369d24d30
Notes:
blender-bot
2023-02-14 10:32:59 +01:00
Referenced by issue #98735, GPU Subdivision displays the normal overlay of the generated mesh vertices and loops Referenced by issue #98661, 3.2: Potential candidates for corrective releases
|
@ -1788,6 +1788,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++);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
set_vertex_nor(vertex_data, nor, 0);
|
||||
vertex_data.nx = nor.x;
|
||||
vertex_data.ny = nor.y;
|
||||
vertex_data.nz = nor.z;
|
||||
}
|
||||
|
||||
void set_vertex_nor(inout PosNorLoop vertex_data, vec3 nor, float flag)
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -413,9 +413,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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue