From ad02680e9b7a8bbb0045a77f9ced288bf1fe552b Mon Sep 17 00:00:00 2001 From: LockedLunatic Date: Sun, 10 May 2015 01:46:34 +0200 Subject: [PATCH] lighting is DONE!! --- Weave/Game.cpp | 2 +- Weave/Graphix/ViewPort.cpp | 12 ++++++------ shader/basicTexture_VS.hlsl | 4 ++-- shader/lightingTexture_FS.hlsl | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Weave/Game.cpp b/Weave/Game.cpp index 861cf15..ea26819 100644 --- a/Weave/Game.cpp +++ b/Weave/Game.cpp @@ -47,7 +47,7 @@ Game::Game() : playing(true) Shader* shader1 = new Shader("basicTexture_VS.hlsl", "lightingTexture_FS.hlsl"); // load LVL - SceneObject* tmp_world = new SceneObject(shader1, scale(vec3(3.f)), vec4(4.0f, 1.0f, 1.0f, 2.0f), "level_test.dae", "model_levelTest_2D.png"); + SceneObject* tmp_world = new SceneObject(shader1, scale(vec3(2.5f, 1.0f, 2.5f)), vec4(4.0f, 1.0f, 1.0f, 2.0f), "level_test.dae", "model_levelTest_2D.png"); tmp_world->ignore = true; current_world->addObject(tmp_world); diff --git a/Weave/Graphix/ViewPort.cpp b/Weave/Graphix/ViewPort.cpp index affc90a..c9ce4a7 100644 --- a/Weave/Graphix/ViewPort.cpp +++ b/Weave/Graphix/ViewPort.cpp @@ -41,9 +41,9 @@ void ViewPort::bindView(Shader* shader) const{ if (tmp >= 0) glUniformMatrix4fv(tmp, 1, false, value_ptr(projection)); - //tmp = shader->getUniformLocation("uInvProjection"); - //if (tmp >= 0) - // glUniformMatrix4fv(tmp, 1, false, value_ptr(glm::inverse(projection))); + tmp = shader->getUniformLocation("uInvProjection"); + if (tmp >= 0) + glUniformMatrix4fv(tmp, 1, false, value_ptr(glm::inverse(projection))); tmp = shader->getUniformLocation("uView"); if (tmp >= 0) @@ -58,9 +58,9 @@ void ViewPort::bindView(Shader* shader, vec3 pos) const{ if (tmp>=0) glUniformMatrix4fv(tmp, 1, false, value_ptr(projection)); - //tmp = shader->getUniformLocation("uInvProjection"); - //if (tmp >= 0) - // glUniformMatrix4fv(tmp, 1, false, value_ptr(glm::inverse(projection))); + tmp = shader->getUniformLocation("uInvProjection"); + if (tmp >= 0) + glUniformMatrix4fv(tmp, 1, false, value_ptr(glm::inverse(projection))); tmp = shader->getUniformLocation("uView"); if (tmp >= 0) diff --git a/shader/basicTexture_VS.hlsl b/shader/basicTexture_VS.hlsl index a81cc2b..75f9393 100644 --- a/shader/basicTexture_VS.hlsl +++ b/shader/basicTexture_VS.hlsl @@ -17,8 +17,8 @@ uniform int uEnableTransp = 1; void main() { - PointLightPosition1 = (uView * vec4(0.0f, 1.0f, 0.0f, 1.f)).xyz; - DirectionalLightDirection1 = normalize((uView * vec4(-1.f, -0.f, -1.f, 0.f)).xyz); + PointLightPosition1 = (uView * vec4(0.0f, 0.3f, -3.0f, 1.f)).xyz; + DirectionalLightDirection1 = normalize((uView * vec4(-1.f, -0.f, -0.f, 0.f)).xyz); fUVs = aUV; world_Position = (uView * uModel * vec4(aPosition, 1)).xyz; diff --git a/shader/lightingTexture_FS.hlsl b/shader/lightingTexture_FS.hlsl index be5d715..7a1b272 100644 --- a/shader/lightingTexture_FS.hlsl +++ b/shader/lightingTexture_FS.hlsl @@ -16,8 +16,8 @@ void main() float specularConst = material[3]; vec4 uvColor = texture(uColorTexture, fUVs); - vec3 AmbientLightColor = 0 * vec3(0.2f, 0.2f, 0.2f); - vec3 PointLightColor1 = 0 * vec3(1.0f, 1.0f, 1.0f); + vec3 AmbientLightColor = 0.5 * vec3(0.2f, 0.2f, 0.2f); + vec3 PointLightColor1 = 1 * vec3(1.0f, 0.0f, 0.0f); vec3 DirectionalLightColor1 = 1 * vec3(0.6f, 0.6f, 0.6f); vec3 cameraVec = normalize(world_Position); @@ -26,14 +26,14 @@ void main() float SpecularCosPoint1 = clamp(dot(cameraVec, normalize(reflect(PointLightDirection1, worldNormal))), 0, 1); float SpecularCosDirection1 = clamp(dot(cameraVec, normalize(reflect(-DirectionalLightDirection1, worldNormal))), 0, 1); - SpecularCosPoint1 = 0; + //SpecularCosPoint1 = 0; //SpecularCosDirection1 = 0; float cosThetaPoint1 = clamp(dot(worldNormal, PointLightDirection1), 0, 1); float cosThetaDirection1 = clamp(dot(worldNormal, -DirectionalLightDirection1), 0, 1); - cosThetaPoint1 = 0; - cosThetaDirection1 = 0; + //cosThetaPoint1 = 0; + //cosThetaDirection1 = 0; float squaredist1 = worldPointLightDir1.x * worldPointLightDir1.x + worldPointLightDir1.y * worldPointLightDir1.y + worldPointLightDir1.z * worldPointLightDir1.z; -- 2.47.3