From 6cf551ffb4fc2f52f6089a2283465873985478e7 Mon Sep 17 00:00:00 2001 From: 4VRDriver <44267643+4VRDriver@users.noreply.github.com> Date: Sun, 6 Sep 2020 21:18:48 +0200 Subject: [PATCH] Load in normal and height maps (model loading, not rendering) --- res/shaders/basic.fs | 9 ++++----- src/Controller.cpp | 4 ++-- src/Model.cpp | 6 ++++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/res/shaders/basic.fs b/res/shaders/basic.fs index b8870c3..7afec01 100644 --- a/res/shaders/basic.fs +++ b/res/shaders/basic.fs @@ -2,6 +2,10 @@ layout(location = 0) out vec4 f_color; +in vec3 v_normal; +in vec2 v_texCoord; +in vec3 v_fragmentPosition; + struct Material { sampler2D texture_diffuse0; sampler2D texture_diffuse1; @@ -20,10 +24,6 @@ struct Light { }; uniform Light u_light; -in vec3 v_normal; -in vec2 v_texCoord; -in vec3 v_fragmentPosition; - uniform mat3 u_normalMatrix; uniform vec3 u_viewPosition; @@ -45,7 +45,6 @@ void main() { float spec = pow(max(dot(viewDir, reflectDir), 0.0), u_material.shininess); vec3 specular = u_light.specular * spec * vec3(texture(u_material.texture_specular0, v_texCoord)); - //f_color = v_color; //vec4 texColor1 = texture(u_material.u_texture_diffuse0, v_texCoord); //vec4 texColor2 = texture(u_material.u_texture_diffuse1, v_texCoord); //f_color = texColor1; diff --git a/src/Controller.cpp b/src/Controller.cpp index 7b9f826..fb5e1a3 100644 --- a/src/Controller.cpp +++ b/src/Controller.cpp @@ -53,7 +53,7 @@ void Controller::run() { Model model_container("res/models/container.obj"); Model model_cube("res/models/cube.obj"); - //Entity backpack1(&model_cube, &shaderProgram); + //Entity backpack1(&model_backpack, &shaderProgram); Entity cube(&model_container, &shaderProgram); Entity lightSource(&model_cube, &lightProgram); @@ -73,8 +73,8 @@ void Controller::run() { shaderProgram.setUniform("u_material.shininess", 32.0f); shaderProgram.unbind(); - scene.push_back(lightSource); scene.push_back(cube); + scene.push_back(lightSource); camera->translate(glm::vec3(0.0f, 0.0f, 7.5f)); diff --git a/src/Model.cpp b/src/Model.cpp index 07b8494..4b13d4f 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -103,6 +103,12 @@ Mesh Model::processMesh(aiMesh *mesh, const aiScene *scene) { std::vector specularMaps = loadMaterialTextures(material, aiTextureType_SPECULAR, texture_specular); textures.insert(textures.end(), specularMaps.begin(), specularMaps.end()); + + std::vector normalMaps = loadMaterialTextures(material, aiTextureType_NORMALS, texture_normal); + textures.insert(textures.end(), normalMaps.begin(), normalMaps.end()); + + std::vector heightMaps = loadMaterialTextures(material, aiTextureType_HEIGHT, texture_height); + textures.insert(textures.end(), heightMaps.begin(), heightMaps.end()); } return Mesh(vertices, indices, textures);