Next: , Previous: GlobalState, Up: Functions



12.4 Lights

Without lights you wouldn't be able to see anything. Luckily fluxus gives you one for free by default, a white diffuse point light attached to the camera. For more interesting lighting, you'll need these functions. Using the standard fixed function graphics pipeline, simplistically speaking, OpenGL multiplies these values with the surface material (set with local state commands like ambient and diffuse) and the texture colour value to give the final colour.

Example
     

12.4.1 (make-light type-string cameralocked-string)

Returns

lightid-number

Description

Makes a new light. The type can be one of: "point", "directional" or "spot". If the cameralocked string is not "free" then it will be attached to the camera, and move around when you move the camera.

Example
      (make-light "spot" "locked")
     

12.4.2 (light-ambient lightid-number colour)

Returns

void

Description

Sets the ambient contribution for the specified light.

Example
      (light-ambient mylight (vector 1 1 1)) ; a boring light
     

12.4.3 (light-diffuse lightid-number colour)

Returns

void

Description

Sets the diffuse contribution for the specified light.

Example
      (light-diffuse mylight (vector 1 1 1))
     

12.4.4 (light-specular lightid-number colour)

Returns

void

Description

Sets the specular contribution for the specified light.

Example
      (light-specular mylight (vector 1 1 1))
     

12.4.5 (light-position lightid-number position-vector)

Returns

void

Description

Sets the position of the specified light. In worldspace if free, in camera space is attached.

Example
      (light-position mylight (vector 0 100 0))
     

12.4.6 (light-spot-angle lightid-number angle-number)

Returns

void

Description

Sets the spotlight cone angle of the specified light. If it's not a spot light, this command has no effect.

Example
      (light-position mylight (vector 0 100 0))
     

12.4.7 (light-spot-exponent lightid-number exponent-number)

Returns

void

Description

Sets the spotlight exponent (fuzzyness of the cone) of the specified light. If it's not a spot light, this command has no effect.

Example
      (light-spot-exponent mylight 0.1)
     

12.4.8 (light-attenuation lightid-number type-string attenuation-number)

Returns

void

Description

Sets the light attenuation (fade off with distance) of the specified light. The type string can be one of: "constant", "linear" or "quadratic".

Example
      (light-spot-exponent mylight 0.1)
     

12.4.9 (light-direction lightid-number direction-vector)

Returns

void

Description

Sets the direction of a directional light. If it's not a directional light, this command has no effect.

Example
      (light-spot-exponent mylight 0.1)