From 8aae5bdb28f99a6f6a1cf7bae2be621b47a0f1b7 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 21 Feb 2017 09:39:28 +0100 Subject: The variable layer editing shader was made OpenGL 2.0 compatible. Fixed a bug in the scaling of colors for the variable layer editing. --- lib/Slic3r/GUI/3DScene.pm | 4 ++-- xs/src/libslic3r/Slicing.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index c20af1bfb..13306d26c 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -1700,8 +1700,8 @@ void main() 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.); + (1. - lod) * texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row + 0.5 )), -10000.) + + lod * texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row * 2. + 1.)), 10000.); // Mix the final color. gl_FragColor = vec4(intensity_specular, intensity_specular, intensity_specular, 1.) + diff --git a/xs/src/libslic3r/Slicing.cpp b/xs/src/libslic3r/Slicing.cpp index 7fceb34c5..ea43e704f 100644 --- a/xs/src/libslic3r/Slicing.cpp +++ b/xs/src/libslic3r/Slicing.cpp @@ -657,7 +657,7 @@ int generate_layer_height_texture( cell_first = clamp(0, ncells1-1, int(ceil(lo * z_to_cell1))); cell_last = clamp(0, ncells1-1, int(floor(hi * z_to_cell1))); for (int cell = cell_first; cell <= cell_last; ++ cell) { - coordf_t idxf = (0.5 * hscale + (h - slicing_params.layer_height)) * coordf_t(palette_raw.size()) / hscale; + coordf_t idxf = (0.5 * hscale + (h - slicing_params.layer_height)) * coordf_t(palette_raw.size()-1) / hscale; int idx1 = clamp(0, int(palette_raw.size() - 1), int(floor(idxf))); int idx2 = std::min(int(palette_raw.size() - 1), idx1 + 1); coordf_t t = idxf - coordf_t(idx1); -- cgit v1.2.3