Class ContrastAdjustmentFilter

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

public class ContrastAdjustmentFilter extends com.jme3.post.Filter
A filter to adjust the colors of a rendered scene by normalizing each color channel to a specified range, applying a power law, and scaling the output. The alpha channel is unaffected.
Author:
pavl_g.
  • 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
    Instantiates a contrast-adjustment filter with the default parameters:
    ContrastAdjustmentFilter(float exponent)
    Instantiates a contrast-adjustment filter with the default input range and output scaling.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Retrieves the blue-channel exponent.
    float
    Retrieves the output scale factor for the blue channel.
    float
    Retrieves the green-channel exponent.
    float
    Retrieves the output scale factor for the green channel.
    float
    Returns the lower limit of the input range.
    protected com.jme3.material.Material
    Returns the Material used in this Filter.
    float
    Retrieves the red-channel exponent.
    float
    Retrieves the output scale factor for the red channel.
    float
    Returns the upper limit of the input range.
    protected void
    initFilter(com.jme3.asset.AssetManager assetManager, com.jme3.renderer.RenderManager renderManager, com.jme3.renderer.ViewPort viewPort, int width, int height)
    Initializes the Filter when it is added to a FilterPostProcessor.
    void
    read(com.jme3.export.JmeImporter im)
    De-serializes this filter, for example when loading from a J3O file.
    setBlueExponent(float exponent)
    Sets the power-law exponent for the blue channel.
    setBlueScale(float factor)
    Sets the output scale factor for the blue channel.
    setExponents(float redExponent, float greenExponent, float blueExponent)
    Sets the power-law exponent for each color channel.
    setGreenExponent(float exponent)
    Sets the power-law exponent for the green channel.
    setGreenScale(float factor)
    Sets the output scale factor for the green channel.
    setInputRange(float lowerLimit, float upperLimit)
    Sets the input range for each color channel.
    setLowerLimit(float level)
    Sets the lower limit of the input range.
    setRedExponent(float exponent)
    Sets the power-law exponent for the red channel.
    setRedScale(float factor)
    Sets the output scale factor for the red channel.
    setScales(float redScale, float greenScale, float blueScale)
    Adjusts the output scaling for each color channel.
    setUpperLimit(float level)
    Sets the upper limit of the input range.
    Represent this Filter as a String.
    void
    write(com.jme3.export.JmeExporter ex)
    Serializes this filter, 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, wait, wait, wait
  • Constructor Details

    • ContrastAdjustmentFilter

      public ContrastAdjustmentFilter()
      Instantiates a contrast-adjustment filter with the default parameters:

      input range from 0 to 1

      power-law exponent=1 for all color channels

      output scale factor=1 for all color channels Such a filter has no effect.

    • ContrastAdjustmentFilter

      public ContrastAdjustmentFilter(float exponent)
      Instantiates a contrast-adjustment filter with the default input range and output scaling.
      Parameters:
      exponent - the desired power-law exponent for all color channels
  • Method Details

    • setExponents

      public ContrastAdjustmentFilter setExponents(float redExponent, float greenExponent, float blueExponent)
      Sets the power-law exponent for each color channel. The default value for each exponent is 1, which produces a linear filter.
      Parameters:
      redExponent - the desired red-channel exponent
      greenExponent - the desired green-channel exponent
      blueExponent - the desired blue-channel exponent
      Returns:
      this filter instance, for chaining
    • setRedExponent

      public ContrastAdjustmentFilter setRedExponent(float exponent)
      Sets the power-law exponent for the red channel.
      Parameters:
      exponent - the desired exponent (default=1 for linear)
      Returns:
      this filter instance, for chaining
    • setGreenExponent

      public ContrastAdjustmentFilter setGreenExponent(float exponent)
      Sets the power-law exponent for the green channel.
      Parameters:
      exponent - the desired exponent (default=1 for linear)
      Returns:
      this filter instance, for chaining
    • setBlueExponent

      public ContrastAdjustmentFilter setBlueExponent(float exponent)
      Sets the power-law exponent for the blue channel.
      Parameters:
      exponent - the desired exponent (default=1 for linear)
      Returns:
      this filter instance, for chaining
    • getRedExponent

      public float getRedExponent()
      Retrieves the red-channel exponent.
      Returns:
      the power-law exponent (default=1 for linear)
    • getGreenExponent

      public float getGreenExponent()
      Retrieves the green-channel exponent.
      Returns:
      the power-law exponent (default=1 for linear)
    • getBlueExponent

      public float getBlueExponent()
      Retrieves the blue-channel exponent.
      Returns:
      the power-law exponent (default=1 for linear)
    • setInputRange

      public ContrastAdjustmentFilter setInputRange(float lowerLimit, float upperLimit)
      Sets the input range for each color channel.

      Before applying the power law, the input levels get normalized: lowerLimit and below normalize to 0 and upperLimit normalizes to 1.

      Parameters:
      lowerLimit - the desired lower limit (default=0)
      upperLimit - the desired upper limit (default=1)
      Returns:
      this filter instance, for chaining
    • setUpperLimit

      public ContrastAdjustmentFilter setUpperLimit(float level)
      Sets the upper limit of the input range.
      Parameters:
      level - the input level that should be normalized to 1 (default=1)
      Returns:
      this filter instance, for chaining
    • setLowerLimit

      public ContrastAdjustmentFilter setLowerLimit(float level)
      Sets the lower limit of the input range.
      Parameters:
      level - the highest input level that should be normalized to 0 (default=0)
      Returns:
      this filter instance, for chaining
    • getLowerLimit

      public float getLowerLimit()
      Returns the lower limit of the input range.
      Returns:
      the input level (default=0)
    • getUpperLimit

      public float getUpperLimit()
      Returns the upper limit of the input range.
      Returns:
      the input level (default=1)
    • setScales

      public ContrastAdjustmentFilter setScales(float redScale, float greenScale, float blueScale)
      Adjusts the output scaling for each color channel. The default for each scale factor is 1, which has no effect.
      Parameters:
      redScale - the red-channel scale factor
      greenScale - the green-channel scale factor
      blueScale - the blue-channel scale factor
      Returns:
      this filter instance, for chaining
    • setRedScale

      public ContrastAdjustmentFilter setRedScale(float factor)
      Sets the output scale factor for the red channel.
      Parameters:
      factor - the desired scale factor (default=1)
      Returns:
      this filter instance, for chaining
    • setGreenScale

      public ContrastAdjustmentFilter setGreenScale(float factor)
      Sets the output scale factor for the green channel.
      Parameters:
      factor - the desired scale factor (default=1)
      Returns:
      this filter instance, for chaining
    • setBlueScale

      public ContrastAdjustmentFilter setBlueScale(float factor)
      Sets the output scale factor for the blue channel.
      Parameters:
      factor - the desired scale factor (default=1)
      Returns:
      this filter instance, for chaining
    • getRedScale

      public float getRedScale()
      Retrieves the output scale factor for the red channel.
      Returns:
      the scale factor (default=1 for no effect)
    • getGreenScale

      public float getGreenScale()
      Retrieves the output scale factor for the green channel.
      Returns:
      the scale factor (default=1 for no effect)
    • getBlueScale

      public float getBlueScale()
      Retrieves the output scale factor for the blue channel.
      Returns:
      the scale factor (default=1 for no effect)
    • initFilter

      protected void initFilter(com.jme3.asset.AssetManager assetManager, com.jme3.renderer.RenderManager renderManager, com.jme3.renderer.ViewPort viewPort, int width, int height)
      Initializes the Filter when it is added to a FilterPostProcessor.
      Specified by:
      initFilter in class com.jme3.post.Filter
      Parameters:
      assetManager - for loading assets (not null)
      renderManager - unused
      viewPort - unused
      width - unused
      height - unused
    • getMaterial

      protected com.jme3.material.Material getMaterial()
      Returns the Material used in this Filter. This method is invoked on every frame.
      Specified by:
      getMaterial in class com.jme3.post.Filter
      Returns:
      the pre-existing instance, or null if the Filter hasn't been initialized
    • read

      public void read(com.jme3.export.JmeImporter im) throws IOException
      De-serializes this filter, 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:
      im - the importer to use (not null)
      Throws:
      IOException - from the importer
    • write

      public void write(com.jme3.export.JmeExporter ex) throws IOException
      Serializes this filter, 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:
      ex - the exporter to use (not null)
      Throws:
      IOException - from the exporter
    • toString

      public String toString()
      Represent this Filter as a String.
      Overrides:
      toString in class Object
      Returns:
      a descriptive string of text (not null)