HTML5: Unicode characters in the shader

  1. Add any Unicode character to the FP or VP shader (for example, add comment “// Привет!”) and it will not work in HTML5. Errors from the Chrome 72.0.3626.121 console:

WebGL: INVALID_VALUE: shaderSource: string not ASCII
WARNING:GRAPHICS: ERROR: 0:? : ‘’ : syntax error

I tried to find the cause of the error in the generated asm.js code. I found that because of the character length in Unicode, extra characters are added to the shader code:

function _glShaderSource(shader, count, string, length) {
    var source = GL.getSource(shader, count, string, length);
    // ^^^ variable "source" will contain random characters from memory at the end.
    GLctx.shaderSource(GL.shaders[shader], source)
}
  1. It would be great if Defold could check errors in HTML5 debug build and output the invalid shader code.
1 Like

It does if you bundle with bob as far as I know.

Html5 build and rum is rum through Bob.

2 Likes

Yarr!

6 Likes

Demo
Sources

2 Likes