-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Antialiasing tests fail with vtk >=9.0.0 #443
Comments
Created environment using: conda create -n vcs-mesa-18.3.1 -c cdat/label/vtk_dev -c conda-forge/label/vtk_dev -c conda-forge vcs=8.2.2020.04.20.14.05.g2383318 "vtk=9.0.0.rc1" "mesalib=18.3.1" pillow Conda list # packages in environment at /home/titters/conda/envs/vcs-test:
#
# Name Version Build Channel
mesalib 18.3.1 h590aaf7_0 conda-forge
vcs 8.2.2020.04.20.14.05.g2383318 pyh9f0ad1d_0 cdat/label/vtk_dev
vtk 9.0.0.rc1 with_osmesa_py38he42c7bc_4 [mesalib] conda-forge/label/vtk_dev
It looks like the default antialiasing changed from 8 to 0. |
I ran the following script that generates a baseline image and then attempts to set antialiasing to 8. Source file: clt.nc
import vcs
import cdms2
import argparse
from PIL import Image, ImageChops
parser = argparse.ArgumentParser()
parser.add_argument('version', type=str)
args = parser.parse_args()
with cdms2.open('clt.nc') as f:
data = f('clt')
def plot(version, aa=None, gm=None):
x = vcs.init(bg=True)
if aa is not None:
x.setantialiasing(aa)
else:
aa = f'baseline'
x.plot(data, gm, bg=True)
post_aa = x.backend.renWin.GetMultiSamples()
fname = f'vcs-aa-mesa_{version}-{aa}-{post_aa}.png'
x.png(fname)
x.close()
return fname
baseline = plot(args.version)
aa0 = plot(args.version, 0)
img1 = Image.open(baseline)
img2 = Image.open(aa0)
diff1 = ImageChops.difference(img1, img2)
diff1.save('vcs-aa-mesa-baseline-aa0.png') Generated the following plots: AA set to 0. The expected output is baseline being generate with aa set to 8 and the second image being generated with aa set to 0 which would cause the third image to show a difference. Here's the line calling Lines 1616 to 1619 in a06bb98
otherwise it's set when the render window is create: Lines 623 to 636 in a06bb98
|
NOTE: this is on a local linux machine running ubuntu, another issue is present on a headless machine conda-forge/vtk-feedstock#81.@muryanto1 Here's the condensed info, in the broken environment we cannot set antialiasing through the Broken environment: conda create -n vcs-mesa-18.3.1-9.0.0 -c cdat/label/vtk_dev -c conda-forge/label/vtk_dev -c conda-forge vtk "mesalib=18.3.1" pillow Working environment: conda create -n vcs-mesa-18.3.1-8.2.0 -c cdat/label/vtk_dev -c conda-forge/label/vtk_dev -c conda-forge "vtk=8.2.0" "mesalib=18.3.1" pillow Scripts: import vtk
from PIL import ImageChops
from PIL import Image
colors = vtk.vtkNamedColors()
def draw_line(prefix, aa=None):
renderer = vtk.vtkRenderer()
window = vtk.vtkRenderWindow()
window.SetOffScreenRendering(1)
window.SetSize(640, 480)
window.AddRenderer(renderer)
source = vtk.vtkLineSource()
source.SetPoint1([0.0, 0.0, 0.0])
source.SetPoint2([640.0, 480.0, 0.0])
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.GetProperty().SetLineWidth(1.0)
actor.GetProperty().SetColor(colors.GetColor3d('Black'))
actor.SetMapper(mapper)
renderer.AddActor(actor)
renderer.SetBackground(colors.GetColor3d('White'))
postfix = ''
if aa is not None:
window.SetMultiSamples(aa)
postfix = f'_{aa}'
value = window.GetMultiSamples()
postfix = f'{postfix}_{value}'
window.Render()
image = vtk.vtkWindowToImageFilter()
image.SetInput(window)
image.SetInputBufferTypeToRGB()
image.ReadFrontBufferOff()
image.Update()
filename = f'{prefix}{postfix}.png'
writer = vtk.vtkPNGWriter()
writer.SetFileName(filename)
writer.SetInputConnection(image.GetOutputPort())
writer.Write()
return filename
base = draw_line('aa')
aa32 = draw_line('aa', 32)
img1 = Image.open(base)
img2 = Image.open(aa32)
diff = ImageChops.difference(img1, img2)
diff.save('aa_diff.png') |
Here's the topic on VTK's discourse https://discourse.vtk.org/t/vtk-9-0-0rc3-python-cant-set-multisamples/3223. Will move to a bug once I clarify the usage. |
Opened a bug on VTK's gitlab https://gitlab.kitware.com/vtk/vtk/-/issues/17891 |
When We had three issues:
Key points from the VTK issue:
Issue resolutions:
|
Forgot to mention according to my conversation with the VTK developer antialiasing does not work on headless machines, the behavior should be the same as setting antialiasing to 0 on machines with graphics hardware. |
Fixes the unittest in e78fed3. |
Antiasliasing unittest is failing (https://circleci.com/gh/CDAT/vcs/3293).
https://github.com/CDAT/vcs/blob/master/tests/test_vcs_antialiasing.py
The text was updated successfully, but these errors were encountered: