Package com.jme3.post.filters
Class ContrastAdjustmentFilter
java.lang.Object
com.jme3.post.Filter
com.jme3.post.filters.ContrastAdjustmentFilter
- All Implemented Interfaces:
Savable
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jme3.post.Filter
Filter.Pass
-
Field Summary
Fields inherited from class com.jme3.post.Filter
defaultPass, enabled, material, postRenderPasses, processor
-
Constructor Summary
ConstructorDescriptionInstantiates 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 TypeMethodDescriptionfloat
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 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
(AssetManager assetManager, RenderManager renderManager, ViewPort viewPort, int width, int height) Initializes the Filter when it is added to a FilterPostProcessor.void
read
(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.toString()
Represent this Filter as a String.void
write
(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
-
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 exponentgreenExponent
- the desired green-channel exponentblueExponent
- the desired blue-channel exponent- Returns:
- this filter instance, for chaining
-
setRedExponent
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
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
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
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
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
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
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 factorgreenScale
- the green-channel scale factorblueScale
- the blue-channel scale factor- Returns:
- this filter instance, for chaining
-
setRedScale
Sets the output scale factor for the red channel.- Parameters:
factor
- the desired scale factor (default=1)- Returns:
- this filter instance, for chaining
-
setGreenScale
Sets the output scale factor for the green channel.- Parameters:
factor
- the desired scale factor (default=1)- Returns:
- this filter instance, for chaining
-
setBlueScale
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(AssetManager assetManager, RenderManager renderManager, ViewPort viewPort, int width, int height) Initializes the Filter when it is added to a FilterPostProcessor.- Specified by:
initFilter
in classFilter
- Parameters:
assetManager
- for loading assets (not null)renderManager
- unusedviewPort
- unusedwidth
- unusedheight
- unused
-
getMaterial
Returns the Material used in this Filter. This method is invoked on every frame.- Specified by:
getMaterial
in classFilter
- Returns:
- the pre-existing instance, or null if the Filter hasn't been initialized
-
read
De-serializes this filter, for example when loading from a J3O file.- Specified by:
read
in interfaceSavable
- Overrides:
read
in classFilter
- Parameters:
im
- the importer to use (not null)- Throws:
IOException
- from the importer
-
write
Serializes this filter, for example when saving to a J3O file.- Specified by:
write
in interfaceSavable
- Overrides:
write
in classFilter
- Parameters:
ex
- the exporter to use (not null)- Throws:
IOException
- from the exporter
-
toString
Represent this Filter as a String.
-