Seam artifact with vtkTextureMapToCylinder
My colleague ran into this last week. Consider the following:
import vtk
# Create a cylinder of height 1 along the Y axis,
# centered on the origin.
cylinderSource = vtk.vtkCylinderSource()
cylinderSource.SetCenter(0.0, 0.0, 0.0)
cylinderSource.SetResolution(100)
cylinderSource.CappingOff()
# Generate texture coordinates by mapping input
# dataset points onto a cylinder that we specify
# manually.
textureMappedCylinder = vtk.vtkTextureMapToCylinder()
textureMappedCylinder.AutomaticCylinderGenerationOff()
textureMappedCylinder.SetPoint1(0.0, -0.5, 0.0)
textureMappedCylinder.SetPoint2(0.0, 0.5, 0.0)
textureMappedCylinder.SetInputConnection(cylinderSource.GetOutputPort())
# We use PreventSeamOff as we want a single
# repetition of our texture around the cylinder.
textureMappedCylinder.PreventSeamOff()
# Create a mapper to map the cylinder to screen.
mapper = vtk.vtkDataSetMapper()
mapper.SetInputConnection(textureMappedCylinder.GetOutputPort())
# Create a 2x2 checker pattern
imageSource = vtk.vtkImageCanvasSource2D()
imageSource.SetScalarTypeToUnsignedChar()
imageSource.SetExtent(0, 200, 0, 200, 0, 0)
imageSource.SetNumberOfScalarComponents(3)
imageSource.SetDrawColor(255, 255, 255)
imageSource.FillBox(0, 200, 0, 200)
imageSource.SetDrawColor(0, 0, 0)
imageSource.FillBox(0, 100, 0, 100)
imageSource.FillBox(100, 200, 100, 200)
# Create a texture with our checker pattern as input.
texture = vtk.vtkTexture()
texture.SetInputConnection(imageSource.GetOutputPort())
texture.InterpolateOn()
# Set up an actor with our mapper and texture.
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.SetTexture(texture)
# Set up a renderer and add the actor
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderer.SetBackground(1, 1, 1)
# Position camera to show the artifact
camera = renderer.GetActiveCamera()
camera.SetPosition(3.0, 0.0, 0.0)
window = vtk.vtkRenderWindow()
window.AddRenderer(renderer)
window.SetSize(600, 600)
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(window)
interactor.Start()
Result:
Notice the artifact at the seam. It gets better with RepeatOff and InterpolateOff on the vtkTexture, but shouldn't this look alright out of the box?
I know the vtkTextureMapToCylinder code has been here essentially forever, but seeing as you guys have at least touched it throughout the years, do you know if this is expected behavior or if something is fishy, @will.schroeder @brad.king @utkarsh.ayachit ?