4 ms·
If you want live-tweakable or generated webgpu shaders, which will be useful in many applications text based is much better as no complex tooling is required.
by antoineMoPa 7y ago
If you want live-tweakable or generated webgpu shaders, which will be useful in many applications text based is much better as no complex tooling is required.
- rubber_duck 7y agoUseful to what applications ? Even writing modern JS requires a compiler stack, adding a shading language would be a matter of writing a webpack loader.
- antoineMoPa 7y agoAs an example, ShaderToy (and ShaderGif which I built) compile shaders directly in the browser.
- jfkebwjsbx 7y agoAs they have already told you, shaders being in binary or text form is orthogonal to making a tool like ShaderToy. However, binary form is way more compact for transmission, storage and performance. Almost nobody will use the text form except developers.
- mantap 7y agoThe transmission/storage size of shaders isn't important. Textures and 3D models dominate in any non trivial project. Kind of like dieting by trimming your toenails.
- jacobolus 7y agoThat’s maybe true for current 3D graphics heavy projects, but is not necessarily true for any arbitrary future use of GPU compute.
- mantap 7y agoGPUs are machines for crunching data, be it graphics or NNs. I can't think of many use case where that isn't true. Also if you anticipate the GPU being used as an accelerator, that is all the more reason to use a text based format because it allows for easy code generation.
- jfkebwjsbx 7y agoYou are wrong. Many projects use GPUs without big datasets. See ShaderToy, for instance: a lot of computation, almost no input data. Many other games, too: they may use the GPU for rendering fast yet have say 50 MiB of textures and assets only. If you think of AAA games, ML and whatnot, of course. But I doubt anybody will use WebGPU for those, to be honest.
- mantap 7y ago50MB of textures is a lot compared to shader source code size, which will be in the kilobytes for such a small project. The same with shadertoy, the storage or transmission of a shadertoy shader is never going to be significant compared to all the assets on the page. The contention was that a binary representation is necessary to save space for storage or transmission. It just isn't.
- throwaway34241 7y ago> However, binary form is way more compact That’s what I might expect too, so I was surprised to find out that SPIR-V is usually substantially larger than text based shaders. It also doesn’t seem to compress optimally using standard algorithms. [1] [1] https://aras-p.info/blog/2016/09/13/Shader-Compression-Some-Data/ https://aras-p.info/blog/2016/09/13/Shader-Compression-Some-...
- rubber_duck 7y agoI'm sure there will be JS libraries that can compile them in the browser - a minor inconvenience for those apps.
- fulafel 7y agoWhy does it require a compiler stack?
- imtringued 7y agoIf you want to use React with JSX then you must add babel to your project.
- tachyonbeam 7y agoYou could still build something like Shadertoy if the WebGPU shaders internally used a binary format. You would just need to have a JS or WASM library that compiles text shaders into the binary format. It's not that difficult to do, and it can absolutely run in the browser.
- slavik81 7y agoThere's a SPIR-V text representation that maps directly to the binary representation. Even if it was given a binary, the browser could display the equivalent text representation.