Traces - Multiple Screenshots for Animation

Hey!
I am currently trying to build an animation out of multiple screenshots from VTK.
However, when doing X screenshots in an iteration with moving actors on a transparent background, I receive some kind of “traces” of the actors. See Image

I added in “renWin.Render()” after each iteration but somehow this doesnt do the trick. Does anybody have an advice for me?

Thanks !

HI @BennyS,

Thanks for sharing!

Is there any way for you to share the data and the script or some way to reproduce the case ?

This could be related to some sort of temporal interpolation in the animation where you might want it to snap to the steps instead of interpolate. It is hard to say though for me without a way to reproduce the issue.

Kind regards,

Julien

Thanks for your fast response.
Unfortunately sharing the whole system is not possible but I can provide the code for the “animation”. Basically the animation is only rotating two actors.

for i in range(0,20):
    #time.sleep(1)
    glyph.RotateX(1/100.0*i)
    profile.RotateX(1/100.0*i)
    glyph.RotateY(1/100.0*i)
    profile.RotateY(1/100.0*i)
    
     

    w2if = vtk.vtkWindowToImageFilter()
    w2if.SetInput(renWin)
    w2if.SetInputBufferTypeToRGBA()
    w2if.ReadFrontBufferOff()
    w2if.Update()
        

    writer = vtk.vtkPNGWriter()
    writer.SetFileName("Output/" + datetime.datetime.now().strftime("%Y-%m-%d")+"_"+str(i)+".png")
    writer.SetInputConnection(w2if.GetOutputPort())
    writer.Write()

Hi @BennyS,

Thanks for the code snippet.

That is indeed odd. Have you tried forcing the rendering the window (renWin.Render()) in between the rotation step and the window to image step?

Regards,

Julien

Hi Julien,

yes indeed I tried also with renWen.Render().
I am currently working from my macbook and somehow I have this feeling that this might be MacOS related (dont ask me why, just a feeling). Hopefully it is MacOS related and I can render at home with my windows machine properly.Otherwise i’m getting really desperate.

@Timothee_Chabat ever seen something like this?

I don’t know but I have several thing that come to mind …

I have seen similar issues when using OSPRay (see https://discourse.paraview.org/t/artifacts-when-saving-screenshot-with-transparent-background-and-high-resolution-with-enabled-ray-tracing/10339). Are you using it or is it classic GPU rendering ?

This may indeed be related, especially if your Mac is recent.

Otherwise have you tried to make a screenshot outside the animation ? Does it works correctly ?

Another thing that could make this happen is very very large data, because I suspect the “traces” you see are induced by precision error in your actor framebuffers. What are the bounding boxes of your data ?

Hey thanks for participating.
My macbook pro is from 2013, so still intel.
So I also did make a screenshot with a single Rotate execution - still happening. Each node/connection is shown double then, once the original position and one time in the rotated position.
Is RotateX/RotateZ creating copies? I haven’t found anything stating this, but it somehow looks like.

The dimensions are: 302 nodes, 537 edges. I brought that data to a cube of dimensions 1x1x1.

I guess glyph and profile are filters ? If yes then they are not duplicating geometries.

so not related to animations it seems.

I don’t have any ideas currently, a shareable minimal example would be usefull to track this issue down.

So I tested finally on my windows machine, unfortunately - same issue.

Here is more code:

nodePoints = vtk.vtkPoints()

i = 0
dim = np.shape(xyz)
if (dim[1] == 2):
    for (x,y) in xyz:
        nodePoints.InsertPoint(i,x, y, 0)
        i+=1
elif (dim[1] == 3):
    for (x,y,z) in xyz:
        nodePoints.InsertPoint(i,x, y, z)
        i+=1

inputData = vtk.vtkPolyData()
inputData.SetPoints(nodePoints)

sphere = vtk.vtkSphereSource()
sphere.SetRadius(1)
sphere.SetPhiResolution(60)
sphere.SetThetaResolution(60)

glyphPoints = vtk.vtkGlyph3D()
glyphPoints.SetInputData(inputData)
glyphPoints.SetSourceConnection(sphere.GetOutputPort())
glyphPoints.ClampingOff()

glyphMapper = vtk.vtkPolyDataMapper()
glyphMapper.SetInputConnection(glyphPoints.GetOutputPort())

glyph = vtk.vtkActor()
glyph.SetMapper(glyphMapper)

Similarily, the connecting lines are visualized using the vtkTubeFilter.

Then I am setting up the rendering

# Now create the RenderWindow, Renderer and Interactor 
ren = vtk.vtkRenderer() 

#ren.SetBackground(1,1,1)
ren.SetBackgroundAlpha(1)
renWin = vtk.vtkRenderWindow() 
ren.SetLayer(1)
renWin.AddRenderer(ren) 
renWin.SetAlphaBitPlanes(1)




iren = vtk.vtkRenderWindowInteractor() 

iren.SetRenderWindow(renWin) 

# Add the actors 
ren.AddActor(glyph) 
ren.AddActor(profile) 

renWin.SetSize(1600, 1600)
renWin.SetNumberOfLayers(2)

renWin.Render()
iren.Initialize()

Sooooo, to be honest, I dont know how to proceed.

Haha…of course I found it just right now, straight after posting the other stuff.

ren.SetLayer(1) changed to ren.SetLayer(0) and now it works, would be interesting what this is actually doing, since I am definitely not a vtk expert.

Edit: Maybe this is not the solution… this works, but the background isnt transparent anymore:D

1 Like