I know GLSL is riddled with bugs and caveats, but it seems like there is a straightforward bug with the shader compiler in babylon around handling of single line comments. Reproduction:
In all of these, there is syntax error caused by the commented out line. Delete that commented line before the return, and then no error. Also, changing to a multiline comment (with /*... */) resolves.
It seems as if the compiler is trying to parse out the for loop even if itās commented.
Looking at the code in the console, it looks like each semicolon in the single-line comment is causing a line break: what comes after the semicolon is on a new line which isnāt commented outā¦
// This will stay commented out;this will be on the next line
// First line;second line;third line
This got more complicated. I think Iāve discovered three issues that are semi-related. The PR now only addresses the first one.
Having semi-colons in single line comments breaks things. The PR addresses this and hopefully the CI shows no issues this time.
Multiline macro definitions have a similar issue with semicolons.
Single line comments are not always parsed correctly. For instance, using single line comments on a multi-line macro can still cause processor errors on commented code.
I think addressing (3) requires a better understanding of the processing than what I currently have (or have time for). I would think that whatever parses out multiline comments, should also handle single line comments. I havenāt found where that it is yet though. Fixing that might negate need for the change I made in this PR.
Addressing (2) might be more difficult, and maybe not worthwhile. I suspect multiline macros are used rarely, and even less with statements containing semi-colons. I think to fix would require explicit checks for #define state and \ terminators.
Here is a PG that can be used to show all three issues. In the currrent PG (before this PR is merged), it will error unless the line with the commented for loop is removed. Modifying to see the other two issues is explained in comments: