VTK WASM

Hello, I am assembling tools from 3D Slicer for use in the browser. After assembling the tools, it complains about shaders. Could you please advise me on how to modify shader code if I start my project using the command “npx itk-wasm -i kitware/vtk-wasm -b ./build-emscripten -s . build”? Is this possible?


It says ERROR: 0:130: ‘/’ : wrong operand types - …

Can you please show the full console log that includes line 130 of the shader source? The line numbers are on the left of the dev console in your first image. It only shows up line 40.

Hello, thank you for your response. Below I have attached the source code with text, as well as an image. We need to somehow edit the shader source code inside the wasm build.

gl_FragDepth = gl_FragCoord.z + cFactor*cscale + 1.0*cOffset/65000;

Ah, I see. This error was fixed in VTK couple months back - see vtk/vtk@505304b. This commit is not part of a VTK release yet. I think you’re using VTK 9.2.x. Depending on your level of comfort, for the time being, you can either build your app with kitware/vtk-wasm, see instructions here or you can compile VTK master branch with emscripten from source, see instructions here. If you need more resources, take a look at VTK/Getting Started/Using WebAssembly

1 Like

If you’re already using latest VTK, it may be that Slicer 3D is not building VTK for GLES. Set the cmake variable VTK_OPENGL_USE_GLES to ON to configure VTK for OpenGL ES 3.0

1 Like

Thank you for reply!

@mazurkin.daniel did you succeed in building Slicer code with vtk-wasm? Do you have any material you can share?

2 Likes