Источник света
This commit is contained in:
parent
93f8ab2653
commit
60e3f8a1d9
|
@ -0,0 +1,13 @@
|
|||
#ifndef LIGHTS_H
|
||||
#define LIGHTS_H
|
||||
|
||||
#include <GLM/glm.hpp>
|
||||
|
||||
// Точечный источник света
|
||||
struct LightData
|
||||
{
|
||||
alignas(16) glm::vec3 position; // Позиция
|
||||
alignas(16) glm::vec3 color; // Цвет
|
||||
};
|
||||
|
||||
#endif // LIGHTS_H
|
|
@ -10,6 +10,12 @@ layout(std140, binding = 1) uniform Material
|
|||
float p;
|
||||
};
|
||||
|
||||
layout(std140, binding = 2) uniform Light
|
||||
{
|
||||
vec3 position;
|
||||
vec3 color;
|
||||
} light_f;
|
||||
|
||||
uniform sampler2D tex_diffuse;
|
||||
uniform sampler2D tex_ambient;
|
||||
uniform sampler2D tex_specular;
|
||||
|
|
|
@ -10,6 +10,12 @@ layout(std140, binding = 0) uniform Camera
|
|||
mat4 view;
|
||||
};
|
||||
|
||||
layout(std140, binding = 2) uniform Light
|
||||
{
|
||||
vec3 position;
|
||||
vec3 color;
|
||||
} light_v;
|
||||
|
||||
uniform mat4 model;
|
||||
|
||||
out vec2 texCoord;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "Scene.h"
|
||||
#include "Shader.h"
|
||||
#include "Lights.h"
|
||||
|
||||
#define WINDOW_WIDTH 800
|
||||
#define WINDOW_HEIGHT 600
|
||||
|
@ -103,9 +104,15 @@ int main(void)
|
|||
// Расположение Uniform-переменной
|
||||
GLuint model_uniform = base.getUniformLoc("model");
|
||||
|
||||
// Источник света
|
||||
LightData light = { {1.0f, 3.0f, 0.0f} // позиция
|
||||
, {1.0f, 1.0f, 1.0f} // цвет
|
||||
};
|
||||
|
||||
// Uniform-буферы
|
||||
UBO cameraUB(sizeof(glm::mat4)*2, 0);
|
||||
UBO material_data(sizeof(Material), 1);
|
||||
UBO light_data(&light, sizeof(LightData), 2);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Использование уменьшенных версий mipmap
|
||||
|
||||
|
|
Loading…
Reference in New Issue