]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
lighting is DONE!!
authorLockedLunatic <locked.lunatic@aon.at>
Sat, 9 May 2015 23:46:34 +0000 (01:46 +0200)
committerLockedLunatic <locked.lunatic@aon.at>
Sat, 9 May 2015 23:46:34 +0000 (01:46 +0200)
Weave/Game.cpp
Weave/Graphix/ViewPort.cpp
shader/basicTexture_VS.hlsl
shader/lightingTexture_FS.hlsl

index 861cf158501b3715d2eaba33af977104b7e1ccd7..ea2681955e6f411d8049fd54a8927f08dd8c07a4 100644 (file)
@@ -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);
 
index affc90aba20b5c44f4f02848185729691e4da3c7..c9ce4a73523b75bb7f30c589f478bd274edba954 100644 (file)
@@ -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)
index a81cc2ba3dc4f5adafc7cd26664519ad69ae6846..75f9393c4c32eccea2b469843a59558fc2b73b1e 100644 (file)
@@ -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;
index be5d71526eba7894bfd4d887ccb6abd70875023c..7a1b272323ff7a75d6a0cf093a983d73d2fca8ff 100644 (file)
@@ -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;