ENH: wireframe: refine the rendering logic under paint

1. remove wireframe in 3d view, only keep in paint;
2. pass barycentric_coordinates from outside
3. add shortcut hints

Change-Id: I911e5cdf3475926d9527dc0839fdce072ed54746
(cherry picked from commit 6e16d0ccfb71741e55daabd757be9f9e7613e695)
This commit is contained in:
lane.wei 2022-10-25 15:55:35 +08:00 committed by Lane.Wei
parent 79b5c94f4f
commit a9a228d071
9 changed files with 137 additions and 39 deletions

View file

@ -1,4 +1,4 @@
#version 130
#version 110
#define INTENSITY_CORRECTION 0.6
@ -45,6 +45,10 @@ float edgeFactor(float lineWidth) {
vec3 wireframe(vec3 fill, vec3 stroke, float lineWidth) {
return mix(stroke, fill, edgeFactor(lineWidth));
//if (any(lessThan(barycentric_coordinates, vec3(0.005, 0.005, 0.005))))
// return vec3(1.0, 0.0, 0.0);
//else
// return fill;
}
vec3 getWireframeColor(vec3 fill) {

View file

@ -1,7 +1,10 @@
#version 130
#version 110
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
attribute vec3 v_position;
attribute vec3 v_barycentric;
uniform mat4 volume_world_matrix;
// Clipping plane, x = min z, y = max z. Used by the FFF and SLA previews to clip with a top / bottom plane.
uniform vec2 z_range;
@ -22,15 +25,19 @@ struct SlopeDetection
uniform SlopeDetection slope;
void main()
{
model_pos = gl_Vertex;
//model_pos = gl_Vertex;
model_pos = vec4(v_position, 1.0);
// Point in homogenous coordinates.
vec4 world_pos = volume_world_matrix * gl_Vertex;
//vec4 world_pos = volume_world_matrix * gl_Vertex;
vec4 world_pos = volume_world_matrix * model_pos;
gl_Position = ftransform();
//gl_Position = ftransform();
gl_Position = gl_ModelViewProjectionMatrix * vec4(v_position.x, v_position.y, v_position.z, 1.0);
// Fill in the scalars for fragment shader clipping. Fragments with any of these components lower than zero are discarded.
clipping_planes_dots = vec3(dot(world_pos, clipping_plane), world_pos.z - z_range.x, z_range.y - world_pos.z);
//compute the Barycentric Coordinates
int vertexMod3 = gl_VertexID % 3;
barycentric_coordinates = vec3(float(vertexMod3 == 0), float(vertexMod3 == 1), float(vertexMod3 == 2));
//int vertexMod3 = gl_VertexID % 3;
//barycentric_coordinates = vec3(float(vertexMod3 == 0), float(vertexMod3 == 1), float(vertexMod3 == 2));
barycentric_coordinates = v_barycentric;
}