gouraud.fs 692 B

1234567891011121314151617181920212223242526
  1. #version 110
  2. const vec3 ZERO = vec3(0.0, 0.0, 0.0);
  3. // x = tainted, y = specular;
  4. varying vec2 intensity;
  5. varying vec3 delta_box_min;
  6. varying vec3 delta_box_max;
  7. varying float world_z;
  8. uniform vec4 uniform_color;
  9. // x = min z, y = max z;
  10. uniform vec2 z_range;
  11. void main()
  12. {
  13. if ((world_z < z_range.x) || (z_range.y < world_z))
  14. discard;
  15. // if the fragment is outside the print volume -> use darker color
  16. vec3 color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? mix(uniform_color.rgb, ZERO, 0.3333) : uniform_color.rgb;
  17. gl_FragColor = vec4(vec3(intensity.y, intensity.y, intensity.y) + color * intensity.x, uniform_color.a);
  18. }