[BUG - WebGL] Wrapping a float in a ternary operator leads to wrong image being produced

Bug report and files:


We have an original shader, which we have slightly changed in a semantics-preserving manner. Line:

vec3 p3 = from + (s3 + zoffset) * dir / (0.500 / 0.5);


vec3 p3 = from + (s3 + zoffset) * dir / (0.500 / (injectionSwitch.x > injectionSwitch.y ? 0.5 : 0.5));

This small change causes the background to be more blue compared to the original. What is interesting in this case is that the value of injectionSwitch should not matter, as the ternary expression will always evaluate to the same value. Tested using Chrome and Firefox.

  1. Operating system version.
    Ubuntu 14.04

  2. Graphics hardware.
    GK110 (GeForce GTX Titan), driver version 370.28

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

  4. 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)”.

  5. Description of the expected result.
    Image rendered visually identical to original image.