[vtkusers] Scalars and diffuse lighting

David Gobbi david.gobbi at gmail.com
Tue Apr 12 13:59:05 EDT 2011


Okay, here is my best explanation of what is going on.  Someone
please correct me if there are mistakes.

The use of lighting coefficients is limited when using scalars.
Generally, VTK uses the scalars as the diffuse color while ignoring
the diffuse coefficient (i.e. assuming it is 1.0).  The ambient and
specular colors and coefficients are used as specified in the
property, i.e. they are not taken from the scalars.

This behavior can be slightly modified via the mapper
SetScalarMaterialMode method, by making it so that the ambient
color tracks the scalars, or so that both ambient and diffuse color
tracks the scalars.

Long story short: diffuse coefficient is ignored when using scalars.
This does not appear to be a bug, I think this was done intentionally
to keep the mapper implementation from becoming too complex.
Kind of surprising that it isn't better documented, though.

 - David


On Tue, Apr 12, 2011 at 10:49 AM, David Gobbi <david.gobbi at gmail.com> wrote:
> Hi Andrew,
>
> I'm not 100% sure on this, but I think it has to do with the
> ScalarMaterialMode in the mapper.  Try doing this, for instance, to
> see if it helps:
>
> mapper->SetScalarMaterialModeToAmbientAndDiffuse();
>
> The PolyDataMapper seems to use glColor() for color scalars, but it
> uses glMaterial() for the property color, and I think that this is
> responsible for the different behavior.
>
>  - David
>
>
> On Tue, Apr 12, 2011 at 10:23 AM, andrew.derek.ward
> <andrew.derek.ward at gmail.com> wrote:
>> Hello,
>>
>> I am trying to determine how lighting works in colour scalar mode.
>>
>> I have an actor of colour (255,0,0) with ambient lighting set to 0.1 and
>> diffuse lighting set to 0.7
>>
>> Without scalars, this actor looks fine, but if I enable scalars giving every
>> cell the same colour (255,0,0) the
>> diffuse lighting coefficient does not seem to have any affect.
>>
>> It is as though VTK locks the diffuse lighting coefficient to 1.0 when
>> scalars are enabled, giving me a brighter
>> looking actor than my original non-scalar coloured one.
>>
>> This appears to be similar to these unanswered questions:
>> http://www.vtk.org/pipermail/vtkusers/1999-July/050896.html
>> http://www.vtk.org/pipermail/vtkusers/2002-October/063444.html
>>
>> Any help/explanation greatly appreciated.
>>
>> Regards,
>>
>> Andrew
>



More information about the vtkusers mailing list