three.js icon indicating copy to clipboard operation
three.js copied to clipboard

MeshDepthMaterial morph targets

Open MKHenson opened this issue 14 years ago • 2 comments

Hi guys

I am rendering the scene to a depth buffer using the override material method. From what I can see in the source code, the depth material does not allow for morphing or skinning. Is something that could be added?

Alternatively, to successfully render an animated scene, would I need to use the depth plugin? (I've had a quick attempt at using it, but was having quite a few issues setting it up and would rather use the override material method if possible. )

MKHenson avatar Nov 30 '12 12:11 MKHenson

From what I can see in the source code, the depth material does not allow for morphing or skinning.

It does, that's how shadow maps work:

https://github.com/mrdoob/three.js/blob/master/src/extras/renderers/plugins/ShadowMapPlugin.js#L22

Alternatively, to successfully render an animated scene, would I need to use the depth plugin?

That's the main idea behind depth plugin, to simplify management of depth materials.

alteredq avatar Dec 01 '12 13:12 alteredq

Hmm perhaps I'm doing something wrong then. When I add a depth filter to my scene it works well except when there are morphs. It seems to only draw the morph in its default state, unanimated:

Issue

I create the depth material as such:

this.depthMat = new THREE.MeshDepthMaterial( { morphTargets: true, skinning: true } );

...

Then render the scene as such:

//Render the depth
if ( this.depthTarget )
{       
    // Render depth into texture
    this.scene.overrideMaterial = this.depthMat;
    this.renderer.render( this.scene, this.camera, this.depthTarget, true );
}

//Render post processes
this.scene.overrideMaterial = null;
this.composer.render(0.02);

MKHenson avatar Dec 02 '12 21:12 MKHenson