readme
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#ifndef LIGHT_CLASS
|
||||
#define LIGHT_CLASS
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
// These have to match the sizes in deferred_lighting.frag and default.frag
|
||||
static constexpr int MAX_DIRECTIONAL_LIGHTS = 4;
|
||||
static constexpr int MAX_POINT_LIGHTS = 16;
|
||||
static constexpr int MAX_SPOT_LIGHTS = 8;
|
||||
|
||||
// Spot and point shadows share one depth texture cut into tiles.
|
||||
// A spot light takes 1 tile, a point light takes 6. Lights past the limit just don't cast shadows.
|
||||
static constexpr int SHADOW_ATLAS_COLUMNS = 6; // has to match the shaders too
|
||||
static constexpr int SHADOW_ATLAS_TILES = SHADOW_ATLAS_COLUMNS * SHADOW_ATLAS_COLUMNS;
|
||||
static constexpr int SHADOW_ATLAS_TILE_SIZE = 640;
|
||||
|
||||
class Light {
|
||||
public:
|
||||
glm::vec3 color = glm::vec3(1.0f); // linear rgb
|
||||
float intensity = 1.0f;
|
||||
bool castShadow = true; // spot and point lights, the sun always has its own shadow map
|
||||
int shadowTile = -1; // first atlas tile, set each frame by the render system
|
||||
};
|
||||
|
||||
// Parallel rays with no position, so it lights the whole scene from one direction
|
||||
class DirectionalLight : public Light {
|
||||
public:
|
||||
glm::vec3 direction = glm::vec3(0.0f, -1.0f, 0.0f); // the way the light travels
|
||||
};
|
||||
|
||||
// Fades with distance and reaches nothing past radius
|
||||
class PointLight : public Light {
|
||||
public:
|
||||
glm::vec3 position = glm::vec3(0.0f);
|
||||
float radius = 10.0f;
|
||||
};
|
||||
|
||||
// A cone from a point. Full brightness inside innerAngle, fading to nothing at outerAngle.
|
||||
class SpotLight : public Light {
|
||||
public:
|
||||
glm::vec3 position = glm::vec3(0.0f);
|
||||
glm::vec3 direction = glm::vec3(0.0f, -1.0f, 0.0f); // the way the cone points
|
||||
float radius = 20.0f;
|
||||
float innerAngle = 20.0f; // degrees from the center of the cone
|
||||
float outerAngle = 30.0f;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user