Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::LightEmissionData Struct Reference

A struct, used as a component, describing the emissive properties of the light it represents per the Blinn-Phong shading model. More...

#include <light.hpp>

Public Types

enum  LightType : int { directional =0 , point =1 , spot =2 }
 Integers representing different types of light sources.
 

Static Public Member Functions

static LightEmissionData MakeDirectionalLight (const glm::vec3 &diffuse, const glm::vec3 &specular, const glm::vec3 &ambient)
 Creates a directional source of light, which (in a scene) faces one direction and experiences no attenuation.
 
static LightEmissionData MakePointLight (const glm::vec3 &diffuse, const glm::vec3 &specular, const glm::vec3 &ambient, float linearConst, float quadraticConst)
 Creates a point source of light which has a position and experiences attenuation, but has no direction.
 
static LightEmissionData MakeSpotLight (float innerAngle, float outerAngle, const glm::vec3 &diffuse, const glm::vec3 &specular, const glm::vec3 &ambient, float linearConst, float quadraticConst)
 Creates a spotlight which has a position, experiences attenuation, and has a direction.
 
static float CalculateRadius (const glm::vec4 &diffuseColor, float decayLinear, float decayQuadratic, float intensityCutoff)
 A function that computes the cutoff radius for a light source based on its emissive properties.
 
static std::string getComponentTypeName ()
 The component type string associated with this object.
 

Public Attributes

LightType mType
 The type of light described by this object.
 
glm::vec4 mDiffuseColor
 The color of the diffuse component of the light represented by this object.
 
glm::vec4 mSpecularColor
 The color of the specular component of the light represented by this object.
 
glm::vec4 mAmbientColor
 The color of the ambient component of the light represented by this object.
 
GLfloat mDecayLinear
 A linear factor governing the attenuation in light intensity with distance from source, per the Blinn-Phong model.
 
GLfloat mDecayQuadratic
 A quadractic factor governing the attenuation in light intensity with distance from source, per the Blinn-Phong model.
 
GLfloat mCosCutoffInner
 The cos of the angle between the surface of the inner cone of a spot light (within which light intensity is highest), and the direction vector of the light.
 
GLfloat mCosCutoffOuter
 The cos of the angle between the surface of the outer cone of a spot light (beyond which light intensity drops to 0), and the direction vector of the light.
 
GLfloat mRadius {0.f}
 The computed radius of the light beyond which the light is no longer active, based on its emission data.
 

Detailed Description

A struct, used as a component, describing the emissive properties of the light it represents per the Blinn-Phong shading model.

Its appearance in json might be as follows:

{
"ambient": [0.04, 0.1, 0.04],
"diffuse": [2.4, 8.7, 2.4],
"specular": [ 2.0, 2.0, 2.0],
"linearConst": 0.10,
"quadraticConst": 0.10,
"lightType": "point",
"type": "LightEmissionData"
}
See also
ECSWorld::registerComponentTypes()

Member Function Documentation

◆ CalculateRadius()

float LightEmissionData::CalculateRadius ( const glm::vec4 & diffuseColor,
float decayLinear,
float decayQuadratic,
float intensityCutoff )
static

A function that computes the cutoff radius for a light source based on its emissive properties.

Parameters
diffuseColorThe diffuse color of the light.
decayLinearThe linear factor governing light intensity decay.
decayQuadraticThe quadratic factor governing light intensity decay.
intensityCutoffThe nth fraction of the max intensity of the light beyond which the light is considered inactive. Eg., intensityCutoff = 40.f => intensityAtRadius = maxIntensity/40.f.
Returns
float

◆ getComponentTypeName()

static std::string ToyMaker::LightEmissionData::getComponentTypeName ( )
inlinestatic

The component type string associated with this object.

Returns
std::string The component type string of this object.
See also
ECSWorld::registerComponentTypes()

◆ MakeDirectionalLight()

LightEmissionData LightEmissionData::MakeDirectionalLight ( const glm::vec3 & diffuse,
const glm::vec3 & specular,
const glm::vec3 & ambient )
static

Creates a directional source of light, which (in a scene) faces one direction and experiences no attenuation.

Parameters
diffuseThe diffuse component of a light per the Blinn-Phong model.
specularThe specular component of a light per the Blinn-Phong model.
ambientThe ambient component of a light per the Blinn-Phong model.
Returns
LightEmissionData The constructed light data object.

◆ MakePointLight()

LightEmissionData LightEmissionData::MakePointLight ( const glm::vec3 & diffuse,
const glm::vec3 & specular,
const glm::vec3 & ambient,
float linearConst,
float quadraticConst )
static

Creates a point source of light which has a position and experiences attenuation, but has no direction.

Parameters
diffuseThe diffuse component of the light per the Blinn-Phong model.
specularThe specular component of the light per the Blinn-Phong model.
ambientThe ambient component of the light per the Blinn-Phong model.
linearConstThe factor governing linear reduction in intensity of light with distance.
quadraticConstThe factor governing quadratic reduction in intensity of light with distance.
Returns
LightEmissionData The constructed light data object.

◆ MakeSpotLight()

LightEmissionData LightEmissionData::MakeSpotLight ( float innerAngle,
float outerAngle,
const glm::vec3 & diffuse,
const glm::vec3 & specular,
const glm::vec3 & ambient,
float linearConst,
float quadraticConst )
static

Creates a spotlight which has a position, experiences attenuation, and has a direction.

Parameters
diffuseThe diffuse component of the light per the Blinn-Phong model.
specularThe specular component of the light per the Blinn-Phong model.
ambientThe ambient component of the light per the Blinn-Phong model.
linearConstThe factor governing linear reduction in intensity of light with distance.
quadraticConstThe factor governing quadratic reduction in intensity of light with distance.
innerAngleThe angle, in degrees, made by the inner cone of the spotlight (where intensity is strongest) relative to the direction vector of the light.
outerAngleThe angle, in degrees, made by the outer cone of the spotlight (beyond which no light is present) relative to the direction vector of the light.
Returns
LightEmissionData The constructed light data object.

Member Data Documentation

◆ mAmbientColor

glm::vec4 ToyMaker::LightEmissionData::mAmbientColor

The color of the ambient component of the light represented by this object.

Represents this source's contribution to indirect lighting affecting an object, reflected from other objects in the scene. This factor just approximates indirect ambient light, and doesn't model real ambient lighting.

◆ mDiffuseColor

glm::vec4 ToyMaker::LightEmissionData::mDiffuseColor

The color of the diffuse component of the light represented by this object.

The diffuse color is what we would think of as "the color" of an object. In light, it is the color of the light affecting object surfaces pointing towards the light source.

◆ mRadius

GLfloat ToyMaker::LightEmissionData::mRadius {0.f}

The computed radius of the light beyond which the light is no longer active, based on its emission data.

See also
CalculateRadius

◆ mSpecularColor

glm::vec4 ToyMaker::LightEmissionData::mSpecularColor

The color of the specular component of the light represented by this object.

The specular color is the color on portions of the surface where light bounces off an object and towards the camera.


The documentation for this struct was generated from the following files: