All Projects → cansik → Processing Postfx

cansik / Processing Postfx

A shader based postFX library for processing.

Programming Languages

java
68154 projects - #9 most used programming language
processing
702 projects

Projects that are alternatives of or similar to Processing Postfx

lut
color lookup tables (LUTs) for color grading
Stars: ✭ 84 (-26.32%)
Mutual labels:  filter, effect
Videobeautify
With this APP, you can do all kinds of professional optimising and beautifying to your videos
Stars: ✭ 450 (+294.74%)
Mutual labels:  effect, filter
SOUL-VA
The SOUL Virtual Analog Library
Stars: ✭ 45 (-60.53%)
Mutual labels:  filter, effect
DissolveEffectForTMPro
DissolveEffectForTMPro provide dissolve effect component for TextMeshPro in Unity.
Stars: ✭ 86 (-24.56%)
Mutual labels:  shader, effect
Unity Grabsquares Effect
Unity GrabSquares Effect
Stars: ✭ 39 (-65.79%)
Mutual labels:  shader, effect
URP-Sun-Shafts
A URP port of Unity's classic Standard Assets Effects package's Sun Shaft effect
Stars: ✭ 36 (-68.42%)
Mutual labels:  shader, effect
Uieffect
UIEffect is an effect component for uGUI element in Unity. Let's decorate your UI with effects!
Stars: ✭ 3,449 (+2925.44%)
Mutual labels:  shader, effect
Kinobinary
Binary image effect for Unity
Stars: ✭ 180 (+57.89%)
Mutual labels:  shader, effect
Kinobloom
Bloom effect for Unity
Stars: ✭ 704 (+517.54%)
Mutual labels:  shader, effect
Hologramshader
✏️ Test of an hologram material made in Unity.
Stars: ✭ 684 (+500%)
Mutual labels:  shader, effect
FunFilter
Freely painted area, the software will automatically add filter on its.
Stars: ✭ 15 (-86.84%)
Mutual labels:  filter, effect
X Postprocessing Library
Unity Post Processing Stack Library | Unity引擎的高品质后处理库
Stars: ✭ 1,079 (+846.49%)
Mutual labels:  shader, effect
sparkar-pixelate-shader
simple script-only pixelate shader with Facebook SparkAR.
Stars: ✭ 35 (-69.3%)
Mutual labels:  filter, shader
DissolveEffectForUGUI
A dissolve effect for uGUI, without material instancing. Please star and watch this project :)
Stars: ✭ 67 (-41.23%)
Mutual labels:  shader, effect
Shinyeffectforugui
Shiny effect of uGUI, which does not need mask or normal map.
Stars: ✭ 204 (+78.95%)
Mutual labels:  shader, effect
image-editor-effects
💎 A WebGL example of image adjustment / effects shaders found in Photoshop, other image editors and game engines.
Stars: ✭ 68 (-40.35%)
Mutual labels:  filter, shader
Ezfilter
A lightweight (<180KB), easy-to-extend Android filter and dynamic sticker framework for adding filters and stickers for camera, video, bitmap and view.(一个轻量级(<180KB)、易扩展的Android滤镜和动态贴纸框架,支持摄像头、视频、图片和视图添加滤镜和贴纸。)
Stars: ✭ 155 (+35.96%)
Mutual labels:  shader, filter
Computestochasticreflections
Compute Stochastic Screen Space Reflections for unity post processing
Stars: ✭ 163 (+42.98%)
Mutual labels:  shader, effect
Unity Frosted Glass
❄️ Test of a frosted glass material in Unity.
Stars: ✭ 506 (+343.86%)
Mutual labels:  shader, effect
React Native Gpuimage
GPUImage Component in React Native
Stars: ✭ 45 (-60.53%)
Mutual labels:  shader, filter

PostFX for Processing Build Status Build status codebeat badge

A simple post effects library for processing.

Introduction

PostFX is a simple post effects library for processing. Post effects are applied to the whole scene after it was rendered, to enhance the scene with some special effects. For example the bloom effect helps to simulate the light diffusion to be more realistic.

PFX Example

Example of the post effects sobel, bloom and toon.

Why did I implement it?

There are a lot of tutorials which help you to implement a bloom filter in OpenGL (e.g. Learn OpenGL - Bloom). But for processing I could not find one that is as performant as I needed in my P3D renderings.

So I started to implement a simple but fast library to run post effects on P2D and P3D graphics objects.

What is included?

Here you find two examples which are based on the Lenna and Lichtenstein test images:

Lenna Effect

Lenna Effect

The PostFX library currently contains following built in effects:

  • bright pass
  • blur horizontal
  • blur vertical
  • sobel edge detection
  • toon filter

Version 1.1 adds a lot of new shaders:

Color

  • Brightness and Contrast Shader
  • Saturation and Vibrance Shader
  • Invert Shader
  • Grayscale Shader

Reconstruction

  • Denoise Shader

Effects

  • Bloom Shader
  • Pixelate Shader
  • Chromatic aberration shader
  • Noise Shader
  • Vignette Shader
  • RGB Split Shader

And there is also a method to run your own custom shaders.

Some of the shaders are from the spite/Wagner respoitory and only adapted to work in processing.

Example

There are two API's to use the PostFX library. The basic one is very easy and removes responsibility of the pass management. The advanced way is, where you have to create pass instances yourself, but have the freedom to manage them by your own.

Custom shaders are supported, in the basic and the advanced version.

Setup

To use the library you have to install it over the processing contribution manager.

Contribution Manager

Import following packages to use all classes of the PostFX library.

import ch.bildspur.postfx.builder.*;
import ch.bildspur.postfx.pass.*;
import ch.bildspur.postfx.*;

Use the library on every PGraphics3D or PGraphics2D object or even on the screen object (g).

Basic Example

To add a post effect to your processing sketch, you just have to create a new PostFX object.

PostFX fx;

void setup()
{
  size(500, 500, P3D);
  
  fx = new PostFX(this);  
}

Now you have to call the render() method of the PostFX library. This returns an object, on which you can call all implemented effects.

void draw()
{
  // draw something onto the screen
  background(22);
  box(100);

  // add bloom filter
  fx.render()
    .bloom(0.5, 20, 40)
    .compose();
}

Finally you can use compose() to draw it onto the main screen (g object). It is also possible to compose to onto another Graphics2D object.

Based on SimpleEffect example

Off-Screen Buffer

To add a post effect onto a off-screen graphics object, you have to create a new graphics object (canvas). To use the basic version of the API, instantiate a new PostFX object.

PostFX fx;
PGraphics canvas;

void setup()
{
  size(500, 500, P2D);
  
  fx = new PostFX(this);  
  canvas = createGraphics(width, height, P3D);
}

Now you have to draw onto your canvas and after rendering, you just pass the canvas into the render() method of the PostFX library. This returns an object, on which you can call all implemented effects.

void draw()
{
  canvas.beginDraw();
  // draw something onto the canvas
  canvas.endDraw();
  
  blendMode(BLEND);
  image(canvas, 0, 0);

  // add bloom filter
  blendMode(SCREEN);
  fx.render(canvas)
    .brightPass(0.5)
    .blur(20, 50)
    .compose();
}

Finally you can use compose() to draw it onto the main screen (g object). It is also possible to compose to onto another Graphics2D object.

Based on OffScreenEffect example

Pass Preloading

For performance reasons it is sometimes necessary to preload the pass and compile the shaders before you use it. For this problem, there is the method preloadPass.

To preload a pass you have to call the method and pass the class type as argument.

void setup()
{
  size(500, 500, P3D);

  fx = new PostFX(this);

  // compile shaders in setup
  fx.preload(BloomPass.class);
  fx.preload(RGBSplitPass.class);
}

Everything else works like usual, but you have now compiled your shaders in the setup() method and not in the time critical draw() method.

Based on PassPreloading example

Advanced

The advanced version is used as the underlaying layer of the basic API. It does not create the pass objects itself, but gives the freedom to manage them by your own.

Instead of an PostFX class you have to create a new PostFXSupervisor which handles all the pass buffers. For each pass, you have to create a pass object, which contains the implementation and the parameters.

It is possible to use the same pass object twice, with different parameter settings.

PostFXSupervisor supervisor;
BrightPass brightPass;
SobelPass sobelPass;

PGraphics canvas;

void setup()
{
  size(500, 500, P2D);

  // create supervisor and load shaders
  supervisor = new PostFXSupervisor(this);
  brightPass = new BrightPass(this, 0.3f);
  sobelPass = new SobelPass(this); 

  canvas = createGraphics(width, height, P3D);
}

To render the effects onto the canvas, you have to call the render() method on the supervisor and pass all the passes.

void draw()
{
  // draw a simple rotating cube around a sphere
  canvas.beginDraw();
  // draw something onto the canvas
  canvas.endDraw();

  blendMode(BLEND);
  image(canvas, 0, 0);

  // add white ring around sphere
  blendMode(SCREEN);
  supervisor.render(canvas);
  supervisor.pass(brightPass);
  supervisor.pass(sobelPass);
  supervisor.compose();
}

Finally, the compose() method draws the scene onto the main screen. It is possible to draw the result onto another another Graphics2D object.

Based on AdvancedEffect example

Custom Shader

This tutorial shows how to create a negate pass.

To add a custom shader as pass, you have to create a new class which implements the Pass interface.

class NegatePass implements Pass
{
  PShader shader;

  public NegatePass()
  {
    shader = loadShader("negateFrag.glsl");
  }

  @Override
    public void prepare(Supervisor supervisor) {
    // set parameters of the shader if needed
  }

  @Override
    public void apply(Supervisor supervisor) {
    PGraphics pass = supervisor.getNextPass();
    supervisor.clearPass(pass);

    pass.beginDraw();
    pass.shader(shader);
    pass.image(supervisor.getCurrentPass(), 0, 0);
    pass.endDraw();
  }
}

The shader for this example is very simple and just calculates one minus the color value.

#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

uniform sampler2D texture;

varying vec4 vertColor;
varying vec4 vertTexCoord;

void main() {
    vec4 c = texture2D(texture, vertTexCoord.st) * vertColor;
    c.xyz = 1.0 - c.xyz;
    gl_FragColor = c;
}

To use the shader, you have to create a new instance of it and then add it as pass:

// in setup
NegatePass negatePass = new NegatePass();

// in draw
supervisor.render(canvas);
supervisor.pass(negatePass);
supervisor.compose();

Based on CustomShaderEffect example

Custom Shader Builder Pattern

With version 1.1 it is now also possible to add a custom shader directly to the builder pattern, which simplifies the whole process:

// in setup
NegatePass negatePass = new NegatePass();

// in draw
fx.render()
  .custom(negatePass)
  .compose();

About

Developed by Florian Bruggisser (bildspur.ch) 2017

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].