glTF-Sample-Viewer icon indicating copy to clipboard operation
glTF-Sample-Viewer copied to clipboard

Live Sample-Viewer throws Uncaught TypeError

Open cx20 opened this issue 5 years ago • 3 comments

I tried the latest version of glTF-Sample-Viewer. However, it seems that I get an error on certain models.

Reproduction procedure:

  1. Access the following URL http://gltf.ux3d.io/
  2. Select Toy Car as the model
  3. Select Display menu
  4. Turn off Image Based The following error is displayed on the console.
renderer.js:395 
Uncaught TypeError: Failed to execute 'uniform1i' on 'WebGL2RenderingContext': parameter 1 is not of type 'WebGLUniformLocation'.
    at gltfRenderer.drawPrimitive (renderer.js:395)
    at gltfRenderer.drawScene (renderer.js:240)
    at GltfView.renderFrameToCanvas (gltf_view.js:44)
    at update (gltf_view.js:128)

cx20 avatar Jan 20 '21 09:01 cx20

In pbr.frag and moving the transmission code out of the USE_IBL fixes the problem. @UX3D-kanzler @UX3D-becher Is this fix feasible and save?

    // Calculate lighting contribution from image based lighting source (IBL)
#ifdef USE_IBL
    f_specular += getIBLRadianceGGX(n, v, materialInfo.perceptualRoughness, materialInfo.f0);
    f_diffuse += getIBLRadianceLambertian(n, materialInfo.albedoColor);

    #ifdef MATERIAL_CLEARCOAT
        f_clearcoat += getIBLRadianceGGX(materialInfo.clearcoatNormal, v, materialInfo.clearcoatRoughness, materialInfo.clearcoatF0);
    #endif

    #ifdef MATERIAL_SHEEN
        f_sheen += getIBLRadianceCharlie(n, v, materialInfo.sheenRoughnessFactor, materialInfo.sheenColorFactor);
    #endif


#endif
#ifdef MATERIAL_TRANSMISSION
	vec2 normalizedFragCoord = vec2(0.0,0.0);
	normalizedFragCoord.x = gl_FragCoord.x/float(u_ScreenSize.x);
	normalizedFragCoord.y = gl_FragCoord.y/float(u_ScreenSize.y);

	f_transmission += materialInfo.transmissionFactor * getIBLRadianceTransmission(n, u_Camera - v_Position, normalizedFragCoord, materialInfo.perceptualRoughness, materialInfo.baseColor, materialInfo.f0, materialInfo.f90);
#endif

UX3D-nopper avatar Jan 20 '21 10:01 UX3D-nopper

This is fixed in the latest version of our release/alpha branch. http://gltf.ux3d.io/ is already updated.

UX3D-kanzler avatar Jan 20 '21 14:01 UX3D-kanzler

Thank you for the quick fix. I have confirmed that it has been fixed.

cx20 avatar Jan 20 '21 14:01 cx20