world_gradient_circle.swsl 661 B

123456789101112131415161718192021222324252627
  1. // Has 2 circles, an inner one that is unaffected and an outer one.
  2. light_mode unshaded;
  3. const highp vec4 color = vec4(1.0, 1.0, 1.0, 1.0);
  4. // Position of the center in pixel terms.
  5. uniform highp vec2 position;
  6. uniform highp float maxRange;
  7. uniform highp float minRange;
  8. uniform highp float bufferRange;
  9. uniform highp float gradient;
  10. void fragment() {
  11. highp float distance = length(FRAGCOORD.xy - position);
  12. if (distance > maxRange) {
  13. discard;
  14. }
  15. else if (distance < minRange) {
  16. COLOR = color;
  17. }
  18. else {
  19. highp float ratio = 1.0 - pow((distance - minRange) / bufferRange, gradient);
  20. COLOR = vec4(color.x, color.y, color.z, ratio);
  21. }
  22. }