Three.js: Individual renderer collector objects

Created on 12 Sep 2016  路  5Comments  路  Source: mrdoob/three.js

I am thinking in the next NodeMaterial update create refractions materials and possible probe lights. I am plan starting with an individual renderer collector objects, maybe a THREE.FrustumObjectCollector? like how:

this.collector = new THREE.FrustumObjectCollector();
this.collector.sortObjects = true;
//...
this.collector.projectObject( scene, camera );
//...
renderObjects( this.collector.opaqueObjects );
renderObjects( this.collector.transparentObjects );

This can optimize Post-Processing too since transparentObjects and opaqueObjects list can be shared in others renderer call using a shared collector like how:

var collector = new THREE.FrustumObjectCollector();
collector.projectObject( scene, camera );
//...
// this.render = function ( scene, camera, renderTarget, forceClear, collector ) {
renderer.render( scene, camera, texture, false, collector );
//...
renderer.render( scene, camera, texture, false, collector );

I could create a RTT only with opaque objects to pre-generate the cubes to probe lights like how:

cubeCamera.enableTransparents = false;
cubeCamera.updateCubeMap( renderer, scene );

//... ( inside CubeCamera.js )
var enableTransparents = renderer.collector.enableTransparents ;
renderer.collector.enabledTransparents = this.enableTransparents;
//... render all targets
renderer.render( scene, cameraPX, renderTarget );
//...
//... returns to default value
renderer.collector.enableTransparents = enableTransparents;
Three.js version
  • [x] Dev

Most helpful comment

Have you thought of using Object3D.layers to determine the objects that are used in the RTT pass?

that is: set all the objects you want to process in the RTT to be in one layer, which is matched by the layer mask in the cameraPX. I have done something like this, and it works with three.js without modification, also allows much more flexibility that just transparent/non transparent.

All 5 comments

Something like #9545?

Have you thought of using Object3D.layers to determine the objects that are used in the RTT pass?

that is: set all the objects you want to process in the RTT to be in one layer, which is matched by the layer mask in the cameraPX. I have done something like this, and it works with three.js without modification, also allows much more flexibility that just transparent/non transparent.

Thanks! I did not know the Layers, this is very good. Maybe it solves in Material.layers because a possible problem of MultiMaterial in same Mesh and facilitate to share materials.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings