You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The developer wants to use the function rand1f from the typegpu-noise package in their vanilla WebGPU project, and does not want to migrate their codebase to use TypeGPU.
Run @typegpu/tgpu-cli to generate typed definitions based on a .wgsl file.
tgpu-cli gen -i shader.wgsl -o shader.js
The generated file will look like:
// shader.js/* generated via tgpu-cli by TypeGPU */importtgpufrom'typegpu';exportconstmain=tgpu.computeFn([32,1,1]).implement(/* wgsl */` // ... let value = rand1f(); // external function // ... `);
In a file that the dev owns, e.g. main.js, add import to the external typed function you want to call, and to the entry function.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Scenario
The developer wants to use the function
rand1f
from thetypegpu-noise
package in their vanilla WebGPU project, and does not want to migrate their codebase to use TypeGPU.Their custom shader resembles the following code:
Steps to succeed
@typegpu/tgpu-cli
to generate typed definitions based on a.wgsl
file.The generated file will look like:
main.js
, add import to the external typed function you want to call, and to the entry function.Beta Was this translation helpful? Give feedback.
All reactions