global reMgr = maxOps.GetCurRenderElementMgr() fn uniqueNodes nodes = -- code by denisT ( local handles = #{} for node in nodes where not handles[GetHandleByAnim node] collect ( InstanceMgr.GetInstances node &inst for i in inst do handles[GetHandleByAnim i] = on node ) ) fn compareNames str1 str2 = -- code by Swordslayer ( stricmp str1.name str2.name ) if (re = getclassinstances CShading_LightSelect + getclassinstances CShading_LightMix).count > 0 then for e in re do reMgr.RemoveRenderElement e reMgr.AddRenderElement (CShading_LightMix elementname:"Interactive LightMix") lightSelEnvRe = CShading_LightSelect elementname:"Environment" reMgr.AddRenderElement (lightSelEnvRe) lightSelEnvRe.addEnvironment = true for i in (uniqueNodes (visibleLights = for l in lights where l.ishidden != true and classOf l != TargetObject collect l)) do ( InstanceMgr.GetInstances i &instances visibleInst = for n in instances where n.ishidden != true collect n qsort visibleInst compareNames lightSelRe = CShading_LightSelect elementname:(i.name as string) reMgr.AddRenderElement (lightSelRe) lightSelRe.includedNodes = visibleInst ) lightSelRest = CShading_LightSelect elementname:"Rest (unassigned)" reMgr.AddRenderElement (lightSelRest) lightSelRest.nodeSource = 1