[vtkusers] Scalars and diffuse lighting

Andrew Ward andrew.derek.ward at gmail.com
Wed Apr 13 04:19:30 EDT 2011


Thanks for your explanation David. This is a shame as I would expect it is a
fairly common requirement for a user to toggle scalars on/off, which perhaps
only affect part of an actor, therefore the other parts of the actor
logically should stay looking exactly the same as before. I am assuming
there is no way to only assign scalars to a portion of an actors cells.

Regards,


Andrew



On 12 April 2011 18:59, David Gobbi <david.gobbi at gmail.com> wrote:

> 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
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110413/0cfe4e79/attachment.htm>


More information about the vtkusers mailing list