How to add a texture without background to surface?

Hi Experts:

I use vtkClipPolyData with a sphere as clip function to clip a polydata surface. And then add a texture to the clip area. See picture and detailed code snippets below. Here comes my question: how to remove the background(in yellow color) of the texture? The texture itself has no backgound. The yellow actually comes from the actor but can’t be set with opactiy zero, otherwise the texture will be invisible.

        vtkActor actor = vtkActor.New();
        actor.PickableOff();
        //actor.GetProperty().SetColor(1.0, 1.0, 0.0); //set actor color, if not set, will use default color

        vtkSphere clipSphere = vtkSphere.New();
        clipSphere.SetRadius(1);
        clipSphere.SetCenter(coordX, coordY, coordZ);

        vtkClipPolyData clipper = vtkClipPolyData.New();
        clipper.GenerateClipScalarsOn();
        clipper.SetClipFunction(clipSphere);

        clipper.SetInputData(polydata);
        clipper.InsideOutOn();       

        vtkTextureMapToPlane texToSphere = vtkTextureMapToPlane.New();
        texToSphere.SetInputConnection(clipper.GetOutputPort());

        vtkPolyDataMapper newMapper = vtkPolyDataMapper.New();
        newMapper.ScalarVisibilityOff();

        newMapper.SetInputConnection(texToSphere.GetOutputPort());
        newMapper.Update();

        actor.SetMapper(newMapper);

        vtkJPEGReader pngReader = vtkJPEGReader.New();
        pngReader.SetFileName(AimImgFilePath);
        pngReader.Update();

        vtkTexture texture = vtkTexture.New();
        texture.SetInputConnection(pngReader.GetOutputPort());
        texture.InterpolateOn();
        texture.RepeatOff();
        //texture.EdgeClampOff();
        texture.MipmapOn();
        actor.SetTexture(texture);

Hello,

What happens when you do this:

texture.InterpolateOff();

?

best,

PC

Hello Paulo,

It doesn’t help when I do this: texture.InterpolateOff(). Texture.InterpolateOff only means that the texture mapping will not interpolate between texels (texture elements) when mapping them onto geometry. This can’t solve my problems. Thanks!

Hello,

What happens when you do this:

texture.PremultipliedAlphaOn();

?

best,

PC

Hello Paulo:

It doesn’t help either with:
texture.PremultipliedAlphaOn();

Thanks anyway. Perhaps I need some other solutions. Any suggestions are appreciated.

Hello,

Please, try each of these one at a time and observe the results:

texture.SetBlendingMode(VTKTextureBlendingMode::VTK_TEXTURE_BLENDING_MODE_NONE);
texture.SetBlendingMode(VTKTextureBlendingMode::VTK_TEXTURE_BLENDING_MODE_REPLACE);
texture.SetBlendingMode(VTKTextureBlendingMode::VTK_TEXTURE_BLENDING_MODE_MODULATE);
texture.SetBlendingMode(VTKTextureBlendingMode::VTK_TEXTURE_BLENDING_MODE_ADD);
texture.SetBlendingMode(VTKTextureBlendingMode::VTK_TEXTURE_BLENDING_MODE_ADD_SIGNED);
texture.SetBlendingMode(VTKTextureBlendingMode::VTK_TEXTURE_BLENDING_MODE_INTERPOLATE);
texture.SetBlendingMode(VTKTextureBlendingMode::VTK_TEXTURE_BLENDING_MODE_SUBTRACT);

regards,
PC