Browse Source

Fix rendering of objects without morph target influences with morph materials

When using a material that has morph target support, we need to supply
morph target weights, and - crucially, as of r111 - base target weight.

Before r111, using a material with morph targets and an object without
morph target influences resulted in us not setting up morph weights
which in most cases would result in rendering the object normally.

After r111, in this situation we'd accidentally use default (0) base
influence which resulted in object not rendering at all.

This change now calls morph target update if the material needs morph
target setup; the update method sets up dummy weights (1 base and 0
for each target) to make sure the shader outputs the value of the base
attribute only.
Arseny Kapoulkine 5 years ago
parent
commit
7571d2f2a8
2 changed files with 10 additions and 1 deletions
  1. 1 1
      src/renderers/WebGLRenderer.js
  2. 9 0
      src/renderers/webgl/WebGLMorphtargets.js

+ 1 - 1
src/renderers/WebGLRenderer.js

@@ -727,7 +727,7 @@ function WebGLRenderer( parameters ) {
 
 		}
 
-		if ( object.morphTargetInfluences ) {
+		if ( material.morphTargets || material.morphNormals ) {
 
 			morphtargets.update( object, geometry, material, program );
 

+ 9 - 0
src/renderers/webgl/WebGLMorphtargets.js

@@ -12,11 +12,20 @@ function WebGLMorphtargets( gl ) {
 
 	var influencesList = {};
 	var morphInfluences = new Float32Array( 8 );
+	var morphInfluencesZero = new Float32Array( 8 );
 
 	function update( object, geometry, material, program ) {
 
 		var objectInfluences = object.morphTargetInfluences;
 
+		if ( objectInfluences === undefined ) {
+
+			program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', 1.0 );
+			program.getUniforms().setValue( gl, 'morphTargetInfluences', morphInfluencesZero );
+			return;
+
+		}
+
 		var length = objectInfluences.length;
 
 		var influences = influencesList[ geometry.id ];