3D surfaces and scatter plots have weird alpha behavior?

I've noticed some odd behavior in the mplot3d toolkit when using
scatter3D with plot_surface. What I want to do is generate the
surface with an alpha level of 0.5, such that any points that are
between me and the surface should come out fully opaque, and any
points behind the surface should be rendered blended with the surface.
Instead, the scattered points are blended with the surface regardless
of whether they are in front of it or behind. There's also a weird
behavior where, depending on the viewing angle, the points will
suddenly snap from fully opaque (even if behind the surface) to
transparent. An example is attached, with renderings of the two
states in the URLs below.

Is this a bug, or am I doing something wrong?

http://dl.dropbox.com/u/8683962/mpl3dalpha-1.png
http://dl.dropbox.com/u/8683962/mpl3dalpha-2.png

surfscat3d.py (329 Bytes)

···

--
Erik Tollerud

At first glance, I wonder if this is just because of mplot3d’s naive approach of figuring out what is behind other things. mplot3d doesn’t do any sort of physics or ray-tracing to figure out how elements are positioned relative to the camera. Try it again with perfectly opaque surface and dots, and I bet you will have dots “magically” appearing in front of the surface at certain viewing angles and then disappearing.

Note, I have only looked at the photos, not the code.

Ben Root

···

On Mon, Oct 4, 2010 at 2:21 PM, Erik Tollerud <erik.tollerud@…287…> wrote:

I’ve noticed some odd behavior in the mplot3d toolkit when using

scatter3D with plot_surface. What I want to do is generate the

surface with an alpha level of 0.5, such that any points that are

between me and the surface should come out fully opaque, and any

points behind the surface should be rendered blended with the surface.

Instead, the scattered points are blended with the surface regardless

of whether they are in front of it or behind. There’s also a weird

behavior where, depending on the viewing angle, the points will

suddenly snap from fully opaque (even if behind the surface) to

transparent. An example is attached, with renderings of the two

states in the URLs below.

Is this a bug, or am I doing something wrong?

http://dl.dropbox.com/u/8683962/mpl3dalpha-1.png

http://dl.dropbox.com/u/8683962/mpl3dalpha-2.png

Erik Tollerud

You're right - if I just change the surface to be opaque, some of the
scatter points randomly disappear and reappear depending on "camera"
angle.

So how does it decide which points are behind/in front of the surface,
then? I can't figure out any obvious pattern...

And is it possible to use the z-order mechanism to get around this?
(e.g. individually set the z-order of scatter points and the patches
in the surface so that at least very roughly the correct pieces are
rendered in front?)

···

On Mon, Oct 4, 2010 at 1:04 PM, Benjamin Root <ben.root@...1304...> wrote:

On Mon, Oct 4, 2010 at 2:21 PM, Erik Tollerud <erik.tollerud@...287...> > wrote:

I've noticed some odd behavior in the mplot3d toolkit when using
scatter3D with plot_surface. What I want to do is generate the
surface with an alpha level of 0.5, such that any points that are
between me and the surface should come out fully opaque, and any
points behind the surface should be rendered blended with the surface.
Instead, the scattered points are blended with the surface regardless
of whether they are in front of it or behind. There's also a weird
behavior where, depending on the viewing angle, the points will
suddenly snap from fully opaque (even if behind the surface) to
transparent. An example is attached, with renderings of the two
states in the URLs below.

Is this a bug, or am I doing something wrong?

http://dl.dropbox.com/u/8683962/mpl3dalpha-1.png
http://dl.dropbox.com/u/8683962/mpl3dalpha-2.png

--
Erik Tollerud

At first glance, I wonder if this is just because of mplot3d's naive
approach of figuring out what is behind other things. mplot3d doesn't do
any sort of physics or ray-tracing to figure out how elements are positioned
relative to the camera. Try it again with perfectly opaque surface and
dots, and I bet you will have dots "magically" appearing in front of the
surface at certain viewing angles and then disappearing.

Note, I have only looked at the photos, not the code.

Ben Root

--
Erik Tollerud