diff --git a/resources/shaders/phong.frag b/resources/shaders/phong.frag index 04cf8d3..4eaed19 100644 --- a/resources/shaders/phong.frag +++ b/resources/shaders/phong.frag @@ -10,7 +10,7 @@ out vec4 outColour; vec3 viewPos = vec3(0.0, 0.0, 0.0); vec3 objectColour = vec3(1.0, 1.0, 1.0); -vec3 lightColour = vec3(0.7, 0.0, 0.65); +vec3 lightColour = vec3(0.7, 0.3, 0.65); // vec3 lightColour = vec3(0.3, 0.85, 1.0); void main() { @@ -21,7 +21,7 @@ void main() { vec3 diffuse = diff * lightColour; - float specularStrength = 0; + float specularStrength = 1; vec3 viewDir = normalize(viewPos - FragPos); vec3 reflectDir = reflect(-lightDir, normal); @@ -30,7 +30,7 @@ void main() { vec3 specular = specularStrength * spec * lightColour; - float ambientStrength = 0.4; + float ambientStrength = 0.1; vec3 ambient = ambientStrength * lightColour; vec3 result = (ambient + diffuse + specular) * objectColour; diff --git a/src/main.cpp b/src/main.cpp index 6861553..43e2f25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,7 +29,7 @@ int main (int argc, char** argv) { Shader shader; shader.load("./resources/shaders/phong").attatch().link().use(); - Mesh mesh{ "./resources/test1.obj" }; + Mesh mesh{ "./resources/lucy.obj" }; mesh.setup(); SDL_Event e; diff --git a/src/mesh.cpp b/src/mesh.cpp index d69f57b..8ccc7ae 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -91,7 +91,7 @@ void Mesh::render(Shader& shader) { // Model matrice glm::mat4 model = glm::mat4(1.0f); - model = glm::translate(model, { -17.0f, -17.0f, -17.0f }); + model = glm::translate(model, { -170.0f, -170.0f, -170.0f }); model = glm::rotate(model, glm::radians(-160.0f + this->rotation), glm::vec3(0.0f, 1.0f, 0.0f)); // Gets uniform for model matrice, to be used later GLint uniTrans = glGetUniformLocation(shader.getProgram(), "model"); diff --git a/src/util/util.cpp b/src/util/util.cpp index 7d53052..ba88a34 100644 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -22,13 +22,12 @@ void OBJLtoGLM(ObjLMesh& mesh, mesh.attrib.vertices[3 * index.vertex_index + 1], mesh.attrib.vertices[3 * index.vertex_index + 2] }; - outVert.push_back(vertex); - outNorm.push_back({ - mesh.attrib.normals[3 * index.normal_index + 0], - mesh.attrib.normals[3 * index.normal_index + 1], - mesh.attrib.normals[3 * index.normal_index + 2] - }); + // outNorm.push_back({ + // mesh.attrib.normals[3 * index.normal_index + 0], + // mesh.attrib.normals[3 * index.normal_index + 1], + // mesh.attrib.normals[3 * index.normal_index + 2] + // }); // outTexCoord.push_back({ // mesh.attrib.texcoords[2 * index.texcoord_index + 0], @@ -36,15 +35,16 @@ void OBJLtoGLM(ObjLMesh& mesh, // 0.0f // }); - // if (uniqueVertices.count(vertex) == 0) { - // uniqueVertices[vertex] = static_cast(outVert.size()); - // } + if (uniqueVertices.count(vertex) == 0) { + uniqueVertices[vertex] = static_cast(outVert.size()); + outVert.push_back(vertex); + } - outIndices.push_back(outIndices.size()); + outIndices.push_back(uniqueVertices[vertex]); } } - // ComputeNormals(outNorm, outVert, outIndices); + ComputeNormals(outNorm, outVert, outIndices); } void ComputeNormals(std::vector& normals,