问题描述
我需要大约 80 个(移动)反映场景中的 ShapeBufferGeometry
,我希望它们共享尽可能多的材质数据.
显然,clone()
方法不适用于 Reflector
.
我得到了不反射任何东西的黑色几何图形.
尝试将 clone()
方法添加到 prototype
中,如下所示,结果根本看不到结果:
I need about 80 (moving) reflecting ShapeBufferGeometry
in a scene and i want them to share as much material data as possible.
Apparently, the clone()
method doesn't work with Reflector
.
I get black geometries that don't reflect anything.
Tried to add a clone()
method to the prototype
as below, resulting in no visible result at all:
// Clone function for Reflector
Reflector.prototype.clone = function() {
return new Reflector( this.geometry, this.options );
}
这将如何运作?可以在多个对象之间共享一个反射器吗?
谢谢.
How would this work? Can share a Reflector among many objects?
Thanks.
推荐答案
请注意,Reflector
的每个实例都使用单独的渲染通道渲染其环境.我非常怀疑场景中的 80 个反射器是否会产生可用的性能.
Please be aware that each instance of Reflector
renders its environment with a separate render pass. I highly doubt that 80 reflectors in a scene are going to produce a usable performance.
此外,Reflector
不是为共享材料而设计的.clone()
方法不能在不重构Reflector
的实现的情况下实现.clone()
方法的目的无论如何都是有问题的,因为你的场景中只能有少量的镜子.所有这些都必须维护唯一的统一数据.渲染器将自动确保在具有兼容材质设置的材质之间共享着色器程序.因此,即使许多对象具有独特的材质对象,也不应该有明显的性能下降.
Besides, Reflector
is not designed for sharing materials. A clone()
method can't be implement without refactoring the implementation of Reflector
. The purpose of a clone()
method is questionable anyway since you can only have a small amount of mirrors in your scene. And all of them have to maintain unique uniform data. The renderer will automatically ensure to share shader programs across materials with compatible material settings. So there should no noticeable performance hit even if many objects have unique material objects.
这篇关于场景中有多个反射器:如何实现 clone() 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!