Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class PostProcess

  1. Object
  2. PostProcess

Full screen effects applied to a rendered frame: bloom, a colour grade, vignette and film grain. It is what turns a correctly lit scene into one that looks shot through a lens.

The scene is drawn into an offscreen image, the effects are applied, and the result is drawn to the screen. Touch controls are drawn afterwards and are never graded. A device that cannot render offscreen (GpuCapabilities.isPostProcessSupported is false) draws the scene directly and ignores this.

GameView view = new GameView() {
    protected void update(double deltaSeconds) {
    }
};
view.setPostProcess(new PostProcess()
        .setBloom(0.75f, 0.6f)
        .setGrade(1.08f, 0.9f, 0xff0e1a24, 0xfffff1dc)
        .setVignette(0.35f)
        .setGrain(0.04f));

All effects start off, so new PostProcess() changes nothing but the cost of the extra pass.

Constructors

public PostProcess()

Methods

public PostProcess setBloom(float threshold, float intensity)Makes bright parts of the frame glow into their surroundings.
public PostProcess setGrade(float contrast, float saturation, int shadowTint, int highlightTint)Grades the colour of the frame.
public PostProcess setVignette(float amount)Darkens the corners of the frame.
public PostProcess setGrain(float amount)Adds moving film grain.
public float getBloomThreshold()Returns the bloom brightness threshold.
public float getBloomIntensity()Returns the bloom intensity, 0 when bloom is off.
public boolean isBloom()Returns true if bloom is on.
public float getContrast()Returns the contrast multiplier.
public float getSaturation()Returns the saturation multiplier.
public int getShadowTint()Returns the shadow tint as ARGB.
public int getHighlightTint()Returns the highlight tint as ARGB.
public float getVignette()Returns the vignette amount.
public float getGrain()Returns the grain amount.

Inherited methods

Constructor details

PostProcess

public PostProcess()

Method details

setBloom

public PostProcess setBloom(float threshold, float intensity)
Makes bright parts of the frame glow into their surroundings.

Parameters

threshold float
how bright a pixel must be to glow, from 0 to 1 of its brightest channel; lower glows more of the frame
intensity float
how strong the glow is; 0 turns bloom off

Returns

this post process for chaining

setGrade

public PostProcess setGrade(float contrast, float saturation, int shadowTint, int highlightTint)
Grades the colour of the frame.

Parameters

contrast float
1 leaves it, above 1 deepens shadows and brightens highlights
saturation float
1 leaves it, 0 is greyscale
shadowTint int
the colour the darkest tones are lifted toward, as ARGB; black leaves them
highlightTint int
the colour the brightest tones are multiplied by, as ARGB; white leaves them

Returns

this post process for chaining

setVignette

public PostProcess setVignette(float amount)
Darkens the corners of the frame.

Parameters

amount float
0 for none, 1 for black corners

Returns

this post process for chaining

setGrain

public PostProcess setGrain(float amount)
Adds moving film grain.

Parameters

amount float
0 for none; 0.03 to 0.06 reads as film

Returns

this post process for chaining

getBloomThreshold

public float getBloomThreshold()
Returns the bloom brightness threshold.

getBloomIntensity

public float getBloomIntensity()
Returns the bloom intensity, 0 when bloom is off.

isBloom

public boolean isBloom()
Returns true if bloom is on.

getContrast

public float getContrast()
Returns the contrast multiplier.

getSaturation

public float getSaturation()
Returns the saturation multiplier.

getShadowTint

public int getShadowTint()
Returns the shadow tint as ARGB.

getHighlightTint

public int getHighlightTint()
Returns the highlight tint as ARGB.

getVignette

public float getVignette()
Returns the vignette amount.

getGrain

public float getGrain()
Returns the grain amount.