Class Effects

java.lang.Object
lol.trq.helios.effect.Effects
All Implemented Interfaces:
AutoCloseable

public final class Effects extends Object implements AutoCloseable
Screen effects: background blur behind a shape, and bloom.

Both work on the framebuffer bound when they are called, and assume drawing units are screen space with the origin at the top left, as on a Minecraft GUI screen: a point (x, y) is at framebuffer pixel (x / pixel, y / pixel) from the top left.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Effects(GlBackend gl, GlStateCache cache, Passes passes, ShapeBatch batch)
    Creates the effects.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    bloom(Runnable sources, int iterations, float offset, float intensity)
    Bloom: draws the glow sources into an offscreen buffer, blurs it, and adds the result onto the bound framebuffer.
    void
    blurBehind(float x, float y, float width, float height, float radius, float pixel, int iterations, float offset, int tint)
    Blurs what is already drawn behind a rounded rectangle and draws the result inside it, the frosted glass effect.
    void
    Deletes the batch the effects draw through.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Effects

      public Effects(GlBackend gl, GlStateCache cache, Passes passes, ShapeBatch batch)
      Creates the effects.
      Parameters:
      gl - the backend
      cache - the host's state cache
      passes - the shared passes
      batch - the batch used to draw blurred results through a shape
  • Method Details

    • blurBehind

      public void blurBehind(float x, float y, float width, float height, float radius, float pixel, int iterations, float offset, int tint)
      Blurs what is already drawn behind a rounded rectangle and draws the result inside it, the frosted glass effect.
      Parameters:
      x - left
      y - top
      width - width
      height - height
      radius - corner radius
      pixel - one framebuffer pixel in drawing units
      iterations - blur strength, 1 to 8; each step roughly doubles the radius
      offset - tap spread, usually 1 to 4
      tint - colour the blurred image is multiplied by; 0xFFFFFFFF for none
    • bloom

      public void bloom(Runnable sources, int iterations, float offset, float intensity)
      Bloom: draws the glow sources into an offscreen buffer, blurs it, and adds the result onto the bound framebuffer. The sources themselves are not drawn on screen; draw them again normally if they should show.
      Parameters:
      sources - draws the glowing parts, in the current projection; the offscreen buffer is bound and cleared
      iterations - blur strength, 1 to 8
      offset - tap spread, usually 1 to 4
      intensity - how strongly the glow is added; 1 adds it once
    • close

      public void close()
      Deletes the batch the effects draw through.
      Specified by:
      close in interface AutoCloseable