Hi,
I know this is old, but I’m also getting an error that seems to originate from the lights_physical_fragment include. This code:
const SIZE = 4;
const RESOLUTION = 256;
// console.log(THREE.ShaderChunk.meshphysical_vert);
// console.log(THREE.ShaderChunk.meshphysical_frag);
const geometry = new THREE.PlaneGeometry(SIZE, SIZE, RESOLUTION, RESOLUTION);
const uniforms = {
...THREE.ShaderLib.physical.uniforms,
diffuse: { value: "#5B82A6" },
roughness: { value: 0.5 },
amplitude: { value: 0.4},
frequency: { value: 0.5 },
speed: { value: 0.3 },
time: { value: 1.0 }
};
const material = new THREE.ShaderMaterial({
uniforms: uniforms,
vertexShader: THREE.ShaderChunk.meshphysical_vert,
fragmentShader: THREE.ShaderChunk.meshphysical_frag,
lights: true,
side: THREE.DoubleSide,
defines: {
STANDARD: '',
PHYSICAL: '',
},
extensions: {
derivatives: true,
},
});
const plane = new THREE.Mesh(geometry, material);
plane.rotation.x = -(Math.PI / 2);
// Place objects
scene.add(plane);
… results in this error:
// Uncaught TypeError:
// WebGL2RenderingContext.uniform3fv:
// Argument 2 could not be converted to any of: Float32Array, sequence<unrestricted float>.
// setValueV3f three.module.js:18471
// upload three.module.js:19376
// setProgram three.module.js:31008
// renderBufferDirect three.module.js:29615
// renderObject three.module.js:30492
// renderObjects three.module.js:30461
// renderScene three.module.js:30310
// render three.module.js:30128
// ...
Additionally, if I copy the contents of THREE.ShaderChunk.meshphysical_frag and comment out “#include <lights_physical_fragment>”, I see another error caused by “#include <lights_fragment_end>”…
// SHADER_INFO_LOG:
// ERROR: 0:1764: 'material' : undeclared identifier
// ERROR: 0:1764: 'RE_IndirectDiffuse_Physical' : no matching overloaded function found
// ERROR: 0:1767: 'material' : undeclared identifier
// ERROR: 0:1767: 'RE_IndirectSpecular_Physical' : no matching overloaded function found
//
// FRAGMENT
//
// ERROR: 0:1764: 'material' : undeclared identifier
// ERROR: 0:1764: 'RE_IndirectDiffuse_Physical' : no matching overloaded function found
// ERROR: 0:1767: 'material' : undeclared identifier
// ERROR: 0:1767: 'RE_IndirectSpecular_Physical' : no matching overloaded function found
//
// 1759: #ifdef USE_CLEARCOAT
// 1760: clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
// 1761: #endif
// 1762: #endif
// 1763: #if defined( RE_IndirectDiffuse )
// > 1764: RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
// 1765: #endif
// 1766: #if defined( RE_IndirectSpecular )
// 1767: RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
// 1768: #endif
// 1769: // #include <aomap_fragment>
// 1770: // vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; three.module.js:20346:13
// onFirstUse (js stack)
// ...
// ...