Skip to content
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: Added type conversions to WGSLNodeFunction and fleshed out precision. #28577

Merged
merged 2 commits into from
Jun 10, 2024

Conversation

cmhhelgeson
Copy link
Contributor

@cmhhelgeson cmhhelgeson commented Jun 7, 2024

Added conversions between WGSL types and their equivalent Threejs in the WGSLNodeFunction.js file. This commit should help resolve particular parsing and conversion issues when creating shaders using wgslFn blocks.

For instance, in the existing code, let's say we wanted to define an argument with this function signature...

const testWGSL = wgslFn( ` fn testFunction(
     workgroupId: vec3<u32>,
     localId: vec3<u32>,
     testVec: vec2<u32>
....

The generated WGSL code to invoke this function might look something like this.

testWGSL(vec3<f32>(workgroupId), vec3<f32>(localId), vec2<f32>(testVec))

While this behavior might be acceptable if we're only passing in arguments to be used in numerical operations, it prevents particular inputs from being used in scenarios where u32s or integers may be required for instance, indexing into a storage buffer.

When this code is implemented, the function will instead pass the parameters as the programmer might expect them to be passed.

testWGSL(nodeUniform0, nodeUniform1, nodeUniform2)

This change should only apply to the types already represented in WGSLNodeBuilder's wgslTypeLib (such as primitive data types, vector types, and matrix types). This should not in anyway affect how other data types like textures or arrays are parsed.

@cmhhelgeson cmhhelgeson marked this pull request as ready for review June 9, 2024 19:02
@sunag sunag changed the title Added type conversions to WGSLNodeFunction and fleshed out precision. Jun 10, 2024
@sunag sunag added this to the r166 milestone Jun 10, 2024
@sunag sunag merged commit e37cf82 into mrdoob:dev Jun 10, 2024
11 checks passed
@cmhhelgeson cmhhelgeson deleted the wgsl_node_function_typeLib branch June 11, 2024 05:09
sunag added a commit to sunag/three.js that referenced this pull request Jun 14, 2024
sunag added a commit that referenced this pull request Jun 14, 2024
@Methuselah96 Methuselah96 mentioned this pull request Jun 19, 2024
36 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants