Class Passes

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

public final class Passes extends Object implements AutoCloseable
Full-screen passes shared by the effects: screen capture, the dual Kawase blur, and compositing a texture onto the bound framebuffer. Every pass saves and restores the state it touches.
  • Field Details

    • FULLSCREEN_VERTEX

      public static final String FULLSCREEN_VERTEX
      The vertex shader for custom full-screen passes; it provides varying vec2 v_uv.
      See Also:
  • Constructor Details

    • Passes

      public Passes(GlBackend gl, GlStateCache cache, FramebufferPool pool, ShaderLoader shaders)
      Creates the passes and compiles their programs.
      Parameters:
      gl - the backend
      cache - the host's state cache
      pool - where intermediate framebuffers come from
      shaders - the loader that resolves the built-in shaders
  • Method Details

    • pool

      public FramebufferPool pool()
      Returns the framebuffer pool.
      Returns:
      the pool
    • captureScreen

      public Framebuffer captureScreen()
      Copies what is drawn so far into a pooled texture the size of the window.
      Returns:
      the copy; release it to the pool
    • blur

      public Framebuffer blur(int texture, int width, int height, int iterations, float offset)
      Blurs a texture with the dual Kawase filter: iterations halvings, then the same number of doublings.
      Parameters:
      texture - the source texture
      width - source width in pixels
      height - source height in pixels
      iterations - how many times to halve, at least 1; each one roughly doubles the blur radius
      offset - the tap spread in source pixels, usually 1 to 4
      Returns:
      the blurred image at the source size; release it to the pool
    • blurSizes

      public static int[][] blurSizes(int width, int height, int iterations)
      The size of each level of a dual Kawase blur, level 0 being the source.
      Parameters:
      width - source width
      height - source height
      iterations - how many halvings
      Returns:
      iterations + 1 sizes, never below 1 pixel
    • composite

      public void composite(int texture, boolean additive, float r, float g, float b, float a)
      Draws a texture over the whole bound framebuffer, multiplied by a tint.
      Parameters:
      texture - the texture
      additive - add onto what is there (for glows), or replace it
      r - red multiplier
      g - green multiplier
      b - blue multiplier
      a - alpha multiplier
    • run

      public void run(ShaderProgram program, Framebuffer source, Framebuffer target, Consumer<ShaderProgram> uniforms)
      Runs a custom full-screen program from one texture into a framebuffer. The program gets u_texture on unit 0 and u_texel, the size of one source pixel in texture coordinates.
      Parameters:
      program - a program built on FULLSCREEN_VERTEX
      source - the source framebuffer
      target - the target framebuffer
      uniforms - sets the program's own uniforms; the program is bound when it runs
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable