[vtkusers] Re: Multitexturing in VTK?

Peter Schmitt pschmitt at gmail.com
Thu Jul 14 10:52:39 EDT 2005


I figured it out... vtkImageBlend 
Gosh I wish I spotted that one earlier.. spent a while looking for a
class just like it!

For the vtkusers archive, here's an example I wrote...

    // colormap texture
    vtkTIFFReader* color = vtkTIFFReader::New();
    color->SetFileName("Colors.tif");

    //opacity texture
    vtkTIFFReader* opacity = vtkTIFFReader::New();
    opacity->SetFileName("Opacity.tif");

    //lookup table to load opacity map
    vtkLookupTable* opacityLookup = vtkLookupTable::New();
    opacityLookup->SetTableRange(0, 1);
    opacityLookup->SetValueRange(1.0, 0.0);
    opacityLookup->SetSaturationRange(0.0, 0.0);
    opacityLookup->SetHueRange(0.0, 0.0);
    opacityLookup->SetAlphaRange(0.0, 1.0);
    opacityLookup->Build();

    vtkImageMapToColors* opacityMap = vtkImageMapToColors::New();
    opacityMap->SetInput(opacity->GetOutput());
    opacityMap->SetLookupTable(opacityLookup);

    vtkImageBlend* blend = vtkImageBlend::New();
    blend->AddInput(color->GetOutput());
    blend->AddInput(opacityMap->GetOutput());

    //set combined texture
    vtkTexture* texture = vtkTexture::New();
    texture->SetInput(blend->GetOutput());

    vtkActor* actor = vtkActor::New();
    actor->SetMapper(mapper);  //mapper = data that texture is mapped on to
    //apply texture map:
    actor->SetTexture(texture);




-Pete Schmitt
http://www.pschmitt.com/

On 7/13/05, Peter Schmitt <pschmitt at gmail.com> wrote:
> Is there any sort of multitexturing in VTK?  I am having a hard time
> googling around for information, but maybe I'm searching for the wrong
> keywords.
> 
> I would like to have a transparency map overlayed on a texture, such
> that my object is colored/shaded only for darker regions on a
> transparency map.
> 
> Another way to look at this:  Is there functionality to
> 1. load colored texture into vtk
> 2. set the alpha-channel for the afforementioned colormap according to
> a second texture
> 
> --
> Pete
> 


-- 
Pete



More information about the vtkusers mailing list