问题
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