Anybody using "Slang"

Hi everyone,

tl;dr: sorry post has become a bit longer: Do you use Slang and does it play nice with Babylon?


I was scavenging the web for a nice looking portal shader and came across Slang. I’d call it love at first sight :heart_eyes: Write shaders once for all targets and get

  • full intellisense,
  • error prediction and
  • actual modules.

So I interviewed AI about it. Slang seems to be real deal because Khronos got involved. Out-of-the-box it transpiles to WGSL. GLSL can be done, too, indirectly. If you use a language feature not supported by WebGPU the transpiler will throw.

However, Babylon handles WebGPU a bit differently than WebGL it seems. I think, here, most importantly it does some heavy string-replace in WGSL shaders we provide. So the AI recommended we will have a harder time using Slang in MaterialPlugins, and so should prefer using Slang for ShaderMaterials.

But it does not look like it: in ShaderMaterial (WGSL), I still do not have to provide location/binding instructions (etc) and I still can write “varying” (which is not proper WGSL code).

And even if I did provide proper wgsl: how do I know which location/group is which?

So in sum: risky. Or is it? Have you tried it? Even battle tested? How does it work for you?

Best wishes
Joe

1 Like

Yeah, maybe not: the transpiler does not preserve symbol names. The output is pretty much garbage :face_with_crossed_out_eyes: