2.13
Lighting: Directional

- 2.13.1. Overview
- 2.13.2. Attenuation
- 2.13.3. Application
- 2.13.4. Types

2.13.1
Overview
1
Directional lighting is the most trivial form of lighting provided by the r2 package. A directional light is a light that emits parallel rays of light in a given eye space direction. It has a color and an intensity, but does not have an origin and therefore is not attenuated over distance. It does not cause objects to cast shadows.
2.13.1.2 Directional lighting
2.13.2
Attenuation
1
Directional lights do not have origins and cannot therefore be attenuated over distance.
2.13.3
Application
1
The final light applied to the surface is given by directional (Directional.hs), where sr, sg, sb are the red, green, and blue channels, respectively, of the surface being lit. Note that the surface-to-light vector stl is simply the negation of the light direction.
2.13.3.2 Directional lighting (Application)

    module Directional where

    import qualified Color4
    import qualified Direction
    import qualified LightDirectional
    import qualified LightDiffuse
    import qualified LightSpecular
    import qualified Normal
    import qualified Position3
    import qualified Spaces
    import qualified Specular
    import qualified Vector3f
    import qualified Vector4f

    directional :: Direction.T Spaces.Eye -> Normal.T -> Position3.T Spaces.Eye -> LightDirectional.T -> Specular.T -> Color4.T -> Vector3f.T
    directional view n position light specular (Vector4f.V4 sr sg sb _) =
      let
        stl             = Vector3f.normalize (Vector3f.negation position)
        light_color     = LightDirectional.color light
        light_intensity = LightDirectional.intensity light
        light_d         = LightDiffuse.diffuse stl n light_color light_intensity
        light_s         = LightSpecular.specularBlinnPhong stl view n light_color light_intensity specular
        lit_d           = Vector3f.mult3 (Vector3f.V3 sr sg sb) light_d
        lit_s           = Vector3f.add3 lit_d light_s
      in
        lit_s

2.13.4
Types
1
Directional lights are represented in the r2 package by the R2LightDirectionalScreenSingle type.