/** * Create a new PostFX context. * * @param sketch Processing context. */ public PostFX(PApplet sketch) { this.sketch = sketch; supervisor = new PostFXSupervisor(sketch); builder = new PostFXBuilder(this, supervisor); }
/** * Preload a specific path to avoid delay because of shader compiling. * * @param type Type of the pass to preload. * @param <T> Type of the pass to preload. * @return */ public <T extends Pass> T preload(Class<T> type) { return builder.getPass(type); }
.toneMapping(1.2f) .exposure(1.0f) .compose(passResult);
/** * Clears all cached passes. */ public void clearPassCache() { builder.getPasses().clear(); } }
/** * Run a sobel edge detection pass on the texture. * * @return Builder object. */ public PostFXBuilder sobel() { SobelPass pass = getPass(SobelPass.class); supervisor.pass(pass); return this; }
/** * @param sketch Processing context. * @param width Width of the pass buffer. * @param height Height of the pass buffer. */ public PostFX(PApplet sketch, int width, int height) { this.sketch = sketch; supervisor = new PostFXSupervisor(sketch, width, height); builder = new PostFXBuilder(this, supervisor); }
/** * Run a chromatic aberration effect pass on the texture. * * @return Builder object. */ public PostFXBuilder chromaticAberration() { ChromaticAberrationPass pass = getPass(ChromaticAberrationPass.class); supervisor.pass(pass); return this; }
/** * Run a grayscale pass on the texture. * * @return Builder object. */ public PostFXBuilder grayScale() { GrayScalePass pass = getPass(GrayScalePass.class); supervisor.pass(pass); return this; }
/** * Run a toon pass on the texture. * * @return Builder object. */ public PostFXBuilder toon() { ToonPass pass = getPass(ToonPass.class); supervisor.pass(pass); return this; }
/** * Run an invert pass on the texture. * * @return Builder object. */ public PostFXBuilder invert() { InvertPass pass = getPass(InvertPass.class); supervisor.pass(pass); return this; }
/** * Run an exposure pass on the texture. * * @return Builder object. */ public PostFXBuilder exposure(float exposure) { ExposurePass pass = getPass(ExposurePass.class); pass.setExposure(exposure); supervisor.pass(pass); return this; }
/** * Run an tone mapping pass on the texture. * * @return Builder object. */ public PostFXBuilder toneMapping(float gamma) { ToneMappingPass pass = getPass(ToneMappingPass.class); pass.setGamma(gamma); supervisor.pass(pass); return this; }
/** * Run a bright pass pass on the texture. * * @param threshold Threshold of the brightness. * @return Builder object. */ public PostFXBuilder brightPass(float threshold) { BrightPass pass = getPass(BrightPass.class); pass.setThreshold(threshold); supervisor.pass(pass); return this; }
/** * Run a pixel effect pass on the texture. * * @param amount Amount of the pixel effect. * @return Builder object. */ public PostFXBuilder pixelate(float amount) { PixelatePass pass = getPass(PixelatePass.class); pass.setAmount(amount); supervisor.pass(pass); return this; }
/** * Run a denoise pass on the texture. * * @param exponent Exponent of the denoise effect. * @return Builder object. */ public PostFXBuilder denoise(float exponent) { DenoisePass pass = getPass(DenoisePass.class); pass.setExponent(exponent); supervisor.pass(pass); return this; }
/** * Run a RGB split pass on the texture. * * @param delta Delta of the rgb split effect. * @return Builder object. */ public PostFXBuilder rgbSplit(float delta) { RGBSplitPass pass = getPass(RGBSplitPass.class); pass.setDelta(delta); supervisor.pass(pass); return this; }
/** * Run a binary glitch pass on the texture. * * @param strength Size of the binary glitch windows. * @return Builder object. */ public PostFXBuilder binaryGlitch(float strength) { BinaryGlitchPass pass = getPass(BinaryGlitchPass.class); pass.setStrength(strength); supervisor.pass(pass); return this; } }
/** * Run a vignette pass on the texture. * * @param amount Amount of the vignette effect. * @param falloff Fall off of the vignette effect. * @return Builder object. */ public PostFXBuilder vignette(float amount, float falloff) { VignettePass pass = getPass(VignettePass.class); pass.setAmount(amount); pass.setFalloff(falloff); supervisor.pass(pass); return this; }
/** * Run a brightness and contrast correction pass on the texture. * * @param brightness Amount of brightness to add to the picture (default 0.0). * @param contrast Contrast of the image (default 1.0). * @return Builder object. */ public PostFXBuilder brightnessContrast(float brightness, float contrast) { BrightnessContrastPass pass = getPass(BrightnessContrastPass.class); pass.setBrightness(brightness); pass.setContrast(contrast); supervisor.pass(pass); return this; }