Open samarthswarup opened 4 years ago
Very strange... I have similar hardware but not exactly the same. I cannot reproduce this at the moment
Are you using an external monitor?
FYI: originally posted on https://stackoverflow.com/questions/62250320/pyvista-add-volume-shows-a-blank-image
it appears add_mesh
is okay but add_volume
is not showing.
Can you also try this simpler example:
import pyvista as pv
model = pv.Wavelet()
p = pv.Plotter(notebook=False)
p.add_volume(model)
p.show()
I am using an external monitor (LG 27MD5KA), but the same problem happens even if I don't use it. I also tried the simpler example above, but that also shows a blank image.
This is very, very odd behavior. Let's do some debugging... use this snippet with a box in there so we can see where the volume should be:
import pyvista as pv
model = pv.Wavelet()
p = pv.Plotter(notebook=False)
p.add_volume(model)
p.add_mesh(model.outline(), color='white')
p.show()
Can you try clicking the scene to move the camera a bit? Also, can you hit the r
and v
keys a few times to see if those reset the camera and cause the volume to appear?
If those two things fail, can you try passing differing arguments of mapper
to add_volume
to see if any of these make a difference? Choices are: 'fixed_point'
, 'gpu'
, 'open_gl'
, and 'smart'
. Then do the same thing of clicking the scene trying to move the camera around.
E.g.
import pyvista as pv
model = pv.Wavelet()
p = pv.Plotter(notebook=False)
p.add_volume(model, mapper='fixed_point')
p.add_mesh(model.outline(), color='white')
p.show()
Here is the output for the first snippet. I clicked on it and moved the camera a bit (that's the image below). I also tried hitting r
and v
a few times, but the volume did not show up.
However, the second snippet does result in the volume showing up. It only works for fixed_point
. For gpu
, open_gl
, and smart
, it looks like the output above.
Aha, then you need to use the 'fixed_point'
mapper for volume rendering from now on (this is the default mapper for windows, and Mac uses 'smart'
by default). There are a few issues in the main PyVista repo detailing how defaults for the volume mapper were chosen and we tried to use something that works for most people as the different mappers can have issues with specific hardware. To get around this, we have a way to set a default for the volume mapper. After you import pyvista, set 'fixed_point'
as the default mapper in rcParams
so that you no longer have to specify it:
import pyvista as pv
pv.rcParams['volume_mapper'] = 'fixed_point'
model = pv.Wavelet()
p = pv.Plotter(notebook=False)
p.add_volume(model) # Note you do not need to specify mapper now
p.add_mesh(model.outline(), color='white')
p.show()
So set pv.rcParams['volume_mapper'] = 'fixed_point'
then run your original workflow
Thanks. I tried the damavand volcano example again, with and without fixed_point
for the volume mapper. For completeness, here's the code again:
import pyvista as pv
from pyvista import examples
pv.rcParams['volume_mapper'] = 'fixed_point'
model = examples.download_damavand_volcano()
opacity = [0, 0.75, 0, 0.75, 1.0]
clim = [0, 100]
p = pv.Plotter(off_screen=True)
p.add_volume(model, cmap="magma", clim=clim,
opacity=opacity, opacity_unit_distance=6000,)
p.show(screenshot='volcano.png')
This takes about 2 minutes to run and produces the following image:
If I comment out the line pv.rcParams['volume_mapper'] = 'fixed_point'
, it takes about 2 seconds to run and produces the following image:
Any idea what might be causing this difference?
If I comment out the line pv.rcParams['volume_mapper'] = 'fixed_point', it takes about 2 seconds to run and produces the following image:
huh, I thought you said the default mapper doesn't work for you? I'm not following which mappers work for you and which don't...
However, it doesn't surprise me that the 'fixed_point'
mapper has poor performance for these data.
Hi Bane:
I am able to save the image to file using the default mapper, as I had mentioned in my original post, but not able to display it on screen.
Hi, I've been having a similar issue today but I'm using Windows and found that the volume is only rendered with the mapper='smart'
option for my own small dataset. When I run any of the examples from the website I don't specify anything extra and they always plot. I've no idea why I need to use smart
especially for my own small dataset (30-50K points).
Description
I am trying a very simple add_volume example:
When I run this, a window pops up, but it only displays a blank image:
On the other hand, if I try to save the image to file, like so:
then it saves an image:
Here is the output of pv.Report():
Example Data