Skip to content

Commit

Permalink
Merge pull request cedricpinson#975 from cedricpinson/morph-negative-…
Browse files Browse the repository at this point in the history
…normalization

Fixes normalization of morph weights
  • Loading branch information
cedricpinson authored Apr 27, 2018
2 parents 5515bd6 + e41041b commit 243dcd1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sources/osgShader/CompilerVertex.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,14 @@ var CompilerVertex = {

nWeights = this.createVariable('vec4', 'nTargetWeights');

var str = '%output = abs(%wts)\n;';
str += '%output = %wts / max(1.0, %output.x + %output.y + %output.z + %output.w);';
// alternative version that could handle negative weights as well
// var str = '%output = %wts / max(1.0, abs(%wts.x + %wts.y + %wts.z + %wts.w));';

// normalize weights to avoid negative weight for base normal/tangent
this.getNode('InlineCode')
.code('%output = %wts / max(1.0, %wts[0] + %wts[1] + %wts[2] + %wts[3]);')
.code(str)
.inputs({ wts: targetWeights })
.outputs({ output: nWeights });

Expand Down

0 comments on commit 243dcd1

Please sign in to comment.