-
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 doesn't appear to work for png output (2.12) #267
Comments
@aashish24 @danlipsa that's the bug I was just talking about with you. |
@danlipsa this is a big problem, I can confirm at least with mesa no antialiasing ever seems to be applied. |
Here is the code snippet from the issue mentioned above: import vcs
x = vcs.init(bg=False,geometry=(900,900))
for anti in [0,8,64]:
x.setantialiasing(anti)
x.plot([1,3,5,7,10,24,36,3,6,8,9,10])
x.png('_'.join(['antialias',str(anti),'.png']))
x.pdf('_'.join(['antialias',str(anti),'.pdf']))
x.clear() I have been able to confirm that this results in three pngs with no antialiasing. However, it seems to be related to the clearing of the canvas in the last line of the loop. If instead I change the code to Additionally, if I change the code as follows: import vcs
for anti in [0,8,64]:
x = vcs.init(bg=False,geometry=(900,900))
x.setantialiasing(anti)
x.plot([1,3,5,7,10,24,36,3,6,8,9,10])
x.png('_'.join(['antialias',str(anti),'.png']))
x.pdf('_'.join(['antialias',str(anti),'.pdf'])) Then I get one png which appears with no antialiasing, but two with it. For this reason, I believe there may be a bug with the For now I may leave this alone, as once we update our pipelines to use Context2D (thus allowing us to use the OpenGL2 backend), the clear issue may go away on it's own. If not, it would make sense to debug the clear issue further at that point. |
So now that I have a working debug build of VTK to test vtk-cdat issues, I have been able to confirm that although you can set This explains why we can't seem to change the value in the loop, but only the first value chosen is used. It would also mean that there is probably not a bug in the canvas Does this jive with your understanding of how multisample antialiasing works in VTK @danlipsa and @aashish24? |
Maybe its a bug in VTK and you need to call Modified so that it can re-set the proper OpenGL functions? |
Here's a vanilla import vtk
def buildPolyData():
N = 12
pts = [
[0, 0.0, 0.0, 0.0],
[1, 3.0, 3.0, 0.0],
[2, 6.0, 6.0, 0.0],
[3, 9.0, 7.0, 0.0],
[4, 12.0, 10.0, 0.0],
[5, 15.0, 24.0, 0.0],
[6, 18.0, 36.0, 0.0],
[7, 21.0, 3.0, 0.0],
[8, 24.0, 6.5, 0.0],
[9, 27.0, 8.0, 0.0],
[10, 30.0, 9.0, 0.0],
[11, 33.0, 10.0, 0.0]
]
points = vtk.vtkPoints()
points.SetNumberOfPoints(N)
for i in range(N):
points.SetPoint(*pts[i])
lines = vtk.vtkCellArray()
for i in range(N - 1):
lines.InsertNextCell(2)
lines.InsertCellPoint(i)
lines.InsertCellPoint(i + 1)
poly = vtk.vtkPolyData()
poly.SetPoints(points)
poly.SetLines(lines)
return poly
pd = buildPolyData()
polyMapper = vtk.vtkPolyDataMapper()
polyMapper.SetInputData(pd)
polyMapper.Update()
polyActor1 = vtk.vtkActor()
polyActor1.SetMapper(polyMapper)
ren1 = vtk.vtkRenderer()
ren1.AddActor(polyActor1)
ren1.SetBackground(0.1, 0.2, 0.4)
ren1.ResetCamera()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
renWin.SetSize(800, 800)
for anti in [0,8,64]:
renWin.SetMultiSamples(anti)
print('RenderWindow multisamples is now: %d' % renWin.GetMultiSamples())
renWin.Render()
# Just gives us a chance to look at the render window
stuff = raw_input('Please enter something:\n')
print('You entered %s' % stuff)
pd.Modified() I have run this with both OpenGL and OpenGL2 builds and got the same results. That is, the first value of multisamples is the only one used in all three I have noticed in the So you're probably right we should focus on the OpenGL2 conversion. |
Using the code example in #266 I have been trying to generate clean
*.png
output, however it seems that antialiasing is not working for this output format.Example output seems to show slightly different file sizes, but the line output in the examples doesn't appear to improve with a high antialiasing setting - there are jaggies in all of the png outputs, whereas the pdf output is much sharper.
antialiasing = 1 (44.7K)

antialiasing = 8 (45.5K)

antialiasing = 64 (45.5K)

pdf output
171102_antiAliasing_1_.pdf
The text was updated successfully, but these errors were encountered: