mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 15:07:31 -06:00
Tech ENABLE_GL_SHADERS_ATTRIBUTES - Added shaders for glsl version 140
(cherry picked from commit prusa3d/PrusaSlicer@76d1d4949b)
This commit is contained in:
parent
bb044754af
commit
1e4f16bd39
76 changed files with 1145 additions and 143 deletions
11
resources/shaders/110/background.fs
Normal file
11
resources/shaders/110/background.fs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
uniform vec4 top_color;
|
||||||
|
uniform vec4 bottom_color;
|
||||||
|
|
||||||
|
varying vec2 tex_coord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = mix(bottom_color, top_color, tex_coord.y);
|
||||||
|
}
|
8
resources/shaders/110/flat.fs
Normal file
8
resources/shaders/110/flat.fs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
uniform vec4 uniform_color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = uniform_color;
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
#version 110
|
#version 110
|
||||||
|
|
||||||
attribute vec3 v_position;
|
|
||||||
|
|
||||||
uniform mat4 view_model_matrix;
|
uniform mat4 view_model_matrix;
|
||||||
uniform mat4 projection_matrix;
|
uniform mat4 projection_matrix;
|
||||||
|
|
||||||
|
attribute vec3 v_position;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
10
resources/shaders/110/flat_texture.fs
Normal file
10
resources/shaders/110/flat_texture.fs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
uniform sampler2D uniform_texture;
|
||||||
|
|
||||||
|
varying vec2 tex_coord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = texture2D(uniform_texture, tex_coord);
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
#version 110
|
#version 110
|
||||||
|
|
||||||
attribute vec3 v_position;
|
|
||||||
attribute vec2 v_tex_coord;
|
|
||||||
|
|
||||||
uniform mat4 view_model_matrix;
|
uniform mat4 view_model_matrix;
|
||||||
uniform mat4 projection_matrix;
|
uniform mat4 projection_matrix;
|
||||||
|
|
||||||
|
attribute vec3 v_position;
|
||||||
|
attribute vec2 v_tex_coord;
|
||||||
|
|
||||||
varying vec2 tex_coord;
|
varying vec2 tex_coord;
|
||||||
|
|
||||||
void main()
|
void main()
|
105
resources/shaders/110/gouraud.fs
Normal file
105
resources/shaders/110/gouraud.fs
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||||
|
//BBS: add grey and orange
|
||||||
|
//const vec3 GREY = vec3(0.9, 0.9, 0.9);
|
||||||
|
const vec3 ORANGE = vec3(0.8, 0.4, 0.0);
|
||||||
|
const vec3 LightRed = vec3(0.78, 0.0, 0.0);
|
||||||
|
const vec3 LightBlue = vec3(0.73, 1.0, 1.0);
|
||||||
|
const float EPSILON = 0.0001;
|
||||||
|
|
||||||
|
struct PrintVolumeDetection
|
||||||
|
{
|
||||||
|
// 0 = rectangle, 1 = circle, 2 = custom, 3 = invalid
|
||||||
|
int type;
|
||||||
|
// type = 0 (rectangle):
|
||||||
|
// x = min.x, y = min.y, z = max.x, w = max.y
|
||||||
|
// type = 1 (circle):
|
||||||
|
// x = center.x, y = center.y, z = radius
|
||||||
|
vec4 xy_data;
|
||||||
|
// x = min z, y = max z
|
||||||
|
vec2 z_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SlopeDetection
|
||||||
|
{
|
||||||
|
bool actived;
|
||||||
|
float normal_z;
|
||||||
|
mat3 volume_world_normal_matrix;
|
||||||
|
};
|
||||||
|
|
||||||
|
uniform vec4 uniform_color;
|
||||||
|
uniform SlopeDetection slope;
|
||||||
|
|
||||||
|
//BBS: add outline_color
|
||||||
|
uniform bool is_outline;
|
||||||
|
|
||||||
|
uniform bool offset_depth_buffer;
|
||||||
|
|
||||||
|
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||||
|
uniform sampler2D environment_tex;
|
||||||
|
uniform bool use_environment_tex;
|
||||||
|
#endif // ENABLE_ENVIRONMENT_MAP
|
||||||
|
|
||||||
|
uniform PrintVolumeDetection print_volume;
|
||||||
|
|
||||||
|
varying vec3 clipping_planes_dots;
|
||||||
|
|
||||||
|
// x = diffuse, y = specular;
|
||||||
|
varying vec2 intensity;
|
||||||
|
|
||||||
|
varying vec4 world_pos;
|
||||||
|
varying float world_normal_z;
|
||||||
|
varying vec3 eye_normal;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
if (any(lessThan(clipping_planes_dots, ZERO)))
|
||||||
|
discard;
|
||||||
|
vec3 color = uniform_color.rgb;
|
||||||
|
float alpha = uniform_color.a;
|
||||||
|
|
||||||
|
if (slope.actived) {
|
||||||
|
if(world_pos.z<0.1&&world_pos.z>-0.1)
|
||||||
|
{
|
||||||
|
color = LightBlue;
|
||||||
|
alpha = 0.8;
|
||||||
|
}
|
||||||
|
else if( world_normal_z < slope.normal_z - EPSILON)
|
||||||
|
{
|
||||||
|
color = color * 0.5 + LightRed * 0.5;
|
||||||
|
alpha = 0.8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if the fragment is outside the print volume -> use darker color
|
||||||
|
vec3 pv_check_min = ZERO;
|
||||||
|
vec3 pv_check_max = ZERO;
|
||||||
|
if (print_volume.type == 0) {
|
||||||
|
// rectangle
|
||||||
|
pv_check_min = world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, print_volume.z_data.x);
|
||||||
|
pv_check_max = world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, print_volume.z_data.y);
|
||||||
|
color = (any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO))) ? mix(color, ZERO, 0.3333) : color;
|
||||||
|
}
|
||||||
|
else if (print_volume.type == 1) {
|
||||||
|
// circle
|
||||||
|
float delta_radius = print_volume.xy_data.z - distance(world_pos.xy, print_volume.xy_data.xy);
|
||||||
|
pv_check_min = vec3(delta_radius, 0.0, world_pos.z - print_volume.z_data.x);
|
||||||
|
pv_check_max = vec3(0.0, 0.0, world_pos.z - print_volume.z_data.y);
|
||||||
|
color = (any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO))) ? mix(color, ZERO, 0.3333) : color;
|
||||||
|
}
|
||||||
|
|
||||||
|
//BBS: add outline_color
|
||||||
|
if (is_outline)
|
||||||
|
gl_FragColor = uniform_color;
|
||||||
|
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||||
|
else if (use_environment_tex)
|
||||||
|
gl_FragColor = vec4(0.45 * texture2D(environment_tex, normalize(eye_normal).xy * 0.5 + 0.5).xyz + 0.8 * color * intensity.x, alpha);
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
||||||
|
|
||||||
|
// In the support painting gizmo and the seam painting gizmo are painted triangles rendered over the already
|
||||||
|
// rendered object. To resolved z-fighting between previously rendered object and painted triangles, values
|
||||||
|
// inside the depth buffer are offset by small epsilon for painted triangles inside those gizmos.
|
||||||
|
gl_FragDepth = gl_FragCoord.z - (offset_depth_buffer ? EPSILON : 0.0);
|
||||||
|
}
|
|
@ -25,9 +25,6 @@ struct SlopeDetection
|
||||||
mat3 volume_world_normal_matrix;
|
mat3 volume_world_normal_matrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
attribute vec3 v_position;
|
|
||||||
attribute vec3 v_normal;
|
|
||||||
|
|
||||||
uniform mat4 view_model_matrix;
|
uniform mat4 view_model_matrix;
|
||||||
uniform mat4 projection_matrix;
|
uniform mat4 projection_matrix;
|
||||||
uniform mat3 normal_matrix;
|
uniform mat3 normal_matrix;
|
||||||
|
@ -39,6 +36,9 @@ uniform vec2 z_range;
|
||||||
// Clipping plane - general orientation. Used by the SLA gizmo.
|
// Clipping plane - general orientation. Used by the SLA gizmo.
|
||||||
uniform vec4 clipping_plane;
|
uniform vec4 clipping_plane;
|
||||||
|
|
||||||
|
attribute vec3 v_position;
|
||||||
|
attribute vec3 v_normal;
|
||||||
|
|
||||||
// x = diffuse, y = specular;
|
// x = diffuse, y = specular;
|
||||||
varying vec2 intensity;
|
varying vec2 intensity;
|
||||||
|
|
12
resources/shaders/110/gouraud_light.fs
Normal file
12
resources/shaders/110/gouraud_light.fs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
uniform vec4 uniform_color;
|
||||||
|
uniform float emission_factor;
|
||||||
|
|
||||||
|
// x = tainted, y = specular;
|
||||||
|
varying vec2 intensity;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||||
|
}
|
|
@ -14,13 +14,13 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||||
|
|
||||||
#define INTENSITY_AMBIENT 0.3
|
#define INTENSITY_AMBIENT 0.3
|
||||||
|
|
||||||
attribute vec3 v_position;
|
|
||||||
attribute vec3 v_normal;
|
|
||||||
|
|
||||||
uniform mat4 view_model_matrix;
|
uniform mat4 view_model_matrix;
|
||||||
uniform mat4 projection_matrix;
|
uniform mat4 projection_matrix;
|
||||||
uniform mat3 normal_matrix;
|
uniform mat3 normal_matrix;
|
||||||
|
|
||||||
|
attribute vec3 v_position;
|
||||||
|
attribute vec3 v_normal;
|
||||||
|
|
||||||
// x = tainted, y = specular;
|
// x = tainted, y = specular;
|
||||||
varying vec2 intensity;
|
varying vec2 intensity;
|
||||||
|
|
12
resources/shaders/110/gouraud_light_instanced.fs
Normal file
12
resources/shaders/110/gouraud_light_instanced.fs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
uniform vec4 uniform_color;
|
||||||
|
uniform float emission_factor;
|
||||||
|
|
||||||
|
// x = tainted, y = specular;
|
||||||
|
varying vec2 intensity;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||||
|
}
|
|
@ -14,6 +14,10 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||||
|
|
||||||
#define INTENSITY_AMBIENT 0.3
|
#define INTENSITY_AMBIENT 0.3
|
||||||
|
|
||||||
|
uniform mat4 view_model_matrix;
|
||||||
|
uniform mat4 projection_matrix;
|
||||||
|
uniform mat3 normal_matrix;
|
||||||
|
|
||||||
// vertex attributes
|
// vertex attributes
|
||||||
attribute vec3 v_position;
|
attribute vec3 v_position;
|
||||||
attribute vec3 v_normal;
|
attribute vec3 v_normal;
|
||||||
|
@ -21,10 +25,6 @@ attribute vec3 v_normal;
|
||||||
attribute vec3 i_offset;
|
attribute vec3 i_offset;
|
||||||
attribute vec2 i_scales;
|
attribute vec2 i_scales;
|
||||||
|
|
||||||
uniform mat4 view_model_matrix;
|
|
||||||
uniform mat4 projection_matrix;
|
|
||||||
uniform mat3 normal_matrix;
|
|
||||||
|
|
||||||
// x = tainted, y = specular;
|
// x = tainted, y = specular;
|
||||||
varying vec2 intensity;
|
varying vec2 intensity;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#version 110
|
#version 110
|
||||||
|
|
||||||
attribute vec3 v_position;
|
|
||||||
|
|
||||||
uniform mat4 view_model_matrix;
|
uniform mat4 view_model_matrix;
|
||||||
uniform mat4 projection_matrix;
|
uniform mat4 projection_matrix;
|
||||||
|
|
||||||
|
attribute vec3 v_position;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||||
|
|
||||||
attribute vec3 v_position;
|
|
||||||
|
|
||||||
uniform mat4 view_model_matrix;
|
uniform mat4 view_model_matrix;
|
||||||
uniform mat4 projection_matrix;
|
uniform mat4 projection_matrix;
|
||||||
|
|
||||||
|
@ -13,6 +11,8 @@ uniform vec2 z_range;
|
||||||
// Clipping plane - general orientation. Used by the SLA gizmo.
|
// Clipping plane - general orientation. Used by the SLA gizmo.
|
||||||
uniform vec4 clipping_plane;
|
uniform vec4 clipping_plane;
|
||||||
|
|
||||||
|
attribute vec3 v_position;
|
||||||
|
|
||||||
varying vec3 clipping_planes_dots;
|
varying vec3 clipping_planes_dots;
|
||||||
varying vec4 model_pos;
|
varying vec4 model_pos;
|
||||||
varying vec4 world_pos;
|
varying vec4 world_pos;
|
34
resources/shaders/110/printbed.fs
Normal file
34
resources/shaders/110/printbed.fs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
const vec3 back_color_dark = vec3(0.235, 0.235, 0.235);
|
||||||
|
const vec3 back_color_light = vec3(0.365, 0.365, 0.365);
|
||||||
|
|
||||||
|
uniform sampler2D texture;
|
||||||
|
uniform bool transparent_background;
|
||||||
|
uniform bool svg_source;
|
||||||
|
|
||||||
|
varying vec2 tex_coord;
|
||||||
|
|
||||||
|
vec4 svg_color()
|
||||||
|
{
|
||||||
|
// takes foreground from texture
|
||||||
|
vec4 fore_color = texture2D(texture, tex_coord);
|
||||||
|
|
||||||
|
// calculates radial gradient
|
||||||
|
vec3 back_color = vec3(mix(back_color_light, back_color_dark, smoothstep(0.0, 0.5, length(abs(tex_coord.xy) - vec2(0.5)))));
|
||||||
|
|
||||||
|
// blends foreground with background
|
||||||
|
return vec4(mix(back_color, fore_color.rgb, fore_color.a), transparent_background ? fore_color.a : 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 non_svg_color()
|
||||||
|
{
|
||||||
|
// takes foreground from texture
|
||||||
|
vec4 color = texture2D(texture, tex_coord);
|
||||||
|
return vec4(color.rgb, transparent_background ? color.a * 0.25 : color.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = svg_source ? svg_color() : non_svg_color();
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
#version 110
|
#version 110
|
||||||
|
|
||||||
attribute vec3 v_position;
|
|
||||||
attribute vec2 v_tex_coord;
|
|
||||||
|
|
||||||
uniform mat4 view_model_matrix;
|
uniform mat4 view_model_matrix;
|
||||||
uniform mat4 projection_matrix;
|
uniform mat4 projection_matrix;
|
||||||
|
|
||||||
|
attribute vec3 v_position;
|
||||||
|
attribute vec2 v_tex_coord;
|
||||||
|
|
||||||
varying vec2 tex_coord;
|
varying vec2 tex_coord;
|
||||||
|
|
||||||
void main()
|
void main()
|
16
resources/shaders/110/thumbnail.fs
Normal file
16
resources/shaders/110/thumbnail.fs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
uniform vec4 uniform_color;
|
||||||
|
uniform float emission_factor;
|
||||||
|
|
||||||
|
// x = tainted, y = specular;
|
||||||
|
varying vec2 intensity;
|
||||||
|
//varying float drop;
|
||||||
|
varying vec4 world_pos;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
if (world_pos.z < 0.0)
|
||||||
|
discard;
|
||||||
|
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||||
|
}
|
41
resources/shaders/110/variable_layer_height.fs
Normal file
41
resources/shaders/110/variable_layer_height.fs
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
#define M_PI 3.1415926535897932384626433832795
|
||||||
|
|
||||||
|
// 2D texture (1D texture split by the rows) of color along the object Z axis.
|
||||||
|
uniform sampler2D z_texture;
|
||||||
|
// Scaling from the Z texture rows coordinate to the normalized texture row coordinate.
|
||||||
|
uniform float z_to_texture_row;
|
||||||
|
uniform float z_texture_row_to_normalized;
|
||||||
|
uniform float z_cursor;
|
||||||
|
uniform float z_cursor_band_width;
|
||||||
|
|
||||||
|
// x = tainted, y = specular;
|
||||||
|
varying vec2 intensity;
|
||||||
|
|
||||||
|
varying float object_z;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
float object_z_row = z_to_texture_row * object_z;
|
||||||
|
// Index of the row in the texture.
|
||||||
|
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.25 * cos(min(M_PI, abs(M_PI * (object_z - z_cursor) * 1.8 / z_cursor_band_width))) + 0.25;
|
||||||
|
// Calculate level of detail from the object Z coordinate.
|
||||||
|
// This makes the slowly sloping surfaces to be shown 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 = vec4(0.25, 0.25, 0.25, 1.0);
|
||||||
|
if (z_texture_row >= 0.0)
|
||||||
|
color = mix(texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row + 0.5 )), -10000.),
|
||||||
|
texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row * 2. + 1.)), 10000.), lod);
|
||||||
|
// Mix the final color.
|
||||||
|
gl_FragColor = vec4(vec3(intensity.y), 1.0) + intensity.x * mix(color, vec4(1.0, 1.0, 0.0, 1.0), z_blend);
|
||||||
|
}
|
|
@ -14,16 +14,16 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||||
|
|
||||||
#define INTENSITY_AMBIENT 0.3
|
#define INTENSITY_AMBIENT 0.3
|
||||||
|
|
||||||
attribute vec3 v_position;
|
|
||||||
attribute vec3 v_normal;
|
|
||||||
attribute vec2 v_tex_coord;
|
|
||||||
|
|
||||||
uniform mat4 view_model_matrix;
|
uniform mat4 view_model_matrix;
|
||||||
uniform mat4 projection_matrix;
|
uniform mat4 projection_matrix;
|
||||||
uniform mat3 normal_matrix;
|
uniform mat3 normal_matrix;
|
||||||
uniform mat4 volume_world_matrix;
|
uniform mat4 volume_world_matrix;
|
||||||
uniform float object_max_z;
|
uniform float object_max_z;
|
||||||
|
|
||||||
|
attribute vec3 v_position;
|
||||||
|
attribute vec3 v_normal;
|
||||||
|
attribute vec2 v_tex_coord;
|
||||||
|
|
||||||
// x = tainted, y = specular;
|
// x = tainted, y = specular;
|
||||||
varying vec2 intensity;
|
varying vec2 intensity;
|
||||||
|
|
11
resources/shaders/140/background.fs
Normal file
11
resources/shaders/140/background.fs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
uniform vec4 top_color;
|
||||||
|
uniform vec4 bottom_color;
|
||||||
|
|
||||||
|
in vec2 tex_coord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = mix(bottom_color, top_color, tex_coord.y);
|
||||||
|
}
|
12
resources/shaders/140/background.vs
Normal file
12
resources/shaders/140/background.vs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
in vec3 v_position;
|
||||||
|
in vec2 v_tex_coord;
|
||||||
|
|
||||||
|
out vec2 tex_coord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
tex_coord = v_tex_coord;
|
||||||
|
gl_Position = vec4(v_position, 1.0);
|
||||||
|
}
|
8
resources/shaders/140/flat.fs
Normal file
8
resources/shaders/140/flat.fs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
uniform vec4 uniform_color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = uniform_color;
|
||||||
|
}
|
11
resources/shaders/140/flat.vs
Normal file
11
resources/shaders/140/flat.vs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
uniform mat4 view_model_matrix;
|
||||||
|
uniform mat4 projection_matrix;
|
||||||
|
|
||||||
|
in vec3 v_position;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||||
|
}
|
10
resources/shaders/140/flat_texture.fs
Normal file
10
resources/shaders/140/flat_texture.fs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
uniform sampler2D uniform_texture;
|
||||||
|
|
||||||
|
in vec2 tex_coord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = texture(uniform_texture, tex_coord);
|
||||||
|
}
|
15
resources/shaders/140/flat_texture.vs
Normal file
15
resources/shaders/140/flat_texture.vs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
uniform mat4 view_model_matrix;
|
||||||
|
uniform mat4 projection_matrix;
|
||||||
|
|
||||||
|
in vec3 v_position;
|
||||||
|
in vec2 v_tex_coord;
|
||||||
|
|
||||||
|
out vec2 tex_coord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
tex_coord = v_tex_coord;
|
||||||
|
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||||
|
}
|
105
resources/shaders/140/gouraud.fs
Normal file
105
resources/shaders/140/gouraud.fs
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||||
|
//BBS: add grey and orange
|
||||||
|
//const vec3 GREY = vec3(0.9, 0.9, 0.9);
|
||||||
|
const vec3 ORANGE = vec3(0.8, 0.4, 0.0);
|
||||||
|
const vec3 LightRed = vec3(0.78, 0.0, 0.0);
|
||||||
|
const vec3 LightBlue = vec3(0.73, 1.0, 1.0);
|
||||||
|
const float EPSILON = 0.0001;
|
||||||
|
|
||||||
|
struct PrintVolumeDetection
|
||||||
|
{
|
||||||
|
// 0 = rectangle, 1 = circle, 2 = custom, 3 = invalid
|
||||||
|
int type;
|
||||||
|
// type = 0 (rectangle):
|
||||||
|
// x = min.x, y = min.y, z = max.x, w = max.y
|
||||||
|
// type = 1 (circle):
|
||||||
|
// x = center.x, y = center.y, z = radius
|
||||||
|
vec4 xy_data;
|
||||||
|
// x = min z, y = max z
|
||||||
|
vec2 z_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SlopeDetection
|
||||||
|
{
|
||||||
|
bool actived;
|
||||||
|
float normal_z;
|
||||||
|
mat3 volume_world_normal_matrix;
|
||||||
|
};
|
||||||
|
|
||||||
|
uniform vec4 uniform_color;
|
||||||
|
uniform SlopeDetection slope;
|
||||||
|
|
||||||
|
//BBS: add outline_color
|
||||||
|
uniform bool is_outline;
|
||||||
|
|
||||||
|
uniform bool offset_depth_buffer;
|
||||||
|
|
||||||
|
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||||
|
uniform sampler2D environment_tex;
|
||||||
|
uniform bool use_environment_tex;
|
||||||
|
#endif // ENABLE_ENVIRONMENT_MAP
|
||||||
|
|
||||||
|
uniform PrintVolumeDetection print_volume;
|
||||||
|
|
||||||
|
in vec3 clipping_planes_dots;
|
||||||
|
|
||||||
|
// x = diffuse, y = specular;
|
||||||
|
in vec2 intensity;
|
||||||
|
|
||||||
|
in vec4 world_pos;
|
||||||
|
in float world_normal_z;
|
||||||
|
in vec3 eye_normal;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
if (any(lessThan(clipping_planes_dots, ZERO)))
|
||||||
|
discard;
|
||||||
|
vec3 color = uniform_color.rgb;
|
||||||
|
float alpha = uniform_color.a;
|
||||||
|
|
||||||
|
if (slope.actived) {
|
||||||
|
if(world_pos.z<0.1&&world_pos.z>-0.1)
|
||||||
|
{
|
||||||
|
color = LightBlue;
|
||||||
|
alpha = 0.8;
|
||||||
|
}
|
||||||
|
else if( world_normal_z < slope.normal_z - EPSILON)
|
||||||
|
{
|
||||||
|
color = color * 0.5 + LightRed * 0.5;
|
||||||
|
alpha = 0.8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if the fragment is outside the print volume -> use darker color
|
||||||
|
vec3 pv_check_min = ZERO;
|
||||||
|
vec3 pv_check_max = ZERO;
|
||||||
|
if (print_volume.type == 0) {
|
||||||
|
// rectangle
|
||||||
|
pv_check_min = world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, print_volume.z_data.x);
|
||||||
|
pv_check_max = world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, print_volume.z_data.y);
|
||||||
|
color = (any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO))) ? mix(color, ZERO, 0.3333) : color;
|
||||||
|
}
|
||||||
|
else if (print_volume.type == 1) {
|
||||||
|
// circle
|
||||||
|
float delta_radius = print_volume.xy_data.z - distance(world_pos.xy, print_volume.xy_data.xy);
|
||||||
|
pv_check_min = vec3(delta_radius, 0.0, world_pos.z - print_volume.z_data.x);
|
||||||
|
pv_check_max = vec3(0.0, 0.0, world_pos.z - print_volume.z_data.y);
|
||||||
|
color = (any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO))) ? mix(color, ZERO, 0.3333) : color;
|
||||||
|
}
|
||||||
|
|
||||||
|
//BBS: add outline_color
|
||||||
|
if (is_outline)
|
||||||
|
gl_FragColor = uniform_color;
|
||||||
|
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||||
|
else if (use_environment_tex)
|
||||||
|
gl_FragColor = vec4(0.45 * texture(environment_tex, normalize(eye_normal).xy * 0.5 + 0.5).xyz + 0.8 * color * intensity.x, alpha);
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
||||||
|
|
||||||
|
// In the support painting gizmo and the seam painting gizmo are painted triangles rendered over the already
|
||||||
|
// rendered object. To resolved z-fighting between previously rendered object and painted triangles, values
|
||||||
|
// inside the depth buffer are offset by small epsilon for painted triangles inside those gizmos.
|
||||||
|
gl_FragDepth = gl_FragCoord.z - (offset_depth_buffer ? EPSILON : 0.0);
|
||||||
|
}
|
77
resources/shaders/140/gouraud.vs
Normal file
77
resources/shaders/140/gouraud.vs
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
#define INTENSITY_CORRECTION 0.6
|
||||||
|
|
||||||
|
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||||
|
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||||
|
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||||
|
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||||
|
#define LIGHT_TOP_SHININESS 20.0
|
||||||
|
|
||||||
|
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||||
|
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||||
|
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||||
|
//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION)
|
||||||
|
//#define LIGHT_FRONT_SHININESS 5.0
|
||||||
|
|
||||||
|
#define INTENSITY_AMBIENT 0.3
|
||||||
|
|
||||||
|
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||||
|
|
||||||
|
struct SlopeDetection
|
||||||
|
{
|
||||||
|
bool actived;
|
||||||
|
float normal_z;
|
||||||
|
mat3 volume_world_normal_matrix;
|
||||||
|
};
|
||||||
|
|
||||||
|
uniform mat4 view_model_matrix;
|
||||||
|
uniform mat4 projection_matrix;
|
||||||
|
uniform mat3 normal_matrix;
|
||||||
|
uniform mat4 volume_world_matrix;
|
||||||
|
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;
|
||||||
|
// Clipping plane - general orientation. Used by the SLA gizmo.
|
||||||
|
uniform vec4 clipping_plane;
|
||||||
|
|
||||||
|
in vec3 v_position;
|
||||||
|
in vec3 v_normal;
|
||||||
|
|
||||||
|
// x = diffuse, y = specular;
|
||||||
|
out vec2 intensity;
|
||||||
|
|
||||||
|
out vec3 clipping_planes_dots;
|
||||||
|
|
||||||
|
out vec4 world_pos;
|
||||||
|
out float world_normal_z;
|
||||||
|
out vec3 eye_normal;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// First transform the normal into camera space and normalize the result.
|
||||||
|
eye_normal = normalize(normal_matrix * v_normal);
|
||||||
|
|
||||||
|
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||||
|
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||||
|
float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0);
|
||||||
|
|
||||||
|
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||||
|
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
||||||
|
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||||
|
|
||||||
|
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||||
|
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
|
||||||
|
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||||
|
|
||||||
|
// Point in homogenous coordinates.
|
||||||
|
world_pos = volume_world_matrix * vec4(v_position, 1.0);
|
||||||
|
|
||||||
|
// z component of normal vector in world coordinate used for slope shading
|
||||||
|
world_normal_z = slope.actived ? (normalize(slope.volume_world_normal_matrix * v_normal)).z : 0.0;
|
||||||
|
|
||||||
|
gl_Position = projection_matrix * position;
|
||||||
|
// 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);
|
||||||
|
}
|
12
resources/shaders/140/gouraud_light.fs
Normal file
12
resources/shaders/140/gouraud_light.fs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
uniform vec4 uniform_color;
|
||||||
|
uniform float emission_factor;
|
||||||
|
|
||||||
|
// x = tainted, y = specular;
|
||||||
|
in vec2 intensity;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||||
|
}
|
45
resources/shaders/140/gouraud_light.vs
Normal file
45
resources/shaders/140/gouraud_light.vs
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
#define INTENSITY_CORRECTION 0.6
|
||||||
|
|
||||||
|
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||||
|
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||||
|
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||||
|
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||||
|
#define LIGHT_TOP_SHININESS 20.0
|
||||||
|
|
||||||
|
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||||
|
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||||
|
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||||
|
|
||||||
|
#define INTENSITY_AMBIENT 0.3
|
||||||
|
|
||||||
|
uniform mat4 view_model_matrix;
|
||||||
|
uniform mat4 projection_matrix;
|
||||||
|
uniform mat3 normal_matrix;
|
||||||
|
|
||||||
|
in vec3 v_position;
|
||||||
|
in vec3 v_normal;
|
||||||
|
|
||||||
|
// x = tainted, y = specular;
|
||||||
|
out vec2 intensity;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// First transform the normal into camera space and normalize the result.
|
||||||
|
vec3 normal = normalize(normal_matrix * v_normal);
|
||||||
|
|
||||||
|
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||||
|
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||||
|
float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0);
|
||||||
|
|
||||||
|
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||||
|
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
||||||
|
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||||
|
|
||||||
|
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||||
|
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
|
||||||
|
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||||
|
|
||||||
|
gl_Position = projection_matrix * position;
|
||||||
|
}
|
12
resources/shaders/140/gouraud_light_instanced.fs
Normal file
12
resources/shaders/140/gouraud_light_instanced.fs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
uniform vec4 uniform_color;
|
||||||
|
uniform float emission_factor;
|
||||||
|
|
||||||
|
// x = tainted, y = specular;
|
||||||
|
in vec2 intensity;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||||
|
}
|
50
resources/shaders/140/gouraud_light_instanced.vs
Normal file
50
resources/shaders/140/gouraud_light_instanced.vs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
#define INTENSITY_CORRECTION 0.6
|
||||||
|
|
||||||
|
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||||
|
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||||
|
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||||
|
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||||
|
#define LIGHT_TOP_SHININESS 20.0
|
||||||
|
|
||||||
|
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||||
|
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||||
|
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||||
|
|
||||||
|
#define INTENSITY_AMBIENT 0.3
|
||||||
|
|
||||||
|
uniform mat4 view_model_matrix;
|
||||||
|
uniform mat4 projection_matrix;
|
||||||
|
uniform mat3 normal_matrix;
|
||||||
|
|
||||||
|
// vertex attributes
|
||||||
|
in vec3 v_position;
|
||||||
|
in vec3 v_normal;
|
||||||
|
// instance attributes
|
||||||
|
in vec3 i_offset;
|
||||||
|
in vec2 i_scales;
|
||||||
|
|
||||||
|
// x = tainted, y = specular;
|
||||||
|
out vec2 intensity;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// First transform the normal into camera space and normalize the result.
|
||||||
|
vec3 eye_normal = normalize(normal_matrix * v_normal);
|
||||||
|
|
||||||
|
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||||
|
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||||
|
float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0);
|
||||||
|
|
||||||
|
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||||
|
vec4 world_position = vec4(v_position * vec3(vec2(1.5 * i_scales.x), 1.5 * i_scales.y) + i_offset - vec3(0.0, 0.0, 0.5 * i_scales.y), 1.0);
|
||||||
|
vec4 eye_position = view_model_matrix * world_position;
|
||||||
|
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(eye_position.xyz), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||||
|
|
||||||
|
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||||
|
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
|
||||||
|
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||||
|
|
||||||
|
gl_Position = projection_matrix * eye_position;
|
||||||
|
}
|
11
resources/shaders/140/imgui.fs
Normal file
11
resources/shaders/140/imgui.fs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
uniform sampler2D Texture;
|
||||||
|
|
||||||
|
in vec2 Frag_UV;
|
||||||
|
in vec4 Frag_Color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = Frag_Color * texture(Texture, Frag_UV.st);
|
||||||
|
}
|
17
resources/shaders/140/imgui.vs
Normal file
17
resources/shaders/140/imgui.vs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
uniform mat4 ProjMtx;
|
||||||
|
|
||||||
|
in vec2 Position;
|
||||||
|
in vec2 UV;
|
||||||
|
in vec4 Color;
|
||||||
|
|
||||||
|
out vec2 Frag_UV;
|
||||||
|
out vec4 Frag_Color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
Frag_UV = UV;
|
||||||
|
Frag_Color = Color;
|
||||||
|
gl_Position = ProjMtx * vec4(Position.xy, 0.0, 1.0);
|
||||||
|
}
|
13
resources/shaders/140/mm_contour.fs
Normal file
13
resources/shaders/140/mm_contour.fs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
const float EPSILON = 0.0001;
|
||||||
|
|
||||||
|
uniform vec4 uniform_color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = uniform_color;
|
||||||
|
// Values inside depth buffer for fragments of the contour of a selected area are offset
|
||||||
|
// by small epsilon to solve z-fighting between painted triangles and contour lines.
|
||||||
|
gl_FragDepth = gl_FragCoord.z - EPSILON;
|
||||||
|
}
|
11
resources/shaders/140/mm_contour.vs
Normal file
11
resources/shaders/140/mm_contour.vs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
uniform mat4 view_model_matrix;
|
||||||
|
uniform mat4 projection_matrix;
|
||||||
|
|
||||||
|
in vec3 v_position;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||||
|
}
|
90
resources/shaders/140/mm_gouraud.fs
Normal file
90
resources/shaders/140/mm_gouraud.fs
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
#define INTENSITY_CORRECTION 0.6
|
||||||
|
|
||||||
|
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||||
|
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||||
|
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||||
|
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||||
|
#define LIGHT_TOP_SHININESS 20.0
|
||||||
|
|
||||||
|
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||||
|
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||||
|
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||||
|
|
||||||
|
#define INTENSITY_AMBIENT 0.3
|
||||||
|
|
||||||
|
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||||
|
const float EPSILON = 0.0001;
|
||||||
|
//BBS: add grey and orange
|
||||||
|
//const vec3 GREY = vec3(0.9, 0.9, 0.9);
|
||||||
|
const vec3 ORANGE = vec3(0.8, 0.4, 0.0);
|
||||||
|
const vec3 LightRed = vec3(0.78, 0.0, 0.0);
|
||||||
|
const vec3 LightBlue = vec3(0.73, 1.0, 1.0);
|
||||||
|
uniform vec4 uniform_color;
|
||||||
|
|
||||||
|
uniform bool volume_mirrored;
|
||||||
|
|
||||||
|
uniform mat4 view_model_matrix;
|
||||||
|
uniform mat3 normal_matrix;
|
||||||
|
|
||||||
|
in vec3 clipping_planes_dots;
|
||||||
|
in vec4 model_pos;
|
||||||
|
in vec4 world_pos;
|
||||||
|
|
||||||
|
struct SlopeDetection
|
||||||
|
{
|
||||||
|
bool actived;
|
||||||
|
float normal_z;
|
||||||
|
mat3 volume_world_normal_matrix;
|
||||||
|
};
|
||||||
|
uniform SlopeDetection slope;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
if (any(lessThan(clipping_planes_dots, ZERO)))
|
||||||
|
discard;
|
||||||
|
vec3 color = uniform_color.rgb;
|
||||||
|
float alpha = uniform_color.a;
|
||||||
|
|
||||||
|
vec3 triangle_normal = normalize(cross(dFdx(model_pos.xyz), dFdy(model_pos.xyz)));
|
||||||
|
#ifdef FLIP_TRIANGLE_NORMALS
|
||||||
|
triangle_normal = -triangle_normal;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (volume_mirrored)
|
||||||
|
triangle_normal = -triangle_normal;
|
||||||
|
|
||||||
|
vec3 transformed_normal = normalize(slope.volume_world_normal_matrix * triangle_normal);
|
||||||
|
|
||||||
|
if (slope.actived) {
|
||||||
|
if(world_pos.z<0.1&&world_pos.z>-0.1)
|
||||||
|
{
|
||||||
|
color = LightBlue;
|
||||||
|
alpha = 1.0;
|
||||||
|
}
|
||||||
|
else if( transformed_normal.z < slope.normal_z - EPSILON)
|
||||||
|
{
|
||||||
|
color = color * 0.5 + LightRed * 0.5;
|
||||||
|
alpha = 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// First transform the normal into camera space and normalize the result.
|
||||||
|
vec3 eye_normal = normalize(normal_matrix * triangle_normal);
|
||||||
|
|
||||||
|
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||||
|
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||||
|
float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0);
|
||||||
|
|
||||||
|
// x = diffuse, y = specular;
|
||||||
|
vec2 intensity = vec2(0.0);
|
||||||
|
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||||
|
vec3 position = (view_model_matrix * model_pos).xyz;
|
||||||
|
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||||
|
|
||||||
|
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||||
|
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
|
||||||
|
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||||
|
|
||||||
|
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
||||||
|
}
|
35
resources/shaders/140/mm_gouraud.vs
Normal file
35
resources/shaders/140/mm_gouraud.vs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||||
|
|
||||||
|
uniform mat4 view_model_matrix;
|
||||||
|
uniform mat4 projection_matrix;
|
||||||
|
|
||||||
|
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;
|
||||||
|
// Clipping plane - general orientation. Used by the SLA gizmo.
|
||||||
|
uniform vec4 clipping_plane;
|
||||||
|
|
||||||
|
in vec3 v_position;
|
||||||
|
|
||||||
|
out vec3 clipping_planes_dots;
|
||||||
|
out vec4 model_pos;
|
||||||
|
out vec4 world_pos;
|
||||||
|
struct SlopeDetection
|
||||||
|
{
|
||||||
|
bool actived;
|
||||||
|
float normal_z;
|
||||||
|
mat3 volume_world_normal_matrix;
|
||||||
|
};
|
||||||
|
uniform SlopeDetection slope;
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
model_pos = vec4(v_position, 1.0);
|
||||||
|
// Point in homogenous coordinates.
|
||||||
|
world_pos = volume_world_matrix * model_pos;
|
||||||
|
|
||||||
|
gl_Position = projection_matrix * view_model_matrix * model_pos;
|
||||||
|
// 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);
|
||||||
|
}
|
35
resources/shaders/140/printbed.fs
Normal file
35
resources/shaders/140/printbed.fs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
const vec3 back_color_dark = vec3(0.235, 0.235, 0.235);
|
||||||
|
const vec3 back_color_light = vec3(0.365, 0.365, 0.365);
|
||||||
|
|
||||||
|
uniform sampler2D in_texture;
|
||||||
|
uniform bool transparent_background;
|
||||||
|
uniform bool svg_source;
|
||||||
|
|
||||||
|
in vec2 tex_coord;
|
||||||
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
vec4 svg_color()
|
||||||
|
{
|
||||||
|
// takes foreground from texture
|
||||||
|
vec4 fore_color = texture(in_texture, tex_coord);
|
||||||
|
|
||||||
|
// calculates radial gradient
|
||||||
|
vec3 back_color = vec3(mix(back_color_light, back_color_dark, smoothstep(0.0, 0.5, length(abs(tex_coord.xy) - vec2(0.5)))));
|
||||||
|
|
||||||
|
// blends foreground with background
|
||||||
|
return vec4(mix(back_color, fore_color.rgb, fore_color.a), transparent_background ? fore_color.a : 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 non_svg_color()
|
||||||
|
{
|
||||||
|
// takes foreground from texture
|
||||||
|
vec4 color = texture(in_texture, tex_coord);
|
||||||
|
return vec4(color.rgb, transparent_background ? color.a * 0.25 : color.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
frag_color = svg_source ? svg_color() : non_svg_color();
|
||||||
|
}
|
15
resources/shaders/140/printbed.vs
Normal file
15
resources/shaders/140/printbed.vs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
uniform mat4 view_model_matrix;
|
||||||
|
uniform mat4 projection_matrix;
|
||||||
|
|
||||||
|
in vec3 v_position;
|
||||||
|
in vec2 v_tex_coord;
|
||||||
|
|
||||||
|
out vec2 tex_coord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
tex_coord = v_tex_coord;
|
||||||
|
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||||
|
}
|
16
resources/shaders/140/thumbnail.fs
Normal file
16
resources/shaders/140/thumbnail.fs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
uniform vec4 uniform_color;
|
||||||
|
uniform float emission_factor;
|
||||||
|
|
||||||
|
// x = tainted, y = specular;
|
||||||
|
in vec2 intensity;
|
||||||
|
//varying float drop;
|
||||||
|
in vec4 world_pos;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
if (world_pos.z < 0.0)
|
||||||
|
discard;
|
||||||
|
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||||
|
}
|
51
resources/shaders/140/thumbnail.vs
Normal file
51
resources/shaders/140/thumbnail.vs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
#define INTENSITY_CORRECTION 0.6
|
||||||
|
|
||||||
|
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||||
|
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||||
|
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||||
|
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||||
|
#define LIGHT_TOP_SHININESS 20.0
|
||||||
|
|
||||||
|
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||||
|
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||||
|
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||||
|
|
||||||
|
#define INTENSITY_AMBIENT 0.3
|
||||||
|
|
||||||
|
in vec3 v_position;
|
||||||
|
in vec3 v_normal;
|
||||||
|
|
||||||
|
uniform mat4 view_model_matrix;
|
||||||
|
uniform mat4 projection_matrix;
|
||||||
|
uniform mat3 normal_matrix;
|
||||||
|
|
||||||
|
uniform mat4 volume_world_matrix;
|
||||||
|
|
||||||
|
// x = tainted, y = specular;
|
||||||
|
out vec2 intensity;
|
||||||
|
out vec4 world_pos;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// First transform the normal into camera space and normalize the result.
|
||||||
|
vec3 normal = normalize(normal_matrix * v_normal);
|
||||||
|
|
||||||
|
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||||
|
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||||
|
float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0);
|
||||||
|
|
||||||
|
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||||
|
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
||||||
|
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||||
|
|
||||||
|
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||||
|
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
|
||||||
|
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||||
|
|
||||||
|
// Point in homogenous coordinates.
|
||||||
|
world_pos = volume_world_matrix * gl_Vertex;
|
||||||
|
|
||||||
|
gl_Position = projection_matrix * position;
|
||||||
|
}
|
41
resources/shaders/140/variable_layer_height.fs
Normal file
41
resources/shaders/140/variable_layer_height.fs
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
#define M_PI 3.1415926535897932384626433832795
|
||||||
|
|
||||||
|
// 2D texture (1D texture split by the rows) of color along the object Z axis.
|
||||||
|
uniform sampler2D z_texture;
|
||||||
|
// Scaling from the Z texture rows coordinate to the normalized texture row coordinate.
|
||||||
|
uniform float z_to_texture_row;
|
||||||
|
uniform float z_texture_row_to_normalized;
|
||||||
|
uniform float z_cursor;
|
||||||
|
uniform float z_cursor_band_width;
|
||||||
|
|
||||||
|
// x = tainted, y = specular;
|
||||||
|
in vec2 intensity;
|
||||||
|
|
||||||
|
in float object_z;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
float object_z_row = z_to_texture_row * object_z;
|
||||||
|
// Index of the row in the texture.
|
||||||
|
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.25 * cos(min(M_PI, abs(M_PI * (object_z - z_cursor) * 1.8 / z_cursor_band_width))) + 0.25;
|
||||||
|
// Calculate level of detail from the object Z coordinate.
|
||||||
|
// This makes the slowly sloping surfaces to be shown 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 = vec4(0.25, 0.25, 0.25, 1.0);
|
||||||
|
if (z_texture_row >= 0.0)
|
||||||
|
color = mix(texture(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row + 0.5 )), -10000.),
|
||||||
|
texture(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row * 2. + 1.)), 10000.), lod);
|
||||||
|
// Mix the final color.
|
||||||
|
gl_FragColor = vec4(vec3(intensity.y), 1.0) + intensity.x * mix(color, vec4(1.0, 1.0, 0.0, 1.0), z_blend);
|
||||||
|
}
|
60
resources/shaders/140/variable_layer_height.vs
Normal file
60
resources/shaders/140/variable_layer_height.vs
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#version 140
|
||||||
|
|
||||||
|
#define INTENSITY_CORRECTION 0.6
|
||||||
|
|
||||||
|
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||||
|
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||||
|
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||||
|
#define LIGHT_TOP_SHININESS 20.0
|
||||||
|
|
||||||
|
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||||
|
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||||
|
//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION)
|
||||||
|
//#define LIGHT_FRONT_SHININESS 5.0
|
||||||
|
|
||||||
|
#define INTENSITY_AMBIENT 0.3
|
||||||
|
|
||||||
|
uniform mat4 view_model_matrix;
|
||||||
|
uniform mat4 projection_matrix;
|
||||||
|
uniform mat3 normal_matrix;
|
||||||
|
uniform mat4 volume_world_matrix;
|
||||||
|
uniform float object_max_z;
|
||||||
|
|
||||||
|
in vec3 v_position;
|
||||||
|
in vec3 v_normal;
|
||||||
|
in vec2 v_tex_coord;
|
||||||
|
|
||||||
|
// x = tainted, y = specular;
|
||||||
|
out vec2 intensity;
|
||||||
|
|
||||||
|
out float object_z;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// =====================================================
|
||||||
|
// NOTE:
|
||||||
|
// when object_max_z > 0.0 we are rendering the overlay
|
||||||
|
// when object_max_z == 0.0 we are rendering the volumes
|
||||||
|
// =====================================================
|
||||||
|
|
||||||
|
// First transform the normal into camera space and normalize the result.
|
||||||
|
vec3 normal = (object_max_z > 0.0) ? vec3(0.0, 0.0, 1.0) : normalize(normal_matrix * v_normal);
|
||||||
|
|
||||||
|
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||||
|
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||||
|
float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0);
|
||||||
|
|
||||||
|
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||||
|
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
||||||
|
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||||
|
|
||||||
|
// Perform the same lighting calculation for the 2nd light source (no specular)
|
||||||
|
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
|
||||||
|
|
||||||
|
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||||
|
|
||||||
|
// Scaled to widths of the Z texture.
|
||||||
|
object_z = (object_max_z > 0.0) ? object_max_z * v_tex_coord.y : (volume_world_matrix * vec4(v_position, 1.0)).z;
|
||||||
|
|
||||||
|
gl_Position = projection_matrix * position;
|
||||||
|
}
|
|
@ -2370,7 +2370,7 @@ int CLI::run(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
ThumbnailsParams thumbnail_params;
|
ThumbnailsParams thumbnail_params;
|
||||||
GLShaderProgram* shader = opengl_mgr.get_shader("thumbnail_attr");
|
GLShaderProgram* shader = opengl_mgr.get_shader("thumbnail");
|
||||||
if (!shader) {
|
if (!shader) {
|
||||||
BOOST_LOG_TRIVIAL(error) << boost::format("can not get shader for rendering thumbnail");
|
BOOST_LOG_TRIVIAL(error) << boost::format("can not get shader for rendering thumbnail");
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,7 @@ void Bed3D::Axes::render()
|
||||||
if (!m_arrow.is_initialized())
|
if (!m_arrow.is_initialized())
|
||||||
m_arrow.init_from(stilized_arrow(16, DefaultTipRadius, DefaultTipLength, DefaultStemRadius, m_stem_length));
|
m_arrow.init_from(stilized_arrow(16, DefaultTipRadius, DefaultTipLength, DefaultStemRadius, m_stem_length));
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ void Bed3D::render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, co
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_triangles.get_vertices_count() > 0) {
|
if (m_triangles.get_vertices_count() > 0) {
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("printbed_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("printbed");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
@ -671,7 +671,7 @@ void Bed3D::render_model(const Transform3d& view_matrix, const Transform3d& proj
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_model.get_filename().empty()) {
|
if (!m_model.get_filename().empty()) {
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
shader->set_uniform("emission_factor", 0.0f);
|
shader->set_uniform("emission_factor", 0.0f);
|
||||||
|
@ -706,7 +706,7 @@ void Bed3D::render_default(bool bottom, const Transform3d& view_matrix, const Tr
|
||||||
|
|
||||||
update_bed_triangles();
|
update_bed_triangles();
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
|
|
|
@ -821,9 +821,8 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat");
|
||||||
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat");
|
||||||
assert(boost::algorithm::iends_with(shader->get_name(), "_attr"));
|
|
||||||
|
|
||||||
if (type == ERenderType::Transparent) {
|
if (type == ERenderType::Transparent) {
|
||||||
glsafe(::glEnable(GL_BLEND));
|
glsafe(::glEnable(GL_BLEND));
|
||||||
|
|
|
@ -307,7 +307,7 @@ void GCodeViewer::SequentialView::Marker::render(int canvas_width, int canvas_he
|
||||||
if (!m_visible)
|
if (!m_visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -788,7 +788,7 @@ void GCodeViewer::init(ConfigOptionMode mode, PresetBundle* preset_bundle)
|
||||||
case EMoveType::Seam: {
|
case EMoveType::Seam: {
|
||||||
// if (wxGetApp().is_gl_version_greater_or_equal_to(3, 3)) {
|
// if (wxGetApp().is_gl_version_greater_or_equal_to(3, 3)) {
|
||||||
// buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::InstancedModel;
|
// buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::InstancedModel;
|
||||||
// buffer.shader = "gouraud_light_instanced_attr";
|
// buffer.shader = "gouraud_light_instanced";
|
||||||
// buffer.model.model.init_from(diamond(16));
|
// buffer.model.model.init_from(diamond(16));
|
||||||
// buffer.model.color = option_color(type);
|
// buffer.model.color = option_color(type);
|
||||||
// buffer.model.instances.format = InstanceVBuffer::EFormat::InstancedModel;
|
// buffer.model.instances.format = InstanceVBuffer::EFormat::InstancedModel;
|
||||||
|
@ -799,7 +799,7 @@ void GCodeViewer::init(ConfigOptionMode mode, PresetBundle* preset_bundle)
|
||||||
|
|
||||||
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::BatchedModel;
|
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::BatchedModel;
|
||||||
buffer.vertices.format = VBuffer::EFormat::PositionNormal3;
|
buffer.vertices.format = VBuffer::EFormat::PositionNormal3;
|
||||||
buffer.shader = "gouraud_light_attr";
|
buffer.shader = "gouraud_light";
|
||||||
|
|
||||||
buffer.model.data = diamond(16);
|
buffer.model.data = diamond(16);
|
||||||
buffer.model.color = option_color(type);
|
buffer.model.color = option_color(type);
|
||||||
|
@ -811,13 +811,13 @@ void GCodeViewer::init(ConfigOptionMode mode, PresetBundle* preset_bundle)
|
||||||
case EMoveType::Extrude: {
|
case EMoveType::Extrude: {
|
||||||
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Triangle;
|
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Triangle;
|
||||||
buffer.vertices.format = VBuffer::EFormat::PositionNormal3;
|
buffer.vertices.format = VBuffer::EFormat::PositionNormal3;
|
||||||
buffer.shader = "gouraud_light_attr";
|
buffer.shader = "gouraud_light";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EMoveType::Travel: {
|
case EMoveType::Travel: {
|
||||||
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Line;
|
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Line;
|
||||||
buffer.vertices.format = VBuffer::EFormat::Position;
|
buffer.vertices.format = VBuffer::EFormat::Position;
|
||||||
buffer.shader = "flat_attr";
|
buffer.shader = "flat";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1425,7 +1425,7 @@ void GCodeViewer::_render_calibration_thumbnail_internal(ThumbnailData& thumbnai
|
||||||
if (!buffer.visible || !buffer.has_data())
|
if (!buffer.visible || !buffer.has_data())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
GLShaderProgram* shader = opengl_manager.get_shader("flat_attr");
|
GLShaderProgram* shader = opengl_manager.get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
|
@ -4029,7 +4029,7 @@ void GCodeViewer::render_shells()
|
||||||
//if (!m_shells.visible || m_shells.volumes.empty())
|
//if (!m_shells.visible || m_shells.volumes.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ void GLCanvas3D::LayersEditing::select_object(const Model& model, int object_id)
|
||||||
|
|
||||||
bool GLCanvas3D::LayersEditing::is_allowed() const
|
bool GLCanvas3D::LayersEditing::is_allowed() const
|
||||||
{
|
{
|
||||||
return wxGetApp().get_shader("variable_layer_height_attr") != nullptr && m_z_texture_id > 0;
|
return wxGetApp().get_shader("variable_layer_height") != nullptr && m_z_texture_id > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLCanvas3D::LayersEditing::is_enabled() const
|
bool GLCanvas3D::LayersEditing::is_enabled() const
|
||||||
|
@ -355,7 +355,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_screen(const GLCanvas3D& canvas)
|
||||||
|
|
||||||
bool GLCanvas3D::LayersEditing::is_initialized() const
|
bool GLCanvas3D::LayersEditing::is_initialized() const
|
||||||
{
|
{
|
||||||
return wxGetApp().get_shader("variable_layer_height_attr") != nullptr;
|
return wxGetApp().get_shader("variable_layer_height") != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GLCanvas3D::LayersEditing::get_tooltip(const GLCanvas3D& canvas) const
|
std::string GLCanvas3D::LayersEditing::get_tooltip(const GLCanvas3D& canvas) const
|
||||||
|
@ -397,7 +397,7 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
||||||
|
|
||||||
const float cnv_inv_width = 1.0f / cnv_width;
|
const float cnv_inv_width = 1.0f / cnv_width;
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ void GLCanvas3D::LayersEditing::render_profile(const GLCanvas3D& canvas)
|
||||||
m_profile.profile.init_from(std::move(init_data));
|
m_profile.profile.init_from(std::move(init_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||||
|
@ -534,7 +534,7 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
|
||||||
if (current_shader != nullptr)
|
if (current_shader != nullptr)
|
||||||
current_shader->stop_using();
|
current_shader->stop_using();
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -946,7 +946,7 @@ void GLCanvas3D::SequentialPrintClearance::render()
|
||||||
const ColorRGBA FILL_COLOR = { 0.7f, 0.7f, 1.0f, 0.5f };
|
const ColorRGBA FILL_COLOR = { 0.7f, 0.7f, 1.0f, 0.5f };
|
||||||
const ColorRGBA NO_FILL_COLOR = { 0.75f, 0.75f, 0.75f, 0.75f };
|
const ColorRGBA NO_FILL_COLOR = { 0.75f, 0.75f, 0.75f, 0.75f };
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2006,7 +2006,7 @@ void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w,
|
||||||
void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params,
|
void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params,
|
||||||
const GLVolumeCollection& volumes, Camera::EType camera_type, bool use_top_view, bool for_picking)
|
const GLVolumeCollection& volumes, Camera::EType camera_type, bool use_top_view, bool for_picking)
|
||||||
{
|
{
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("thumbnail_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("thumbnail");
|
||||||
ModelObjectPtrs& model_objects = GUI::wxGetApp().model().objects;
|
ModelObjectPtrs& model_objects = GUI::wxGetApp().model().objects;
|
||||||
std::vector<ColorRGBA> colors = ::get_extruders_colors();
|
std::vector<ColorRGBA> colors = ::get_extruders_colors();
|
||||||
switch (OpenGLManager::get_framebuffers_type())
|
switch (OpenGLManager::get_framebuffers_type())
|
||||||
|
@ -5557,7 +5557,7 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
||||||
|
|
||||||
camera.apply_projection(plate_build_volume);
|
camera.apply_projection(plate_build_volume);
|
||||||
|
|
||||||
//GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
|
//GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||||
if (!for_picking && (shader == nullptr)) {
|
if (!for_picking && (shader == nullptr)) {
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("render_thumbnail with no picking: shader is null, return directly");
|
BOOST_LOG_TRIVIAL(info) << boost::format("render_thumbnail with no picking: shader is null, return directly");
|
||||||
return;
|
return;
|
||||||
|
@ -6619,7 +6619,7 @@ void GLCanvas3D::_render_background()
|
||||||
m_background.init_from(std::move(init_data));
|
m_background.init_from(std::move(init_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("background_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("background");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
shader->set_uniform("top_color", use_error_color ? ERROR_BG_LIGHT_COLOR : DEFAULT_BG_LIGHT_COLOR);
|
shader->set_uniform("top_color", use_error_color ? ERROR_BG_LIGHT_COLOR : DEFAULT_BG_LIGHT_COLOR);
|
||||||
|
@ -6742,7 +6742,7 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
|
||||||
else
|
else
|
||||||
m_volumes.set_show_sinking_contours(!m_gizmos.is_hiding_instances());
|
m_volumes.set_show_sinking_contours(!m_gizmos.is_hiding_instances());
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("gouraud");
|
||||||
ECanvasType canvas_type = this->m_canvas_type;
|
ECanvasType canvas_type = this->m_canvas_type;
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
@ -7170,7 +7170,7 @@ void GLCanvas3D::_render_style_editor()
|
||||||
|
|
||||||
void GLCanvas3D::_render_volumes_for_picking() const
|
void GLCanvas3D::_render_volumes_for_picking() const
|
||||||
{
|
{
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -8008,7 +8008,7 @@ void GLCanvas3D::_render_camera_target()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
@ -8127,7 +8127,7 @@ void GLCanvas3D::_render_sla_slices()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
|
|
|
@ -575,21 +575,21 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
||||||
if (position) {
|
if (position) {
|
||||||
position_id = shader->get_attrib_location("v_position");
|
position_id = shader->get_attrib_location("v_position");
|
||||||
if (position_id != -1) {
|
if (position_id != -1) {
|
||||||
glsafe(::glVertexAttribPointer(position_id, Geometry::position_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (GLvoid*)Geometry::position_offset_bytes(data.format)));
|
glsafe(::glVertexAttribPointer(position_id, Geometry::position_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (const void*)Geometry::position_offset_bytes(data.format)));
|
||||||
glsafe(::glEnableVertexAttribArray(position_id));
|
glsafe(::glEnableVertexAttribArray(position_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (normal) {
|
if (normal) {
|
||||||
normal_id = shader->get_attrib_location("v_normal");
|
normal_id = shader->get_attrib_location("v_normal");
|
||||||
if (normal_id != -1) {
|
if (normal_id != -1) {
|
||||||
glsafe(::glVertexAttribPointer(normal_id, Geometry::normal_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (GLvoid*)Geometry::normal_offset_bytes(data.format)));
|
glsafe(::glVertexAttribPointer(normal_id, Geometry::normal_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (const void*)Geometry::normal_offset_bytes(data.format)));
|
||||||
glsafe(::glEnableVertexAttribArray(normal_id));
|
glsafe(::glEnableVertexAttribArray(normal_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tex_coord) {
|
if (tex_coord) {
|
||||||
tex_coord_id = shader->get_attrib_location("v_tex_coord");
|
tex_coord_id = shader->get_attrib_location("v_tex_coord");
|
||||||
if (tex_coord_id != -1) {
|
if (tex_coord_id != -1) {
|
||||||
glsafe(::glVertexAttribPointer(tex_coord_id, Geometry::tex_coord_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (GLvoid*)Geometry::tex_coord_offset_bytes(data.format)));
|
glsafe(::glVertexAttribPointer(tex_coord_id, Geometry::tex_coord_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (const void*)Geometry::tex_coord_offset_bytes(data.format)));
|
||||||
glsafe(::glEnableVertexAttribArray(tex_coord_id));
|
glsafe(::glEnableVertexAttribArray(tex_coord_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -612,11 +612,11 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
||||||
|
|
||||||
void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instances_count)
|
void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instances_count)
|
||||||
{
|
{
|
||||||
if (instances_vbo == 0)
|
if (instances_vbo == 0 || instances_count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_current_shader();
|
GLShaderProgram* shader = wxGetApp().get_current_shader();
|
||||||
if (shader == nullptr || !boost::algorithm::iends_with(shader->get_name(), "_instanced_attr"))
|
if (shader == nullptr || !boost::algorithm::iends_with(shader->get_name(), "_instanced"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// vertex attributes
|
// vertex attributes
|
||||||
|
@ -637,11 +637,12 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
|
||||||
}
|
}
|
||||||
|
|
||||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, instances_vbo));
|
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, instances_vbo));
|
||||||
glsafe(::glVertexAttribPointer(offset_id, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (GLvoid*)0));
|
const size_t instance_stride = 5 * sizeof(float);
|
||||||
|
glsafe(::glVertexAttribPointer(offset_id, 3, GL_FLOAT, GL_FALSE, instance_stride, (const void*)0));
|
||||||
glsafe(::glEnableVertexAttribArray(offset_id));
|
glsafe(::glEnableVertexAttribArray(offset_id));
|
||||||
glsafe(::glVertexAttribDivisor(offset_id, 1));
|
glsafe(::glVertexAttribDivisor(offset_id, 1));
|
||||||
|
|
||||||
glsafe(::glVertexAttribPointer(scales_id, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (GLvoid*)(3 * sizeof(float))));
|
glsafe(::glVertexAttribPointer(scales_id, 2, GL_FLOAT, GL_FALSE, instance_stride, (const void*)(3 * sizeof(float))));
|
||||||
glsafe(::glEnableVertexAttribArray(scales_id));
|
glsafe(::glEnableVertexAttribArray(scales_id));
|
||||||
glsafe(::glVertexAttribDivisor(scales_id, 1));
|
glsafe(::glVertexAttribDivisor(scales_id, 1));
|
||||||
|
|
||||||
|
@ -650,8 +651,6 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
|
||||||
const GLenum mode = get_primitive_mode(data.format);
|
const GLenum mode = get_primitive_mode(data.format);
|
||||||
const GLenum index_type = get_index_type(data);
|
const GLenum index_type = get_index_type(data);
|
||||||
|
|
||||||
shader->set_uniform("uniform_color", data.color);
|
|
||||||
|
|
||||||
const size_t vertex_stride_bytes = Geometry::vertex_stride_bytes(data.format);
|
const size_t vertex_stride_bytes = Geometry::vertex_stride_bytes(data.format);
|
||||||
const bool position = Geometry::has_position(data.format);
|
const bool position = Geometry::has_position(data.format);
|
||||||
const bool normal = Geometry::has_normal(data.format);
|
const bool normal = Geometry::has_normal(data.format);
|
||||||
|
@ -659,15 +658,17 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
|
||||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_render_data.vbo_id));
|
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_render_data.vbo_id));
|
||||||
|
|
||||||
if (position) {
|
if (position) {
|
||||||
glsafe(::glVertexAttribPointer(position_id, Geometry::position_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (GLvoid*)Geometry::position_offset_bytes(data.format)));
|
glsafe(::glVertexAttribPointer(position_id, Geometry::position_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (const void*)Geometry::position_offset_bytes(data.format)));
|
||||||
glsafe(::glEnableVertexAttribArray(position_id));
|
glsafe(::glEnableVertexAttribArray(position_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (normal) {
|
if (normal) {
|
||||||
glsafe(::glVertexAttribPointer(normal_id, Geometry::normal_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (GLvoid*)Geometry::normal_offset_bytes(data.format)));
|
glsafe(::glVertexAttribPointer(normal_id, Geometry::normal_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (const void*)Geometry::normal_offset_bytes(data.format)));
|
||||||
glsafe(::glEnableVertexAttribArray(normal_id));
|
glsafe(::glEnableVertexAttribArray(normal_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shader->set_uniform("uniform_color", data.color);
|
||||||
|
|
||||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_render_data.ibo_id));
|
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_render_data.ibo_id));
|
||||||
glsafe(::glDrawElementsInstanced(mode, indices_count(), index_type, (const void*)0, instances_count));
|
glsafe(::glDrawElementsInstanced(mode, indices_count(), index_type, (const void*)0, instances_count));
|
||||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace GUI {
|
||||||
glsafe(::glLineStipple(4, 0xAAAA));
|
glsafe(::glLineStipple(4, 0xAAAA));
|
||||||
glsafe(::glEnable(GL_LINE_STIPPLE));
|
glsafe(::glEnable(GL_LINE_STIPPLE));
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
|
|
|
@ -33,46 +33,36 @@ std::pair<bool, std::string> GLShadersManager::init()
|
||||||
|
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
|
|
||||||
|
const std::string prefix = GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 1) ? "140/" : "110/";
|
||||||
// imgui shader
|
// imgui shader
|
||||||
valid &= append_shader("imgui", { "imgui.vs", "imgui.fs" });
|
valid &= append_shader("imgui", { prefix + "imgui.vs", prefix + "imgui.fs" });
|
||||||
// basic shader, used to render all what was previously rendered using the immediate mode
|
// basic shader, used to render all what was previously rendered using the immediate mode
|
||||||
valid &= append_shader("flat_attr", { "flat_attr.vs", "flat.fs" });
|
valid &= append_shader("flat", { prefix + "flat.vs", prefix + "flat.fs" });
|
||||||
// basic shader for textures, used to render textures
|
// basic shader for textures, used to render textures
|
||||||
valid &= append_shader("flat_texture_attr", { "flat_texture_attr.vs", "flat_texture.fs" });
|
valid &= append_shader("flat_texture", { prefix + "flat_texture.vs", prefix + "flat_texture.fs" });
|
||||||
// used to render 3D scene background
|
// used to render 3D scene background
|
||||||
valid &= append_shader("background_attr", { "background_attr.vs", "background.fs" });
|
valid &= append_shader("background", { prefix + "background.vs", prefix + "background.fs" });
|
||||||
// used to render bed axes and model, selection hints, gcode sequential view marker model, preview shells, options in gcode preview
|
// used to render bed axes and model, selection hints, gcode sequential view marker model, preview shells, options in gcode preview
|
||||||
valid &= append_shader("gouraud_light_attr", { "gouraud_light_attr.vs", "gouraud_light.fs" });
|
valid &= append_shader("gouraud_light", { prefix + "gouraud_light.vs", prefix + "gouraud_light.fs" });
|
||||||
//used to render thumbnail
|
//used to render thumbnail
|
||||||
valid &= append_shader("thumbnail_attr", {"thumbnail_attr.vs", "thumbnail.fs"});
|
valid &= append_shader("thumbnail", { prefix + "thumbnail.vs", prefix + "thumbnail.fs"});
|
||||||
valid &= append_shader("thumbnail", {"thumbnail.vs", "thumbnail.fs"});
|
|
||||||
// used to render printbed
|
// used to render printbed
|
||||||
valid &= append_shader("printbed_attr", { "printbed_attr.vs", "printbed.fs" });
|
valid &= append_shader("printbed", { prefix + "printbed.vs", prefix + "printbed.fs" });
|
||||||
// used to render options in gcode preview
|
// used to render options in gcode preview
|
||||||
if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 3)) {
|
if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 3)) {
|
||||||
valid &= append_shader("gouraud_light_instanced_attr", { "gouraud_light_instanced_attr.vs", "gouraud_light_instanced.fs" });
|
valid &= append_shader("gouraud_light_instanced", { prefix + "gouraud_light_instanced.vs", prefix + "gouraud_light_instanced.fs" });
|
||||||
}
|
}
|
||||||
|
|
||||||
// used to render objects in 3d editor
|
// used to render objects in 3d editor
|
||||||
//if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 0)) {
|
valid &= append_shader("gouraud", { prefix + "gouraud.vs", prefix + "gouraud.fs" }
|
||||||
if (0) {
|
|
||||||
valid &= append_shader("gouraud", { "gouraud_130.vs", "gouraud_130.fs" }
|
|
||||||
#if ENABLE_ENVIRONMENT_MAP
|
|
||||||
, { "ENABLE_ENVIRONMENT_MAP"sv }
|
|
||||||
#endif // ENABLE_ENVIRONMENT_MAP
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
valid &= append_shader("gouraud_attr", { "gouraud_attr.vs", "gouraud.fs" }
|
|
||||||
#if ENABLE_ENVIRONMENT_MAP
|
#if ENABLE_ENVIRONMENT_MAP
|
||||||
, { "ENABLE_ENVIRONMENT_MAP"sv }
|
, { "ENABLE_ENVIRONMENT_MAP"sv }
|
||||||
#endif // ENABLE_ENVIRONMENT_MAP
|
#endif // ENABLE_ENVIRONMENT_MAP
|
||||||
);
|
);
|
||||||
}
|
|
||||||
// used to render variable layers heights in 3d editor
|
// used to render variable layers heights in 3d editor
|
||||||
valid &= append_shader("variable_layer_height_attr", { "variable_layer_height_attr.vs", "variable_layer_height.fs" });
|
valid &= append_shader("variable_layer_height", { prefix + "variable_layer_height.vs", prefix + "variable_layer_height.fs" });
|
||||||
// used to render highlight contour around selected triangles inside the multi-material gizmo
|
// used to render highlight contour around selected triangles inside the multi-material gizmo
|
||||||
valid &= append_shader("mm_contour_attr", { "mm_contour_attr.vs", "mm_contour_attr.fs" });
|
valid &= append_shader("mm_contour", { prefix + "mm_contour.vs", prefix + "mm_contour.fs" });
|
||||||
// Used to render painted triangles inside the multi-material gizmo. Triangle normals are computed inside fragment shader.
|
// Used to render painted triangles inside the multi-material gizmo. Triangle normals are computed inside fragment shader.
|
||||||
// For Apple's on Arm CPU computed triangle normals inside fragment shader using dFdx and dFdy has the opposite direction.
|
// For Apple's on Arm CPU computed triangle normals inside fragment shader using dFdx and dFdy has the opposite direction.
|
||||||
// Because of this, objects had darker colors inside the multi-material gizmo.
|
// Because of this, objects had darker colors inside the multi-material gizmo.
|
||||||
|
@ -80,12 +70,9 @@ std::pair<bool, std::string> GLShadersManager::init()
|
||||||
// Since macOS 12 (Monterey), this issue with the opposite direction on Apple's Arm CPU seems to be fixed, and computed
|
// Since macOS 12 (Monterey), this issue with the opposite direction on Apple's Arm CPU seems to be fixed, and computed
|
||||||
// triangle normals inside fragment shader have the right direction.
|
// triangle normals inside fragment shader have the right direction.
|
||||||
if (platform_flavor() == PlatformFlavor::OSXOnArm && wxPlatformInfo::Get().GetOSMajorVersion() < 12)
|
if (platform_flavor() == PlatformFlavor::OSXOnArm && wxPlatformInfo::Get().GetOSMajorVersion() < 12)
|
||||||
valid &= append_shader("mm_gouraud_attr", { "mm_gouraud_attr.vs", "mm_gouraud_attr.fs" }, { "FLIP_TRIANGLE_NORMALS"sv });
|
valid &= append_shader("mm_gouraud", { prefix + "mm_gouraud.vs", prefix + "mm_gouraud.fs" }, { "FLIP_TRIANGLE_NORMALS"sv });
|
||||||
else
|
else
|
||||||
valid &= append_shader("mm_gouraud_attr", { "mm_gouraud_attr.vs", "mm_gouraud_attr.fs" });
|
valid &= append_shader("mm_gouraud", { prefix + "mm_gouraud.vs", prefix + "mm_gouraud.fs" });
|
||||||
|
|
||||||
//BBS: add shader for outline
|
|
||||||
valid &= append_shader("outline", { "outline.vs", "outline.fs" });
|
|
||||||
|
|
||||||
return { valid, error };
|
return { valid, error };
|
||||||
}
|
}
|
||||||
|
|
|
@ -680,7 +680,7 @@ void GLTexture::render_sub_texture(unsigned int tex_id, float left, float right,
|
||||||
GLModel model;
|
GLModel model;
|
||||||
model.init_from(std::move(init_data));
|
model.init_from(std::move(init_data));
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_texture_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat_texture");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||||
|
|
|
@ -500,7 +500,7 @@ void GLGizmoAdvancedCut::on_render_for_picking()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_move_grabber.color = picking_color_component(0);
|
m_move_grabber.color = picking_color_component(0);
|
||||||
GLShaderProgram *shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram *shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||||
|
@ -866,7 +866,7 @@ void GLGizmoAdvancedCut::render_cut_plane_and_grabbers()
|
||||||
glsafe(::glEnable(GL_BLEND));
|
glsafe(::glEnable(GL_BLEND));
|
||||||
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||||
|
|
||||||
GLShaderProgram *shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram *shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
|
@ -934,7 +934,7 @@ void GLGizmoAdvancedCut::render_cut_plane_and_grabbers()
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
GLShaderProgram *shader = wxGetApp().get_shader("gouraud_light_attr");
|
GLShaderProgram *shader = wxGetApp().get_shader("gouraud_light");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
@ -1069,9 +1069,9 @@ void GLGizmoAdvancedCut::render_connector_model(GLModel &model, const ColorRGBA
|
||||||
{
|
{
|
||||||
GLShaderProgram *shader = nullptr;
|
GLShaderProgram *shader = nullptr;
|
||||||
if (for_picking)
|
if (for_picking)
|
||||||
shader = wxGetApp().get_shader("flat_attr");
|
shader = wxGetApp().get_shader("flat");
|
||||||
else
|
else
|
||||||
shader = wxGetApp().get_shader("gouraud_light_attr");
|
shader = wxGetApp().get_shader("gouraud_light");
|
||||||
if (shader) {
|
if (shader) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
|
|
|
@ -262,7 +262,7 @@ void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const
|
||||||
|
|
||||||
void GLGizmoBase::render_grabbers(float size) const
|
void GLGizmoBase::render_grabbers(float size) const
|
||||||
{
|
{
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
@ -276,7 +276,7 @@ void GLGizmoBase::render_grabbers(float size) const
|
||||||
|
|
||||||
void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
|
void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
|
||||||
{
|
{
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ bool GLGizmoFdmSupports::on_key_down_select_tool_type(int keyCode) {
|
||||||
void GLGizmoFdmSupports::render_triangles(const Selection& selection) const
|
void GLGizmoFdmSupports::render_triangles(const Selection& selection) const
|
||||||
{
|
{
|
||||||
ClippingPlaneDataWrapper clp_data = this->get_clipping_plane_data();
|
ClippingPlaneDataWrapper clp_data = this->get_clipping_plane_data();
|
||||||
auto* shader = wxGetApp().get_shader("mm_gouraud_attr");
|
auto* shader = wxGetApp().get_shader("mm_gouraud");
|
||||||
if (!shader)
|
if (!shader)
|
||||||
return;
|
return;
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
|
@ -64,7 +64,7 @@ void GLGizmoFlatten::on_render()
|
||||||
{
|
{
|
||||||
const Selection& selection = m_parent.get_selection();
|
const Selection& selection = m_parent.get_selection();
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ void GLGizmoFlatten::on_render()
|
||||||
void GLGizmoFlatten::on_render_for_picking()
|
void GLGizmoFlatten::on_render_for_picking()
|
||||||
{
|
{
|
||||||
const Selection& selection = m_parent.get_selection();
|
const Selection& selection = m_parent.get_selection();
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ void GLGizmoHollow::on_render_for_picking()
|
||||||
|
|
||||||
void GLGizmoHollow::render_points(const Selection& selection, bool picking)
|
void GLGizmoHollow::render_points(const Selection& selection, bool picking)
|
||||||
{
|
{
|
||||||
GLShaderProgram* shader = picking ? wxGetApp().get_shader("flat_attr") : wxGetApp().get_shader("gouraud_light_attr");
|
GLShaderProgram* shader = picking ? wxGetApp().get_shader("flat") : wxGetApp().get_shader("gouraud_light");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ void GLGizmoMmuSegmentation::set_painter_gizmo_data(const Selection &selection)
|
||||||
void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const
|
void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const
|
||||||
{
|
{
|
||||||
ClippingPlaneDataWrapper clp_data = this->get_clipping_plane_data();
|
ClippingPlaneDataWrapper clp_data = this->get_clipping_plane_data();
|
||||||
auto* shader = wxGetApp().get_shader("mm_gouraud_attr");
|
auto* shader = wxGetApp().get_shader("mm_gouraud");
|
||||||
if (!shader)
|
if (!shader)
|
||||||
return;
|
return;
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
|
@ -162,7 +162,7 @@ void GLGizmoMove3D::on_render()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
@ -256,7 +256,7 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat_attr" : "gouraud_light_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat" : "gouraud_light");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ GLGizmoPainterBase::ClippingPlaneDataWrapper GLGizmoPainterBase::get_clipping_pl
|
||||||
|
|
||||||
void GLGizmoPainterBase::render_triangles(const Selection& selection) const
|
void GLGizmoPainterBase::render_triangles(const Selection& selection) const
|
||||||
{
|
{
|
||||||
auto* shader = wxGetApp().get_shader("gouraud_attr");
|
auto* shader = wxGetApp().get_shader("gouraud");
|
||||||
if (! shader)
|
if (! shader)
|
||||||
return;
|
return;
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
@ -219,7 +219,7 @@ void GLGizmoPainterBase::render_cursor_circle()
|
||||||
|
|
||||||
m_circle.set_color(render_color);
|
m_circle.set_color(render_color);
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||||
|
@ -240,7 +240,7 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
|
||||||
s_sphere->init_from(its_make_sphere(1.0, double(PI) / 12.0));
|
s_sphere->init_from(its_make_sphere(1.0, double(PI) / 12.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
|
||||||
// BBS
|
// BBS
|
||||||
void GLGizmoPainterBase::render_cursor_height_range(const Transform3d& trafo) const
|
void GLGizmoPainterBase::render_cursor_height_range(const Transform3d& trafo) const
|
||||||
{
|
{
|
||||||
GLShaderProgram *shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram *shader = wxGetApp().get_shader("flat");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1070,7 +1070,7 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui, const Transform3d& matrix)
|
||||||
auto* shader = wxGetApp().get_current_shader();
|
auto* shader = wxGetApp().get_current_shader();
|
||||||
if (! shader)
|
if (! shader)
|
||||||
return;
|
return;
|
||||||
assert(shader->get_name() == "gouraud_attr" || shader->get_name() == "mm_gouraud_attr");
|
assert(shader->get_name() == "gouraud" || shader->get_name() == "mm_gouraud");
|
||||||
ScopeGuard guard([shader]() { if (shader) shader->set_uniform("offset_depth_buffer", false);});
|
ScopeGuard guard([shader]() { if (shader) shader->set_uniform("offset_depth_buffer", false);});
|
||||||
shader->set_uniform("offset_depth_buffer", true);
|
shader->set_uniform("offset_depth_buffer", true);
|
||||||
for (auto iva : {std::make_pair(&m_iva_enforcers, enforcers_color),
|
for (auto iva : {std::make_pair(&m_iva_enforcers, enforcers_color),
|
||||||
|
@ -1178,7 +1178,7 @@ void TriangleSelectorPatch::render(ImGuiWrapper* imgui, const Transform3d& matri
|
||||||
auto* shader = wxGetApp().get_current_shader();
|
auto* shader = wxGetApp().get_current_shader();
|
||||||
if (!shader)
|
if (!shader)
|
||||||
return;
|
return;
|
||||||
assert(shader->get_name() == "gouraud_attr" || shader->get_name() == "mm_gouraud_attr");
|
assert(shader->get_name() == "gouraud" || shader->get_name() == "mm_gouraud");
|
||||||
|
|
||||||
for (size_t buffer_idx = 0; buffer_idx < m_triangle_patches.size(); ++buffer_idx) {
|
for (size_t buffer_idx = 0; buffer_idx < m_triangle_patches.size(); ++buffer_idx) {
|
||||||
if (this->has_VBOs(buffer_idx)) {
|
if (this->has_VBOs(buffer_idx)) {
|
||||||
|
@ -1604,7 +1604,7 @@ void TriangleSelectorGUI::render_debug(ImGuiWrapper* imgui)
|
||||||
if (curr_shader != nullptr)
|
if (curr_shader != nullptr)
|
||||||
curr_shader->stop_using();
|
curr_shader->stop_using();
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
|
@ -1661,7 +1661,7 @@ void TriangleSelectorGUI::render_paint_contour(const Transform3d& matrix)
|
||||||
if (curr_shader != nullptr)
|
if (curr_shader != nullptr)
|
||||||
curr_shader->stop_using();
|
curr_shader->stop_using();
|
||||||
|
|
||||||
auto* contour_shader = wxGetApp().get_shader("mm_contour_attr");
|
auto* contour_shader = wxGetApp().get_shader("mm_contour");
|
||||||
if (contour_shader != nullptr) {
|
if (contour_shader != nullptr) {
|
||||||
contour_shader->start_using();
|
contour_shader->start_using();
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ void GLGizmoRotate::on_render()
|
||||||
m_grabbers.front().matrix = local_transform(selection);
|
m_grabbers.front().matrix = local_transform(selection);
|
||||||
|
|
||||||
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
|
||||||
if (!picking && m_hover_id != -1)
|
if (!picking && m_hover_id != -1)
|
||||||
color = m_grabbers.front().hover_color;
|
color = m_grabbers.front().hover_color;
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat_attr" : "gouraud_light_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat" : "gouraud_light");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ void GLGizmoScale3D::on_render()
|
||||||
const float grabber_mean_size = (float)((selection_box.size().x() + selection_box.size().y() + selection_box.size().z()) / 3.0);
|
const float grabber_mean_size = (float)((selection_box.size().x() + selection_box.size().y() + selection_box.size().z()) / 3.0);
|
||||||
|
|
||||||
//draw connections
|
//draw connections
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
// BBS: when select multiple objects, uniform scale can be deselected, display the connection(4,5)
|
// BBS: when select multiple objects, uniform scale can be deselected, display the connection(4,5)
|
||||||
|
|
|
@ -98,7 +98,7 @@ bool GLGizmoSeam::on_key_down_select_tool_type(int keyCode) {
|
||||||
void GLGizmoSeam::render_triangles(const Selection& selection) const
|
void GLGizmoSeam::render_triangles(const Selection& selection) const
|
||||||
{
|
{
|
||||||
ClippingPlaneDataWrapper clp_data = this->get_clipping_plane_data();
|
ClippingPlaneDataWrapper clp_data = this->get_clipping_plane_data();
|
||||||
auto* shader = wxGetApp().get_shader("mm_gouraud_attr");
|
auto* shader = wxGetApp().get_shader("mm_gouraud");
|
||||||
if (!shader)
|
if (!shader)
|
||||||
return;
|
return;
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
|
@ -641,7 +641,7 @@ void GLGizmoSimplify::on_render()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Transform3d trafo_matrix = selected_volume->world_matrix();
|
const Transform3d trafo_matrix = selected_volume->world_matrix();
|
||||||
auto* gouraud_shader = wxGetApp().get_shader("gouraud_light_attr");
|
auto* gouraud_shader = wxGetApp().get_shader("gouraud_light");
|
||||||
glsafe(::glPushAttrib(GL_DEPTH_TEST));
|
glsafe(::glPushAttrib(GL_DEPTH_TEST));
|
||||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||||
gouraud_shader->start_using();
|
gouraud_shader->start_using();
|
||||||
|
@ -654,7 +654,7 @@ void GLGizmoSimplify::on_render()
|
||||||
gouraud_shader->stop_using();
|
gouraud_shader->stop_using();
|
||||||
|
|
||||||
if (m_show_wireframe) {
|
if (m_show_wireframe) {
|
||||||
auto* contour_shader = wxGetApp().get_shader("mm_contour_attr");
|
auto* contour_shader = wxGetApp().get_shader("mm_contour");
|
||||||
contour_shader->start_using();
|
contour_shader->start_using();
|
||||||
contour_shader->set_uniform("view_model_matrix", view_model_matrix);
|
contour_shader->set_uniform("view_model_matrix", view_model_matrix);
|
||||||
contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
|
|
@ -127,7 +127,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
||||||
if (! has_points && ! has_holes)
|
if (! has_points && ! has_holes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLShaderProgram* shader = picking ? wxGetApp().get_shader("flat_attr") : wxGetApp().get_shader("gouraud_light_attr");
|
GLShaderProgram* shader = picking ? wxGetApp().get_shader("flat") : wxGetApp().get_shader("gouraud_light");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -448,7 +448,7 @@ void GLGizmoText::on_render()
|
||||||
ColorRGBA color = picking_color_component(0);
|
ColorRGBA color = picking_color_component(0);
|
||||||
m_grabbers[0].color = color;
|
m_grabbers[0].color = color;
|
||||||
|
|
||||||
GLShaderProgram *shader = wxGetApp().get_shader("gouraud_light_attr");
|
GLShaderProgram *shader = wxGetApp().get_shader("gouraud_light");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
m_grabbers[0].render_for_picking(mean_size);
|
m_grabbers[0].render_for_picking(mean_size);
|
||||||
|
@ -500,7 +500,7 @@ void GLGizmoText::on_render_for_picking()
|
||||||
ColorRGBA color = picking_color_component(0);
|
ColorRGBA color = picking_color_component(0);
|
||||||
m_grabbers[0].color = color;
|
m_grabbers[0].color = color;
|
||||||
|
|
||||||
GLShaderProgram *shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram *shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
m_grabbers[0].render_for_picking(mean_size);
|
m_grabbers[0].render_for_picking(mean_size);
|
||||||
|
|
|
@ -2411,10 +2411,10 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
|
||||||
|
|
||||||
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
|
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
|
||||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
|
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
|
||||||
GLint last_texture; glsafe(::glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
GLint last_texture; glsafe(::glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
||||||
GLint last_polygon_mode[2]; glsafe(::glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode));
|
GLint last_polygon_mode[2]; glsafe(::glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode));
|
||||||
GLint last_viewport[4]; glsafe(::glGetIntegerv(GL_VIEWPORT, last_viewport));
|
GLint last_viewport[4]; glsafe(::glGetIntegerv(GL_VIEWPORT, last_viewport));
|
||||||
GLint last_scissor_box[4]; glsafe(::glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box));
|
GLint last_scissor_box[4]; glsafe(::glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box));
|
||||||
GLint last_texture_env_mode; glsafe(::glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &last_texture_env_mode));
|
GLint last_texture_env_mode; glsafe(::glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &last_texture_env_mode));
|
||||||
glsafe(::glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT));
|
glsafe(::glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT));
|
||||||
glsafe(::glEnable(GL_BLEND));
|
glsafe(::glEnable(GL_BLEND));
|
||||||
|
@ -2468,17 +2468,17 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
|
||||||
|
|
||||||
const int position_id = shader->get_attrib_location("Position");
|
const int position_id = shader->get_attrib_location("Position");
|
||||||
if (position_id != -1) {
|
if (position_id != -1) {
|
||||||
glsafe(::glVertexAttribPointer(position_id, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos)));
|
glsafe(::glVertexAttribPointer(position_id, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (const void*)IM_OFFSETOF(ImDrawVert, pos)));
|
||||||
glsafe(::glEnableVertexAttribArray(position_id));
|
glsafe(::glEnableVertexAttribArray(position_id));
|
||||||
}
|
}
|
||||||
const int uv_id = shader->get_attrib_location("UV");
|
const int uv_id = shader->get_attrib_location("UV");
|
||||||
if (uv_id != -1) {
|
if (uv_id != -1) {
|
||||||
glsafe(::glVertexAttribPointer(uv_id, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv)));
|
glsafe(::glVertexAttribPointer(uv_id, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (const void*)IM_OFFSETOF(ImDrawVert, uv)));
|
||||||
glsafe(::glEnableVertexAttribArray(uv_id));
|
glsafe(::glEnableVertexAttribArray(uv_id));
|
||||||
}
|
}
|
||||||
const int color_id = shader->get_attrib_location("Color");
|
const int color_id = shader->get_attrib_location("Color");
|
||||||
if (color_id != -1) {
|
if (color_id != -1) {
|
||||||
glsafe(::glVertexAttribPointer(color_id, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col)));
|
glsafe(::glVertexAttribPointer(color_id, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (const void*)IM_OFFSETOF(ImDrawVert, col)));
|
||||||
glsafe(::glEnableVertexAttribArray(color_id));
|
glsafe(::glEnableVertexAttribArray(color_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2521,10 +2521,13 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
|
||||||
glsafe(::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, last_texture_env_mode));
|
glsafe(::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, last_texture_env_mode));
|
||||||
glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture));
|
glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture));
|
||||||
glsafe(::glPopAttrib());
|
glsafe(::glPopAttrib());
|
||||||
glsafe(::glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]));
|
glsafe(::glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]);
|
||||||
|
glsafe(::glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1])));
|
||||||
glsafe(::glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]));
|
glsafe(::glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]));
|
||||||
glsafe(::glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]));
|
glsafe(::glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]));
|
||||||
|
|
||||||
|
shader->stop_using();
|
||||||
|
|
||||||
if (curr_shader != nullptr)
|
if (curr_shader != nullptr)
|
||||||
curr_shader->start_using();
|
curr_shader->start_using();
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ void MeshClipper::render_cut(const ColorRGBA& color)
|
||||||
if (curr_shader != nullptr)
|
if (curr_shader != nullptr)
|
||||||
curr_shader->stop_using();
|
curr_shader->stop_using();
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
|
|
@ -577,7 +577,7 @@ void PartPlate::render_logo_texture(GLTexture &logo_texture, GLModel& logo_buffe
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logo_buffer.is_initialized()) {
|
if (logo_buffer.is_initialized()) {
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("printbed_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("printbed");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||||
|
@ -849,7 +849,7 @@ void PartPlate::show_tooltip(const std::string tooltip)
|
||||||
|
|
||||||
void PartPlate::render_icons(bool bottom, bool only_name, int hover_id)
|
void PartPlate::render_icons(bool bottom, bool only_name, int hover_id)
|
||||||
{
|
{
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("printbed_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("printbed");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||||
|
@ -940,7 +940,7 @@ void PartPlate::render_icons(bool bottom, bool only_name, int hover_id)
|
||||||
|
|
||||||
void PartPlate::render_only_numbers(bool bottom)
|
void PartPlate::render_only_numbers(bool bottom)
|
||||||
{
|
{
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("printbed_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("printbed");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||||
|
@ -973,7 +973,7 @@ void PartPlate::render_only_numbers(bool bottom)
|
||||||
|
|
||||||
void PartPlate::render_rectangle_for_picking(const Transform3d &view_matrix, const Transform3d &projection_matrix, GLModel &buffer, const ColorRGBA render_color)
|
void PartPlate::render_rectangle_for_picking(const Transform3d &view_matrix, const Transform3d &projection_matrix, GLModel &buffer, const ColorRGBA render_color)
|
||||||
{
|
{
|
||||||
GLShaderProgram *shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram *shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
|
@ -2502,7 +2502,7 @@ void PartPlate::render(const Transform3d& view_matrix, const Transform3d& projec
|
||||||
{
|
{
|
||||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
GLShaderProgram *shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram *shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
glsafe(::glEnable(GL_BLEND));
|
glsafe(::glEnable(GL_BLEND));
|
||||||
|
|
|
@ -1570,7 +1570,7 @@ void Selection::render_center(bool gizmo_is_dragging)
|
||||||
if (!m_valid || is_empty())
|
if (!m_valid || is_empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1600,7 +1600,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field, bool unif
|
||||||
if (sidebar_field.empty())
|
if (sidebar_field.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader(boost::starts_with(sidebar_field, "layer") ? "flat_attr" : "gouraud_light_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader(boost::starts_with(sidebar_field, "layer") ? "flat" : "gouraud_light");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2231,7 +2231,7 @@ void Selection::render_bounding_box(const BoundingBoxf3& box, const ColorRGB& co
|
||||||
|
|
||||||
glsafe(::glLineWidth(2.0f * m_scale_factor));
|
glsafe(::glLineWidth(2.0f * m_scale_factor));
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader == nullptr)
|
if (shader == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -917,7 +917,7 @@ void CalibUtils::process_and_store_3mf(Model *model, const DynamicPrintConfig &f
|
||||||
ThumbnailData* thumbnail_data = &plate_data_list[0]->plate_thumbnail;
|
ThumbnailData* thumbnail_data = &plate_data_list[0]->plate_thumbnail;
|
||||||
unsigned int thumbnail_width = 512, thumbnail_height = 512;
|
unsigned int thumbnail_width = 512, thumbnail_height = 512;
|
||||||
const ThumbnailsParams thumbnail_params = {{}, false, true, true, true, 0};
|
const ThumbnailsParams thumbnail_params = {{}, false, true, true, true, 0};
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("thumbnail_attr");
|
GLShaderProgram* shader = wxGetApp().get_shader("thumbnail");
|
||||||
|
|
||||||
for (unsigned int obj_idx = 0; obj_idx < (unsigned int)model->objects.size(); ++ obj_idx) {
|
for (unsigned int obj_idx = 0; obj_idx < (unsigned int)model->objects.size(); ++ obj_idx) {
|
||||||
const ModelObject &model_object = *model->objects[obj_idx];
|
const ModelObject &model_object = *model->objects[obj_idx];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue