My project involves utilizing Three.js r58 (with the WebGLRenderer) to display a 3D model of a building with detailed information about the positions and dim levels of the lights inside.
For each light sourced from the database, I create a CubeGeometry object (to represent the physical light) and a SpotLight (to simulate the light output). Here is the code snippet:
// 'this' refers to an existing custom object retrieved from the database - all code within it is functional
var geometry = new THREE.CubeGeometry(4.8, 0.6, 1.36);
var material = new THREE.MeshBasicMaterial({color:0x444444, vertexColors:THREE.FaceColors});
this.objectMesh = new THREE.Mesh(geometry, material);
this.objectMesh.position.set(0, 20, 0);
scene.add(this.objectMesh);
this.lightEmitter = new THREE.SpotLight(0xffffff, 0, 22, true);
this.lightEmitter.position.set(this.objectMesh.position.x, this.objectMesh.position.y - (this.objectMesh.geometry.height / 10), this.objectMesh.position.z);
this.lightEmitter.rotation.set(this.objectMesh.rotation.x, this.objectMesh.rotation.y, this.objectMesh.rotation.z)
this.lightEmitter.target.position.set(this.objectMesh.position.x, 0, this.objectMesh.position.z);
this.lightEmitter.angle = 0.9;
scene.add(this.lightEmitter);
Initially, everything was functioning well with up to 37 lights in the scene. However, upon adding the 38th light, I encountered the following error:
Could not initialise shader
VALIDATE_STATUS: false, gl error [1285]
This issue arose across Firefox and Chrome on a Windows 7 PC with a GeForce GTX 650, as well as Firefox on an Ubuntu laptop. Additionally, Chrome on an Android Nexus 7 displayed another error:
(0): error C6007: Constant register limit exceeded; more than 256 constant registers needed to compile program
50 lines, 1 errors
. I'm uncertain if these are related.
When I replaced the building model with a flat plane, I encountered the ERROR: too many uniforms
message with 38 lights, while 37 worked fine. Disabling shadows for lights and objects did not resolve the issue.
Is this due to hardware or OpenGL/WebGL limitations from displaying numerous lights in the scene? If not, any insights into what could be causing this problem would be appreciated.