mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-11-01 21:21:10 -06:00
New tech ENABLE_SLOPE_RENDERING - 1st installment of rendering objects colored by facets slope
This commit is contained in:
parent
84c9136e2d
commit
b36051af82
12 changed files with 277 additions and 19 deletions
|
|
@ -20,13 +20,22 @@ const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
|||
|
||||
struct PrintBoxDetection
|
||||
{
|
||||
bool active;
|
||||
vec3 min;
|
||||
vec3 max;
|
||||
bool volume_detection;
|
||||
mat4 volume_world_matrix;
|
||||
};
|
||||
|
||||
struct SlopeDetection
|
||||
{
|
||||
bool active;
|
||||
// x = yellow z, y = red z
|
||||
vec2 z_range;
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
|
||||
uniform PrintBoxDetection print_box;
|
||||
uniform SlopeDetection slope;
|
||||
|
||||
// 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;
|
||||
|
|
@ -41,6 +50,8 @@ varying vec3 delta_box_max;
|
|||
|
||||
varying vec3 clipping_planes_dots;
|
||||
|
||||
varying float world_normal_z;
|
||||
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
|
|
@ -61,7 +72,7 @@ void main()
|
|||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
// compute deltas for out of print volume detection (world coordinates)
|
||||
if (print_box.volume_detection)
|
||||
if (print_box.active)
|
||||
{
|
||||
vec3 v = (print_box.volume_world_matrix * gl_Vertex).xyz;
|
||||
delta_box_min = v - print_box.min;
|
||||
|
|
@ -73,6 +84,9 @@ void main()
|
|||
delta_box_max = ZERO;
|
||||
}
|
||||
|
||||
// z component of normal vector in world coordinate used for slope shading
|
||||
world_normal_z = slope.active ? (normalize(slope.volume_world_normal_matrix * gl_Normal)).z : 0.0;
|
||||
|
||||
gl_Position = ftransform();
|
||||
// Point in homogenous coordinates.
|
||||
vec4 world_pos = print_box.volume_world_matrix * gl_Vertex;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue