It's working!
This commit is contained in:
@@ -10,7 +10,7 @@ out vec4 outColour;
|
|||||||
|
|
||||||
vec3 viewPos = vec3(0.0, 0.0, 0.0);
|
vec3 viewPos = vec3(0.0, 0.0, 0.0);
|
||||||
vec3 objectColour = vec3(1.0, 1.0, 1.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);
|
// vec3 lightColour = vec3(0.3, 0.85, 1.0);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@@ -21,7 +21,7 @@ void main() {
|
|||||||
vec3 diffuse = diff * lightColour;
|
vec3 diffuse = diff * lightColour;
|
||||||
|
|
||||||
|
|
||||||
float specularStrength = 0;
|
float specularStrength = 1;
|
||||||
|
|
||||||
vec3 viewDir = normalize(viewPos - FragPos);
|
vec3 viewDir = normalize(viewPos - FragPos);
|
||||||
vec3 reflectDir = reflect(-lightDir, normal);
|
vec3 reflectDir = reflect(-lightDir, normal);
|
||||||
@@ -30,7 +30,7 @@ void main() {
|
|||||||
vec3 specular = specularStrength * spec * lightColour;
|
vec3 specular = specularStrength * spec * lightColour;
|
||||||
|
|
||||||
|
|
||||||
float ambientStrength = 0.4;
|
float ambientStrength = 0.1;
|
||||||
vec3 ambient = ambientStrength * lightColour;
|
vec3 ambient = ambientStrength * lightColour;
|
||||||
|
|
||||||
vec3 result = (ambient + diffuse + specular) * objectColour;
|
vec3 result = (ambient + diffuse + specular) * objectColour;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ int main (int argc, char** argv) {
|
|||||||
Shader shader;
|
Shader shader;
|
||||||
shader.load("./resources/shaders/phong").attatch().link().use();
|
shader.load("./resources/shaders/phong").attatch().link().use();
|
||||||
|
|
||||||
Mesh mesh{ "./resources/test1.obj" };
|
Mesh mesh{ "./resources/lucy.obj" };
|
||||||
mesh.setup();
|
mesh.setup();
|
||||||
|
|
||||||
SDL_Event e;
|
SDL_Event e;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void Mesh::render(Shader& shader) {
|
|||||||
|
|
||||||
// Model matrice
|
// Model matrice
|
||||||
glm::mat4 model = glm::mat4(1.0f);
|
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));
|
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
|
// Gets uniform for model matrice, to be used later
|
||||||
GLint uniTrans = glGetUniformLocation(shader.getProgram(), "model");
|
GLint uniTrans = glGetUniformLocation(shader.getProgram(), "model");
|
||||||
|
|||||||
@@ -22,13 +22,12 @@ void OBJLtoGLM(ObjLMesh& mesh,
|
|||||||
mesh.attrib.vertices[3 * index.vertex_index + 1],
|
mesh.attrib.vertices[3 * index.vertex_index + 1],
|
||||||
mesh.attrib.vertices[3 * index.vertex_index + 2]
|
mesh.attrib.vertices[3 * index.vertex_index + 2]
|
||||||
};
|
};
|
||||||
outVert.push_back(vertex);
|
|
||||||
|
|
||||||
outNorm.push_back({
|
// outNorm.push_back({
|
||||||
mesh.attrib.normals[3 * index.normal_index + 0],
|
// mesh.attrib.normals[3 * index.normal_index + 0],
|
||||||
mesh.attrib.normals[3 * index.normal_index + 1],
|
// mesh.attrib.normals[3 * index.normal_index + 1],
|
||||||
mesh.attrib.normals[3 * index.normal_index + 2]
|
// mesh.attrib.normals[3 * index.normal_index + 2]
|
||||||
});
|
// });
|
||||||
|
|
||||||
// outTexCoord.push_back({
|
// outTexCoord.push_back({
|
||||||
// mesh.attrib.texcoords[2 * index.texcoord_index + 0],
|
// mesh.attrib.texcoords[2 * index.texcoord_index + 0],
|
||||||
@@ -36,15 +35,16 @@ void OBJLtoGLM(ObjLMesh& mesh,
|
|||||||
// 0.0f
|
// 0.0f
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// if (uniqueVertices.count(vertex) == 0) {
|
if (uniqueVertices.count(vertex) == 0) {
|
||||||
// uniqueVertices[vertex] = static_cast<uint32_t>(outVert.size());
|
uniqueVertices[vertex] = static_cast<uint32_t>(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<glm::vec3>& normals,
|
void ComputeNormals(std::vector<glm::vec3>& normals,
|
||||||
|
|||||||
Reference in New Issue
Block a user