Add colors and refine the directional light
This commit is contained in:
parent
62a4b739dd
commit
3c413c70b9
36
src/colors.h
Normal file
36
src/colors.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "math.h"
|
||||||
|
|
||||||
|
namespace Color {
|
||||||
|
constexpr Vector3 WHITE {1.0f, 1.0f, 1.0f};
|
||||||
|
constexpr Vector3 BLACK {0.0f, 0.0f, 0.0f};
|
||||||
|
constexpr Vector3 GRAY {0.5f, 0.5f, 0.5f};
|
||||||
|
constexpr Vector3 LIGHT_GRAY {0.75f, 0.75f, 0.75f};
|
||||||
|
constexpr Vector3 DARK_GRAY {0.25f, 0.25f, 0.25f};
|
||||||
|
|
||||||
|
constexpr Vector3 RED {1.0f, 0.0f, 0.0f};
|
||||||
|
constexpr Vector3 GREEN {0.0f, 1.0f, 0.0f};
|
||||||
|
constexpr Vector3 BLUE {0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
|
constexpr Vector3 CYAN {0.0f, 1.0f, 1.0f};
|
||||||
|
constexpr Vector3 MAGENTA {1.0f, 0.0f, 1.0f};
|
||||||
|
constexpr Vector3 YELLOW {1.0f, 1.0f, 0.0f};
|
||||||
|
|
||||||
|
constexpr Vector3 ORANGE {1.0f, 0.5f, 0.0f};
|
||||||
|
constexpr Vector3 PURPLE {0.5f, 0.0f, 0.5f};
|
||||||
|
constexpr Vector3 PINK {1.0f, 0.0f, 0.5f};
|
||||||
|
constexpr Vector3 BROWN {0.6f, 0.3f, 0.0f};
|
||||||
|
|
||||||
|
constexpr Vector3 LIME {0.5f, 1.0f, 0.0f};
|
||||||
|
constexpr Vector3 TEAL {0.0f, 0.5f, 0.5f};
|
||||||
|
constexpr Vector3 NAVY {0.0f, 0.0f, 0.5f};
|
||||||
|
constexpr Vector3 OLIVE {0.5f, 0.5f, 0.0f};
|
||||||
|
constexpr Vector3 MAROON {0.5f, 0.0f, 0.0f};
|
||||||
|
|
||||||
|
constexpr Vector3 GOLD {1.0f, 0.84f, 0.0f};
|
||||||
|
constexpr Vector3 SILVER {0.75f, 0.75f, 0.75f};
|
||||||
|
constexpr Vector3 SKY_BLUE {0.53f, 0.81f, 0.92f};
|
||||||
|
constexpr Vector3 TURQUOISE {0.25f, 0.88f, 0.82f};
|
||||||
|
constexpr Vector3 INDIGO {0.29f, 0.0f, 0.51f};
|
||||||
|
}
|
||||||
@ -3,9 +3,10 @@
|
|||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
#include "colors.h"
|
||||||
|
|
||||||
struct Light {
|
struct Light {
|
||||||
Vector3 color = Vector3(1.0f, 1.0f, 1.0f);
|
Vector3 color = Color::WHITE;
|
||||||
f32 ambient_intensity = 1.0f;
|
f32 ambient_intensity = 1.0f;
|
||||||
f32 diffuse_intensity = 0.0f;
|
f32 diffuse_intensity = 0.0f;
|
||||||
};
|
};
|
||||||
|
|||||||
14
src/main.cpp
14
src/main.cpp
@ -7,6 +7,7 @@
|
|||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
#include "light.h"
|
#include "light.h"
|
||||||
#include "material.h"
|
#include "material.h"
|
||||||
|
#include "colors.h"
|
||||||
|
|
||||||
|
|
||||||
static const char *vertex_shader_code = "shaders/shader.vert";
|
static const char *vertex_shader_code = "shaders/shader.vert";
|
||||||
@ -102,16 +103,17 @@ int main() {
|
|||||||
dull_material.specular_intensity = 0.3f;
|
dull_material.specular_intensity = 0.3f;
|
||||||
|
|
||||||
Directional_Light sun_light;
|
Directional_Light sun_light;
|
||||||
sun_light.ambient_intensity = 0.0f;
|
sun_light.color = Color::WHITE;
|
||||||
sun_light.diffuse_intensity = 0.0f;
|
sun_light.ambient_intensity = 0.3f;
|
||||||
sun_light.direction = Vector3(2.0f, -1.0, -2.0f);
|
sun_light.diffuse_intensity = 0.3f;
|
||||||
|
sun_light.direction = Vector3(5.0f, -1.0, -5.0f);
|
||||||
|
|
||||||
Point_Light point_lights[MAX_POINT_LIGHTS];
|
Point_Light point_lights[MAX_POINT_LIGHTS];
|
||||||
u32 point_light_count = 0;
|
u32 point_light_count = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
Point_Light point_light;
|
Point_Light point_light;
|
||||||
point_light.color = Vector3(1.0f, 0.0f, 1.0f);
|
point_light.color = Color::MAGENTA;
|
||||||
point_light.ambient_intensity = 0.0f;
|
point_light.ambient_intensity = 0.0f;
|
||||||
point_light.diffuse_intensity = 0.3f;
|
point_light.diffuse_intensity = 0.3f;
|
||||||
point_light.position = Vector3(10.0f, 2.0f, 0.0f);
|
point_light.position = Vector3(10.0f, 2.0f, 0.0f);
|
||||||
@ -125,7 +127,7 @@ int main() {
|
|||||||
|
|
||||||
{
|
{
|
||||||
Point_Light point_light;
|
Point_Light point_light;
|
||||||
point_light.color = Vector3(0.0f, 1.0f, 0.0f);
|
point_light.color = Color::GREEN;
|
||||||
point_light.ambient_intensity = 0.0f;
|
point_light.ambient_intensity = 0.0f;
|
||||||
point_light.diffuse_intensity = 0.3f;
|
point_light.diffuse_intensity = 0.3f;
|
||||||
point_light.position = Vector3(-10.0f, 2.0f, 0.0f);
|
point_light.position = Vector3(-10.0f, 2.0f, 0.0f);
|
||||||
@ -142,7 +144,7 @@ int main() {
|
|||||||
|
|
||||||
{
|
{
|
||||||
Spot_Light spot_light;
|
Spot_Light spot_light;
|
||||||
spot_light.color = Vector3(0.0f, 0.0f, 1.0f);
|
spot_light.color = Color::BLUE;
|
||||||
spot_light.direction = glm::normalize(Vector3(0.0f, -1.0f, 0.0f));
|
spot_light.direction = glm::normalize(Vector3(0.0f, -1.0f, 0.0f));
|
||||||
spot_light.ambient_intensity = 5.0f;
|
spot_light.ambient_intensity = 5.0f;
|
||||||
spot_light.diffuse_intensity = 2.0f;
|
spot_light.diffuse_intensity = 2.0f;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user