# Why the quality of volume rendering in vtk.js is so much worse than in native vtk?

**URL:** https://discourse.vtk.org/t/why-the-quality-of-volume-rendering-in-vtk-js-is-so-much-worse-than-in-native-vtk/6767
**Category:** Web
**Created:** [October 5, 2021, 9:23am UTC](https://discourse.vtk.org/t/why-the-quality-of-volume-rendering-in-vtk-js-is-so-much-worse-than-in-native-vtk/6767 "2021-10-05T09:23:25Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![take5v](https://discourse.vtk.org/user_avatar/discourse.vtk.org/take5v/32/2810_2.png) [@take5v](https://discourse.vtk.org/u/take5v)
#### Post date: [October 5, 2021, 9:23am UTC](https://discourse.vtk.org/t/why-the-quality-of-volume-rendering-in-vtk-js-is-so-much-worse-than-in-native-vtk/6767/1 "2021-10-05T09:23:25Z")

</div>

Hi,

I really appreciate the work done in porting vtk to the web and I hope vtk.js project will flourish in the future. However, currently, there is a great gap in the quality of volume rendering between native vtk and vtk.js. The same volume with the same preset rendered in Slicer3D

 ![slicer](https://discourse.vtk.org/uploads/default/original/2X/2/21d4429e94ef26023438c993dd7627f23482090e.jpeg) and vtk.js ![vtkjs-webgl](https://discourse.vtk.org/uploads/default/original/2X/6/6d9bf6e4f311452632cb6b65885a803473d5a8d7.png).

So I have the following questions. Is it still a work in progress in improving the quality of volume rendering in vtk.js? Are there any WebGL API limitations so that it wouldn’t be possible to achieve comparable quality? Does the WebGPU have similar limitations to WebGL?

Best regards,  
Stas

---

<div class="post-metadata">

### Author: ![take5v](https://discourse.vtk.org/user_avatar/discourse.vtk.org/take5v/32/2810_2.png) [@take5v](https://discourse.vtk.org/u/take5v)
#### Post date: [October 5, 2021, 9:39am UTC](https://discourse.vtk.org/t/why-the-quality-of-volume-rendering-in-vtk-js-is-so-much-worse-than-in-native-vtk/6767/2 "2021-10-05T09:39:40Z")

</div>

It was also my mistake. I double-checked the code and now I enabled shade in vtk.js: ![vtkjs-webgl-with-shade](https://discourse.vtk.org/uploads/default/original/2X/e/e114082b167b69970b7921879dc5f2e86ce761a0.png)

For completeness image from Slicer without shade:

 ![slicer-without-shade](https://discourse.vtk.org/uploads/default/original/2X/b/bed868ccf579090b8cdbde95c9fe5c2cbd3a01c5.jpeg)

Still, there are some weird dots artefacts in vtk.js. Is there any way to minimize it?

Best regards,  
Stas

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [October 5, 2021, 2:01pm UTC](https://discourse.vtk.org/t/why-the-quality-of-volume-rendering-in-vtk-js-is-so-much-worse-than-in-native-vtk/6767/3 "2021-10-05T14:01:22Z")

</div>

The dot artifacts likely have to do with sampling distance. Check out the sampleDistance property on the VolumeMapper.

---

<div class="post-metadata">

### Author: ![take5v](https://discourse.vtk.org/user_avatar/discourse.vtk.org/take5v/32/2810_2.png) [@take5v](https://discourse.vtk.org/u/take5v)
#### Post date: [October 5, 2021, 3:00pm UTC](https://discourse.vtk.org/t/why-the-quality-of-volume-rendering-in-vtk-js-is-so-much-worse-than-in-native-vtk/6767/4 "2021-10-05T15:00:27Z")

</div>

That’s right, thank you very much! I chose 0.2 sampling distance and got much better quality. As far as I understood vtk.js mapper supports adaptive quality (sample distance, maybe?), but now I feel slightly some lag when rotating a volume. Is there any way I can set expected fps for interactions?

Best regards,  
Stas

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [October 5, 2021, 6:39pm UTC](https://discourse.vtk.org/t/why-the-quality-of-volume-rendering-in-vtk-js-is-so-much-worse-than-in-native-vtk/6767/5 "2021-10-05T18:39:49Z")

</div>

I believe there is some downsampling (i.e. higher sampling distance) that can occur on interaction, which can help with rendering while interacting. I’m not sure how to set it explicitly. I would let @ken-martin on that if needed.

---

<div class="post-metadata">

### Author: ![ken-martin](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ken-martin/32/884_2.png) [@ken-martin](https://discourse.vtk.org/u/ken-martin)
#### Post date: [October 5, 2021, 6:48pm UTC](https://discourse.vtk.org/t/why-the-quality-of-volume-rendering-in-vtk-js-is-so-much-worse-than-in-native-vtk/6767/6 "2021-10-05T18:48:03Z")

</div>

You can set the desiredUpdateRate and desiredStillUpdateRate as desired. vtk.js will downsample to try to maintain the desiredupdaterate when interacting. You can play with those settings and the sample distance some to see the tradeoffs.

---

<div class="post-metadata">

### Author: ![ken-martin](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ken-martin/32/884_2.png) [@ken-martin](https://discourse.vtk.org/u/ken-martin)
#### Post date: [October 5, 2021, 6:48pm UTC](https://discourse.vtk.org/t/why-the-quality-of-volume-rendering-in-vtk-js-is-so-much-worse-than-in-native-vtk/6767/7 "2021-10-05T18:48:21Z")

</div>

Those rates are on the renderWIndowInteractor.

---

<div class="post-metadata">

### Author: ![take5v](https://discourse.vtk.org/user_avatar/discourse.vtk.org/take5v/32/2810_2.png) [@take5v](https://discourse.vtk.org/u/take5v)
#### Post date: [October 5, 2021, 8:00pm UTC](https://discourse.vtk.org/t/why-the-quality-of-volume-rendering-in-vtk-js-is-so-much-worse-than-in-native-vtk/6767/8 "2021-10-05T20:00:37Z")

</div>

Great, thank you for your help!
