# VTK WASM

**URL:** https://discourse.vtk.org/t/vtk-wasm/11650
**Category:** Development
**Tags:** vtkwasm
**Created:** [June 9, 2023, 7:14am UTC](https://discourse.vtk.org/t/vtk-wasm/11650 "2023-06-09T07:14:28Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mazurkin.daniel](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mazurkin.daniel/32/7277_2.png) [@mazurkin.daniel](https://discourse.vtk.org/u/mazurkin.daniel)
#### Post date: [June 9, 2023, 7:14am UTC](https://discourse.vtk.org/t/vtk-wasm/11650/1 "2023-06-09T07:14:28Z")

</div>

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?

 ![image](https://discourse.vtk.org/uploads/default/original/2X/2/20ecc4435830983728c8cd9465eb76d3ffe64d22.png)  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/b/bf59aee41527f8ef3d5dd9763bfe83fa1c014870.png)

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [June 9, 2023, 6:59pm UTC](https://discourse.vtk.org/t/vtk-wasm/11650/2 "2023-06-09T18:59:47Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mazurkin.daniel](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mazurkin.daniel/32/7277_2.png) [@mazurkin.daniel](https://discourse.vtk.org/u/mazurkin.daniel)
#### Post date: [June 10, 2023, 4:26pm UTC](https://discourse.vtk.org/t/vtk-wasm/11650/3 "2023-06-10T16:26:53Z")

</div>

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.

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

```

 ![image](https://discourse.vtk.org/uploads/default/original/2X/6/629d0586384bcb73e82c476345931535bfa26a66.png)

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [June 10, 2023, 6:27pm UTC](https://discourse.vtk.org/t/vtk-wasm/11650/4 "2023-06-10T18:27:41Z")

</div>

Ah, I see. This error was fixed in VTK couple months back - see [vtk/vtk@505304b](https://gitlab.kitware.com/vtk/vtk/-/commit/505304bd33dd8602f77f075fba5b4017e360a981). 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](https://hub.docker.com/r/kitware/vtk-wasm), see instructions [here](https://gitlab.kitware.com/vtk/vtk-wasm-docker/-/blob/main/README.md) or you can compile VTK master branch with emscripten from source, see instructions [here](https://docs.vtk.org/en/latest/advanced/build_wasm_emscripten.html). If you need more resources, take a look at [VTK/Getting Started/Using WebAssembly](https://docs.vtk.org/en/latest/getting_started/index.html#using-webassembly)

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [June 10, 2023, 6:50pm UTC](https://discourse.vtk.org/t/vtk-wasm/11650/5 "2023-06-10T18:50:48Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mazurkin.daniel](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mazurkin.daniel/32/7277_2.png) [@mazurkin.daniel](https://discourse.vtk.org/u/mazurkin.daniel)
#### Post date: [June 11, 2023, 4:35am UTC](https://discourse.vtk.org/t/vtk-wasm/11650/6 "2023-06-11T04:35:20Z")

</div>

Thank you for reply!

---

<div class="post-metadata">

### Author: ![pieper](https://discourse.vtk.org/user_avatar/discourse.vtk.org/pieper/32/17_2.png) [@pieper](https://discourse.vtk.org/u/pieper)
#### Post date: [April 16, 2024, 8:50pm UTC](https://discourse.vtk.org/t/vtk-wasm/11650/7 "2024-04-16T20:50:34Z")

</div>

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