Fanning Software Consulting

Lights Interfering in Models

QUESTION: In object graphics, how can I keep a light source added to one model from interfering with (or, shining on) objects in another model? The two models are in the same view.

ANSWER: Rick Towler provides this answer.

Interesting question. I've always wanted the light to shine on everything...

You can control this by creating two separate views. Create identical views, one for each lighting scenario, and set the Transparent keyword on one. Add your objects accordingly and place them in a viewgroup to display.

Remember to order your views in your viewgroup such that the opaque view is first (farthest away) followed by the transparent one(s).

   o1 = obj_new('orb', COLOR=[100,200,255], POS=[-2,0,0])
   o2 = obj_new('orb', COLOR=[255,200,100], POS=[2,0,0])
   l1 = OBJ_NEW('IDLgrLight', TYPE=1, INTENSITY=1.0)
   view1 = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[-3,-3,6,6])
   view2 = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[-3,-3,6,6], $
   viewgroup = OBJ_NEW('IDLgrViewgroup')
   m1 = OBJ_NEW('IDLgrModel')
   m2 = OBJ_NEW('IDLgrModel')
   m2->Add, [o2]
   m1->Add, [o1,l1]
   view1->Add, m1
   view2->Add, m2
   viewgroup->Add, [view1,view2]
   window->Draw, viewgroup

Web Coyote's Guide to IDL Programming