
188 11. Performance and Rendering Algorithms in Blend4Web
We needed a parser, which was generated using the PEG.js* generator on the basis
of the preprocessor directives grammar. is parser produces an abstract syntax tree
(AST)—a JavaScript object containing GLSL and preprocessor tokens. en, the analysis
of this object is performed in order to substitute the macro values, which saves us the
necessity to specify the #define directives. At the next stage, the shader text code is cre-
ated from theAST. When an #include directive is met, the AST from the corresponding
include le is simply inserted into the current tree. Finally, the shader i ...