Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2017-02-20 23:54:53 +0300
committerbubnikv <bubnikv@gmail.com>2017-02-20 23:54:53 +0300
commit8cfdc28f2bfe20dccded65cd58dae0ab622253ab (patch)
treeb3471661a37b7cce6f89e521b91aa3d0dc3a5a9f /lib
parent440a5eb2a0f6e43e0e9ce582a33ac599c24d1245 (diff)
Implemented a level of detail on the variable layer height editing tool.
Diffstat (limited to 'lib')
-rw-r--r--lib/Slic3r/GUI/3DScene.pm24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm
index f506f01a7..c20af1bfb 100644
--- a/lib/Slic3r/GUI/3DScene.pm
+++ b/lib/Slic3r/GUI/3DScene.pm
@@ -208,8 +208,10 @@ sub layer_editing_enabled {
} else {
($self->{layer_preview_z_texture_id}) = glGenTextures_p(1);
glBindTexture(GL_TEXTURE_2D, $self->{layer_preview_z_texture_id});
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
glBindTexture(GL_TEXTURE_2D, 0);
}
@@ -1687,15 +1689,23 @@ void main()
float z_texture_row = floor(object_z_row);
// Normalized coordinate from 0. to 1.
float z_texture_col = object_z_row - z_texture_row;
-// float z_blend = 0.5 + 0.5 * cos(min(M_PI, abs(M_PI * (object_z - z_cursor) / 3.)));
-// float z_blend = 0.5 * cos(min(M_PI, abs(M_PI * (object_z - z_cursor)))) + 0.5;
float z_blend = 0.25 * cos(min(M_PI, abs(M_PI * (object_z - z_cursor) * 1.8 / z_cursor_band_width))) + 0.25;
- // Scale z_texture_row to normalized coordinates.
- // Sample the Z texture.
+ // Calculate level of detail from the object Z coordinate.
+ // This makes the slowly sloping surfaces to be show with high detail (with stripes),
+ // and the vertical surfaces to be shown with low detail (no stripes)
+ float z_in_cells = object_z_row * 190.;
+ // Gradient of Z projected on the screen.
+ float dx_vtc = dFdx(z_in_cells);
+ float dy_vtc = dFdy(z_in_cells);
+ float lod = clamp(0.5 * log2(max(dx_vtc*dx_vtc, dy_vtc*dy_vtc)), 0., 1.);
+ // Sample the Z texture. Texture coordinates are normalized to <0, 1>.
+ vec4 color =
+ (1. - lod) * texture2DLod(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row + 0.5 )), 0.) +
+ lod * texture2DLod(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row * 2. + 1.)), 1.);
+ // Mix the final color.
gl_FragColor =
vec4(intensity_specular, intensity_specular, intensity_specular, 1.) +
-// intensity_tainted * texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row + 0.5)), -2.5);
- (1. - z_blend) * intensity_tainted * texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row + 0.5)), -200.) +
+ (1. - z_blend) * intensity_tainted * color +
z_blend * vec4(1., 1., 0., 0.);
// and reset the transparency.
gl_FragColor.a = 1.;