K3D-jupyter icon indicating copy to clipboard operation
K3D-jupyter copied to clipboard

Issue with sparse_voxels Z-buffer

Open CoenHordijk opened this issue 2 years ago • 8 comments

  • K3D version: 2.14.5

  • Python version: Python 3.95

  • Operating System: Windows

  • Using WebGL / GPU accelarated view

Description

Z buffering seems to fail on some near cubes in this sample.

What I Did

` import k3d import numpy as np N = 111220

sparse_voxels = np.random.randint(0, 1115, size=(N, 4), dtype=np.uint16) sparse_voxels[:, 3] = np.random.randint(1, 5, size=(N,))

plot = k3d.plot(grid_visible = False) obj = k3d.sparse_voxels(sparse_voxels, [300, 300, 300], compression_level=1, outlines=False) plot += obj plot.display() `

somecubesk3d

CoenHordijk avatar Oct 03 '22 12:10 CoenHordijk

That is very strange results. I cannot replicate that on my computer. Can you share (even on private channel: [email protected]) information about your GPU card? It is visible in developer console in browser: image

artur-trzesiok avatar Dec 16 '22 19:12 artur-trzesiok

@CoenHordijk can you confirm that opacity of object is 1? It looks kind of "Order-independent transparency" issue. Please also share information about depth bits (it is also in developer console - on my screenshost i put bottom segment from rectangle on it)

artur-trzesiok avatar Dec 16 '22 19:12 artur-trzesiok

import k3d import numpy as np N = 111220

sparse_voxels = np.random.randint(0, 1115, size=(N, 4), dtype=np.uint16) sparse_voxels[:, 3] = np.random.randint(1, 5, size=(N,))

plot = k3d.plot(grid_visible = False) obj = k3d.sparse_voxels(sparse_voxels, [300, 300, 300], compression_level=1, outlines=False) plot += obj plot.display()

That is very strange results. I cannot replicate that on my computer. Can you share (even on private channel: [email protected]) information about your GPU card? It is visible in developer console in browser: image

Here it is: image

CoenHordijk avatar Dec 19 '22 10:12 CoenHordijk

@CoenHordijk can you confirm that opacity of object is 1? It looks kind of "Order-independent transparency" issue. Please also share information about depth bits (it is also in developer console - on my screenshost i put bottom segment from rectangle on it)

It seems this only occurs with opacity less than 1 (0.955 does generate this artifact). Because the k3d panel is now freezing in Chrome, I wasn't able to replay the issue in this browser. So I took the MS Edge browser and succesfully replayed the issue here, with opacity = 0.955 and with the following console output:

image

CoenHordijk avatar Dec 19 '22 11:12 CoenHordijk

I was able to replay the issue in Chrome as well now:

image

CoenHordijk avatar Dec 19 '22 11:12 CoenHordijk

@CoenHordijk do you confirm that it happen with opacity <1 but it is ok with opacity = 1?

artur-trzesiok avatar Dec 19 '22 11:12 artur-trzesiok

opacity = 1 is fine indeed

CoenHordijk avatar Dec 19 '22 11:12 CoenHordijk

Thanks @CoenHordijk !

So it is problem with https://en.wikipedia.org/wiki/Order-independent_transparency . It is not easy problem in computer graphics. Three.js that k3d depends on have no support to that.

There are some techniques to solve that like depth peels. I have that feature in beta stage. But even when we will release it it won't be enable by default because add extra overhead to rendering. So that will be decision of user to add:

plot.depth_peels = 8

artur-trzesiok avatar Dec 19 '22 11:12 artur-trzesiok