Class Smaa

All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable

public final class Smaa extends Antialiasing
SMAA (Subpixel Morphological Antialiasing) post-processing effect.

Three passes, each with its own shader:

  1. Edge detection: marks pixels where a luma edge starts (left/top).
  2. Blending weights: finds the ends of each edge and looks up the area to blend in the precomputed area and search lookup tables.
  3. Neighbourhood blending: mixes each pixel with its neighbour along the edge, only where weights exist.
The algorithm is by Jorge Jimenez et al.; see assets/shader/postprocess/smaa-LICENSE.md for the license and attribution of the shaders and the lookup tables.
  • Constructor Details

    • Smaa

      public Smaa(int viewportWidth, int viewportHeight, int quality)
      Creates the SMAA effect.
      Parameters:
      viewportWidth - The viewport width in pixels.
      viewportHeight - The viewport height in pixels.
      quality - The quality in [0,1,2], from worst to best.
  • Method Details

    • setViewportSize

      public void setViewportSize(int width, int height)
      Specified by:
      setViewportSize in class Antialiasing
    • updateQuality

      public void updateQuality(int quality)
      Updates the SMAA quality setting. Changing the quality requires new shader programs, so the filters are recreated.
      Specified by:
      updateQuality in class Antialiasing
      Parameters:
      quality - The quality in [0,1,2], from worst to best.
    • rebind

      public void rebind()
      Description copied from class: PostProcessorEffect
      Concrete objects shall be responsible to recreate or rebind its own resources whenever its needed, usually when the OpenGL context is lost. E.g., frame buffer textures should be updated and shader parameters should be re-uploaded/rebound.
      Specified by:
      rebind in class PostProcessorEffect
    • render

      public void render(com.badlogic.gdx.graphics.glutils.FrameBuffer src, com.badlogic.gdx.graphics.glutils.FrameBuffer dest, GaiaSkyFrameBuffer full, GaiaSkyFrameBuffer half)
      Description copied from class: PostProcessorEffect
      Concrete objects shall implement its own rendering, given the source and destination buffers.
      Specified by:
      render in class PostProcessorEffect
    • updateShaders

      public void updateShaders()
      Description copied from class: PostProcessorEffect
      Re-compiles the shaders of all filters in this effect.
      Overrides:
      updateShaders in class PostProcessorEffect
    • dispose

      public void dispose()
      Description copied from class: PostProcessorEffect
      Default implementation uses the resources in the disposables list.
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class PostProcessorEffect