• help with shader on emescripten

    From Alessio Mochi@21:1/5 to All on Fri Mar 12 07:55:55 2021
    Hello,
    i am trying to compile on emscripten the wireframe shader
    // vertex shader
    const char * strVertexShader =
    "precision mediump float;"
    "attribute vec4 aPosition;"
    "attribute vec4 aColor;"
    "attribute vec4 aNormal;"
    "attribute vec3 a_barycentric;"
    "uniform mat4 uNormalMatrix;"
    "uniform mat4 uMvpMatrix;"
    "uniform vec3 uLightColor;"
    "uniform vec3 uLightDirection;"
    "uniform bool uActiveColorPerMesh;"
    "uniform vec4 uColorPerMesh;"
    "varying vec4 vColor;"
    "varying vec3 vbc;"
    "void main() {"
    "vbc = a_barycentric;"
    "gl_Position = uMvpMatrix * aPosition;"
    "vec3 normal = normalize(vec3(uNormalMatrix * aNormal));"
    "float nDotL = max(dot(uLightDirection, normal), 0.0);"
    "vec3 diffuse = vec3(0, 0, 0);"
    "if (!uActiveColorPerMesh) { diffuse = uLightColor * aColor.rgb * nDotL; }"
    "else { diffuse = uColorPerMesh.rgb * aColor.rgb * nDotL; }"
    "vColor = vec4(diffuse, aColor.a);"
    "}";


    // fragment shader
    const char *fsCode =
    "precision mediump float;"
    "varying vec4 vColor;"
    "varying vec3 vbc;"
    "const float lineWidth = 0.5;"
    "float edgeFactor() {"
    "vec3 d = fwidth(vbc);"
    "vec3 f = step(d * lineWidth, vbc);"
    "return min(min(f.x, f.y), f.z);"
    "}"

    "void main() {"
    "gl_FragColor =vec4(min(vec3(edgeFactor()), vColor.xyz), 1.0);"
    "}";

    On the desktop with qt shader compile correctly but when I try to compile on emscripten I get one error on the fragment shader

    "Shader_29:
    main.js:1 ------------------------------------------
    main.js:1 No compiled fragment shader when at least one graphics shader is attached.
    "
    I use the canvas and rendering call directly from emscripten. Thanks in advance.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)