Загрузка карт фоновой и зеркальной составляющих
This commit is contained in:
parent
44c6c024b3
commit
e4f4141f20
@ -57,6 +57,8 @@ class Model : public Movable
|
||||
GLuint verteces_count; // Количество вершин
|
||||
GLuint first_index, indices_count; // Первый и количество индексов
|
||||
Texture texture_diffuse; // Диффузная текстура
|
||||
Texture texture_ambient; // Текстура фонового освщения
|
||||
Texture texture_specular; // Текстура зеркального отражения
|
||||
};
|
||||
|
||||
// Класс сгруппированной модели
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
enum TexType {
|
||||
TEX_DIFFUSE,
|
||||
TEX_AMBIENT,
|
||||
TEX_SPECULAR,
|
||||
TEX_AVAILABLE_COUNT
|
||||
};
|
||||
|
||||
|
@ -11,6 +11,8 @@ layout(std140, binding = 1) uniform Material
|
||||
};
|
||||
|
||||
uniform sampler2D tex_diffuse;
|
||||
uniform sampler2D tex_ambient;
|
||||
uniform sampler2D tex_specular;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
|
@ -18,7 +18,7 @@ Model::Model(const Model& copy) :
|
||||
vao(copy.vao),
|
||||
verteces_count(copy.verteces_count), first_index(copy.first_index), indices_count(copy.indices_count),
|
||||
vertex_vbo(copy.vertex_vbo), index_vbo(copy.index_vbo), normals_vbo(copy.normals_vbo), texCoords_vbo(copy.texCoords_vbo),
|
||||
texture_diffuse(copy.texture_diffuse), material(copy.material)
|
||||
texture_diffuse(copy.texture_diffuse), texture_ambient(copy.texture_ambient), texture_specular(copy.texture_specular), material(copy.material)
|
||||
{
|
||||
|
||||
}
|
||||
@ -37,6 +37,9 @@ void Model::render(const GLuint &model_uniform, UBO &material_buffer, const glm:
|
||||
|
||||
// Подключаем текстуры
|
||||
texture_diffuse.use();
|
||||
texture_ambient.use();
|
||||
texture_specular.use();
|
||||
|
||||
|
||||
// Загружаем данные о материале
|
||||
material_buffer.load(&material, sizeof(material));
|
||||
@ -176,6 +179,12 @@ void Model::set_texture(Texture& texture)
|
||||
case TEX_DIFFUSE:
|
||||
texture_diffuse = texture;
|
||||
break;
|
||||
case TEX_AMBIENT:
|
||||
texture_ambient = texture;
|
||||
break;
|
||||
case TEX_SPECULAR:
|
||||
texture_specular = texture;
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
@ -304,6 +313,10 @@ GrouptedModel loadOBJtoGroupted(const char* filename, const char* mtl_directory,
|
||||
// Текстуры
|
||||
Texture diffuse(TEX_DIFFUSE, texture_directory + materials[materials_ids[i]].diffuse_texname);
|
||||
s->set_texture(diffuse);
|
||||
Texture ambient(TEX_AMBIENT, texture_directory + materials[materials_ids[i]].ambient_texname);
|
||||
s->set_texture(ambient);
|
||||
Texture specular(TEX_SPECULAR, texture_directory + materials[materials_ids[i]].specular_texname);
|
||||
s->set_texture(specular);
|
||||
|
||||
// Материал
|
||||
s->material.ka = glm::vec3(materials[materials_ids[i]].ambient[0], materials[materials_ids[i]].ambient[1], materials[materials_ids[i]].ambient[2]);
|
||||
|
@ -93,7 +93,7 @@ int main(void)
|
||||
base.load(GL_FRAGMENT_SHADER, "shaders/shader.frag");
|
||||
base.link();
|
||||
// Установим значения текстур
|
||||
const char* textures_base_shader_names[] = {"tex_diffuse"};
|
||||
const char* textures_base_shader_names[] = {"tex_diffuse", "tex_ambient", "tex_specular"};
|
||||
base.bindTextures(textures_base_shader_names, sizeof(textures_base_shader_names)/sizeof(const char*));
|
||||
// camera.move({0,0,-20});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user