Sfoglia il codice sorgente

TSL: add mat convert (#28890)

* WebGPURenderer: add mat4 to mat3 convert

* WebGPURenderer: add mat4 to mat3 convert
ypy 1 anno fa
parent
commit
dbd5e11b7f

+ 1 - 5
src/nodes/accessors/BatchNode.js

@@ -69,11 +69,7 @@ class BatchNode extends Node {
 			textureLoad( matriceTexture, ivec2( x.add( 3 ), y ) )
 			textureLoad( matriceTexture, ivec2( x.add( 3 ), y ) )
 		);
 		);
 
 
-		const bm = mat3(
-			batchingMatrix[ 0 ].xyz,
-			batchingMatrix[ 1 ].xyz,
-			batchingMatrix[ 2 ].xyz
-		 );
+		const bm = mat3( batchingMatrix );
 
 
 		positionLocal.assign( batchingMatrix.mul( positionLocal ) );
 		positionLocal.assign( batchingMatrix.mul( positionLocal ) );
 
 

+ 1 - 1
src/nodes/accessors/InstanceNode.js

@@ -75,7 +75,7 @@ class InstanceNode extends Node {
 
 
 		// NORMAL
 		// NORMAL
 
 
-		const m = mat3( instanceMatrixNode[ 0 ].xyz, instanceMatrixNode[ 1 ].xyz, instanceMatrixNode[ 2 ].xyz );
+		const m = mat3( instanceMatrixNode );
 
 
 		const transformedNormal = normalLocal.div( vec3( m[ 0 ].dot( m[ 0 ] ), m[ 1 ].dot( m[ 1 ] ), m[ 2 ].dot( m[ 2 ] ) ) );
 		const transformedNormal = normalLocal.div( vec3( m[ 0 ].dot( m[ 0 ] ), m[ 1 ].dot( m[ 1 ] ), m[ 2 ].dot( m[ 2 ] ) ) );
 
 

+ 13 - 0
src/nodes/core/NodeBuilder.js

@@ -1323,6 +1323,19 @@ class NodeBuilder {
 		const fromTypeLength = this.getTypeLength( fromType );
 		const fromTypeLength = this.getTypeLength( fromType );
 		const toTypeLength = this.getTypeLength( toType );
 		const toTypeLength = this.getTypeLength( toType );
 
 
+		if ( fromTypeLength === 16 && toTypeLength === 9 ) {
+
+			return `${ this.getType( toType ) }(${ snippet }[0].xyz, ${ snippet }[1].xyz, ${ snippet }[2].xyz)`;
+
+		}
+
+		if ( fromTypeLength === 9 && toTypeLength === 4 ) {
+
+			return `${ this.getType( toType ) }(${ snippet }[0].xy, ${ snippet }[1].xy)`;
+
+		}
+
+
 		if ( fromTypeLength > 4 ) { // fromType is matrix-like
 		if ( fromTypeLength > 4 ) { // fromType is matrix-like
 
 
 			// @TODO: ignore for now
 			// @TODO: ignore for now