[vtkusers] how to turn off lighting?
Terry J. Ligocki
tjligocki at lbl.gov
Fri Jan 24 02:51:44 EST 2003
Glen.Coates at csiro.au wrote:
> I'm writing an application which displays slices taken through a
> volume in 3D. I would like the slices to rendered with the same
> brightness irrespective of their relative orientation to the camera,
> unlike under the standard lighting model where brightness is inversely
> proportional to the angle between the slice and the view plane.
>
> Is there some way of turning off lighting and having everything lit
> exactly the same all the time in 3D?
One way to do this is to set the "diffuse" and "specular" reflection
properties of the geometry/slice to 0.0 and the "ambient" property to
some constant between 0.0 and 1.0 (probably close to 1.0). This will
turn off all view dependent shading and set a constant intensity, view
independent illumination for the geometry/slice.
To do this in VTK, create a "vtkProperty" object (I'll call it
"sliceProp") and call the methods "sliceProp.SetDiffuse(0.0)",
"sliceProp.SetSpecular(0.0)", and "sliceProp.SetAmbient(1.0)" (this is
C++, in Tcl it would be "sliceProp SetDiffuse 0.0", "sliceProp
SetSpecular 0.0", "sliceProp SetAmbient 1.0").
Next, determine which "vtkActor(s)" represent your slice(s) (I'll call
one of them "sliceActor") and set the property of the actor(s) to the
"vtkProperty" defined above, e.g., "sliceActor.SetProperty(sliceProp)"
(C++) or "sliceActor SetProperty sliceProp" (Tcl).
This should give you the behavior you want. If this isn't clear please
post (or send me) a fragment of your code which includes the VTK
pipeline for one or more of your slices and I can more clearly show you
the code necessary to get constant shading.
I hope this helps...
Terry J. (Ligocki, tjligocki at lbl.gov)
Applied Numerical Algorithms Group
Lawrence Berkeley National Laboratory
More information about the vtkusers
mailing list