Add Directional Light to world class

This commit is contained in:
4VRDriver
2020-09-15 13:46:17 +02:00
parent 6dd36f4254
commit 56190d3cb6
8 changed files with 95 additions and 53 deletions

View File

@@ -82,41 +82,28 @@ void Controller::run() {
//Model model_plant("res/models/plant.ffo");
Model model_container("res/models/container.ffo");
Model model_cube("res/models/cube.ffo");
Model model_dragon("res/models/dragon.ffo");
//Model model_dragon("res/models/dragon.ffo");
Model model_hut("res/models/hut.ffo");
//Model model_sphere("res/models/sphere.ffo");
//Entity backpack(&model_backpack, &shaderProgram);
//Entity sphere(&model_sphere, &shaderProgram);
Entity container(&model_container, &shaderProgram);
Entity dragon(&model_dragon, &shaderProgram);
//Entity container(&model_container, &shaderProgram);
Entity hut(&model_hut, &shaderProgram);
//Entity dragon(&model_dragon, &shaderProgram);
//Entity plant(&model_plant, &shaderProgram);
Entity lightSource(&model_cube, &lightProgram);
lightSource.translate(glm::vec3(-5.0f, 1.0f, 0.0f));
lightSource.setScale(0.2f);
//plant.setScale(5.0f);
dragon.setScale(0.2f);
glm::vec3 lightColor = glm::vec3(1.0f, 1.0f, 1.0f);
glm::vec3 diffuseColor = lightColor * glm::vec3(1.0f);
glm::vec3 ambientColor = diffuseColor * glm::vec3(0.1f);
glm::vec3 specularColor = glm::vec3(1.0f);
shaderProgram.bind();
shaderProgram.setUniform("u_directionalLight.isActive", 1);
shaderProgram.setUniform("u_directionalLight.direction", glm::vec3(-0.2f, -1.0f, -0.3f));
shaderProgram.setUniform("u_directionalLight.ambient", ambientColor * 0.25f);
shaderProgram.setUniform("u_directionalLight.diffuse", diffuseColor * 0.25f);
shaderProgram.setUniform("u_directionalLight.specular", specularColor * 0.25f);
shaderProgram.setUniform("u_material.shininess", 32.0f);
shaderProgram.unbind();
//dragon.setScale(0.2f);
World world(&shaderProgram);
world.addEntity(dragon);
world.addEntity(hut);
world.addEntity(lightSource);
world.updateLight(0, lightSource.getPosition(), glm::vec3(1.0f));
world.updatePointLight(0, true, lightSource.getPosition(), glm::vec3(1.0f));
camera->translate(glm::vec3(0.0f, 0.0f, 7.5f));