Git Product home page Git Product logo

filters4processing's Introduction

Filters4Processing

A growing collection of pixel shaders ported to Processing to be used with the filter() function. Most of these shaders come from the excellent Shadertoy by Iñigo Quilez.

Note: This repository focuses on filters. If you want to port any other type of shader from Shadertoy to Processing, check out this other repository Shadertoy2Processing

Filters

Gaussian blur

screenshot

Barrel Blur Chroma

screenshot

Barrel & Pincushion

screenshot

Bicubic Filter

screenshot

Bilateral Filter (denoise)

screenshot

Contrast, Saturation, Brightness

screenshot

Dithering

screenshot

Edge filter

screenshot

Metaballs

screenshot

Droste

screenshot

Usage

This is a minimal example showing how to import a shader file in Processing and use it as a filter.

Note: Some shaders require additional uniforms. For details, refer to the example sketches included.

// Create an image object
PImage  myImage;

// Create a shader object
PShader myFilter;

void setup() {

  size( 512, 512, P2D );

  // Import the image file
  myImage  = loadImage( "texture.jpg" );

  // Import the shader file
  myFilter = loadShader( "shader.glsl" );

  // Pass the size of the window to the shader
  myFilter.set("sketchSize", float(width), float(height));

}

void draw() {

  // Draw the image on the scene
  image( myImage, 0, 0 );

  // Apply the shader to the scene
  filter( myFilter );

}

Notes about porting filters from Shadertoy

Shadertoy and Processing both have their own quirks when it comes to shader programming. We need to make some changes in order to make Shadertoy code work with Processing.

Replace: void mainImage( out vec4 fragColor, in vec2 fragCoord ) -> void main( void )

Replace all:

  • iChannel0 -> texture
  • fragCoord -> gl_FragCoord
  • fragColor -> gl_FragColor

There is more to it than this but these tips should cover most basic filters.

Now go dig for some shaders and help us extend the library of filters available for Processing!

Acknowledgments

Thanks to all the Shadertoy contributors for their hard work. This collection wouldn't exist without them. Thanks to Andres Colubri for his work on the Processing Shader API.

License

All shaders from Shadertoy belong to there respective authors. Unless otherwise specified in the shader file, they are licensed under Creative Commons (CC BY-NC-SA 3.0)

filters4processing's People

Contributors

sableraf avatar monkstone avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.