mirror of
https://github.com/QIDITECH/QIDIStudio.git
synced 2026-01-31 00:48:41 +03:00
update resources
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
#version 110
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = uniform_color;
|
||||
}
|
||||
}
|
||||
8
resources/shaders/110/background.vs
Normal file
8
resources/shaders/110/background.vs
Normal file
@@ -0,0 +1,8 @@
|
||||
#version 110
|
||||
|
||||
attribute vec3 v_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
||||
@@ -4,9 +4,15 @@ uniform mat4 view_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec2 v_undefine;
|
||||
attribute mat4 instanceMatrix;
|
||||
// per instance data
|
||||
// in mat4 instanceMatrix;
|
||||
attribute vec4 i_data0;
|
||||
attribute vec4 i_data1;
|
||||
attribute vec4 i_data2;
|
||||
attribute vec4 i_data3;
|
||||
// end per instance data
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection_matrix * view_matrix * instanceMatrix * vec4(v_position, 1.0);
|
||||
mat4 model_matrix = mat4(i_data0, i_data1, i_data2, i_data3);
|
||||
gl_Position = projection_matrix * view_matrix * 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 u_texture;
|
||||
|
||||
varying vec2 v_texcoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(u_texture, v_texcoord);
|
||||
}
|
||||
16
resources/shaders/110/flat_texture.vs
Normal file
16
resources/shaders/110/flat_texture.vs
Normal file
@@ -0,0 +1,16 @@
|
||||
#version 110
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec2 v_tex_coord;
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 u_uvTransformMatrix;
|
||||
|
||||
varying vec2 v_texcoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
v_texcoord = (u_uvTransformMatrix * vec3(v_tex_coord, 1.0)).xy;
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
78
resources/shaders/110/fxaa.fs
Normal file
78
resources/shaders/110/fxaa.fs
Normal file
@@ -0,0 +1,78 @@
|
||||
#version 110
|
||||
|
||||
uniform vec4 u_viewport_size;
|
||||
uniform sampler2D u_sampler;
|
||||
|
||||
varying vec2 tex_coords;
|
||||
|
||||
// thanks https://github.com/mattdesl/glsl-fxaa
|
||||
#ifndef FXAA_REDUCE_MIN
|
||||
#define FXAA_REDUCE_MIN (1.0/ 128.0)
|
||||
#endif
|
||||
#ifndef FXAA_REDUCE_MUL
|
||||
#define FXAA_REDUCE_MUL (1.0 / 8.0)
|
||||
#endif
|
||||
#ifndef FXAA_SPAN_MAX
|
||||
#define FXAA_SPAN_MAX 8.0
|
||||
#endif
|
||||
|
||||
vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inv_resolution,
|
||||
vec2 v_rgbNW, vec2 v_rgbNE,
|
||||
vec2 v_rgbSW, vec2 v_rgbSE,
|
||||
vec2 v_rgbM) {
|
||||
vec4 color;
|
||||
vec2 inverseVP = inv_resolution;
|
||||
vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;
|
||||
vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;
|
||||
vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;
|
||||
vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;
|
||||
vec4 texColor = texture2D(tex, v_rgbM);
|
||||
vec3 rgbM = texColor.xyz;
|
||||
vec3 luma = vec3(0.299, 0.587, 0.114);
|
||||
float lumaNW = dot(rgbNW, luma);
|
||||
float lumaNE = dot(rgbNE, luma);
|
||||
float lumaSW = dot(rgbSW, luma);
|
||||
float lumaSE = dot(rgbSE, luma);
|
||||
float lumaM = dot(rgbM, luma);
|
||||
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
||||
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
||||
|
||||
vec2 dir;
|
||||
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
||||
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
|
||||
|
||||
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
|
||||
(0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
|
||||
|
||||
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
|
||||
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
|
||||
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
|
||||
dir * rcpDirMin)) * inverseVP;
|
||||
|
||||
vec3 rgbA = 0.5 * (
|
||||
texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +
|
||||
texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);
|
||||
vec3 rgbB = rgbA * 0.5 + 0.25 * (
|
||||
texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +
|
||||
texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);
|
||||
|
||||
float lumaB = dot(rgbB, luma);
|
||||
if ((lumaB < lumaMin) || (lumaB > lumaMax))
|
||||
color = vec4(rgbA, texColor.a);
|
||||
else
|
||||
color = vec4(rgbB, texColor.a);
|
||||
return color;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 fragCoord = tex_coords * u_viewport_size.xy;
|
||||
vec2 add = u_viewport_size.zw;
|
||||
|
||||
vec2 rgbNW = tex_coords+vec2(-add.x, -add.y);
|
||||
vec2 rgbNE = tex_coords+vec2( add.x, -add.y);
|
||||
vec2 rgbSW = tex_coords+vec2(-add.x, add.y);
|
||||
vec2 rgbSE = tex_coords+vec2( add.x, add.y);
|
||||
vec2 rgbM = tex_coords;
|
||||
gl_FragColor = fxaa(u_sampler, fragCoord, u_viewport_size.zw, rgbNW, rgbNE, rgbSW, rgbSE, rgbM);
|
||||
}
|
||||
12
resources/shaders/110/fxaa.vs
Normal file
12
resources/shaders/110/fxaa.vs
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 110
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec2 v_tex_coord;
|
||||
|
||||
varying vec2 tex_coords;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coords = v_tex_coord;
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
||||
35
resources/shaders/110/gaussian_blur33.fs
Normal file
35
resources/shaders/110/gaussian_blur33.fs
Normal file
@@ -0,0 +1,35 @@
|
||||
#version 110
|
||||
uniform sampler2D u_sampler;
|
||||
uniform mat3 u_convolution_matrix;
|
||||
uniform vec2 u_viewport_size;
|
||||
|
||||
varying vec2 tex_coords;
|
||||
|
||||
vec4 sample(float offsetX, float offsetY)
|
||||
{
|
||||
return texture2D(u_sampler, vec2(tex_coords.x + offsetX, tex_coords.y + offsetY));
|
||||
}
|
||||
void main()
|
||||
{
|
||||
vec4 pixels[9];
|
||||
float deltaWidth = 1.0 / u_viewport_size.x;
|
||||
float deltaHeight = 1.0 / u_viewport_size.y;
|
||||
pixels[0] = sample(-deltaWidth, deltaHeight );
|
||||
pixels[1] = sample(0.0, deltaHeight );
|
||||
pixels[2] = sample(deltaWidth, deltaHeight );
|
||||
pixels[3] = sample(-deltaWidth, 0.0);
|
||||
pixels[4] = sample(0.0, 0.0);
|
||||
pixels[5] = sample(deltaWidth, 0.0);
|
||||
pixels[6] = sample(-deltaWidth, -deltaHeight);
|
||||
pixels[7] = sample(0.0, -deltaHeight);
|
||||
pixels[8] = sample(deltaWidth, -deltaHeight);
|
||||
vec4 accumulator = vec4(0.0);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
accumulator += pixels[3 * i + j] * u_convolution_matrix[i][j];
|
||||
}
|
||||
}
|
||||
gl_FragColor = accumulator;
|
||||
}
|
||||
12
resources/shaders/110/gaussian_blur33.vs
Normal file
12
resources/shaders/110/gaussian_blur33.vs
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 110
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec2 v_tex_coord;
|
||||
|
||||
varying vec2 tex_coords;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coords = v_tex_coord;
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ 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;
|
||||
const float ONE_OVER_EPSILON = 1e4;
|
||||
|
||||
struct PrintVolumeDetection
|
||||
{
|
||||
@@ -47,8 +48,7 @@ varying vec3 clipping_planes_dots;
|
||||
varying vec2 intensity;
|
||||
|
||||
uniform PrintVolumeDetection print_volume;
|
||||
|
||||
varying vec4 model_pos;
|
||||
uniform vec3 extruder_printable_heights;
|
||||
varying vec4 world_pos;
|
||||
varying float world_normal_z;
|
||||
varying vec3 eye_normal;
|
||||
@@ -73,22 +73,25 @@ void main()
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
vec3 pv_check_min = (world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, print_volume.z_data.x)) * ONE_OVER_EPSILON;
|
||||
vec3 pv_check_max = (world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, print_volume.z_data.y)) * ONE_OVER_EPSILON;
|
||||
bool is_out_print_limit =(any(lessThan(pv_check_min, vec3(1.0))) || any(greaterThan(pv_check_max, vec3(1.0))));
|
||||
if (print_volume.type == 0) {// rectangle
|
||||
color = is_out_print_limit ? 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;
|
||||
pv_check_min = vec3(delta_radius, 0.0, world_pos.z - print_volume.z_data.x) * ONE_OVER_EPSILON;
|
||||
pv_check_max = vec3(0.0, 0.0, world_pos.z - print_volume.z_data.y) * ONE_OVER_EPSILON;
|
||||
color = (any(lessThan(pv_check_min, vec3(1.0))) || any(greaterThan(pv_check_max, vec3(1.0)))) ? mix(color, ZERO, 0.3333) : color;
|
||||
}
|
||||
if(extruder_printable_heights.x >= 1.0 ){
|
||||
pv_check_min = (world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, extruder_printable_heights.y)) * ONE_OVER_EPSILON;
|
||||
pv_check_max = (world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, extruder_printable_heights.z)) * ONE_OVER_EPSILON;
|
||||
bool is_out_printable_height = (all(greaterThan(pv_check_min, vec3(1.0))) && all(lessThan(pv_check_max, vec3(1.0)))) ;
|
||||
color = is_out_printable_height ? mix(color, ZERO, 0.7) : color;
|
||||
}
|
||||
|
||||
//QDS: add outline_color
|
||||
if (is_outline)
|
||||
gl_FragColor = uniform_color;
|
||||
@@ -98,7 +101,7 @@ void main()
|
||||
#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.
|
||||
@@ -1,5 +1,4 @@
|
||||
#version 110
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
@@ -28,6 +27,13 @@ struct SlopeDetection
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec3 v_normal;
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 normal_matrix;
|
||||
|
||||
uniform mat4 volume_world_matrix;
|
||||
uniform SlopeDetection slope;
|
||||
|
||||
@@ -49,32 +55,31 @@ varying vec3 eye_normal;
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
eye_normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
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;
|
||||
vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
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;
|
||||
|
||||
if(is_text_shape){
|
||||
|
||||
if(!is_text_shape){
|
||||
NdotL = max(dot(eye_normal, LIGHT_BACK_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_BACK_DIFFUSE;
|
||||
}
|
||||
model_pos = gl_Vertex;
|
||||
// Point in homogenous coordinates.
|
||||
world_pos = volume_world_matrix * gl_Vertex;
|
||||
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 * gl_Normal)).z : 0.0;
|
||||
world_normal_z = slope.actived ? (normalize(slope.volume_world_normal_matrix * v_normal)).z : 0.0;
|
||||
|
||||
gl_Position = ftransform();
|
||||
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);
|
||||
}
|
||||
@@ -14,30 +14,32 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
uniform mat4 volume_world_matrix;
|
||||
attribute vec3 v_position;
|
||||
attribute vec3 v_normal;
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 normal_matrix;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
varying vec4 world_pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
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;
|
||||
vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
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 = ftransform();
|
||||
gl_Position = projection_matrix * position;
|
||||
}
|
||||
51
resources/shaders/110/hotbed.fs
Normal file
51
resources/shaders/110/hotbed.fs
Normal file
@@ -0,0 +1,51 @@
|
||||
#version 110
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
const vec3 WHITE = vec3(1.0, 1.0, 1.0);
|
||||
const float ONE_OVER_EPSILON = 1e4;
|
||||
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;
|
||||
};
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform float emission_factor;
|
||||
uniform PrintVolumeDetection print_volume;
|
||||
// x = diffuse, y = specular;
|
||||
varying vec2 intensity;
|
||||
varying vec4 world_pos;
|
||||
void main()
|
||||
{
|
||||
vec3 color = uniform_color.rgb;
|
||||
float alpha = uniform_color.a;
|
||||
// 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);
|
||||
|
||||
pv_check_min = pv_check_min * ONE_OVER_EPSILON;
|
||||
pv_check_max = pv_check_max * ONE_OVER_EPSILON;
|
||||
color = (any(lessThan(pv_check_min, vec3(1.0))) || any(greaterThan(pv_check_max, vec3(1.0)))) ? mix(color, WHITE, 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);
|
||||
|
||||
pv_check_min = pv_check_min * ONE_OVER_EPSILON;
|
||||
pv_check_max = pv_check_max * ONE_OVER_EPSILON;
|
||||
color = (any(lessThan(pv_check_min, vec3(1.0))) || any(greaterThan(pv_check_max, vec3(1.0)))) ? mix(color, WHITE, 0.3333) : color;
|
||||
}
|
||||
//gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
||||
gl_FragColor = vec4(vec3(intensity.y) + color * (intensity.x + emission_factor), alpha);
|
||||
}
|
||||
47
resources/shaders/110/hotbed.vs
Normal file
47
resources/shaders/110/hotbed.vs
Normal file
@@ -0,0 +1,47 @@
|
||||
#version 110
|
||||
|
||||
#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 view_normal_matrix;
|
||||
uniform mat4 volume_world_matrix;
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec3 v_normal;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
varying vec4 world_pos;
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 normal = normalize(view_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;
|
||||
world_pos = volume_world_matrix * vec4(v_position, 1.0);
|
||||
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;
|
||||
}
|
||||
11
resources/shaders/110/imgui.fs
Normal file
11
resources/shaders/110/imgui.fs
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 110
|
||||
|
||||
uniform sampler2D Texture;
|
||||
|
||||
varying vec2 Frag_UV;
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color * texture2D(Texture, Frag_UV.st);
|
||||
}
|
||||
17
resources/shaders/110/imgui.vs
Normal file
17
resources/shaders/110/imgui.vs
Normal file
@@ -0,0 +1,17 @@
|
||||
#version 110
|
||||
|
||||
uniform mat4 ProjMtx;
|
||||
|
||||
attribute vec2 Position;
|
||||
attribute vec2 UV;
|
||||
attribute vec4 Color;
|
||||
|
||||
varying vec2 Frag_UV;
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
Frag_UV = UV;
|
||||
color = Color;
|
||||
gl_Position = ProjMtx * vec4(Position.xy, 0.0, 1.0);
|
||||
}
|
||||
10
resources/shaders/110/mainframe_composite.fs
Normal file
10
resources/shaders/110/mainframe_composite.fs
Normal file
@@ -0,0 +1,10 @@
|
||||
#version 110
|
||||
|
||||
uniform sampler2D u_sampler;
|
||||
|
||||
varying vec2 tex_coords;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(u_sampler, tex_coords);
|
||||
}
|
||||
12
resources/shaders/110/mainframe_composite.vs
Normal file
12
resources/shaders/110/mainframe_composite.vs
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 110
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec2 v_tex_coord;
|
||||
|
||||
varying vec2 tex_coords;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coords = v_tex_coord;
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
||||
11
resources/shaders/110/mm_contour.vs
Normal file
11
resources/shaders/110/mm_contour.vs
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 110
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
attribute vec3 v_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
@@ -21,10 +21,13 @@ const float EPSILON = 0.0001;
|
||||
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 CHESS_WIDTH = 2.0;
|
||||
const vec3 COLOR_A = vec3(1.0, 1.0, 0.0);
|
||||
const vec3 COLOR_B = vec3(0.3, 0.3, 0.0);
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
varying vec3 clipping_planes_dots;
|
||||
varying vec4 model_pos;
|
||||
varying vec3 model_pos;
|
||||
varying vec4 world_pos;
|
||||
uniform bool volume_mirrored;
|
||||
|
||||
@@ -57,6 +60,8 @@ vec3 getWireframeColor(vec3 fill) {
|
||||
return (brightness > 0.75) ? vec3(0.11, 0.165, 0.208) : vec3(0.988, 0.988, 0.988);
|
||||
}
|
||||
uniform bool show_wireframe;
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat3 normal_matrix;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -73,20 +78,20 @@ void main()
|
||||
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.7 + LightRed * 0.3;
|
||||
alpha = 1.0;
|
||||
alpha = 1.0;
|
||||
if(abs(world_pos.z) < 0.1){
|
||||
color = LightBlue;
|
||||
}
|
||||
else if( transformed_normal.z < slope.normal_z - EPSILON){
|
||||
bool x_flag = mod(world_pos.x, CHESS_WIDTH) < (CHESS_WIDTH / 2.0);
|
||||
bool y_flag = mod(world_pos.y, CHESS_WIDTH) < (CHESS_WIDTH / 2.0);
|
||||
vec3 temp_color = (x_flag^^y_flag) ? COLOR_A : COLOR_B;
|
||||
color = mix(color,temp_color,0.2);
|
||||
}
|
||||
}
|
||||
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 eye_normal = normalize(gl_NormalMatrix * triangle_normal);
|
||||
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.
|
||||
@@ -95,7 +100,7 @@ void main()
|
||||
// x = diffuse, y = specular;
|
||||
vec2 intensity = vec2(0.0, 0.0);
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec3 position = (gl_ModelViewMatrix * model_pos).xyz;
|
||||
vec3 position = (view_model_matrix * vec4(model_pos, 1.0)).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).
|
||||
@@ -103,7 +108,7 @@ void main()
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
if (show_wireframe) {
|
||||
vec3 wireframeColor = show_wireframe ? getWireframeColor(color) : color;
|
||||
vec3 wireframeColor = getWireframeColor(color);
|
||||
vec3 triangleColor = wireframe(color, wireframeColor, 1.0);
|
||||
gl_FragColor = vec4(vec3(intensity.y) + triangleColor * intensity.x, alpha);
|
||||
}
|
||||
@@ -2,17 +2,19 @@
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
//attribute vec3 v_position;
|
||||
//attribute vec3 v_barycentric;
|
||||
|
||||
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;
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec3 v_color;
|
||||
|
||||
varying vec3 clipping_planes_dots;
|
||||
varying vec4 model_pos;
|
||||
varying vec3 model_pos;
|
||||
varying vec4 world_pos;
|
||||
varying vec3 barycentric_coordinates;
|
||||
|
||||
@@ -25,12 +27,12 @@ struct SlopeDetection
|
||||
uniform SlopeDetection slope;
|
||||
void main()
|
||||
{
|
||||
model_pos = gl_Vertex;
|
||||
model_pos = v_position;
|
||||
//model_pos = vec4(v_position, 1.0);
|
||||
// Point in homogenous coordinates.
|
||||
world_pos = volume_world_matrix * model_pos;
|
||||
world_pos = volume_world_matrix * vec4(model_pos, 1.0);
|
||||
|
||||
gl_Position = ftransform();
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
//gl_Position = gl_ModelViewProjectionMatrix * vec4(v_position, 1.0);
|
||||
// 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);
|
||||
@@ -38,5 +40,5 @@ void main()
|
||||
//compute the Barycentric Coordinates
|
||||
//int vertexMod3 = gl_VertexID % 3;
|
||||
//barycentric_coordinates = vec3(float(vertexMod3 == 0), float(vertexMod3 == 1), float(vertexMod3 == 2));
|
||||
barycentric_coordinates = gl_Color.xyz;//v_barycentric
|
||||
barycentric_coordinates = v_color.xyz;
|
||||
}
|
||||
@@ -3,32 +3,34 @@
|
||||
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 sampler2D u_sampler;
|
||||
uniform bool transparent_background;
|
||||
uniform bool svg_source;
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
vec4 svg_color()
|
||||
vec4 svg_color(vec2 uv)
|
||||
{
|
||||
// takes foreground from texture
|
||||
vec4 fore_color = texture2D(texture, tex_coord);
|
||||
// takes foreground from u_sampler
|
||||
vec4 fore_color = texture2D(u_sampler, uv);
|
||||
|
||||
// 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)))));
|
||||
vec3 back_color = vec3(mix(back_color_light, back_color_dark, smoothstep(0.0, 0.5, length(abs(uv) - 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()
|
||||
vec4 non_svg_color(vec2 uv)
|
||||
{
|
||||
// takes foreground from texture
|
||||
vec4 color = texture2D(texture, tex_coord);
|
||||
// takes foreground from u_sampler
|
||||
vec4 color = texture2D(u_sampler, uv);
|
||||
return vec4(color.rgb, transparent_background ? color.a * 0.25 : color.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = svg_source ? svg_color() : non_svg_color();
|
||||
// flip uv
|
||||
vec2 uv = vec2(tex_coord.x, 1.0 - tex_coord.y);
|
||||
gl_FragColor = svg_source ? svg_color(uv) : non_svg_color(uv);
|
||||
}
|
||||
6
resources/shaders/110/silhouette.fs
Normal file
6
resources/shaders/110/silhouette.fs
Normal file
@@ -0,0 +1,6 @@
|
||||
#version 110
|
||||
uniform vec3 u_base_color;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(u_base_color, 1.0);
|
||||
}
|
||||
11
resources/shaders/110/silhouette.vs
Normal file
11
resources/shaders/110/silhouette.vs
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 110
|
||||
|
||||
uniform mat4 u_model_matrix;
|
||||
uniform mat4 u_view_projection_matrix;
|
||||
|
||||
attribute vec3 v_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_view_projection_matrix * u_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
57
resources/shaders/110/silhouette_composite.fs
Normal file
57
resources/shaders/110/silhouette_composite.fs
Normal file
@@ -0,0 +1,57 @@
|
||||
#version 110
|
||||
uniform sampler2D u_sampler;
|
||||
uniform mat3 u_convolution_matrix;
|
||||
uniform vec3 u_viewport_size_alpha;
|
||||
uniform vec3 u_picking_color;
|
||||
varying vec2 tex_coords;
|
||||
|
||||
vec4 sample(float offsetX, float offsetY)
|
||||
{
|
||||
return texture2D(u_sampler, vec2(tex_coords.x + offsetX, tex_coords.y + offsetY));
|
||||
}
|
||||
|
||||
// see https://docs.gl/sl4/sign
|
||||
// glsl 110 & 120 may not support the sign func
|
||||
float sign_glsl_110(float value)
|
||||
{
|
||||
if (value > 1e-6) {
|
||||
return 1.0;
|
||||
}
|
||||
else if (value < -1e-6) {
|
||||
return -1.0;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pixels[9];
|
||||
float deltaWidth = 1.0 / u_viewport_size_alpha.x;
|
||||
float deltaHeight = 1.0 / u_viewport_size_alpha.y;
|
||||
float alpha = u_viewport_size_alpha.z;
|
||||
float effect_width = 2.0;
|
||||
deltaWidth = deltaWidth * effect_width;
|
||||
deltaHeight = deltaHeight * effect_width;
|
||||
pixels[0] = sample(-deltaWidth, deltaHeight );
|
||||
pixels[1] = sample(0.0, deltaHeight );
|
||||
pixels[2] = sample(deltaWidth, deltaHeight );
|
||||
pixels[3] = sample(-deltaWidth, 0.0);
|
||||
pixels[4] = sample(0.0, 0.0);
|
||||
pixels[5] = sample(deltaWidth, 0.0);
|
||||
pixels[6] = sample(-deltaWidth, -deltaHeight);
|
||||
pixels[7] = sample(0.0, -deltaHeight);
|
||||
pixels[8] = sample(deltaWidth, -deltaHeight);
|
||||
vec4 accumulator = vec4(0.0);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
accumulator += sign_glsl_110(pixels[3 * i + j].a) * vec4(u_picking_color, 1.0) * u_convolution_matrix[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
if ((abs(accumulator.a) - alpha * pixels[4].a) * 1e6 > 1.0) {
|
||||
accumulator = vec4(u_picking_color, abs(accumulator.a));
|
||||
}
|
||||
gl_FragColor = accumulator;
|
||||
}
|
||||
12
resources/shaders/110/silhouette_composite.vs
Normal file
12
resources/shaders/110/silhouette_composite.vs
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 110
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec2 v_tex_coord;
|
||||
|
||||
varying vec2 tex_coords;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coords = v_tex_coord;
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
||||
50
resources/shaders/110/thumbnail.vs
Normal file
50
resources/shaders/110/thumbnail.vs
Normal file
@@ -0,0 +1,50 @@
|
||||
#version 110
|
||||
|
||||
#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
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute 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;
|
||||
varying vec2 intensity;
|
||||
varying 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 * vec4(v_position, 1.0);
|
||||
|
||||
gl_Position = projection_matrix * position;
|
||||
}
|
||||
16
resources/shaders/110/toolpaths_lines.vs
Normal file
16
resources/shaders/110/toolpaths_lines.vs
Normal file
@@ -0,0 +1,16 @@
|
||||
#version 110
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec3 v_normal;
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 normal_matrix;
|
||||
|
||||
varying vec3 eye_normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
eye_normal = normal_matrix * v_normal;
|
||||
}
|
||||
@@ -14,6 +14,14 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
|
||||
#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 projection_matrix;
|
||||
uniform mat3 normal_matrix;
|
||||
|
||||
uniform mat4 volume_world_matrix;
|
||||
uniform float object_max_z;
|
||||
|
||||
@@ -25,28 +33,28 @@ varying float object_z;
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
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;
|
||||
vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
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.
|
||||
if (object_max_z > 0.0)
|
||||
// when rendering the overlay
|
||||
object_z = object_max_z * gl_MultiTexCoord0.y;
|
||||
object_z = object_max_z * v_tex_coord.y;
|
||||
else
|
||||
// when rendering the volumes
|
||||
object_z = (volume_world_matrix * gl_Vertex).z;
|
||||
|
||||
gl_Position = ftransform();
|
||||
object_z = (volume_world_matrix * vec4(v_position, 1.0)).z;
|
||||
|
||||
gl_Position = projection_matrix * position;
|
||||
}
|
||||
8
resources/shaders/140/background.fs
Normal file
8
resources/shaders/140/background.fs
Normal file
@@ -0,0 +1,8 @@
|
||||
#version 140
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
out vec4 frag_color;
|
||||
void main()
|
||||
{
|
||||
frag_color = uniform_color;
|
||||
}
|
||||
8
resources/shaders/140/background.vs
Normal file
8
resources/shaders/140/background.vs
Normal file
@@ -0,0 +1,8 @@
|
||||
#version 140
|
||||
|
||||
in vec3 v_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
||||
9
resources/shaders/140/flat.fs
Normal file
9
resources/shaders/140/flat.fs
Normal file
@@ -0,0 +1,9 @@
|
||||
#version 140
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
out vec4 frag_color;
|
||||
void main()
|
||||
{
|
||||
frag_color = 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);
|
||||
}
|
||||
19
resources/shaders/140/flat_instance.vs
Normal file
19
resources/shaders/140/flat_instance.vs
Normal file
@@ -0,0 +1,19 @@
|
||||
#version 140
|
||||
|
||||
uniform mat4 view_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
in vec3 v_position;
|
||||
|
||||
// per instance data
|
||||
// in mat4 instanceMatrix;
|
||||
in vec4 i_data0;
|
||||
in vec4 i_data1;
|
||||
in vec4 i_data2;
|
||||
in vec4 i_data3;
|
||||
// end per instance data
|
||||
void main()
|
||||
{
|
||||
mat4 model_matrix = mat4(i_data0, i_data1, i_data2, i_data3);
|
||||
gl_Position = projection_matrix * view_matrix * model_matrix* vec4(v_position, 1.0);
|
||||
}
|
||||
12
resources/shaders/140/flat_texture.fs
Normal file
12
resources/shaders/140/flat_texture.fs
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 140
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
in vec2 v_texcoord;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = texture(u_texture, v_texcoord);
|
||||
}
|
||||
16
resources/shaders/140/flat_texture.vs
Normal file
16
resources/shaders/140/flat_texture.vs
Normal file
@@ -0,0 +1,16 @@
|
||||
#version 140
|
||||
|
||||
in vec3 v_position;
|
||||
in vec2 v_tex_coord;
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 u_uvTransformMatrix;
|
||||
|
||||
out vec2 v_texcoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
v_texcoord = (u_uvTransformMatrix * vec3(v_tex_coord, 1.0)).xy;
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
79
resources/shaders/140/fxaa.fs
Normal file
79
resources/shaders/140/fxaa.fs
Normal file
@@ -0,0 +1,79 @@
|
||||
#version 140
|
||||
|
||||
uniform vec4 u_viewport_size;
|
||||
uniform sampler2D u_sampler;
|
||||
|
||||
in vec2 tex_coords;
|
||||
out vec4 frag_color;
|
||||
|
||||
// thanks https://github.com/mattdesl/glsl-fxaa
|
||||
#ifndef FXAA_REDUCE_MIN
|
||||
#define FXAA_REDUCE_MIN (1.0/ 128.0)
|
||||
#endif
|
||||
#ifndef FXAA_REDUCE_MUL
|
||||
#define FXAA_REDUCE_MUL (1.0 / 8.0)
|
||||
#endif
|
||||
#ifndef FXAA_SPAN_MAX
|
||||
#define FXAA_SPAN_MAX 8.0
|
||||
#endif
|
||||
|
||||
vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inv_resolution,
|
||||
vec2 v_rgbNW, vec2 v_rgbNE,
|
||||
vec2 v_rgbSW, vec2 v_rgbSE,
|
||||
vec2 v_rgbM) {
|
||||
vec4 color;
|
||||
vec2 inverseVP = inv_resolution;
|
||||
vec3 rgbNW = texture(tex, v_rgbNW).xyz;
|
||||
vec3 rgbNE = texture(tex, v_rgbNE).xyz;
|
||||
vec3 rgbSW = texture(tex, v_rgbSW).xyz;
|
||||
vec3 rgbSE = texture(tex, v_rgbSE).xyz;
|
||||
vec4 texColor = texture(tex, v_rgbM);
|
||||
vec3 rgbM = texColor.xyz;
|
||||
vec3 luma = vec3(0.299, 0.587, 0.114);
|
||||
float lumaNW = dot(rgbNW, luma);
|
||||
float lumaNE = dot(rgbNE, luma);
|
||||
float lumaSW = dot(rgbSW, luma);
|
||||
float lumaSE = dot(rgbSE, luma);
|
||||
float lumaM = dot(rgbM, luma);
|
||||
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
||||
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
||||
|
||||
vec2 dir;
|
||||
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
||||
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
|
||||
|
||||
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
|
||||
(0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
|
||||
|
||||
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
|
||||
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
|
||||
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
|
||||
dir * rcpDirMin)) * inverseVP;
|
||||
|
||||
vec3 rgbA = 0.5 * (
|
||||
texture(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +
|
||||
texture(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);
|
||||
vec3 rgbB = rgbA * 0.5 + 0.25 * (
|
||||
texture(tex, fragCoord * inverseVP + dir * -0.5).xyz +
|
||||
texture(tex, fragCoord * inverseVP + dir * 0.5).xyz);
|
||||
|
||||
float lumaB = dot(rgbB, luma);
|
||||
if ((lumaB < lumaMin) || (lumaB > lumaMax))
|
||||
color = vec4(rgbA, texColor.a);
|
||||
else
|
||||
color = vec4(rgbB, texColor.a);
|
||||
return color;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 fragCoord = tex_coords * u_viewport_size.xy;
|
||||
vec2 add = u_viewport_size.zw;
|
||||
|
||||
vec2 rgbNW = tex_coords+vec2(-add.x, -add.y);
|
||||
vec2 rgbNE = tex_coords+vec2( add.x, -add.y);
|
||||
vec2 rgbSW = tex_coords+vec2(-add.x, add.y);
|
||||
vec2 rgbSE = tex_coords+vec2( add.x, add.y);
|
||||
vec2 rgbM = tex_coords;
|
||||
frag_color = fxaa(u_sampler, fragCoord, add, rgbNW, rgbNE, rgbSW, rgbSE, rgbM);
|
||||
}
|
||||
12
resources/shaders/140/fxaa.vs
Normal file
12
resources/shaders/140/fxaa.vs
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 140
|
||||
|
||||
in vec3 v_position;
|
||||
in vec2 v_tex_coord;
|
||||
|
||||
out vec2 tex_coords;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coords = v_tex_coord;
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
||||
34
resources/shaders/140/gaussian_blur33.fs
Normal file
34
resources/shaders/140/gaussian_blur33.fs
Normal file
@@ -0,0 +1,34 @@
|
||||
#version 140
|
||||
uniform sampler2D u_sampler;
|
||||
uniform mat3 u_convolution_matrix;
|
||||
uniform vec2 u_viewport_size;
|
||||
|
||||
in vec2 tex_coords;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
vec4 sample(float offsetX, float offsetY)
|
||||
{
|
||||
return texture(u_sampler, vec2(tex_coords.x + offsetX, tex_coords.y + offsetY));
|
||||
}
|
||||
void main()
|
||||
{
|
||||
vec4 pixels[9];
|
||||
float deltaWidth = 1.0 / u_viewport_size.x;
|
||||
float deltaHeight = 1.0 / u_viewport_size.y;
|
||||
pixels[0] = sample(-deltaWidth, deltaHeight );
|
||||
pixels[1] = sample(0.0, deltaHeight );
|
||||
pixels[2] = sample(deltaWidth, deltaHeight );
|
||||
pixels[3] = sample(-deltaWidth, 0.0);
|
||||
pixels[4] = sample(0.0, 0.0);
|
||||
pixels[5] = sample(deltaWidth, 0.0);
|
||||
pixels[6] = sample(-deltaWidth, -deltaHeight);
|
||||
pixels[7] = sample(0.0, -deltaHeight);
|
||||
pixels[8] = sample(deltaWidth, -deltaHeight);
|
||||
vec4 accumulator = vec4(0.0);
|
||||
for (int i = 0; i < 9; ++i)
|
||||
{
|
||||
accumulator += pixels[i] * u_convolution_matrix[i / 3][i % 3];
|
||||
}
|
||||
frag_color = accumulator;
|
||||
}
|
||||
12
resources/shaders/140/gaussian_blur33.vs
Normal file
12
resources/shaders/140/gaussian_blur33.vs
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 140
|
||||
|
||||
in vec3 v_position;
|
||||
in vec2 v_tex_coord;
|
||||
|
||||
out vec2 tex_coords;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coords = v_tex_coord;
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
||||
111
resources/shaders/140/gouraud.fs
Normal file
111
resources/shaders/140/gouraud.fs
Normal file
@@ -0,0 +1,111 @@
|
||||
#version 140
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
//QDS: 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;
|
||||
const float ONE_OVER_EPSILON = 1e4;
|
||||
|
||||
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;
|
||||
|
||||
//QDS: 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
|
||||
|
||||
in vec3 clipping_planes_dots;
|
||||
|
||||
// x = diffuse, y = specular;
|
||||
in vec2 intensity;
|
||||
|
||||
uniform PrintVolumeDetection print_volume;
|
||||
uniform vec3 extruder_printable_heights;
|
||||
in vec4 world_pos;
|
||||
in float world_normal_z;
|
||||
in vec3 eye_normal;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
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 = (world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, print_volume.z_data.x)) * ONE_OVER_EPSILON;
|
||||
vec3 pv_check_max = (world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, print_volume.z_data.y)) * ONE_OVER_EPSILON;
|
||||
bool is_out_print_limit =(any(lessThan(pv_check_min, vec3(1.0))) || any(greaterThan(pv_check_max, vec3(1.0))));
|
||||
if (print_volume.type == 0) {// rectangle
|
||||
color = is_out_print_limit ? 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) * ONE_OVER_EPSILON;
|
||||
pv_check_max = vec3(0.0, 0.0, world_pos.z - print_volume.z_data.y) * ONE_OVER_EPSILON;
|
||||
color = (any(lessThan(pv_check_min, vec3(1.0))) || any(greaterThan(pv_check_max, vec3(1.0)))) ? mix(color, ZERO, 0.3333) : color;
|
||||
}
|
||||
if(extruder_printable_heights.x >= 1.0 ){
|
||||
pv_check_min = (world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, extruder_printable_heights.y)) * ONE_OVER_EPSILON;
|
||||
pv_check_max = (world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, extruder_printable_heights.z)) * ONE_OVER_EPSILON;
|
||||
bool is_out_printable_height = (all(greaterThan(pv_check_min, vec3(1.0))) && all(lessThan(pv_check_max, vec3(1.0)))) ;
|
||||
color = is_out_printable_height ? mix(color, ZERO, 0.7) : color;
|
||||
}
|
||||
//QDS: add outline_color
|
||||
if (is_outline)
|
||||
frag_color = uniform_color;
|
||||
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||
else if (use_environment_tex)
|
||||
frag_color = vec4(0.45 * texture(environment_tex, normalize(eye_normal).xy * 0.5 + 0.5).xyz + 0.8 * color * intensity.x, alpha);
|
||||
#endif
|
||||
else
|
||||
frag_color = 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);
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
#version 130
|
||||
|
||||
#version 140
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
@@ -14,6 +13,9 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION)
|
||||
//#define LIGHT_FRONT_SHININESS 5.0
|
||||
|
||||
const vec3 LIGHT_BACK_DIR = vec3(0.1397015, 0.6985074,0.6985074);
|
||||
#define LIGHT_BACK_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
@@ -25,6 +27,13 @@ struct SlopeDetection
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
|
||||
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;
|
||||
uniform SlopeDetection slope;
|
||||
|
||||
@@ -32,48 +41,45 @@ uniform SlopeDetection slope;
|
||||
uniform vec2 z_range;
|
||||
// Clipping plane - general orientation. Used by the SLA gizmo.
|
||||
uniform vec4 clipping_plane;
|
||||
|
||||
uniform bool is_text_shape;
|
||||
// x = diffuse, y = specular;
|
||||
varying vec2 intensity;
|
||||
out vec2 intensity;
|
||||
|
||||
varying vec3 clipping_planes_dots;
|
||||
out vec3 clipping_planes_dots;
|
||||
|
||||
varying vec4 model_pos;
|
||||
varying vec4 world_pos;
|
||||
varying float world_normal_z;
|
||||
varying vec3 eye_normal;
|
||||
|
||||
varying vec3 barycentric_coordinates;
|
||||
out vec4 model_pos;
|
||||
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(gl_NormalMatrix * gl_Normal);
|
||||
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;
|
||||
vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
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;
|
||||
|
||||
model_pos = gl_Vertex;
|
||||
if(!is_text_shape){
|
||||
NdotL = max(dot(eye_normal, LIGHT_BACK_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_BACK_DIFFUSE;
|
||||
}
|
||||
// Point in homogenous coordinates.
|
||||
world_pos = volume_world_matrix * gl_Vertex;
|
||||
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 * gl_Normal)).z : 0.0;
|
||||
world_normal_z = slope.actived ? (normalize(slope.volume_world_normal_matrix * v_normal)).z : 0.0;
|
||||
|
||||
gl_Position = ftransform();
|
||||
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);
|
||||
|
||||
//compute the Barycentric Coordinates
|
||||
int vertexMod3 = gl_VertexID % 3;
|
||||
barycentric_coordinates = vec3(float(vertexMod3 == 0), float(vertexMod3 == 1), float(vertexMod3 == 2));
|
||||
}
|
||||
14
resources/shaders/140/gouraud_light.fs
Normal file
14
resources/shaders/140/gouraud_light.fs
Normal file
@@ -0,0 +1,14 @@
|
||||
#version 140
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform float emission_factor;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
in vec2 intensity;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#version 110
|
||||
#version 140
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
@@ -14,25 +14,32 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
|
||||
#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;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
out vec2 intensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
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;
|
||||
vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
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 = ftransform();
|
||||
gl_Position = projection_matrix * position;
|
||||
}
|
||||
67
resources/shaders/140/gouraud_light_instanced.vs
Normal file
67
resources/shaders/140/gouraud_light_instanced.vs
Normal file
@@ -0,0 +1,67 @@
|
||||
#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
|
||||
|
||||
// vertex attributes
|
||||
in vec3 v_position;
|
||||
in vec3 v_normal;
|
||||
// instance attributes
|
||||
in vec3 i_offset;
|
||||
in vec2 i_scales;
|
||||
|
||||
in mat4 instanceMatrix;
|
||||
uniform mat4 view_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
out vec2 intensity;
|
||||
|
||||
mat3 inverse_mat3(mat3 m) {
|
||||
float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];
|
||||
float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
|
||||
float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
|
||||
|
||||
float b01 = a22 * a11 - a12 * a21;
|
||||
float b11 = -a22 * a10 + a12 * a20;
|
||||
float b21 = a21 * a10 - a11 * a20;
|
||||
|
||||
float det = a00 * b01 + a01 * b11 + a02 * b21;
|
||||
|
||||
return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),
|
||||
b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),
|
||||
b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 view_model_matrix = view_matrix * instanceMatrix;
|
||||
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 normal = normalize(transpose(inverse_mat3(mat3(view_model_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;
|
||||
}
|
||||
52
resources/shaders/140/hotbed.fs
Normal file
52
resources/shaders/140/hotbed.fs
Normal file
@@ -0,0 +1,52 @@
|
||||
#version 140
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
const vec3 WHITE = vec3(1.0, 1.0, 1.0);
|
||||
const float ONE_OVER_EPSILON = 1e4;
|
||||
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;
|
||||
};
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform float emission_factor;
|
||||
uniform PrintVolumeDetection print_volume;
|
||||
// x = diffuse, y = specular;
|
||||
in vec2 intensity;
|
||||
in vec4 world_pos;
|
||||
|
||||
out vec4 frag_color;
|
||||
void main()
|
||||
{
|
||||
vec3 color = uniform_color.rgb;
|
||||
float alpha = uniform_color.a;
|
||||
// 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);
|
||||
|
||||
pv_check_min = pv_check_min * ONE_OVER_EPSILON;
|
||||
pv_check_max = pv_check_max * ONE_OVER_EPSILON;
|
||||
color = (any(lessThan(pv_check_min, vec3(1.0))) || any(greaterThan(pv_check_max, vec3(1.0)))) ? mix(color, WHITE, 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);
|
||||
|
||||
pv_check_min = pv_check_min * ONE_OVER_EPSILON;
|
||||
pv_check_max = pv_check_max * ONE_OVER_EPSILON;
|
||||
color = (any(lessThan(pv_check_min, vec3(1.0))) || any(greaterThan(pv_check_max, vec3(1.0)))) ? mix(color, WHITE, 0.3333) : color;
|
||||
}
|
||||
frag_color = vec4(vec3(intensity.y) + color * (intensity.x + emission_factor), alpha);
|
||||
}
|
||||
47
resources/shaders/140/hotbed.vs
Normal file
47
resources/shaders/140/hotbed.vs
Normal file
@@ -0,0 +1,47 @@
|
||||
#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 view_normal_matrix;
|
||||
uniform mat4 volume_world_matrix;
|
||||
|
||||
in vec3 v_position;
|
||||
in vec3 v_normal;
|
||||
|
||||
// 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(view_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;
|
||||
world_pos = volume_world_matrix * vec4(v_position, 1.0);
|
||||
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/imgui.fs
Normal file
12
resources/shaders/140/imgui.fs
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 140
|
||||
|
||||
uniform sampler2D Texture;
|
||||
|
||||
in vec2 Frag_UV;
|
||||
in vec4 color;
|
||||
|
||||
out vec4 frag_color;
|
||||
void main()
|
||||
{
|
||||
frag_color = 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 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
Frag_UV = UV;
|
||||
color = Color;
|
||||
gl_Position = ProjMtx * vec4(Position.xy, 0.0, 1.0);
|
||||
}
|
||||
12
resources/shaders/140/mainframe_composite.fs
Normal file
12
resources/shaders/140/mainframe_composite.fs
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 140
|
||||
|
||||
uniform sampler2D u_sampler;
|
||||
|
||||
in vec2 tex_coords;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = texture(u_sampler, tex_coords);
|
||||
}
|
||||
12
resources/shaders/140/mainframe_composite.vs
Normal file
12
resources/shaders/140/mainframe_composite.vs
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 140
|
||||
|
||||
in vec3 v_position;
|
||||
in vec2 v_tex_coord;
|
||||
|
||||
out vec2 tex_coords;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coords = v_tex_coord;
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
||||
12
resources/shaders/140/mm_contour.fs
Normal file
12
resources/shaders/140/mm_contour.fs
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 140
|
||||
|
||||
const float EPSILON = 0.0001;
|
||||
|
||||
out vec4 frag_color;
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
// 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);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#version 110
|
||||
#version 140
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
@@ -21,11 +21,14 @@ const float EPSILON = 0.0001;
|
||||
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 CHESS_WIDTH = 2.0;
|
||||
const vec3 COLOR_A = vec3(1.0, 1.0, 0.0);
|
||||
const vec3 COLOR_B = vec3(0.3, 0.3, 0.0);
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
varying vec3 clipping_planes_dots;
|
||||
varying vec4 model_pos;
|
||||
varying vec4 world_pos;
|
||||
in vec3 clipping_planes_dots;
|
||||
in vec3 model_pos;
|
||||
in vec4 world_pos;
|
||||
uniform bool volume_mirrored;
|
||||
|
||||
struct SlopeDetection
|
||||
@@ -36,6 +39,32 @@ struct SlopeDetection
|
||||
};
|
||||
uniform SlopeDetection slope;
|
||||
|
||||
//QDS: add wireframe logic
|
||||
in vec3 barycentric_coordinates;
|
||||
float edgeFactor(float lineWidth) {
|
||||
vec3 d = fwidth(barycentric_coordinates);
|
||||
vec3 a3 = smoothstep(vec3(0.0), d * lineWidth, barycentric_coordinates);
|
||||
return min(min(a3.x, a3.y), a3.z);
|
||||
}
|
||||
|
||||
vec3 wireframe(vec3 fill, vec3 stroke, float lineWidth) {
|
||||
return mix(stroke, fill, edgeFactor(lineWidth));
|
||||
//if (any(lessThan(barycentric_coordinates, vec3(0.005, 0.005, 0.005))))
|
||||
// return vec3(1.0, 0.0, 0.0);
|
||||
//else
|
||||
// return fill;
|
||||
}
|
||||
|
||||
vec3 getWireframeColor(vec3 fill) {
|
||||
float brightness = 0.2126 * fill.r + 0.7152 * fill.g + 0.0722 * fill.b;
|
||||
return (brightness > 0.75) ? vec3(0.11, 0.165, 0.208) : vec3(0.988, 0.988, 0.988);
|
||||
}
|
||||
uniform bool show_wireframe;
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat3 normal_matrix;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (any(lessThan(clipping_planes_dots, ZERO)))
|
||||
@@ -49,21 +78,22 @@ void main()
|
||||
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.7 + LightRed * 0.3;
|
||||
alpha = 1.0;
|
||||
alpha = 1.0;
|
||||
if(abs(world_pos.z) < 0.1){
|
||||
color = LightBlue;
|
||||
}
|
||||
else if( transformed_normal.z < slope.normal_z - EPSILON){
|
||||
bool x_flag = mod(world_pos.x, CHESS_WIDTH) < (CHESS_WIDTH / 2.0);
|
||||
bool y_flag = mod(world_pos.y, CHESS_WIDTH) < (CHESS_WIDTH / 2.0);
|
||||
vec3 temp_color = (x_flag^^y_flag) ? COLOR_A : COLOR_B;
|
||||
color = mix(color,temp_color,0.2);
|
||||
}
|
||||
}
|
||||
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 eye_normal = normalize(gl_NormalMatrix * triangle_normal);
|
||||
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.
|
||||
@@ -72,12 +102,19 @@ void main()
|
||||
// x = diffuse, y = specular;
|
||||
vec2 intensity = vec2(0.0, 0.0);
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec3 position = (gl_ModelViewMatrix * model_pos).xyz;
|
||||
vec3 position = (view_model_matrix * vec4(model_pos, 1.0)).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);
|
||||
if (show_wireframe) {
|
||||
vec3 wireframeColor = getWireframeColor(color);
|
||||
vec3 triangleColor = wireframe(color, wireframeColor, 1.0);
|
||||
frag_color = vec4(vec3(intensity.y) + triangleColor * intensity.x, alpha);
|
||||
}
|
||||
else {
|
||||
frag_color = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
||||
}
|
||||
}
|
||||
47
resources/shaders/140/mm_gouraud_wireframe.vs
Normal file
47
resources/shaders/140/mm_gouraud_wireframe.vs
Normal file
@@ -0,0 +1,47 @@
|
||||
#version 140
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
//attribute vec3 v_position;
|
||||
//attribute vec3 v_barycentric;
|
||||
|
||||
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;
|
||||
in vec3 v_color;
|
||||
|
||||
out vec3 clipping_planes_dots;
|
||||
out vec3 model_pos;
|
||||
out vec4 world_pos;
|
||||
out vec3 barycentric_coordinates;
|
||||
|
||||
struct SlopeDetection
|
||||
{
|
||||
bool actived;
|
||||
float normal_z;
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
uniform SlopeDetection slope;
|
||||
void main()
|
||||
{
|
||||
model_pos = v_position;
|
||||
//model_pos = vec4(v_position, 1.0);
|
||||
// Point in homogenous coordinates.
|
||||
world_pos = volume_world_matrix * vec4(model_pos, 1.0);
|
||||
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
//gl_Position = gl_ModelViewProjectionMatrix * vec4(v_position, 1.0);
|
||||
// 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);
|
||||
|
||||
//compute the Barycentric Coordinates
|
||||
//int vertexMod3 = gl_VertexID % 3;
|
||||
//barycentric_coordinates = vec3(float(vertexMod3 == 0), float(vertexMod3 == 1), float(vertexMod3 == 2));
|
||||
barycentric_coordinates = v_color.xyz;//v_barycentric
|
||||
}
|
||||
29
resources/shaders/140/printbed.fs
Normal file
29
resources/shaders/140/printbed.fs
Normal file
@@ -0,0 +1,29 @@
|
||||
#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 u_sampler;
|
||||
uniform bool transparent_background;
|
||||
uniform bool svg_source;
|
||||
in vec2 tex_coord;
|
||||
out vec4 frag_color;
|
||||
vec4 svg_color(vec2 uv)
|
||||
{
|
||||
// takes foreground from u_sampler
|
||||
vec4 fore_color = texture(u_sampler, uv);
|
||||
// calculates radial gradient
|
||||
vec3 back_color = vec3(mix(back_color_light, back_color_dark, smoothstep(0.0, 0.5, length(abs(uv) - 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(vec2 uv)
|
||||
{
|
||||
// takes foreground from u_sampler
|
||||
vec4 color = texture(u_sampler, uv);
|
||||
return vec4(color.rgb, transparent_background ? color.a * 0.25 : color.a);
|
||||
}
|
||||
void main()
|
||||
{
|
||||
// flip uv
|
||||
vec2 uv = vec2(tex_coord.x, 1.0 - tex_coord.y);
|
||||
frag_color = svg_source ? svg_color(uv) : non_svg_color(uv);
|
||||
}
|
||||
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);
|
||||
}
|
||||
8
resources/shaders/140/silhouette.fs
Normal file
8
resources/shaders/140/silhouette.fs
Normal file
@@ -0,0 +1,8 @@
|
||||
#version 140
|
||||
uniform vec3 u_base_color;
|
||||
|
||||
out vec4 frag_color;
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4(u_base_color, 1.0);
|
||||
}
|
||||
11
resources/shaders/140/silhouette.vs
Normal file
11
resources/shaders/140/silhouette.vs
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 140
|
||||
|
||||
uniform mat4 u_model_matrix;
|
||||
uniform mat4 u_view_projection_matrix;
|
||||
|
||||
in vec3 v_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_view_projection_matrix * u_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
46
resources/shaders/140/silhouette_composite.fs
Normal file
46
resources/shaders/140/silhouette_composite.fs
Normal file
@@ -0,0 +1,46 @@
|
||||
#version 140
|
||||
uniform sampler2D u_sampler;
|
||||
uniform mat3 u_convolution_matrix;
|
||||
uniform vec3 u_viewport_size_alpha;
|
||||
uniform vec3 u_picking_color;
|
||||
in vec2 tex_coords;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
vec4 sample(float offsetX, float offsetY)
|
||||
{
|
||||
return texture(u_sampler, vec2(tex_coords.x + offsetX, tex_coords.y + offsetY));
|
||||
}
|
||||
void main()
|
||||
{
|
||||
vec4 pixels[9];
|
||||
float deltaWidth = 1.0 / u_viewport_size_alpha.x;
|
||||
float deltaHeight = 1.0 / u_viewport_size_alpha.y;
|
||||
float alpha = u_viewport_size_alpha.z;
|
||||
float effect_width = 2.0;
|
||||
deltaWidth = deltaWidth * effect_width;
|
||||
deltaHeight = deltaHeight * effect_width;
|
||||
|
||||
pixels[0] = sample(-deltaWidth, deltaHeight );
|
||||
pixels[1] = sample(0.0, deltaHeight );
|
||||
pixels[2] = sample(deltaWidth, deltaHeight );
|
||||
pixels[3] = sample(-deltaWidth, 0.0);
|
||||
pixels[4] = sample(0.0, 0.0);
|
||||
pixels[5] = sample(deltaWidth, 0.0);
|
||||
pixels[6] = sample(-deltaWidth, -deltaHeight);
|
||||
pixels[7] = sample(0.0, -deltaHeight);
|
||||
pixels[8] = sample(deltaWidth, -deltaHeight);
|
||||
vec4 accumulator = vec4(0.0);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
accumulator += sign(pixels[3 * i + j].a) * vec4(u_picking_color, 1.0) * u_convolution_matrix[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
if ((abs(accumulator.a) - alpha * pixels[4].a) * 1e6 > 1.0) {
|
||||
accumulator = vec4(u_picking_color, abs(accumulator.a));
|
||||
}
|
||||
frag_color = accumulator;
|
||||
}
|
||||
12
resources/shaders/140/silhouette_composite.vs
Normal file
12
resources/shaders/140/silhouette_composite.vs
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 140
|
||||
|
||||
in vec3 v_position;
|
||||
in vec2 v_tex_coord;
|
||||
|
||||
out vec2 tex_coords;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coords = v_tex_coord;
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
||||
23
resources/shaders/140/thumbnail.fs
Normal file
23
resources/shaders/140/thumbnail.fs
Normal file
@@ -0,0 +1,23 @@
|
||||
#version 140
|
||||
|
||||
uniform bool ban_light;
|
||||
uniform vec4 uniform_color;
|
||||
uniform float emission_factor;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
in vec2 intensity;
|
||||
//varying float drop;
|
||||
in vec4 world_pos;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (world_pos.z < 0.0)
|
||||
discard;
|
||||
if(ban_light){
|
||||
frag_color = uniform_color;
|
||||
} else{
|
||||
frag_color = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||
}
|
||||
}
|
||||
50
resources/shaders/140/thumbnail.vs
Normal file
50
resources/shaders/140/thumbnail.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
|
||||
|
||||
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 * vec4(v_position, 1.0);
|
||||
|
||||
gl_Position = projection_matrix * position;
|
||||
}
|
||||
30
resources/shaders/140/toolpaths_lines.fs
Normal file
30
resources/shaders/140/toolpaths_lines.fs
Normal file
@@ -0,0 +1,30 @@
|
||||
#version 140
|
||||
|
||||
// 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);
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
// x = ambient, y = top diffuse, z = front diffuse, w = global
|
||||
uniform vec4 light_intensity;
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
in vec3 eye_normal;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 normal = normalize(eye_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. Take the abs value to light the lines no matter in which direction the normal points.
|
||||
float NdotL = abs(dot(normal, LIGHT_TOP_DIR));
|
||||
|
||||
float intensity = light_intensity.x + NdotL * light_intensity.y;
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source.
|
||||
NdotL = abs(dot(normal, LIGHT_FRONT_DIR));
|
||||
intensity += NdotL * light_intensity.z;
|
||||
|
||||
frag_color = vec4(uniform_color.rgb * light_intensity.w * intensity, uniform_color.a);
|
||||
}
|
||||
16
resources/shaders/140/toolpaths_lines.vs
Normal file
16
resources/shaders/140/toolpaths_lines.vs
Normal file
@@ -0,0 +1,16 @@
|
||||
#version 140
|
||||
|
||||
in vec3 v_position;
|
||||
in vec3 v_normal;
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 normal_matrix;
|
||||
|
||||
out vec3 eye_normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
eye_normal = normal_matrix * v_normal;
|
||||
}
|
||||
43
resources/shaders/140/variable_layer_height.fs
Normal file
43
resources/shaders/140/variable_layer_height.fs
Normal file
@@ -0,0 +1,43 @@
|
||||
#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;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
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.
|
||||
frag_color = 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
|
||||
|
||||
in vec3 v_position;
|
||||
in vec3 v_normal;
|
||||
in vec2 v_tex_coord;
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 normal_matrix;
|
||||
|
||||
uniform mat4 volume_world_matrix;
|
||||
uniform float object_max_z;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
out vec2 intensity;
|
||||
|
||||
out float object_z;
|
||||
|
||||
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)
|
||||
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
|
||||
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
// Scaled to widths of the Z texture.
|
||||
if (object_max_z > 0.0)
|
||||
// when rendering the overlay
|
||||
object_z = object_max_z * v_tex_coord.y;
|
||||
else
|
||||
// when rendering the volumes
|
||||
object_z = (volume_world_matrix * vec4(v_position, 1.0)).z;
|
||||
|
||||
gl_Position = projection_matrix * position;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
#version 110
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
#version 130
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
//QDS: 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 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;
|
||||
};
|
||||
|
||||
//QDS: add wireframe logic
|
||||
varying vec3 barycentric_coordinates;
|
||||
float edgeFactor(float lineWidth) {
|
||||
vec3 d = fwidth(barycentric_coordinates);
|
||||
vec3 a3 = smoothstep(vec3(0.0), d * lineWidth, barycentric_coordinates);
|
||||
return min(min(a3.x, a3.y), a3.z);
|
||||
}
|
||||
|
||||
vec3 wireframe(vec3 fill, vec3 stroke, float lineWidth) {
|
||||
return mix(stroke, fill, edgeFactor(lineWidth));
|
||||
}
|
||||
|
||||
vec3 getWireframeColor(vec3 fill) {
|
||||
float brightness = 0.2126 * fill.r + 0.7152 * fill.g + 0.0722 * fill.b;
|
||||
return (brightness > 0.75) ? vec3(0.11, 0.165, 0.208) : vec3(0.988, 0.988, 0.988);
|
||||
}
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform SlopeDetection slope;
|
||||
|
||||
//QDS: add outline_color
|
||||
uniform bool is_outline;
|
||||
uniform bool show_wireframe;
|
||||
|
||||
uniform bool offset_depth_buffer;
|
||||
|
||||
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||
uniform sampler2D environment_tex;
|
||||
uniform bool use_environment_tex;
|
||||
#endif // ENABLE_ENVIRONMENT_MAP
|
||||
|
||||
varying vec3 clipping_planes_dots;
|
||||
|
||||
// x = diffuse, y = specular;
|
||||
varying vec2 intensity;
|
||||
|
||||
uniform PrintVolumeDetection print_volume;
|
||||
|
||||
varying vec4 model_pos;
|
||||
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 && world_normal_z < slope.normal_z - EPSILON) {
|
||||
//color = vec3(0.7, 0.7, 1.0);
|
||||
color = ORANGE;
|
||||
alpha = 1.0;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
//QDS: 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);
|
||||
if (show_wireframe) {
|
||||
vec3 wireframeColor = show_wireframe ? getWireframeColor(color) : color;
|
||||
vec3 triangleColor = wireframe(color, wireframeColor, 1.0);
|
||||
gl_FragColor = vec4(vec3(intensity.y) + triangleColor * intensity.x, alpha);
|
||||
}
|
||||
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);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#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);
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
#version 110
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#version 110
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
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;
|
||||
|
||||
varying vec3 clipping_planes_dots;
|
||||
varying vec4 model_pos;
|
||||
varying vec4 world_pos;
|
||||
struct SlopeDetection
|
||||
{
|
||||
bool actived;
|
||||
float normal_z;
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
uniform SlopeDetection slope;
|
||||
void main()
|
||||
{
|
||||
model_pos = gl_Vertex;
|
||||
// Point in homogenous coordinates.
|
||||
world_pos = volume_world_matrix * gl_Vertex;
|
||||
|
||||
gl_Position = ftransform();
|
||||
// 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);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#version 110
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = uniform_color;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#version 110
|
||||
|
||||
uniform bool use_fixed_screen_size;
|
||||
uniform float zoom;
|
||||
uniform float point_size;
|
||||
uniform float near_plane_height;
|
||||
|
||||
float fixed_screen_size()
|
||||
{
|
||||
return point_size;
|
||||
}
|
||||
|
||||
float fixed_world_size()
|
||||
{
|
||||
return (gl_Position.w == 1.0) ? zoom * near_plane_height * point_size : near_plane_height * point_size / gl_Position.w;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ftransform();
|
||||
gl_PointSize = use_fixed_screen_size ? fixed_screen_size() : fixed_world_size();
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
// version 120 is needed for gl_PointCoord
|
||||
#version 120
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform float percent_outline_radius;
|
||||
uniform float percent_center_radius;
|
||||
|
||||
vec4 calc_color(float radius, vec4 color)
|
||||
{
|
||||
return ((radius < percent_center_radius) || (radius > 1.0 - percent_outline_radius)) ?
|
||||
vec4(0.5 * color.rgb, color.a) : color;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 pos = (gl_PointCoord - 0.5) * 2.0;
|
||||
float radius = length(pos);
|
||||
if (radius > 1.0)
|
||||
discard;
|
||||
|
||||
gl_FragColor = calc_color(radius, uniform_color);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#version 120
|
||||
|
||||
uniform bool use_fixed_screen_size;
|
||||
uniform float zoom;
|
||||
uniform float point_size;
|
||||
uniform float near_plane_height;
|
||||
|
||||
float fixed_screen_size()
|
||||
{
|
||||
return point_size;
|
||||
}
|
||||
|
||||
float fixed_world_size()
|
||||
{
|
||||
return (gl_Position.w == 1.0) ? zoom * near_plane_height * point_size : near_plane_height * point_size / gl_Position.w;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ftransform();
|
||||
gl_PointSize = use_fixed_screen_size ? fixed_screen_size() : fixed_world_size();
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#version 110
|
||||
|
||||
const vec3 ORANGE = vec3(0.8, 0.4, 0.0);
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = uniform_color;
|
||||
//gl_FragColor = vec4(ORANGE, 1.0);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#version 110
|
||||
|
||||
attribute vec4 v_position;
|
||||
attribute vec2 v_tex_coords;
|
||||
|
||||
varying vec2 tex_coords;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ftransform();
|
||||
tex_coords = v_tex_coords;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
#version 110
|
||||
|
||||
varying vec3 eye_normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
eye_normal = gl_NormalMatrix * gl_Normal;
|
||||
}
|
||||
Reference in New Issue
Block a user