Light

struct glen::Light

Base light class. Designed to be extended by specific light types

Subclassed by DirectionalLight, PointLight, SpotLight

Public Functions

Light()

Light constructor.

const GLfloat &brightness() const

Return

The brightness of the light

const glm::vec3 &color() const

Return

a vector with the r, g, b color values of the light.

const bool &mesh_enabled() const

Return

True if mesh representing the light is renderable.

Mesh *mesh()

Return

The mesh object of the representation of the light.

Material *material()

Return

The material object of the representation of the light.

Camera *camera()

Return

The camera object used for shadow casting.

const bool &specular_enabled() const

Return

True if light casts a specular reflection.

const bool &diffuse_enabled() const

Return

True if light illuminates diffuse componenet of meshes.

const std::string &type() const = 0

Get the type of the light. Useful for partitioning lights when rendering.

Return

A string representing the type of the light.

void set_brightness(const GLfloat brightness)

Parameters
  • brightness: Set the brightness of the light.

void set_color(const glm::vec3 color)

Parameters
  • color: Set the color of the light with an r, g, b vector. Color values should be in the range 0 to 1.

void enable_mesh()

Make the light itself renderable.

void disable_mesh()

Make the light itself not renderable.

void enable_diffuse()

Make the light illuminate the diffuse component of materials.

void disable_diffuse()

Stop the light from illuminating the diffuse component of materials.

void enable_specular()

Make the light cast specular reflections.

void disable_specular()

Prevent the light from casting specular reflections.

Public Static Attributes

const std::string k_light_shader_type = "light"
const std::string k_light_brightness = "brightness"
const std::string k_light_color = "color"

Directional Light

struct glen::DirectionalLight : public Light

Emits light in a single direction. Rays are parallel like the sun.

Public Functions

DirectionalLight()

Constructor.

DirectionalLight(GLfloat brightness, glm::vec3 color)

Constructor.

Parameters
  • brightness: Set the brightness of the light.

  • color: Set the color of the light with an r, g, b vector. Color values should be in the range 0 to 1.

const std::string &type() const override

Get the type of the light. Useful for partitioning lights when rendering.

Return

A string representing the type of the light.

Mesh *mesh() override

Return

The mesh object of the representation of the light.

Material *material() override

Return

The material object of the representation of the light.

Camera *camera() override

Return

The camera object used for shadow casting.

Public Static Attributes

const std::string TYPE = "directionalLight"

Point Light

struct glen::PointLight : public Light

Emits light in all directions. Uses sphere mesh to display location and size in scene

Public Functions

PointLight()

Constructor.

PointLight(const GLfloat brightness, const glm::vec3 color)

Constructor.

Parameters
  • brightness: Set the brightness of the light.

  • color: Set the color of the light with an r, g, b vector. Color values should be in the range 0 to 1.

const float &radius() const

Return

The radius of the mesh representing the light

const std::string &type() const override

Get the type of the light. Useful for partitioning lights when rendering.

Return

A string representing the type of the light.

Mesh *mesh() override

Return

The mesh object of the representation of the light.

Material *material() override

Return

The material object of the representation of the light.

Camera *camera() override

Return

The camera object used for shadow casting.

void set_radius(const GLfloat radius)

Attention

If the light has a shadow map, this value won’t change the apparent softness of the shadow. You’ll need to change the ShadowMap radius for that.

Parameters
  • radius: The radius of the mesh representing the light

Public Static Attributes

const std::string TYPE = "pointLight"
constexpr GLfloat CAMERA_ANGLE = 90.0f

Spot Light

struct glen::SpotLight : public Light

Emits light in a cone shape like it’s coming from a torch.

Public Functions

SpotLight()

Constructor.

SpotLight(GLfloat brightness, glm::vec3 color)

Constructor.

Parameters
  • brightness: Set the brightness of the light.

  • color: Set the color of the light with an r, g, b vector. Color values should be in the range 0 to 1.

const std::string &type() const override

Get the type of the light. Useful for partitioning lights when rendering.

Return

A string representing the type of the light.

Mesh *mesh() override

Return

The mesh object of the representation of the light.

Material *material() override

Return

The material object of the representation of the light.

Camera *camera() override

Return

The camera object used for shadow casting.

const float cos_inner_angle() const

Return

Number between 0 and 1 represnting the inner angle of the penumbra

const float cos_outer_angle() const

Return

Number between 0 and 1 represnting the outer angle of the penumbra

void set_inner_angle(const GLfloat theta)

Parameters
  • theta: The inner angle (in radians) of the penumbra

void set_outer_angle(const GLfloat theta)

Parameters
  • theta: The outer angle (in radians) of the penumbra