Class PosterizationFilter

java.lang.Object
com.jme3.post.Filter
com.jme3.post.filters.PosterizationFilter
All Implemented Interfaces:
com.jme3.export.Savable

public class PosterizationFilter extends com.jme3.post.Filter
A Post Processing filter to change colors appear with sharp edges as if the available amount of colors available was not enough to draw the true image. Possibly useful in cartoon styled games. Use the strength variable to lessen influence of this filter on the total result. Values from 0.2 to 0.7 appear to give nice results. Based on an article from Geeks3D: http://www.geeks3d.com/20091027/shader-library-posterization-post-processing-effect-glsl/
Author:
Roy Straver a.k.a. Baal Garnaal
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.jme3.post.Filter

    com.jme3.post.Filter.Pass
  • Field Summary

    Fields inherited from class com.jme3.post.Filter

    defaultPass, enabled, material, postRenderPasses, processor
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a posterization Filter
    PosterizationFilter(int numColors)
    Creates a posterization Filter with the given number of colors
    PosterizationFilter(int numColors, float gamma)
    Creates a posterization Filter with the given number of colors and gamma
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Returns current gamma value
    protected com.jme3.material.Material
     
    int
    Returns number of color levels used
    float
    Returns current strength value, i.e.
    protected void
    initFilter(com.jme3.asset.AssetManager manager, com.jme3.renderer.RenderManager renderManager, com.jme3.renderer.ViewPort vp, int w, int h)
     
    void
    read(com.jme3.export.JmeImporter importer)
    Load properties when the filter is de-serialized, for example when loading from a J3O file.
    void
    setGamma(float gamma)
    Sets gamma level used to enhance visual quality
    void
    setNumColors(int numColors)
    Sets number of color levels used to draw the screen
    void
    setStrength(float strength)
    Sets current strength value, i.e.
    void
    write(com.jme3.export.JmeExporter exporter)
    Save properties when the filter is serialized, for example when saving to a J3O file.

    Methods inherited from class com.jme3.post.Filter

    cleanup, cleanUpFilter, getDefaultPassDepthFormat, getDefaultPassTextureFormat, getName, getPostRenderPasses, getRenderedTexture, getRenderFrameBuffer, init, isEnabled, isRequiresBilinear, isRequiresDepthTexture, isRequiresSceneTexture, postFilter, postFrame, postQueue, preFrame, setDepthTexture, setEnabled, setName, setProcessor, setRenderedTexture, setRenderFrameBuffer

    Methods inherited from class java.lang.Object

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

    • PosterizationFilter

      public PosterizationFilter()
      Creates a posterization Filter
    • PosterizationFilter

      public PosterizationFilter(int numColors)
      Creates a posterization Filter with the given number of colors
      Parameters:
      numColors - the desired number of colors (>0, default=8)
    • PosterizationFilter

      public PosterizationFilter(int numColors, float gamma)
      Creates a posterization Filter with the given number of colors and gamma
      Parameters:
      numColors - the desired number of colors (>0, default=8)
      gamma - the desired exponent (default=0.6)
  • Method Details

    • initFilter

      protected void initFilter(com.jme3.asset.AssetManager manager, com.jme3.renderer.RenderManager renderManager, com.jme3.renderer.ViewPort vp, int w, int h)
      Specified by:
      initFilter in class com.jme3.post.Filter
    • getMaterial

      protected com.jme3.material.Material getMaterial()
      Specified by:
      getMaterial in class com.jme3.post.Filter
    • setNumColors

      public void setNumColors(int numColors)
      Sets number of color levels used to draw the screen
      Parameters:
      numColors - the desired number of colors (>0, default=8)
    • setGamma

      public void setGamma(float gamma)
      Sets gamma level used to enhance visual quality
      Parameters:
      gamma - the desired exponent (default=0.6)
    • setStrength

      public void setStrength(float strength)
      Sets current strength value, i.e. influence on final image
      Parameters:
      strength - the desired influence factor (default=1)
    • getNumColors

      public int getNumColors()
      Returns number of color levels used
      Returns:
      the count (>0)
    • getGamma

      public float getGamma()
      Returns current gamma value
      Returns:
      the exponent
    • getStrength

      public float getStrength()
      Returns current strength value, i.e. influence on final image
      Returns:
      the influence factor
    • read

      public void read(com.jme3.export.JmeImporter importer) throws IOException
      Load properties when the filter is de-serialized, for example when loading from a J3O file.
      Specified by:
      read in interface com.jme3.export.Savable
      Overrides:
      read in class com.jme3.post.Filter
      Parameters:
      importer - the importer to use (not null)
      Throws:
      IOException - from the importer
    • write

      public void write(com.jme3.export.JmeExporter exporter) throws IOException
      Save properties when the filter is serialized, for example when saving to a J3O file.
      Specified by:
      write in interface com.jme3.export.Savable
      Overrides:
      write in class com.jme3.post.Filter
      Parameters:
      exporter - the exporter to use (not null)
      Throws:
      IOException - from the exporter