[vtkusers] Problem with lighting: Dark 3D objects, SetLightType() has no effect?

Lars Overgaard lov at mikrofyn.com
Thu Jun 10 03:24:04 EDT 2004


Hi Petru,

Initially, I wanted to fix the lighting problem using only the vtkLight
that is automatically added at first Render(). I didn't succeed. No
matter what light type, intensity and so on, I was using, the light
could not be fixed relative to the camera and my objects looked dark
from many viewing angles.

After receiving your hint, I added four evenly spread lights
(CameraLights, since I allow the user to navigate the camera) and did
the same things to those lights:

renderer = vtkRenderer::New();
renderer->LightFollowCameraOn();
for (int i = 0; i < 4; i++) {
	vtkLight *light = vtkLight::New();
	light->SetLightTypeToCameraLight();
	light->SetIntensity(0.25);
	light->SetPosition((i<2 ? 1 : 0)*(i<1 ? -3 : 3),  (i<2 ? 0 :
1)*(i<3 ? -3 : 3), 1);
	renderer->AddLight(light);
}

It works fine. It is still not clear to me what was wrong in my first
attempt.

One slight problem remaining is that it is hard to find a compromise for
the light intensity that lights up wireframe objects without
"over-exposing" surface objects.

Thanks for your help!
- Lars Overgaard
  Software Engineer, Ph.D.
  MIKROFYN A/S


-----Oprindelig meddelelse-----
Fra: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] På vegne
af Petru Pau
Sendt: 7. juni 2004 10:06
Til: Lars Overgaard; vtkusers at vtk.org
Emne: Re: [vtkusers] Problem with lighting: Dark 3D objects,
SetLightType()has no effect?


My solution to this was to add another light source, somewhere to the
"back" of the object (I did not care about shades). Something like that:

            vtkLight light1 = vtkLight.New();
                light1.SetPosition(0,0,20);
                light1.SetFocalPoint(0, 0, 0);
            vtkLight light2 = vtkLight.New();
                light2.SetPosition(0,0,-20);
                light2.SetFocalPoint(0, 0, 0);
            renderer.AddLight(light1);
            renderer.AddLight(light2);

Hope this helps.
Petru

_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list