Commit 45d77648 authored by Sadman Kazi's avatar Sadman Kazi 🎸

Add phong lighting

parent cb5fd0f7
Pipeline #162 passed with stage
in 3 minutes and 13 seconds
......@@ -29,11 +29,11 @@ coming soon.
- Vertex and Fragment shaders support
- Textures support
- Basic Lighting
- Phong lighting model
- Material support
## Roadmap
These features are planned to be included *very soon*.
- Phong lighting model
- Material support
- Dynamic shaders management
- Level import and export
......
......@@ -20,9 +20,9 @@ uniform sampler2D u_sampler;
uniform DirectionalLight u_dir_light;
vec4 calcLight(BaseLight base, vec3 dir, vec3 normal) {
//calculate attentuation
float diffuseFactor = dot(normal, -dir);
vec4 diffuseColor = vec4(0, 0, 0, 0);
vec4 diffuseColor = vec4(1, 1, 1, 1);
if (diffuseFactor > 0) {
diffuseColor = vec4(base.color, 1.0) * base.intensity * diffuseFactor;
......@@ -45,7 +45,8 @@ void main() {
}
vec3 normal = normalize(normal0);
total_light += calcDirectionalLight(u_dir_light, normal);
//total_light += calcDirectionalLight(u_dir_light, normal);
total_light += calcLight(u_dir_light.base, u_dir_light.direction, normal);
frag_color = color * total_light;
}
......
......@@ -17,6 +17,7 @@
#include "input.h"
#include <iostream>
#include "time.h"
#include <cmath>
#include "phong_shader.h"
Game::Game()
......@@ -43,6 +44,7 @@ Game::Game()
m_camera = new Camera(glm::vec3(0.0f, 0.0f, -2.0f), 70.0f, (float)WIDTH/HEIGHT, 1.0f, 100.0f);
m_transform->setScale(glm::vec3(0.5f, 0.5f, 0.5f));
m_transform->setPos(glm::vec3(0,0,5));
m_counter = 0;
}
......@@ -81,11 +83,10 @@ void Game::render() {
void Game::update() {
m_counter += Time::getDelta();
//std::cout << counter << std::endl;
float sinCounter = m_counter;
float sinCounter = sin(m_counter);
float absSinCounter = abs(sinCounter);
//transform->GetPos().x = sinCounter;
m_transform->setPos(glm::vec3(0,0,5));
m_transform->getPos().x = sinCounter;
m_transform->getRot().y = sinCounter;
//transform->GetRot().z = sinCounter;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment