Load in normal and height maps

(model loading, not rendering)
This commit is contained in:
4VRDriver
2020-09-06 21:18:48 +02:00
parent 8b1fe545c1
commit 6cf551ffb4
3 changed files with 12 additions and 7 deletions

View File

@@ -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;

View File

@@ -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));

View File

@@ -103,6 +103,12 @@ Mesh Model::processMesh(aiMesh *mesh, const aiScene *scene) {
std::vector<Texture*> specularMaps = loadMaterialTextures(material, aiTextureType_SPECULAR, texture_specular);
textures.insert(textures.end(), specularMaps.begin(), specularMaps.end());
std::vector<Texture*> normalMaps = loadMaterialTextures(material, aiTextureType_NORMALS, texture_normal);
textures.insert(textures.end(), normalMaps.begin(), normalMaps.end());
std::vector<Texture*> heightMaps = loadMaterialTextures(material, aiTextureType_HEIGHT, texture_height);
textures.insert(textures.end(), heightMaps.begin(), heightMaps.end());
}
return Mesh(vertices, indices, textures);