Problem converting GLSL to WGSL with glslang and twgsl

Hello,

I don’t know if this belongs here, as I don’t have much experience with shaders I think this is mostly a question of me doing something wrong along the way…

I’ve tried to test the conversion from GLSL to WGSL similarly to what I found on this thread: https://forum.babylonjs.com/t/can-i-use-the-tintwasm-library-in-the-babylon-js-repository/23673

I’ve setup locally a small empty .Net Web App with 4.8.1 framework and I used the approach from user @cx20 on his jsfiddle from the thread above.

The code and directory setup is as follow:

The vertex or fragment code that I want to convert is copied-pasted from the shaders that I found into the constants in js file.

The glslang and twgsl files are from the cdn snapshots 8.26.0 and 8.26.1 downloaded today, I’ve tested with both of them separately.

I’ve converted some fragment and vertex shaders succesfully, but the fragment shader from https://github.com/veldrid/veldrid/blob/master/src/NeoDemo/Assets/Shaders/ShadowMain.frag gives an error in console and the wgsl shader is created only as far as the line seen in the image below:

It’s something that eludes me, is a problem with that shader or I messed something up?

Thank you and have a nice day!

Unfortunately, I’m not an expert on shaders either.
I’ve only tried a very simple example, so I don’t know the cause of this problem.

I don’t know what this error is (it’s SpirV), but you can use the glsl directly with Babylon and it will be automatically converted to WGSL. Maybe doing it this way will give clues on why it doesn’t work.

Hello,

Thanks for the reply, your fiddle was great, I’ve tested 3-4 conversions before that shader and it worked, both vertex and fragment. Also the vertex part of that shader I tested and it was converted ok.

Hi,

Thanks, I’ll try to setup something and put that shader for translation.