enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.31k stars 285 forks source link

black mesh (software rendering issue) #7

Open itohnobue opened 13 years ago

itohnobue commented 13 years ago

Hello, people! First of all, thank you for the great work! We use mayavi in our software and it's very useful :)

Second, about the issue. On some machines without 3D acceleration (or with minor OpenGL support i.e. on Intel integrated cards) we have found a bug: mesh (or StructuredGrid) with assigned data and colormap is colored black.

Seems like this bug was previously described in this mail-list post: https://mail.enthought.com/pipermail/enthought-dev/2009-January/019453.html

I was wondering why before turning black it appears colored for a second and decided to debug the scene building process. While debugging, I found that it turns black after this bunch of code in tvtk/pyface/ui/qt4/scene.py:

   if scene.light_manager is None:
            scene.light_manager = light_manager.LightManager(scene)
            renwin = scene._renwin
            renwin.update_traits()
            vtk_rw = tvtk.to_vtk(renwin)
            renwin.add_observer('StartEvent', messenger.send)
            messenger.connect(vtk_rw, 'StartEvent', self._start_event_callback)
            renwin.add_observer('EndEvent', messenger.send)
            messenger.connect(vtk_rw, 'EndEvent', self._end_event_callback)
            self.created = True

If you comment/delete this lines everything starts working right, with and without opengl acceleration. I'm not sure that this fix is the right way to do it but it works like a charm in my case.

I hope that this information will be useful and'll look forward for your comments about this issue :)

GaelVaroquaux commented 13 years ago

What happens if you comment out only the first line of the if block:

if scene.light_manager is None: scene.light_manager = light_manager.LightManager(scene)

itohnobue commented 13 years ago

It works, but the mouse cursor keeps going 'busy' like the program is doing some work in the background and everything works much slower.

I commented this line:

scene.light_manager = light_manager.LightManager(scene)
GaelVaroquaux commented 13 years ago

It works, but the mouse cursor keep going 'busy' like the program is doing some work in background.

Allright, so the issue seems to be that some software renderers cannot cope with the lights that we give them. Can you, on a computer for which you have the problem, play with the properties of the lights (for instance by pressing 'l' on a scene) until you can get the rendering to work again.

itohnobue commented 13 years ago

I tried to change light mode, number of lights, lights properties (elevation, azimuth, intensity, color) but the mesh still keeps black colored without any effect.

GaelVaroquaux commented 13 years ago

Even when setting the number of lights to 1?

itohnobue commented 13 years ago

I can't set it to be less than 3, the error is:

The 'number_of_lights' trait of a LightManager instance must be 3 <= an integer <= 8, but a value of 1 <type 'int'> was specified.
prabhuramachandran commented 13 years ago

There is little point in setting the number of lights to one. VTK always creates one by default. I'm not sure why commenting the self.light_manager code keeps the cursor busy. This is strange and it has been a little too long since I wrote that code. :(

nmz787 commented 10 years ago

This problem seems to still exist. I used the lfd.uci.edu Python library binaries to install VTK and ets, then copied the installed files to my Portable Python site-packages folder (since Portable Python doesn't show up on the Registry). After I got the wx_embedding example to load and found it was black, I tried compiling mayavi-4.3.1 from source, but that still didn't fix things. Then I found this thread.

I added

event.Skip()
return

just after this line: self._vtk_control.OnPaint(event) in this file: https://github.com/enthought/mayavi/blob/master/tvtk/pyface/ui/wx/scene.py#L528

Pressing 'i' on my keyboard with the wx_embedding demo open did nothing, but clicking the gear (settings) icon and setting the foreground color to something other than white causes python to crash (segfault, not a Python exception). I enabled the faulthandler Python module for wx_embedding.py and got this Segfault Trace:

Fatal Python error: Segmentation fault

Current thread 0x0000027c:
  File "C:\Portable Python 2.7.5.1\App\lib\site-packages\wx-2.9.4-msw\wx\_core.p...", line 9203 in DestroyChildren
  File "C:\ThirdParty\lib\traitsui\wx\toolkit.py", line 477 in destroy_children
  File "C:\ThirdParty\lib\traitsui\ui.py", line 323 in reset
  File "C:\ThirdParty\lib\traitsui\ui.py", line 267 in finish
  File "C:\ThirdParty\lib\traitsui\wx\ui_live.py", line 320 in close
  File "C:\ThirdParty\lib\traitsui\wx\ui_live.py", line 360 in _on_ok
  File "C:\Portable Python 2.7.5.1\App\lib\site-packages\wx-2.9.4-msw\wx\_core.p...", line 7952 in MainLoop
  File "C:\Portable Python 2.7.5.1\App\lib\site-packages\wx-2.9.4-msw\wx\_core.p...", line 8660 in MainLoop
  File "mayavi-4.3.1\examples\mayavi\interactive\wx_embedding.py", line 66 in <module>

strangely the error is slightly different in wx_mayavi_embed_in_notbook.py (I actually had to make some modifications to the way this .py file was calling wxPyhon, but I don't think that is related to the crash):


Thread 0x00000aa8:
  File "C:\ThirdParty\lib\traitsui\image\image.py", line 292 in _process
  File "C:\Portable Python 2.7.5.1\App\lib\threading.py", line 761 in run
  File "C:\Portable Python 2.7.5.1\App\lib\threading.py", line 808 in __bootstrap_inner
  File "C:\Portable Python 2.7.5.1\App\lib\threading.py", line 781 in __bootstrap

Current thread 0x0000026c:
  File "C:\ThirdParty\lib\wx-3.0.1-msw-classic\wx\_core.py", line 9191 in DestroyChildren
  File "C:\ThirdParty\lib\traitsui\wx\toolkit.py", line 477 in destroy_children
  File "C:\ThirdParty\lib\traitsui\ui.py", line 323 in reset
  File "C:\ThirdParty\lib\traitsui\ui.py", line 267 in finish
  File "C:\ThirdParty\lib\traitsui\wx\ui_live.py", line 320 in close
  File "C:\ThirdParty\lib\traitsui\wx\ui_live.py", line 360 in _on_ok
  File "C:\ThirdParty\lib\wx-3.0.1-msw-classic\wx\_core.py", line 7952 in MainLoop
  File "C:\ThirdParty\lib\wx-3.0.1-msw-classic\wx\_core.py", line 8657 in MainLoop
  File "mayavi-4.3.1\examples\mayavi\interactive\wx_mayavi_embed_in_notebook.py", line 95 in <module>

I haven't tried this yet on my computer that I think should have graphics acceleration, I'm pretty sure the machine that is crashing doesn't have acceleration as it is a Virtual Machine.

Any ideas?

ewoudenberg commented 9 years ago

This solved the exact same problem I encountered running Mayavi on a Windows 2003 Server machine over Remote Desktop.

If you're testing from within the Canopy IDE/Editor, you'll need to restart the kernel after commenting out the block starting with:

 if scene.light_manager is None: 

in tvtk/pyface/ui/qt4/scene.py