Having numerous Reflectors in a scene: How to implement a clone() function?

坚强是说给别人听的谎言 提交于 2021-01-27 18:01:22

问题


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.


回答1:


I need about 80 (moving) reflecting ShapeBufferGeometry in a scene and i want them to share as much material data as possible.

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.

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.



来源:https://stackoverflow.com/questions/65425811/having-numerous-reflectors-in-a-scene-how-to-implement-a-clone-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!