I have a 3D geological model. I would now like to project a 2D map onto its surface; however the map only covers some parts of the 3D model surface. Currently I have set repetition off; but the effect is that parts of the 3D surface which are not covered by the map get colour assigned from the map border. The effect is quite ugly - see the right hand part of the image below.
Is there a way to make a texture translucent when the texture coordinates fall outside the [0,1] range? Or alternatively, could I assign a constant colour in this case?
Hi, thanks for the hint. However I can’t figure out how to use this - I assume you are talking about vtkTextureObject?
I currently use vtkOpenGLPolyDataMapper and vtkTexture.
I have got something working; I manually set the border pixels of my image to have 0 as alpha value. But still if somebody can find a more elegant solution I’d be grateful.
Assigning values above 1 in the texture coordinates where you don’t have textures with setting repeat on the vtkTexture to False should do the trick. Here is an example using PyVista to show what this would look like:
from pyvista import examples
texture = examples.download_puppy_texture()
texture.SetRepeat(False)
mesh = examples.load_random_hills()
mesh.texture_map_to_plane(inplace=True)
# Now turn off a region of the texture mapping
idx = mesh.points[:,0] > 5
mesh.t_coords[idx] = [1.1, 1.1]
mesh.plot(texture=texture, cpos='xy',
show_grid=True, color='white')
Hi Bane,
thanks, but setting vtkTexture::SetRepeat(false) is exactly what I had done and I get the picture shown above; the stripes on the right hand side all have texture values > 1.
But it’s interesting to see that it works for the pyvista example. Makes me think if there’s an additional setting I need to change, or if it is a bug in VTK which has been fixed in your version but not mine. What version is your pvyista built on? I am using VTK 8.2 here.
I am also using VTK 8.2 - I don’t think this is a VTK issue. Maybe quickly pip install PyVista and run that example to see?
That’s really strange that it isn’t working for you though… perhaps you are setting other options on the vtkTexture that conflict with the Repeat option? what values above 1 are you using? Because if I use NaN, this doesn’t work
I’m wondering it vtk.vtkTexture.SetEdgeClamp is the method to control this? It’s docs:
Turn on/off the clamping of the texture map when the texture
coords extend beyond the [0,1] range. Only used when Repeat is
off, and edge clamping is supported by the graphics card.
I’m having trouble with this, so I wonder if its a GPU dependent thing?