[BUG - WebGL] Wrapping code in ternary operator with macro declaration leads to compilation failure

Bug report and files:


We have a successfully compiling original fragment shader, which we have slightly modified in a semantics-preserving manner. The line:

backCol2 += mix(.4, 1., v2) * vec3(1.8 * t3 * t3 * t3, 1.4 * t3 * t3, t3) * fade;


backCol2 += mix(.4, 1., v2) * vec3((injectionSwitch.x < injectionSwitch.y ? 1.8 * t3 * t3 * t3 : GLF_live1pi), 1.4 * t3 * t3, t3) * fade;

Tested on Chrome and Firefox, verified with glslangValidator. OpenGL renders the image correctly.

Might be related to https://github.com/mc-imperial/shader-compiler-bugs/issues/57, as they both make use of macros.

  1. Operating system version.

Windows 10

  1. Graphics hardware.

GeForce GTX 770. Driver: 373.06

  1. Reproducer project.
    We have provided the fragment shader at the above link.

  2. Description of single steps to reproduce the problem.
    Navigate to http://htmlpreview.github.io/?https://github.com/mc-imperial/shader-compiler-bugs/blob/master/utils/webgl/webgl_viewer.html with the appropriate browser, enter the shader code in the provided text box and click “Start rendering (Execute)”.

  3. Description of the expected result.
    No compilation error.