Shadertoy: how to use multipass shaders


(Frédéric Devernay) #1

OK, I promised this one.
I implemented as PyPlugs, and pushed to natron-plugins:

The principle is very simple: since multipass cannot be done using a single Shadertoy, use several Shadertoy nodes, route the textures between them, and link the parameters.

In the natron-plugins repo (https://github.com/NatronGitHub/natron-plugins/tree/master/GLSL/Blur/BokehCircular_GL and https://github.com/NatronGitHub/natron-plugins/tree/master/GLSL/Blur/BokehOctagon_GL) I also put the individual shader sources for each Shadertoy, as well as the original shader sources from shadertoy.com. You can learn from these two examples.

The only multipass effects that can not be implemented are the shaders that read back the content of a buffer to compute that same buffer, because compositing graphs cannot have loops (the execution of such a graph would cause an infinite recursion). One example is https://www.shadertoy.com/view/MttSWS