Class Passes
java.lang.Object
lol.trq.helios.effect.Passes
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe vertex shader for custom full-screen passes; it providesvarying vec2 v_uv. -
Constructor Summary
ConstructorsConstructorDescriptionPasses(GlBackend gl, GlStateCache cache, FramebufferPool pool, ShaderLoader shaders) Creates the passes and compiles their programs. -
Method Summary
Modifier and TypeMethodDescriptionblur(int texture, int width, int height, int iterations, float offset) Blurs a texture with the dual Kawase filter:iterationshalvings, then the same number of doublings.static int[][]blurSizes(int width, int height, int iterations) The size of each level of a dual Kawase blur, level 0 being the source.Copies what is drawn so far into a pooled texture the size of the window.voidclose()voidcomposite(int texture, boolean additive, float r, float g, float b, float a) Draws a texture over the whole bound framebuffer, multiplied by a tint.pool()Returns the framebuffer pool.voidrun(ShaderProgram program, Framebuffer source, Framebuffer target, Consumer<ShaderProgram> uniforms) Runs a custom full-screen program from one texture into a framebuffer.
-
Field Details
-
FULLSCREEN_VERTEX
The vertex shader for custom full-screen passes; it providesvarying vec2 v_uv.- See Also:
-
-
Constructor Details
-
Passes
Creates the passes and compiles their programs.- Parameters:
gl- the backendcache- the host's state cachepool- where intermediate framebuffers come fromshaders- the loader that resolves the built-in shaders
-
-
Method Details
-
pool
-
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
Blurs a texture with the dual Kawase filter:iterationshalvings, then the same number of doublings.- Parameters:
texture- the source texturewidth- source width in pixelsheight- source height in pixelsiterations- how many times to halve, at least 1; each one roughly doubles the blur radiusoffset- 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 widthheight- source heightiterations- how many halvings- Returns:
iterations + 1sizes, 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 textureadditive- add onto what is there (for glows), or replace itr- red multiplierg- green multiplierb- blue multipliera- 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 getsu_textureon unit 0 andu_texel, the size of one source pixel in texture coordinates.- Parameters:
program- a program built onFULLSCREEN_VERTEXsource- the source framebuffertarget- the target framebufferuniforms- sets the program's own uniforms; the program is bound when it runs
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-