The Lygia library of wgsl functions sensibly breaks up its library into small files with one or two functions in each file. For example, the rgb2hue.wesl file contains only fn rgb2hue() {}. Consuming Lygia becomes a little verbose, with rgb2hue duplicated two or three times:
import lygia::color::space;
...
rgb2hue::rgb2hue();
or:
import lygia::color::space::rgb2hue::rgb2hue;
...
rgb2hue();
Note that the the small file style is handy for WESL users of Lygia. The npm wesl packager makes many small WeslBundle files in the Lygia dist directory, with indexing to each via package.json exports. npm WESL users can include a selected few of the WeslBundles for full dynamic linking of shaders, without unnecessarily bulging their application bundles with unused functions.
Current WESL will work just fine like this, it's just a little wordy. But I bet we can find ways to make this pattern more concise in WESL, even w/o requiring larger application bundles.
cc: @patriciogonzalezvivo @sdedovic @josephreisinger
The Lygia library of wgsl functions sensibly breaks up its library into small files with one or two functions in each file. For example, the
rgb2hue.weslfile contains onlyfn rgb2hue() {}. Consuming Lygia becomes a little verbose, withrgb2hueduplicated two or three times:or:
Note that the the small file style is handy for WESL users of Lygia. The npm wesl packager makes many small
WeslBundlefiles in the Lygiadistdirectory, with indexing to each viapackage.jsonexports. npm WESL users can include a selected few of theWeslBundles for full dynamic linking of shaders, without unnecessarily bulging their application bundles with unused functions.Current WESL will work just fine like this, it's just a little wordy. But I bet we can find ways to make this pattern more concise in WESL, even w/o requiring larger application bundles.
cc: @patriciogonzalezvivo @sdedovic @josephreisinger