首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将超过37个聚光灯添加到场景时出现Three.js错误

问将超过37个聚光灯添加到场景时出现Three.js错误
EN

Stack Overflow用户
提问于 2013-05-31 10:01:48
回答 1查看 821关注 0票数 2

我正在使用Three.js r58 (使用WebGLRenderer)创建一个系统,显示一个建筑物的3D模型,其中包含灯光的实际位置和暗淡程度。

数据库中的每个灯光都由一个CubeGeometry对象(物理灯光)和一个SpotLight (用于显示灯光输出的外观)表示,如下所示:

代码语言:javascript
复制
// 'this' is an existing custom object as populated from the database - all code there is fine
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);

现在,在场景中多达37个灯光的情况下,一切都工作得很好,但只要我添加38号灯光,我就会收到以下错误:Could not initialise shader VALIDATE_STATUS: false, gl error [1285]

在安装了GeForce GTX650的Windows7PC上的火狐和Chrome浏览器中,以及在Ubuntu笔记本电脑上的火狐浏览器中都可以看到这个错误(不确定显卡,但如果需要,可以找到)。在Android Nexus7上的Chrome上,我得到了一个额外的错误:(0) : error C6007: Constant register limit exceeded; more than 256 constant registers needed to compiled program 50 lines, 1 errors -不确定这是否相关。

如果我从场景中删除建筑模型,并在平面上加载,我也会得到:ERROR: too many uniforms有38个灯光,有37个灯光,它正常工作。我也试过阻止灯光和物体投射和接收阴影,但没有帮助。

在场景中渲染这么多灯光是否会遇到硬件和/或OpenGL和/或WebGL限制?如果没有,有没有人知道是什么导致了这个问题?

EN

回答 1

Stack Overflow用户

发布于 2013-05-31 14:35:55

在正向渲染中,OpenGL ES (和WebGL)对中并发启用的灯光数量有限制。这些限制通常是8,所以我很惊讶你会达到37。随着延迟渲染的发生,事情发生了变化,你可以想要多少灯光就有多少灯光。因此,不使用WebGLRenderer,而使用WebGLDeferredRenderer.

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16848691

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档