K3D-tools / K3D-jupyter

K3D lets you create 3D plots backed by WebGL with high-level API (surfaces, isosurfaces, voxels, mesh, cloud points, vtk objects, volume renderer, colormaps, etc). The primary aim of K3D-jupyter is to be easy for use as stand alone package like matplotlib, but also to allow interoperation with existing libraries as VTK.
MIT License
917 stars 123 forks source link

non-physical alpha blending in scatter plot #372

Open bjudkewitz opened 1 year ago

bjudkewitz commented 1 year ago

When I create a 3d scatter plot of points with alpha<1 (can be 0.99), there are perspectives from which background points are shown in front of foreground points (see screenshot, generated with code below; note that all spheres have the same size, so the larger one should be in the foreground). Switching to alpha = 1 fixes the problem, but that prevents me from using alpha.

Screenshot 2022-09-06 at 17 34 19
import k3d
import numpy as np
coords0 = np.random.randn(20,3)
plot = k3d.plot()
plot.background_color = 0
plot.grid_visible=False
points = k3d.points(positions=coords0,point_size=1, shader='3d', color_range=[0, 1]) 
points.opacity = 0.99
plot += points
plot.display()

python and js version: 2.14.5 Client: mac firefox Server: ubuntu linux

artur-trzesiok commented 1 year ago

Hi!

It's well know limitations in 3d graphics called "order independent transparency". There is couple techniques to solved it. I have it already in k3dpro version (non open-source one) and it seems to be stable. I used depth peels method.

Thanks for that issue. Please obseve tasks with label "order independent transparency" here.