diff --git a/src/Three.TSL.js b/src/Three.TSL.js index 310e7a8ed66c36..c99f306c3dc111 100644 --- a/src/Three.TSL.js +++ b/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; diff --git a/src/nodes/accessors/Batch.js b/src/nodes/accessors/Batch.js index 6cfafc095c755a..f0b2e65caa03e5 100644 --- a/src/nodes/accessors/Batch.js +++ b/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} + */ +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;