Optimization of the OpenGL shaders for clipping with clipping planes.

This commit is contained in:
bubnikv 2019-04-12 11:01:53 +02:00
parent 112f218c03
commit 566bb7041a
2 changed files with 15 additions and 16 deletions

View file

@ -28,13 +28,18 @@ struct PrintBoxDetection
uniform PrintBoxDetection print_box;
// 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;
// Clipping plane - general orientation. Used by the SLA gizmo.
uniform vec4 clipping_plane;
// x = tainted, y = specular;
varying vec2 intensity;
varying vec3 delta_box_min;
varying vec3 delta_box_max;
varying vec3 world_pos;
varying vec3 clipping_planes_dots;
void main()
{
@ -66,8 +71,11 @@ void main()
{
delta_box_min = ZERO;
delta_box_max = ZERO;
}
}
gl_Position = ftransform();
world_pos = vec3(print_box.volume_world_matrix * gl_Vertex);
}
// Point in homogenous coordinates.
vec4 world_pos = print_box.volume_world_matrix * gl_Vertex;
// 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);
}