### 3.4.8 Light Groups

Light groups make it possible to create a 'union' of light_sources and objects, where the objects in the group are illuminated by the lights in the group or, if desired, also by the global light_sources. The light_sources in the group can only illuminate the objects that are in the group.

Light_groups are for example useful when creating scenes in which some objects turn out to be too dark but the average light is exactly how it should be, as the light_sources in the group do not contribute to the global lighting.

Syntax :

    light_group {
      LIGHT_GROUP LIGHT  |
      LIGHT_GROUP OBJECT |
      LIGHT_GROUP
      [LIGHT_GROUP MODIFIER]
    }

    LIGHT_GROUP LIGHT:
         light_source | light_source IDENTIFIER
    LIGHT_GROUP OBJECT:
         OBJECT | OBJECT IDENTIFIER
    LIGHT_GROUP MODIFIER:
         global_lights BOOL | TRANSFORMATION

`global_lights`. Add this command to the light_group to have objects in the group also be illuminated by global light sources.

Light groups may be nested. In this case light groups inherit the light sources of the light group they are contained by.

Light groups can be seen as a 'union of an object with light_source' and can be used in CSG.

Examples, simple light_group:

    #declare RedLight = light_source {
      <-500,500,-500>
      rgb <1,0,0>
    }

    light_group {
      light_source {RedLight}
      sphere {0,1 pigment {rgb 1}}
      global_lights off
    }

Nested light_group:

    #declare L1 = light_group {
      light_source {<10,10,0>, rgb <1,0,0>}
      light_source {<0,0,-100>, rgb <0,0,1>}
      sphere {0,1 pigment {rgb 1}}
    }

    light_group {
      light_source {<0,100,0>, rgb 0.5}
      light_group {L1}
    }

Light_groups in CSG:

    difference {
      light_group {
        sphere {0,1 pigment {rgb 1}}
        light_source {<-100,0,-100> rgb <1,0,0>}
        global_lights off
      }
      light_group {
        sphere {<0,1,0>,1 pigment {rgb 1}}
        light_source {<100,100,0> rgb <0,0,1>}
        global_lights off
      }
      rotate <-45,0,0>
    }

In the last example the result will be a sphere illuminated red, where the part that is differenced away is illuminated blue. In result comparable to the difference between two spheres with a different pigment.