### 3.3.4 CSG Difference

We rotate the lens-shaped intersection about the y-axis so that the broad side is facing the camera.

      intersection{
        sphere { <0, 0, 0>, 1
          translate -0.5*x
        }
        sphere { <0, 0, 0>, 1
          translate 0.5*x
        }
        pigment { Red }
        rotate 90*y
      }

Let's create a cylinder and stick it right in the middle of the lens.

      cylinder { <0, 0, -1> <0, 0, 1>, .35
        pigment { Blue }
      }

We render the scene to see the position of the cylinder. We will place a `difference` block around both the lens-shaped intersection and the cylinder like this:

      difference {
        intersection {
          sphere { <0, 0, 0>, 1
            translate -0.5*x
          }
          sphere { <0, 0, 0>, 1
            translate 0.5*x
          }
          pigment { Red }
          rotate 90*y
        }
        cylinder { <0, 0, -1> <0, 0, 1>, .35
          pigment { Blue }
        }
      }

We render the file again and see the lens-shaped intersection with a neat hole in the middle of it where the cylinder was. The cylinder has been `subtracted` from the intersection. Note that the pigment of the cylinder causes the surface of the hole to be colored blue. If we eliminate this pigment the surface of the hole will be black, as this is the default color if no color is specified.

OK, let's get a little wilder now. Let's declare our perforated lens object to give it a name. Let's also eliminate all textures in the declared object because we will want them to be in the final union instead.

      #declare Lens_With_Hole = difference {
        intersection {
          sphere { <0, 0, 0>, 1
            translate -0.5*x
          }
          sphere { <0, 0, 0>, 1
            translate 0.5*x
          }
          rotate 90*y
        }
        cylinder { <0, 0, -1> <0, 0, 1>, .35 }
      }

Let's use a union to build a complex shape composed of copies of this object.

      union {
        object { Lens_With_Hole translate <-.65, .65, 0> }
        object { Lens_With_Hole translate <.65, .65, 0> }
        object { Lens_With_Hole translate <-.65, -.65, 0> }
        object { Lens_With_Hole translate <.65, -.65, 0> }
        pigment { Red }
      }

We render the scene. An interesting object to be sure. But let's try something more. Let's make it a partially-transparent object by adding some filter to the pigment block.

      union {
        object { Lens_With_Hole translate <-.65, .65, 0> }
        object { Lens_With_Hole translate <.65, .65, 0> }
        object { Lens_With_Hole translate <-.65, -.65, 0> }
        object { Lens_With_Hole translate <.65, -.65, 0> }
        pigment { Red filter .5 }
      }

We render the file again. This looks pretty good... only... we can see parts of each of the lens objects inside the union! This is not good.