From de9ea46bdfd63eb65b9d0a914cfa1ce3784d0faa Mon Sep 17 00:00:00 2001 From: sunag Date: Sun, 16 Mar 2025 14:27:09 -0300 Subject: [PATCH] improve performance --- src/nodes/accessors/MorphNode.js | 48 +++++++++++++++++--------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/nodes/accessors/MorphNode.js b/src/nodes/accessors/MorphNode.js index 48c925fa6ccc74..c2d7b7922e119d 100644 --- a/src/nodes/accessors/MorphNode.js +++ b/src/nodes/accessors/MorphNode.js @@ -1,6 +1,6 @@ import Node from '../core/Node.js'; import { NodeUpdateType } from '../core/constants.js'; -import { float, nodeProxy, Fn, ivec2, int } from '../tsl/TSLBase.js'; +import { float, nodeProxy, Fn, ivec2, int, If } from '../tsl/TSLBase.js'; import { uniform } from '../core/UniformNode.js'; import { reference } from './ReferenceNode.js'; import { positionLocal } from './Position.js'; @@ -24,7 +24,7 @@ const getMorph = /*@__PURE__*/ Fn( ( { bufferMap, influence, stride, width, dept const y = texelIndex.div( width ); const x = texelIndex.sub( y.mul( width ) ); - const bufferAttrib = textureLoad( bufferMap, ivec2( x, y ) ).depth( depth ); + const bufferAttrib = textureLoad( bufferMap, ivec2( x, y ) ).depth( depth ).xyz; return bufferAttrib.mul( influence ); @@ -240,31 +240,35 @@ class MorphNode extends Node { } - if ( hasMorphPosition === true ) { + If( influence.notEqual( 0 ), () => { - positionLocal.addAssign( getMorph( { - bufferMap, - influence, - stride, - width, - depth: i, - offset: int( 0 ) - } ) ); + if ( hasMorphPosition === true ) { - } + positionLocal.addAssign( getMorph( { + bufferMap, + influence, + stride, + width, + depth: i, + offset: int( 0 ) + } ) ); + + } - if ( hasMorphNormals === true ) { + if ( hasMorphNormals === true ) { - normalLocal.addAssign( getMorph( { - bufferMap, - influence, - stride, - width, - depth: i, - offset: int( 1 ) - } ) ); + normalLocal.addAssign( getMorph( { + bufferMap, + influence, + stride, + width, + depth: i, + offset: int( 1 ) + } ) ); - } + } + + } ); } );