Class ContrastAdjustmentFilter

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

public class ContrastAdjustmentFilter extends 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.
  • Constructor Details Link icon

    • ContrastAdjustmentFilter Link icon

      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 Link icon

      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 Link icon

    • setExponents Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

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

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

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

      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 Link icon

      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 Link icon

      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 Link icon

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

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

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

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

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

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

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

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

      public void read(JmeImporter im) throws IOException
      De-serializes this filter, for example when loading from a J3O file.
      Specified by:
      read in interface Savable
      Overrides:
      read in class Filter
      Parameters:
      im - the importer to use (not null)
      Throws:
      IOException - from the importer
    • write Link icon

      public void write(JmeExporter ex) throws IOException
      Serializes this filter, for example when saving to a J3O file.
      Specified by:
      write in interface Savable
      Overrides:
      write in class Filter
      Parameters:
      ex - the exporter to use (not null)
      Throws:
      IOException - from the exporter
    • toString Link icon

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