Skip to content

WebGPU Fn second parameter #31955

@ljamesjr85

Description

@ljamesjr85

Description

I was looking at your webgpu skinning example and noticed a second argument ('void') passed to the Fn exported from 'three/tsl'.

At first I thought maybe it wasn't used. But, it seems like an undocumented part of what the function can take and when I replicated the example for my own use case it only seemed to work then that argument was included specifically as 'void' (see "updatedSkinningPoints")

Reproduction steps

This is used in the example below:
https://github.com/mrdoob/three.js/blob/master/examples/webgpu_skinning_points.html

Code

const updateSkinningPoints = Fn( () => {

								const pointPosition = pointPositionArray.element( instanceIndex );
								const pointSpeed = pointSpeedArray.element( instanceIndex );

								const skinningWorldPosition = objectWorldMatrix( child ).mul( skinningPosition );

								const skinningSpeed = skinningWorldPosition.sub( pointPosition );

								pointSpeed.assign( skinningSpeed );
								pointPosition.assign( skinningWorldPosition );

							}, 'void' );

							materialPoints.positionNode = Fn( () => {

								updateSkinningPoints();

								return pointPositionArray.toAttribute();

							} )().compute( countOfPoints ).onInit( () => {

								// initialize point positions and speeds

								renderer.compute( updateSkinningPoints().compute( countOfPoints ) );

							} );

Live example

https://github.com/mrdoob/three.js/blob/master/examples/webgpu_skinning_points.html

Screenshots

No response

Version

Version In Example

Device

No response

Browser

No response

OS

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions