I am trying to figure out how to do blending modes in WebGL. Until now, I used the native HTML5 Canvas drawing functions, with which you can just do, for instance:
var ctx = new Document.getElementById('canvas').getContext('2d');
ctx.globalCompositeOperation = 'lighter'
Now, I am trying, for performance reasons, to port this to WebGL. However, I have trouble understanding the way I can influence the blending mode in WebGL. As I understood it, a Vertex shader decides what pieces of different textures/polygons are visible, and the fragment shader is then called for each pixel of the visible part of these textures/polygons. However, if I have a blending mode such as lighter (which takes the higher one of each of the components of the underlying colour and the new overlaying colour), I get confused about the role the vertex shader and the fragment shader have in this case.
Even further, in the Pixi.js library I am using to draw with WebGL right now I believe the vertex and fragment shaders are only called after all objects have been drawn to the framebuffer, in other words: only after all objects are placed. (The shaders this library uses can be found here)
Could someone explain how to properly use blending modes in WebGL?