Implemented basic materials in to the fragment shader..
This commit is contained in:
28
src/main.cpp
28
src/main.cpp
@ -196,9 +196,31 @@ while(!glfwWindowShouldClose(window))
|
||||
|
||||
// draw cubes
|
||||
shader.use();
|
||||
shader.setVec3("objectColor", glm::vec3( 1.0f, 0.5, 0.31f));
|
||||
shader.setVec3("lightColor",glm::vec3( 1.0f, 1.0f, 1.0f));
|
||||
shader.setVec3("lightPos", lightpos);
|
||||
|
||||
shader.setVec3("material.ambient", glm::vec3(1.0f, 0.5f, 0.31f));
|
||||
shader.setVec3("material.diffuse", glm::vec3(1.0f, 0.5f, 0.31f));
|
||||
shader.setVec3("material.specular", glm::vec3(0.5, 0.5f, 0.5f));
|
||||
shader.setFloat("material.shininess", 32.0f);
|
||||
|
||||
|
||||
glm::vec3 lightColor;
|
||||
lightColor.x = sin(glfwGetTime() * 2.0f);
|
||||
lightColor.y = sin(glfwGetTime() * 0.7f);
|
||||
lightColor.z = sin(glfwGetTime() * 1.3f);
|
||||
|
||||
glm::vec3 diffuseColor = lightColor * glm::vec3(0.5f);
|
||||
glm::vec3 ambientColor = diffuseColor * glm::vec3(0.2f);
|
||||
|
||||
|
||||
|
||||
shader.setVec3("light.position", lightpos);
|
||||
|
||||
shader.setVec3("light.ambient", ambientColor);
|
||||
shader.setVec3("light.diffuse", diffuseColor);
|
||||
shader.setVec3("light.specular", glm::vec3(1.0f, 1.0f, 1.0f));
|
||||
|
||||
|
||||
|
||||
shader.setVec3("viewPos", camera.Position);
|
||||
|
||||
shader.setMat4("view", view);
|
||||
|
Reference in New Issue
Block a user