I’m doing some testing with GLSL 3.0 and three.js and I would like to know your opinion about how to deal with the future WebGL2 renderer with regards to the current WebGL1 shaders.
I’ve been thinking in the possible approaches:
- Have an specific 3.0 version of each shader.
- Include some tokens that can be automatically replaced with the differences between the two versions depending on the current WebGL version. Similar to what playcanvas is using (https://github.com/playcanvas/engine/blob/master/src/graphics/chunks.js#L66-L69).
- Include some kind of postprocessing of the whole shader like https://github.com/Jam3/glsl-100-to-300 so this could help also converting users’s WebGL1 shaders.
Probably the second option is the low hanging fruit here, and it’s actually the one I’m following on my experiments, as it won’t need much code to modify and it should works just out of the box. Things could get more complicated as long as we’ll start using specific WebGL2 features like for Uniform Buffer Objects.
Does anyone has an strong opinion here why we should choose one or another?