2018-05-21 11:08:02 +00:00
|
|
|
#version 110
|
|
|
|
|
|
|
|
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
2020-03-16 07:35:13 +00:00
|
|
|
const vec3 GREEN = vec3(0.0, 0.7, 0.0);
|
|
|
|
const vec3 YELLOW = vec3(0.5, 0.7, 0.0);
|
|
|
|
const vec3 RED = vec3(0.7, 0.0, 0.0);
|
2020-03-13 14:09:07 +00:00
|
|
|
const float EPSILON = 0.0001;
|
|
|
|
|
|
|
|
struct SlopeDetection
|
|
|
|
{
|
2020-03-31 10:51:50 +00:00
|
|
|
bool actived;
|
2020-10-02 13:43:39 +00:00
|
|
|
float normal_z;
|
2020-03-13 14:09:07 +00:00
|
|
|
mat3 volume_world_normal_matrix;
|
|
|
|
};
|
|
|
|
|
|
|
|
uniform vec4 uniform_color;
|
|
|
|
uniform SlopeDetection slope;
|
2018-05-21 11:08:02 +00:00
|
|
|
|
2020-12-11 11:27:07 +00:00
|
|
|
#ifdef ENABLE_ENVIRONMENT_MAP
|
2020-12-10 12:20:18 +00:00
|
|
|
uniform sampler2D environment_tex;
|
|
|
|
uniform bool use_environment_tex;
|
|
|
|
#endif // ENABLE_ENVIRONMENT_MAP
|
2020-05-28 13:27:29 +00:00
|
|
|
|
2019-04-12 09:01:53 +00:00
|
|
|
varying vec3 clipping_planes_dots;
|
|
|
|
|
2018-05-21 11:08:02 +00:00
|
|
|
// x = tainted, y = specular;
|
|
|
|
varying vec2 intensity;
|
|
|
|
|
|
|
|
varying vec3 delta_box_min;
|
|
|
|
varying vec3 delta_box_max;
|
|
|
|
|
2020-03-13 14:09:07 +00:00
|
|
|
varying float world_normal_z;
|
2020-05-28 13:27:29 +00:00
|
|
|
varying vec3 eye_normal;
|
2018-05-21 11:08:02 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2019-04-12 09:01:53 +00:00
|
|
|
if (any(lessThan(clipping_planes_dots, ZERO)))
|
2019-03-25 11:01:02 +00:00
|
|
|
discard;
|
2021-01-14 12:00:54 +00:00
|
|
|
vec3 color = uniform_color.rgb;
|
|
|
|
float alpha = uniform_color.a;
|
|
|
|
if (slope.actived && world_normal_z < slope.normal_z - EPSILON) {
|
|
|
|
color = vec3(0.7f, 0.7f, 1.f);
|
|
|
|
alpha = 1.f;
|
|
|
|
}
|
2018-05-21 11:08:02 +00:00
|
|
|
// if the fragment is outside the print volume -> use darker color
|
2020-03-13 14:09:07 +00:00
|
|
|
color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? mix(color, ZERO, 0.3333) : color;
|
2020-12-11 11:27:07 +00:00
|
|
|
#ifdef ENABLE_ENVIRONMENT_MAP
|
2020-05-28 13:27:29 +00:00
|
|
|
if (use_environment_tex)
|
2021-01-14 12:00:54 +00:00
|
|
|
gl_FragColor = vec4(0.45 * texture2D(environment_tex, normalize(eye_normal).xy * 0.5 + 0.5).xyz + 0.8 * color * intensity.x, alpha);
|
2020-05-28 13:27:29 +00:00
|
|
|
else
|
2020-12-10 12:20:18 +00:00
|
|
|
#endif
|
2021-01-14 12:00:54 +00:00
|
|
|
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
2018-05-21 11:08:02 +00:00
|
|
|
}
|