vispy / vispy

Main repository for Vispy
http://vispy.org
Other
3.31k stars 617 forks source link

Issues using MarkerVisuals for 3D scatterplot (no markers displaying) #1257

Open dburkhardt opened 8 years ago

dburkhardt commented 8 years ago

Came to vispy looking for a way to render 3D scatterplots using OpenGL. I fit into the 'Scientist with no experience in OpenGL/GLSL.'

I expected the following code to generate 5 disc markers radiating from the point 0,0,0, but instead I see a blank canvas and get no errors. Can someone please point me in the right direction?

import sys
import numpy as np

from vispy import scene, visuals
from vispy.color import Color
canvas = scene.SceneCanvas(keys='interactive', size=(800, 600), show=True)

# Set up a viewbox to display the cube with interactive arcball
view = canvas.central_widget.add_view()
view.bgcolor = '#efefef'
view.camera = 'arcball'
view.padding = 100

#Initialize markers
n = 5
pos = np.zeros((n,3))
for i in range(n):
    x = y = z = i
    pos[i] = x, y, z

markers = scene.visuals.Markers(pos=pos, face_color = "red", edge_color="black", 
                                symbol = 'disc', parent = view.scene)

if __name__ == '__main__' and sys.flags.interactive == 0:
    canvas.app.run()
dburkhardt commented 8 years ago

Realizing this may be a bug:

The following code from another issue does not display Markers either

import sys
import numpy as np
from vispy import scene
from vispy.scene import visuals

# create data cloud
pos = np.random.normal(size=(1000, 3), scale=0.2)

#
# Make a canvas and add simple view
#
canvas = scene.SceneCanvas(keys='interactive', show=True, bgcolor='w')

view = canvas.central_widget.add_view()
view.camera = 'turntable'
view.camera.fov = 60

scatter = visuals.Markers(parent=view.scene)
# scatter.antialias = 0
scatter.set_data(pos=pos, edge_color=(0.0, 0.0, 0.0, 1.0), face_color=(0.6, 0.5, 0.4, 1.0), size=15)
scatter.set_gl_state(depth_test=True, blend=True, blend_func=('src_alpha', 'one_minus_src_alpha'))

# Add axes
axis = visuals.XYZAxis(parent=view.scene)

if __name__ == '__main__' and sys.flags.interactive == 0:
    canvas.app.run()

screen shot 2016-07-13 at 10 30 04 pm

scottpaine commented 8 years ago

So this is an issue with the Intel Graphics drivers.

I have a laptop with a nVidia GPU and Intel display adapters. If I deactivate the Intel drivers (which are the primary graphic drivers by default), then the nVidia drivers take over the the markers will still display.

That's one workaround, and the problem was identified as a problem with the clipper in the shader, as was discussed later down in this issue

dburkhardt commented 8 years ago

I left a note in the other issue with my bug. I'm using a MacBook Air which does not have an nVidia GPU, only an Intel HD 3000 integrated chip. I can't deactivate the Intel drivers.

Unlike the other users, disabling the clipper in the shader in scene/visuals.py did not work for me.

I only want to be able to use Vispy to create a 3D scatterplot with an arcball/turntable camera (similar to mplot3d/MATLAB), are there other workarounds that will work on my computer? The clouds.py example under examples/demo/gloo/ works fine, but its unclear to me how to add arcball/turntable interactivity without using the scene API.

scottpaine commented 8 years ago

As of now, I don't know any outside of trying to write your own frag/vert shaders and custom camera model using gloo. Maybe someone else has an idea, but I don't have any other workarounds.