Jittery Scalar Bar in Saved GIF
See original GitHub issueBug Description:
When creating a GIF and rendering it onscreen, the scalar bar’s color map shows a smooth color gradient. However, after the animation is saved, the color gradient becomes blocky and jittery.
This appears to be an issue with either a new version of PyVista or a new version of one of its dependencies (potentially VTK). I believe this because I have previously saved GIF files that show a smooth scalar bar. However, I’ve been unsuccessful in pinpointing which version of PyVista or its dependencies causes the issues.
To Reproduce
The following code snippet is copied verbatim from the Create a GIF Movie page on the documentation. I also thought that the issue might be my graphics card drivers, but the example GIF displayed in the documentation also appears to suffer from the same problem.
import numpy as np
import pyvista as pv
x = np.arange(-10, 10, 0.25)
y = np.arange(-10, 10, 0.25)
x, y = np.meshgrid(x, y)
r = np.sqrt(x ** 2 + y ** 2)
z = np.sin(r)
# Create and structured surface
grid = pv.StructuredGrid(x, y, z)
# Create a plotter object and set the scalars to the Z height
plotter = pv.Plotter(notebook=False, off_screen=True)
plotter.add_mesh(grid, scalars=z.ravel(), smooth_shading=True)
# Open a gif
plotter.open_gif("wave.gif")
pts = grid.points.copy()
# Update Z and write a frame for each updated position
nframe = 15
for phase in np.linspace(0, 2 * np.pi, nframe + 1)[:nframe]:
z = np.sin(r + phase)
pts[:, -1] = z.ravel()
plotter.update_coordinates(pts, render=False)
plotter.update_scalars(z.ravel(), render=False)
# must update normals when smooth shading is enabled
plotter.mesh.compute_normals(cell_normals=False, inplace=True)
plotter.render()
plotter.write_frame()
# Closes and finalizes movie
plotter.close()
Screenshots
Jittery Scalar Bar
PyVista==0.30.0, VTK==9.0.3:
PyVista==0.33.2, VTK==9.0.0:
PyVista==0.33.2, VTK==9.0.3:
PyVista==0.33.2, VTK==9.1.0:
Smooth Scalar Bar
Animation Made A Few Months Ago Using Different Code (PyVista and VTK Versions Unknown):
System Information:
--------------------------------------------------------------------------------
Date: Wed Jan 26 11:08:26 2022 Eastern Standard Time
OS : Windows
CPU(s) : 8
Machine : AMD64
Architecture : 64bit
Environment : Python
File system : unknown
GPU Vendor : Intel
GPU Renderer : Intel(R) HD Graphics P530
GPU Version : 4.5.0 - Build 27.20.100.8681
Python 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:18:16) [MSC v.1928 64 bit
(AMD64)]
pyvista : 0.33.2
vtk : 9.1.0
numpy : 1.22.1
imageio : 2.14.1
appdirs : 1.4.4
scooby : 0.5.11
matplotlib : 3.5.1
--------------------------------------------------------------------------------
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:13 (8 by maintainers)
These are some amazing gifs. @tkoyama010, could you add camUrban/PteraSoftware as an external example?
I’ve been thinking about streamlining how we do animation anyway, this might be a good example to base the PR off of.
Yes. Let’s add it. Note: https://github.com/camUrban/PteraSoftware