]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
merged & changed lights Lighting
authorPeter Schaefer <schaeferpm@gmail.com>
Sat, 9 May 2015 23:59:38 +0000 (01:59 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Sat, 9 May 2015 23:59:38 +0000 (01:59 +0200)
Weave/Game.cpp
shader/basicTexture_VS.hlsl
shader/lightingTexture_FS.hlsl

index ea2681955e6f411d8049fd54a8927f08dd8c07a4..badaf127711aac8bf6118b7d968f361a67a35cc8 100644 (file)
@@ -47,7 +47,9 @@ Game::Game() : playing(true)
        Shader* shader1 = new Shader("basicTexture_VS.hlsl", "lightingTexture_FS.hlsl");
 
        // load LVL
-       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");
+
+       SceneObject* tmp_world = new SceneObject(shader1, scale(vec3(2.5f,1.f,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 75f9393c4c32eccea2b469843a59558fc2b73b1e..78881cc4413f21cdbc8c577c69cee514023870b0 100644 (file)
@@ -4,7 +4,7 @@
 in vec3 aNormal, aPosition;
 in vec2 aUV;
 
-out vec3 world_Position, worldNormal;
+out vec3 eyePosition, worldNormal;
 out vec2 fUVs;
 
 out vec3  PointLightPosition1, DirectionalLightDirection1;
@@ -17,16 +17,17 @@ uniform int uEnableTransp = 1;
 
 void main()
 {
-       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);
+       PointLightPosition1 = (uView * vec4(0.0f, 1.0f, 0.0f, 1.f)).xyz;
+       DirectionalLightDirection1 = normalize((uView * vec4(-1.f, -.5f, -.5f, 0.f)).xyz);
+
 
        fUVs = aUV;
-       world_Position = (uView * uModel * vec4(aPosition, 1)).xyz;
+       eyePosition = (uView * uModel * vec4(aPosition, 1.f)).xyz;
        mat3 scale = transpose(mat3(uModel))*mat3(uModel);
        vec3 Normal;
        for (int i = 0; i < 3; ++i)
                Normal[i] = 1/(scale[i][i])*aNormal[i];
        worldNormal = normalize((uView * uModel * vec4(Normal, 0.0f)).xyz);
 
-       gl_Position = uProjection * vec4(world_Position,1.f);
+       gl_Position = uProjection * vec4(eyePosition,1.f);
 }
\ No newline at end of file
index 7a1b272323ff7a75d6a0cf093a983d73d2fca8ff..74ce55c643692517e7b05767dfccc89d2e854395 100644 (file)
@@ -1,13 +1,12 @@
 //Fragment Shader
 #version 330
-in vec3 world_Position, worldNormal;
+in vec3 eyePosition, worldNormal;
 in vec2 fUVs;
 
 in vec3 PointLightPosition1, DirectionalLightDirection1;
 
 out vec4 FragmentColor;
 
-uniform vec3 cameraPos;
 uniform sampler2D uColorTexture;
 uniform vec4 material;                                 //vec4 in the form (ambient, point, directional, glossyness); so far it was (1, 1, 1, 3)
  
@@ -16,12 +15,12 @@ void main()
        float specularConst = material[3];
        vec4 uvColor = texture(uColorTexture, fUVs);
 
-       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 AmbientLightColor = .5f * vec3(0.1f, 0.1f, 0.1f);
+       vec3 PointLightColor1 = 2 * vec3(1.0f, 1.0f, 1.0f);
+       vec3 DirectionalLightColor1 = 2 * vec3(0.6f, 0.6f, 0.6f);
 
-       vec3 cameraVec = normalize(world_Position);
-       vec3 worldPointLightDir1 = PointLightPosition1 - world_Position;
+       vec3 cameraVec = normalize(eyePosition);
+       vec3 worldPointLightDir1 = PointLightPosition1 - eyePosition;
        vec3 PointLightDirection1 = normalize(worldPointLightDir1);
 
        float SpecularCosPoint1 = clamp(dot(cameraVec, normalize(reflect(PointLightDirection1, worldNormal))), 0, 1);