"Hybrid Graph" GLSL shader editor tech preview for Babylon

@Evgeni_Popov Thank you, that makes sense.

This tool takes a full Babylon material’s GLSL, and parses it into an AST, and marks parts of that AST as replaceable with any other GLSL expression. For example, it says “you can replace any texture lookups,” so vec4 albedoTexture=texture(albedoSampler,vAlbedoUV+uvOffset); can be replaced with vec4 albedoTexture=other_main_fn();

The parsing operation is moderately expensive (seconds, not milliseconds) since it’s basically the front-end to a compiler. One way I’m looking at speeding this up is pre-compiling shaders/GLSL so that on first scene load, it just dumps in the saved GLSL without doing any compilation.

But as you’ve pointed out, Babylon generates shader code more on-demand, based on the features available in the browser. Does Babylon do anything like shader precompilation today? Do you have any suggestions for how to think about this problem from a Babylon perspective? For example, are there a known number of combinations of potential shader features, and I could precompile the variations ahead of time? Or any other creative ideas?

No, we can’t do precompilation, because the end result will depend on the OS the browser is running. So the compilation step is out of our hands.

Even pre-generating the glsl is not really possible, there are too many combinations: there are basically as many combinations as the number of combinations of all the different defines + their values of a material.