[vtkusers] Ambient color of lights has no effects on actor's ambient color
王跃恒
xzfnyh at gmail.com
Fri Feb 24 20:58:00 EST 2017
Hi all,
I have set up a very simple scene, with only one actor and one light.
I'm using python, the official 7.1.0 python bundle.
The renderer's ambient set to (0, 0, 0), using ren.SetAmbient(0, 0, 0), and
disable automatic light creation by ren.SetAutomaticLightCreation(False);
the actor's ambient set to 0.5, ambient color use the default (1, 1, 1);
the light's ambient color set to (1.0, 0, 0), I mean red, while diffuse
color and specular color set to (0, 0, 0).
I am expecting a red-ish flat color, since red (ambient) light shine on
grey (ambient) thing produces red, but I get a grey flat color.
It acts like there is always one and only one global pure white ambient
light (not the one I created), or the "ambient" acts like an emissive
component. The light I created has no effect on actor's ambient color.
I am new to VTK, where am I missing :(
The full source code is pretty short, both python2 and python3 will do:
import vtk
if __name__ == '__main__':
# A source process object
cube = vtk.vtkCubeSource()
# A mapper process object
cubeMapper = vtk.vtkPolyDataMapper()
cubeMapper.SetInputConnection(cube.GetOutputPort())
# An actor
cubeActor = vtk.vtkActor()
cubeActor.SetMapper(cubeMapper)
prop = cubeActor.GetProperty()
prop.SetAmbient(0.5)
prop.SetDiffuse(0.0)
prop.SetSpecular(0.0)
# A renderer
ren = vtk.vtkRenderer()
ren.SetAmbient(0.0, 0.0, 0.0)
ren.SetAutomaticLightCreation(False)
ren.AddActor(cubeActor)
light = ren.MakeLight()
light.SetAmbientColor(1.0, 0.0, 0.0)
light.SetDiffuseColor(0.0, 0.0, 0.0)
light.SetSpecularColor(0.0, 0.0, 0.0)
ren.AddLight(light)
# A render window
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
# window interation
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.Initialize()
renWin.Render()
iren.Start()
---------------
Wang Yueheng,
Tsinghua University,
Beijing, China
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170225/6a8b7afb/attachment.html>
More information about the vtkusers
mailing list