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

Examples: WebGPU WGSL/TSL Node Interoperability #28379

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from

Conversation

cmhhelgeson
Copy link

@cmhhelgeson cmhhelgeson commented May 14, 2024

Using a CRT shader adapted from a linked source, I added an example demonstrating how nodes can be interchangeably used as arguments in WGSL functions and manipulated within TSL functions, ultimately producing the same visual output in each.

webgpu_tsl_interoperability

https://raw.githack.com/cmhhelgeson/three.js/webgpu_wgsl_shader/examples/webgpu_tsl_interoperability.html

…strates how to use the same node variables across both wgsl and tsl version of the same shader, as well as demonstrating how to use varying attributes in both wgsl and tsl shaders
@sunag
Copy link
Collaborator

sunag commented May 16, 2024

Thanks for first contributor. Do you can follow mrdoob code style?

@cmhhelgeson
Copy link
Author

Thanks for first contributor. Do you can follow mrdoob code style?

Yes, I will run the linter again.

@mrdoob
Copy link
Owner

mrdoob commented May 17, 2024

Yes, I will run the linter again.

Please, don't rely just on running the linter.

Check this link to see the code indentations that need clean up:
https://github.com/mrdoob/three.js/pull/28379/files

var coord = pixel / cellSize;
// Three color values for each cell (r, g, b)
var subcoord = coord * vec2f(3.0, 1.0);
var offset = vec2<f32>(0, fract(floor(coord.x) * offset));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that your example broken here after your last revision.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added cellOffset but it looks like a black horizontal line in the center of the screen.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The black horizontal line is the intended behavior. There are two shaders in this pull request, a wgsl Shader on top, and a tsl shader on the bottom. However, they each use the same nodes as their inputs and execute the same operations (thus the title, WGSL TSL Node Interoperability). I can adjust the size of the quads so that their unified, but I think that might obscure the purpose of the example, so maybe more explicit labels are needed...

@sunag sunag added this to the r165 milestone May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants