From 6d1e3164d6e061f682b624a4067ec9107fc787a0 Mon Sep 17 00:00:00 2001 From: Peter Schaefer Date: Sun, 10 May 2015 01:59:38 +0200 Subject: [PATCH] merged & changed lights --- Weave/Game.cpp | 4 +++- shader/basicTexture_VS.hlsl | 11 ++++++----- shader/lightingTexture_FS.hlsl | 13 ++++++------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Weave/Game.cpp b/Weave/Game.cpp index ea26819..badaf12 100644 --- a/Weave/Game.cpp +++ b/Weave/Game.cpp @@ -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); diff --git a/shader/basicTexture_VS.hlsl b/shader/basicTexture_VS.hlsl index 75f9393..78881cc 100644 --- a/shader/basicTexture_VS.hlsl +++ b/shader/basicTexture_VS.hlsl @@ -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 diff --git a/shader/lightingTexture_FS.hlsl b/shader/lightingTexture_FS.hlsl index 7a1b272..74ce55c 100644 --- a/shader/lightingTexture_FS.hlsl +++ b/shader/lightingTexture_FS.hlsl @@ -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); -- 2.47.3