Procházet zdrojové kódy

TSL: Add `batchIndirectIndex`. (#34111)

Michael Herzog před 2 dny
rodič
revize
3cc8908cad
2 změnil soubory, kde provedl 10 přidání a 0 odebrání
  1. 1 0
      src/Three.TSL.js
  2. 9 0
      src/nodes/accessors/Batch.js

+ 1 - 0
src/Three.TSL.js

@@ -77,6 +77,7 @@ export const backgroundBlurriness = TSL.backgroundBlurriness;
 export const backgroundIntensity = TSL.backgroundIntensity;
 export const backgroundRotation = TSL.backgroundRotation;
 export const batch = TSL.batch;
+export const batchIndirectIndex = TSL.batchIndirectIndex;
 export const bentNormalView = TSL.bentNormalView;
 export const billboarding = TSL.billboarding;
 export const bitAnd = TSL.bitAnd;

+ 9 - 0
src/nodes/accessors/Batch.js

@@ -107,6 +107,13 @@ function getPreviousNode( batchMesh, id ) {
  */
 export const batchColor = /*@__PURE__*/ varyingProperty( 'vec4', 'vBatchColor' );
 
+/**
+ * TSL object representing a varying property for the batch indirect index (instance ID).
+ *
+ * @type {VaryingNode<uint>}
+ */
+export const batchIndirectIndex = /*@__PURE__*/ varyingProperty( 'uint', 'vBatchIndirectId' );
+
 /**
  * TSL function representing the vertex shader batching setup.
  * Applies the batch transformation matrix to positionLocal, normalLocal, and tangentLocal.
@@ -122,6 +129,8 @@ export const batch = /*@__PURE__*/ Fn( ( [ batchMesh ], builder ) => {
 
 	const indirectId = getIndirectIndex( batchMesh._indirectTexture, int( batchingIdNode ) );
 
+	batchIndirectIndex.assign( indirectId );
+
 	const batchingMatrix = createBatchingMatrixNode( batchMesh._matricesTexture, indirectId );
 
 	const colorsTexture = batchMesh._colorsTexture;

粤ICP备19079148号