-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TSL: Introduce struct
#30394
TSL: Introduce struct
#30394
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
I updated Previous // Sphere Instance Storage
const sphereInstancePositionStorage = instancedArray( spherePositionArray, 'vec3' ).label( 'SpherePosition' );
const sphereVelocityStorage = instancedArray( sphereVelocityArray, 'vec2' ).label( 'SphereVelocity' ); Now const SphereStruct = struct( {
position: 'vec3',
velocity: 'vec2'
} );
// Sphere Instance Storage
const sphereVelocityStorage = instancedArray( sphereArray, SphereStruct ).label( 'SphereData' ); |
It was somewhat well worked, but it worked, I had to make a lot of changes for this to create a new PR. Currently the @Spiri0 I added your example and added you as a co-author. I had to make some small modifications to the example as well. |
Looks cool. If I have time this week, I think I'll update the helper functions in compute_water to return structs and have defined function layouts as well. The current helper functions for indices work fine, but are more fragile than explicitly defining named WGSL/GLSL functions using setLayout, especially if someone tries to call toVar() and assign the same name to variables. |
@cmhhelgeson While you are at it: Can you also check why
The |
|
||
/** @module StructNode **/ | ||
|
||
class StructNode extends Node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It would be great to document this module and StructType
😇 .
Ah here we go, very nice. Now threejs is really drawIndirect capable 💪 😊 |
I'll see what I can do, but I've been time limited since the fall, so it might be a bit. Still got to get back to subgroupFunctionNode and additional compute samples as well. |
"imports": { | ||
"three": "../src/three.webgpu.js", | ||
"three/webgpu": "../src/three.webgpu.js", | ||
"three/tsl": "../src/three.tsl.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks in gh-pages
:
https://threejs.org/examples/?q=struct#webgpu_struct_drawindirect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mugen87 I just started looking into this issue twenty minutes ago, and it seems like it might be an issue with the getTypeFromAttribute function in GLSLNodeBuilder? In some of the vertex shaders, it appears like the nodeVarying5 variable is correctly assigned a value of float, but in each shader, nodeVarying5 is being assigned to the value of a node buffer attribute. I'm not sure why this would be necessary, as none of the position/vertex shaders are explicitly passing any new varyings to the fragment shader. The water position shader only modifies the existing varying of v_normalView. |
Related issue: #29908, #29760
Description
PR introduces
struct
for TSL following the syntax below: