lighting
    :: Material  -- ^ The material of the object which the point is on.
    -> Vector    -- ^ The position vector of the point.
    -> Vector    -- ^ The normal vector of the point.
    -> [Object]  -- ^ The objects in the scene (for tracing shadows).
    -> Light     -- ^ The light source.
    -> Colour    -- ^ The colour that the light source contributes.
lighting mat p n objs (Light x c)
    | lambert <= 0 || not (null ints) = mempty
    | otherwise = (*) <$> lambert *> c <*> mDiffuse mat
  where
    shadow  = normalize $ x <-> p
    lambert = shadow <.> n
    dist    = norm $ x <-> p
    ints    = filter ((<= dist) . snd)
            $ intersections objs (Ray p shadow)
lighting
    :: Material  -- ^ The material of the object which the point is on.
    -> Vector    -- ^ The position vector of the point.
    -> Vector    -- ^ The normal vector of the point.
    -> [Object]  -- ^ The objects in the scene (for tracing shadows).
    -> Light     -- ^ The light source.
    -> Colour
lighting mat p n objs (Light x c)
    | lambert <= 0 || not (null ints) = mempty
    | otherwise = (*) <$> lambert *> c <*> mDiffuse mat
  where
    shadow  = normalize $ x <-> p
    lambert = shadow <.> n
    dist    = norm $ x <-> p
    ints    = filter ((<= dist) . snd)
            $ intersections objs (Ray p shadow)
lighting mat p n objs (Light x c)
    | lambert <= 0 || not (null ints) = mempty
    | otherwise = (*) <$> lambert *> c <*> mDiffuse mat
  where
    shadow  = normalize $ x <-> p
    lambert = shadow <.> n
    dist    = norm $ x <-> p
    ints    = filter ((<= dist) . snd)
            $ intersections objs (Ray p shadow)