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-10 12:20:18 +00:00
|
|
|
#if ENABLE_ENVIRONMENT_MAP
|
|
|
|
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
|
|
|
|
2020-03-13 14:09:07 +00:00
|
|
|
vec3 slope_color()
|
|
|
|
{
|
2020-10-02 13:43:39 +00:00
|
|
|
return (world_normal_z > slope.normal_z - EPSILON) ? GREEN : RED;
|
2020-03-13 14:09:07 +00:00
|
|
|
}
|
2019-03-25 11:01:02 +00:00
|
|
|
|
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;
|
2020-03-31 10:51:50 +00:00
|
|
|
vec3 color = slope.actived ? slope_color() : uniform_color.rgb;
|
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-10 12:20:18 +00:00
|
|
|
#if ENABLE_ENVIRONMENT_MAP
|
2020-05-28 13:27:29 +00:00
|
|
|
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, uniform_color.a);
|
|
|
|
else
|
2020-12-10 12:20:18 +00:00
|
|
|
#endif
|
2020-05-28 13:27:29 +00:00
|
|
|
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, uniform_color.a);
|
2018-05-21 11:08:02 +00:00
|
|
|
}
|