Class PosterizationFilter

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

public class PosterizationFilter extends 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/
  • 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(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h)
      Description copied from class: Filter
      Initialization of filter subclasses. This method is called once when the filter is added to the FilterPostProcessor It should contain Material initializations and extra passes initialization
      Specified by:
      initFilter in class Filter
      Parameters:
      manager - the assetManager
      renderManager - the renderManager
      vp - the viewPort where this filter is rendered
      w - the width of the filter
      h - the height of the filter
    • getMaterial

      protected Material getMaterial()
      Description copied from class: Filter
      Must return the material used for this filter. this method is called every frame.
      Specified by:
      getMaterial in class Filter
      Returns:
      the material used for this 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