Skip to content

Commit c8daade

Browse files
authored
MorphNode: Improve performance (#30742)
1 parent fcae5a2 commit c8daade

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

src/nodes/accessors/MorphNode.js

+26-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Node from '../core/Node.js';
22
import { NodeUpdateType } from '../core/constants.js';
3-
import { float, nodeProxy, Fn, ivec2, int } from '../tsl/TSLBase.js';
3+
import { float, nodeProxy, Fn, ivec2, int, If } from '../tsl/TSLBase.js';
44
import { uniform } from '../core/UniformNode.js';
55
import { reference } from './ReferenceNode.js';
66
import { positionLocal } from './Position.js';
@@ -24,7 +24,7 @@ const getMorph = /*@__PURE__*/ Fn( ( { bufferMap, influence, stride, width, dept
2424
const y = texelIndex.div( width );
2525
const x = texelIndex.sub( y.mul( width ) );
2626

27-
const bufferAttrib = textureLoad( bufferMap, ivec2( x, y ) ).depth( depth );
27+
const bufferAttrib = textureLoad( bufferMap, ivec2( x, y ) ).depth( depth ).xyz;
2828

2929
return bufferAttrib.mul( influence );
3030

@@ -240,31 +240,35 @@ class MorphNode extends Node {
240240

241241
}
242242

243-
if ( hasMorphPosition === true ) {
243+
If( influence.notEqual( 0 ), () => {
244244

245-
positionLocal.addAssign( getMorph( {
246-
bufferMap,
247-
influence,
248-
stride,
249-
width,
250-
depth: i,
251-
offset: int( 0 )
252-
} ) );
245+
if ( hasMorphPosition === true ) {
253246

254-
}
247+
positionLocal.addAssign( getMorph( {
248+
bufferMap,
249+
influence,
250+
stride,
251+
width,
252+
depth: i,
253+
offset: int( 0 )
254+
} ) );
255+
256+
}
255257

256-
if ( hasMorphNormals === true ) {
258+
if ( hasMorphNormals === true ) {
257259

258-
normalLocal.addAssign( getMorph( {
259-
bufferMap,
260-
influence,
261-
stride,
262-
width,
263-
depth: i,
264-
offset: int( 1 )
265-
} ) );
260+
normalLocal.addAssign( getMorph( {
261+
bufferMap,
262+
influence,
263+
stride,
264+
width,
265+
depth: i,
266+
offset: int( 1 )
267+
} ) );
266268

267-
}
269+
}
270+
271+
} );
268272

269273
} );
270274

0 commit comments

Comments
 (0)