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

WebGPU & NodeMaterial: ComputeNode #23905

Merged
merged 12 commits into from
Apr 21, 2022
Merged

WebGPU & NodeMaterial: ComputeNode #23905

merged 12 commits into from
Apr 21, 2022

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Apr 16, 2022

Description

We are very close to having a robust particle system native of Three.js made in GPGPU.
WebGPU compute feature is amazing, the only problem so far was the 16-bit limitation.

WebGPU & NodeMaterial

  • add ComputeNode and StorageBufferNode
  • update webgpu_compute example

ShaderNode

  • add compute( dispatchCount ) ⇒ ( dispatchCount = particlesCount )
  • add timer( timeScale )
  • add storage( bufferAttribute )
  • add func( code ) ⇒ code is a GLSL or WGSL function code

Creating and calling a WGSL function

const funcNode = func( `( someParam:vec2<f32> ) -> vec2<f32> {

	return someValue;

}` );

const funcCallNode = funcNode.call( { someParam: vec2( 1.0, 1.0 ) } );

See more in this example code

This contribution is funded by Google via Igalia

@LeviPesin
Copy link
Contributor

That's amazing!!!

I think that after this PR will be merged and the PixelNode would be added, I would make a PR to add to nodes/gpgpu WebGL and WebGPUComputationRenderers (draft versions here: https://github.com/LeviPesin/THREE.js-PathTracing-Renderer/tree/webgpu/js/pathtracing/utils, I made them as a part of my still-going porting of the @erichlof's Pathtracing Renderer to the Nodes system).

@LeviPesin
Copy link
Contributor

Also, this PR resolves #23598 and almost resolves #23599.


return `${ this.getSignature() }
// system
var<private> instanceIndex : u32;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is better not to hardcode instanceIndex here, but rather use global_invocation_id and similar things (I think something like InvocationIDNode should be created for them).

Copy link
Collaborator Author

@sunag sunag Apr 21, 2022

Choose a reason for hiding this comment

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

I like that we have a single node for use common of "call index", but surely we can have both.

@sunag sunag added this to the r140 milestone Apr 21, 2022
@sunag sunag merged commit f3e92d7 into mrdoob:dev Apr 21, 2022
@sunag sunag deleted the dev-gpgpu branch April 21, 2022 23:59
@sunag sunag mentioned this pull request Apr 22, 2022
this.dispatchCount = dispatchCount;
this.workgroupSize = workgroupSize;

this.computeNode = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be an argument in the constructor?

abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
* add ComputeNode

* fix float function parameters, support to void function

* add StorageBufferNode

* add compute(), timer(), compute(), storage() and func() elements

* WebGPU: add StorageBufferNode and ComputeNode support and cleanup

* update webgpu_compute example

* cleanup

* fix ToneMappingNode in non-physical material

* fixes and cleanup

* fixes and ignore tonemapping in non physical material

* update snapshots
@LeviPesin LeviPesin mentioned this pull request Jan 11, 2023
3 tasks
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.

2 participants