glTF-Sample-Viewer
glTF-Sample-Viewer copied to clipboard
Live Sample-Viewer throws Uncaught TypeError
I tried the latest version of glTF-Sample-Viewer. However, it seems that I get an error on certain models.
Reproduction procedure:
- Access the following URL http://gltf.ux3d.io/
- Select
Toy Caras the model - Select
Displaymenu - Turn off
Image BasedThe 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)
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
This is fixed in the latest version of our release/alpha branch. http://gltf.ux3d.io/ is already updated.
Thank you for the quick fix. I have confirmed that it has been fixed.