Is it possible to compose several fragment shaders in sequence under GLSL ES? I want to use two shaders S1 and S2 where S2 uses several fragments output by S1. For example, I’d like to apply two convolutions in sequence, in which case the second convolution needs access to the output of the first convolution at a bunch of pixel locations.
Share
Yes, however this requires the use of one of two techniques.
The first an easiest is called multi-pass rendering.
In it you render the results of S1 to a texture then render S2 reading from the texture that holds the results of S1. However this is a bit inefficient as it removes some of the parallelism that is possible with a GPU. So it is often recommended that you use something called pipeling. This is a bit more complicated.
This results in multiple iterations being computed at the same time. However each iteration is finished after N iterations.