2-pass shader possible with Processing?

edited June 2016 in GLSL / Shaders

Some of the shadertoy shaders use 2or more passes using the built in buffers, for example https://www.shadertoy.com/view/XsG3z1#. Is it possible to use these buffers from within processing or do they have to be created in the GLSL shader code? If so, any examples I could learn from?

Tagged:

Answers

  • You could apply multiple passes if you use PGraphics, by doing something like this:

    pg1.beginDraw();
    pg1.shader(pass1);
    pg1.rect(0, 0, pg1.width, pg1.heigth);
    pg1.endDraw(); 
    
    pg2.beginDraw();
    pg2.shader(pass2);
    pass2.set("prevOutput", pg1);
    pg2.rect(0, 0, pg2.width, pg2.heigth);
    pg2.endDraw(); 
    

    Here I'm assuming that the prevOutput uniform in pass2 shader is a texture sampler you use to read the output from the previous pass, but not sure if that's the technique used by ShaderToy.

Sign In or Register to comment.