K3D-jupyter
K3D-jupyter copied to clipboard
Issue with sparse_voxels Z-buffer
-
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() `
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:
@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)
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:
Here it is:
@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:
I was able to replay the issue in Chrome as well now:
@CoenHordijk do you confirm that it happen with opacity <1 but it is ok with opacity = 1?
opacity = 1 is fine indeed
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