[vtk-developers] Bug in scalar color mapping?

David Gobbi david.gobbi at gmail.com
Thu Sep 4 19:33:14 EDT 2014


I've run into very odd behavior when I use Ambient and Diffuse
coefficients in combination with vtkDataSetMapper.  This is with
VTK master.

My property is set up like this, with AmbientColor="red" and
DiffuseColor="green".

  property->SetAmbient(0.51);
  property->SetDiffuse(0.49);
  property->SetAmbientColor(1.0, 0.0, 0.0);
  property->SetDiffuseColor(0.0, 1.0, 0.0);

My mapper, however, is set to MapScalars, so it should ignore the
AmbientColor and the DiffuseColor, and use the scalars instead:

  mapper->SetColorModeToMapScalars();
  mapper->SetLookupTable(table);
  mapper->UseLookupTableScalarRangeOn();

The lookup table is a simple greyscale lookup table, and my polydata
has scalars.  So I would expect my data to be rendered in greyscale.
But it's not, it's rendered mint green!  See the left side of the
attached image.

I tried a different scalar mapping pathway:

  mapper->InterpolateScalarsBeforeMappingOn();

The result was totally different, now it's greyscale with ambient
lighting, instead of the mix of ambient and diffuse lighting that I
requested (see right of attached image).


If I slightly modify the ambient and diffuse coefficients, the result
is, once again, completely unexpected:

  property->SetAmbient(0.49);  // was 0.51
  property->SetDiffuse(0.51);  // was 0.49

Now everything is red.  In the second attached image, the left shows
InterpolateScalarsBeforeMappingOff() and the right shows On().


Anyone know what is going on here?  Everything behaves just find if I
set either the Ambient or the Diffuse coefficient to zero.  But when I
use them together, VTK goes crazy.

 - David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mapscalars1.jpg
Type: image/jpeg
Size: 74282 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20140904/eb4cbfaa/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mapscalars2.jpg
Type: image/jpeg
Size: 75610 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20140904/eb4cbfaa/attachment-0003.jpg>


More information about the vtk-developers mailing list