Compare commits
No commits in common. "master" and "v0.1" have entirely different histories.
|
@ -115,9 +115,6 @@ Scene loadOBJtoScene(const char* filename, const char* mtl_directory, const char
|
||||||
|
|
||||||
std::string err;
|
std::string err;
|
||||||
|
|
||||||
// Значение гамма-коррекции
|
|
||||||
extern float inv_gamma;
|
|
||||||
|
|
||||||
// Если в процессе загрузки возникли ошибки - выдадим исключение
|
// Если в процессе загрузки возникли ошибки - выдадим исключение
|
||||||
if (!tinyobj::LoadObj(&attrib, &shapes, &materials, &err, filename, mtl_directory))
|
if (!tinyobj::LoadObj(&attrib, &shapes, &materials, &err, filename, mtl_directory))
|
||||||
throw std::runtime_error(err);
|
throw std::runtime_error(err);
|
||||||
|
@ -217,8 +214,8 @@ Scene loadOBJtoScene(const char* filename, const char* mtl_directory, const char
|
||||||
s->set_texture(specular);
|
s->set_texture(specular);
|
||||||
|
|
||||||
// Материал
|
// Материал
|
||||||
s->material.ka = pow(glm::vec3(materials[materials_ids[i]].ambient[0], materials[materials_ids[i]].ambient[1], materials[materials_ids[i]].ambient[2]), glm::vec3(1/inv_gamma));
|
s->material.ka = glm::vec3(materials[materials_ids[i]].ambient[0], materials[materials_ids[i]].ambient[1], materials[materials_ids[i]].ambient[2]);
|
||||||
s->material.kd = pow(glm::vec3(materials[materials_ids[i]].diffuse[0], materials[materials_ids[i]].diffuse[1], materials[materials_ids[i]].diffuse[2]), glm::vec3(1/inv_gamma));
|
s->material.kd = glm::vec3(materials[materials_ids[i]].diffuse[0], materials[materials_ids[i]].diffuse[1], materials[materials_ids[i]].diffuse[2]);
|
||||||
s->material.ks = glm::vec3(materials[materials_ids[i]].specular[0], materials[materials_ids[i]].specular[1], materials[materials_ids[i]].specular[2]);
|
s->material.ks = glm::vec3(materials[materials_ids[i]].specular[0], materials[materials_ids[i]].specular[1], materials[materials_ids[i]].specular[2]);
|
||||||
s->material.p = (materials[materials_ids[i]].shininess > 0.0f) ? 1000.0f / materials[materials_ids[i]].shininess : 1000.0f;
|
s->material.p = (materials[materials_ids[i]].shininess > 0.0f) ? 1000.0f / materials[materials_ids[i]].shininess : 1000.0f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,9 @@ Texture::Texture(GLuint t, const std::string& filename)
|
||||||
{
|
{
|
||||||
// Загрузка данных с учетом прозрачности
|
// Загрузка данных с учетом прозрачности
|
||||||
if (channels == 3) // RGB
|
if (channels == 3) // RGB
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
else if (channels == 4) // RGBA
|
else if (channels == 4) // RGBA
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB_ALPHA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
|
||||||
|
|
||||||
glGenerateMipmap(GL_TEXTURE_2D); // Генерация мипмапа для активной текстуры
|
glGenerateMipmap(GL_TEXTURE_2D); // Генерация мипмапа для активной текстуры
|
||||||
glBindTexture(GL_TEXTURE_2D, 0); // Отвязка активной текстуры
|
glBindTexture(GL_TEXTURE_2D, 0); // Отвязка активной текстуры
|
||||||
|
@ -255,9 +255,9 @@ TextureCube::TextureCube(GLuint t, const std::string (&filename)[6])
|
||||||
{
|
{
|
||||||
// Загрузка данных с учетом прозрачности
|
// Загрузка данных с учетом прозрачности
|
||||||
if (channels == 3) // RGB
|
if (channels == 3) // RGB
|
||||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_SRGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
else if (channels == 4) // RGBA
|
else if (channels == 4) // RGBA
|
||||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_SRGB_ALPHA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
|
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
|
||||||
|
|
||||||
stbi_image_free(image); // Освобождение оперативной памяти
|
stbi_image_free(image); // Освобождение оперативной памяти
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,6 @@ Texture* pssaoTexture_raw = NULL;
|
||||||
int WINDOW_WIDTH = 800;
|
int WINDOW_WIDTH = 800;
|
||||||
int WINDOW_HEIGHT = 600;
|
int WINDOW_HEIGHT = 600;
|
||||||
|
|
||||||
// Значение гамма-коррекции
|
|
||||||
float inv_gamma = 1/2.2;
|
|
||||||
|
|
||||||
// Функция-callback для изменения размеров буфера кадра в случае изменения размеров поверхности окна
|
// Функция-callback для изменения размеров буфера кадра в случае изменения размеров поверхности окна
|
||||||
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
|
@ -429,6 +426,7 @@ int main(void)
|
||||||
skyboxShader.bindTextures(skybox_shader_names, sizeof(skybox_shader_names)/sizeof(const char*));
|
skyboxShader.bindTextures(skybox_shader_names, sizeof(skybox_shader_names)/sizeof(const char*));
|
||||||
|
|
||||||
// Значение гамма-коррекции
|
// Значение гамма-коррекции
|
||||||
|
float inv_gamma = 1/2.2;
|
||||||
UBO gamma(&inv_gamma, sizeof(inv_gamma), 4);
|
UBO gamma(&inv_gamma, sizeof(inv_gamma), 4);
|
||||||
|
|
||||||
// Пока не произойдет событие запроса закрытия окна
|
// Пока не произойдет событие запроса закрытия окна
|
||||||
|
|
Loading…
Reference in New Issue