Remove tex_id from Vertexes
This commit is contained in:
parent
f2258f41c4
commit
7f2ff589ac
|
@ -26,22 +26,21 @@ namespace simpleengine {
|
|||
glm::vec3 color;
|
||||
glm::vec2 tex_coord;
|
||||
glm::vec3 normal;
|
||||
float texture_id = -1.f;
|
||||
|
||||
LitVertex() = default;
|
||||
|
||||
LitVertex(simpleengine::Vectorf position, glm::vec3 color, glm::vec2 tex_coord, int texture_id = -1.f) :
|
||||
position(position), color(color), tex_coord(tex_coord), normal(glm::vec3(0.f)), texture_id((float) texture_id) {
|
||||
position(position), color(color), tex_coord(tex_coord), normal(glm::vec3(0.f)) {
|
||||
|
||||
}
|
||||
|
||||
LitVertex(simpleengine::Vectorf position, glm::vec3 color, glm::vec2 tex_coord, glm::vec3 normal, int texture_id = -1.f) :
|
||||
position(position), color(color), tex_coord(tex_coord), normal(normal), texture_id((float) texture_id) {
|
||||
position(position), color(color), tex_coord(tex_coord), normal(normal) {
|
||||
|
||||
}
|
||||
|
||||
LitVertex(simpleengine::Vectorf position, glm::vec2 tex_coord, glm::vec3 normal, int texture_id = -1.f) :
|
||||
position(position), color(glm::vec3(1.f)), tex_coord(tex_coord), normal(normal), texture_id((float) texture_id) {
|
||||
position(position), color(glm::vec3(1.f)), tex_coord(tex_coord), normal(normal) {
|
||||
|
||||
}
|
||||
};
|
||||
|
|
|
@ -9,7 +9,8 @@ in mat4 vs_transform;
|
|||
in vec3 vs_to_light;
|
||||
in vec3 vs_to_camera;
|
||||
|
||||
uniform sampler2D u_textures[16];
|
||||
const int SAMP_DIFFUSE = 0;
|
||||
uniform sampler2D u_samplers[16];
|
||||
uniform float u_texture_shine[16];
|
||||
uniform float u_texture_reflectivity[16];
|
||||
|
||||
|
@ -29,12 +30,12 @@ void main() {
|
|||
vec3 diffuse = brightness * light_color;
|
||||
|
||||
// Calculate the specular
|
||||
float shine_damper = u_texture_shine[0];
|
||||
float reflectivity = u_texture_reflectivity[0];
|
||||
float shine_damper = u_texture_shine[SAMP_DIFFUSE];
|
||||
float reflectivity = u_texture_reflectivity[SAMP_DIFFUSE];
|
||||
vec3 final_specular = calculate_specular(unit_normal, shine_damper, reflectivity);
|
||||
|
||||
// Combine diffuse lighting, specular, and the texture into one color.
|
||||
fs_color = vec4(diffuse, 1.f) * texture(u_textures[0], vs_texcoord) + vec4(final_specular, 1.f);
|
||||
fs_color = vec4(diffuse, 1.f) * texture(u_samplers[SAMP_DIFFUSE], vs_texcoord) + vec4(final_specular, 1.f);
|
||||
}
|
||||
|
||||
vec3 calculate_specular(vec3 unit_normal, float shine_damper, float reflectivity) {
|
||||
|
|
|
@ -68,7 +68,6 @@ namespace simpleengine::gfx {
|
|||
for (unsigned int i = 0; i < mesh->mNumVertices; i++) {
|
||||
LitVertex vertex;
|
||||
vertex.color = glm::vec3(1.f);
|
||||
vertex.texture_id = 0; // TODO
|
||||
|
||||
simpleengine::Vectorf position(mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z);
|
||||
vertex.position = position;
|
||||
|
|
|
@ -59,7 +59,6 @@ namespace simpleengine::gfx {
|
|||
vao.enable_attrib(vbo, 1, 3, GL_FLOAT, sizeof(LitVertex), offsetof(LitVertex, color), false);
|
||||
vao.enable_attrib(vbo, 2, 3, GL_FLOAT, sizeof(LitVertex), offsetof(LitVertex, normal), false);
|
||||
vao.enable_attrib(vbo, 3, 2, GL_FLOAT, sizeof(LitVertex), offsetof(LitVertex, tex_coord), false);
|
||||
vao.enable_attrib(vbo, 4, 1, GL_FLOAT, sizeof(LitVertex), offsetof(LitVertex, texture_id), false);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
|
|
Loading…
Reference in New Issue