]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
parameter changes for directional and ambient light
authorLockedLunatic <locked.lunatic@aon.at>
Thu, 19 May 2016 18:17:20 +0000 (20:17 +0200)
committerLockedLunatic <locked.lunatic@aon.at>
Thu, 19 May 2016 18:17:20 +0000 (20:17 +0200)
ambient light moved out of the shader

Weave/Graphix/Lights/AmbientLight.cpp
Weave/Graphix/Lights/DirectionalLight.cpp
Weave/Scene/Scene.cpp
Weave/Scene/Scene.h
shader/lightingTexture_FS.hlsl

index af8e60dcb416da9df47adb671ca2a6ce21a5e741..f49ea52cc2d536572fd321e5e6686413db6f6405 100644 (file)
@@ -1,10 +1,14 @@
 #include "AmbientLight.h"
+#include "../Shader.h"
 
 AmbientLight::AmbientLight(const vec3 & _color) :
        Light(_color)
 {
+       Shader::getShader(SH_LIGHTING)->useShader();
+       Shader::getShader(SH_ACTIVE)->setUniformLocation("AmbientLightColor", color);
 }
 
 AmbientLight::~AmbientLight()
 {
+
 }
\ No newline at end of file
index 4789afc8d017d48cb5cd623d7a277e4e603d2dd7..806242ad806d3414c5e1d678514aa1fc68f9ea2e 100644 (file)
@@ -8,8 +8,8 @@ DirectionalLight::DirectionalLight(const vec3& _color, const float _size, const
        direction(normalize(_direction))
 {
        lightview = lookAt(direction, vec3(0.0f, 0.0f, 0.0f), vec3(0.0f, 1.0f, 0.0f));
-       proj = scale(vec3(size));
-       invproj = scale(vec3(1 / size));
+       proj = scale(vec3(1 / size));
+       invproj = scale(vec3(size));
        
        Shader::getShader(SH_LIGHTING)->useShader();
        Shader::getShader(SH_ACTIVE)->setUniformLocation("DirectionalLightDirection", direction);
@@ -27,8 +27,8 @@ void DirectionalLight::changeSize(const float _size)
 {
        size = _size;
 
-       proj = scale(vec3(size));
-       invproj = scale(vec3(1 / size));
+       proj = scale(vec3(1 / size));
+       invproj = scale(vec3(size));
 }
 
 void DirectionalLight::changeDirection(const vec3& _direction)
index 87051d88944b05f907a0627157eea017111bcdc2..37509b6f4c30c3a82c8fa2fd86bb747c025cb1cc 100644 (file)
@@ -41,7 +41,8 @@ camera(fovy, (float)width/height, zNear, zFar),
 lookat(_lookat)
 {
        //Lights
-       dirLight = new DirectionalLight(vec3(1.2f), 0.2f, vec3(-1.f, -0.5f, -0.5f));
+       ambLight = new AmbientLight(vec3(0.25f));
+       dirLight = new DirectionalLight(vec3(0.4f), 30.0f, vec3(1.f, -0.5f, -0.5f));
        //dirLight = new DirectionalLight(vec3(1.2f), 0.2f, vec3(0.0f, 0.0f, -1.0f));
 
 
index a3072b7337cd349258344020a306cff7af89d6d6..0b551320824ab779c9b09093d29e911e06d41a90 100644 (file)
@@ -81,4 +81,5 @@ protected:
        fBufferObject* shadowdir;
 
        DirectionalLight* dirLight;
+       AmbientLight* ambLight;
 };
index dc8f1e0b44020a49feb60ce03567810b7630717d..9c55e8ff7df42df8647083332b01b26581d6a2ef 100644 (file)
@@ -15,6 +15,7 @@ uniform sampler2D uColorTexture;
 uniform sampler2D uPointLightXP;
 uniform vec4 material;                                 //vec4 in the form (ambient, point, directional, glossyness); so far it was (1, 1, 1, 3)
 uniform vec3 dirLightColor;
+uniform vec3 AmbientLightColor;
 
 float DirLightCalcShadowFactor(vec4 LightSpacePos)
 {
@@ -23,7 +24,7 @@ float DirLightCalcShadowFactor(vec4 LightSpacePos)
        float z = 0.5f * ProjCoords.z + 0.5f;
 
        if (UVCoords.x < 0 || UVCoords.x > 1 || UVCoords.y < 0 || UVCoords.y > 1 || z < 0 || z > 1)
-               return 0.0f;
+               return 1.0f;
 
        float Depth = texture(uPointLightXP, UVCoords).x;
        if (Depth < (z + 0.00001f))
@@ -38,8 +39,7 @@ void main()
        float specularConst = material[3];
        vec4 uvColor = texture(uColorTexture, fUVs);
 
-       vec3 AmbientLightColor = .5f * vec3(0.1f, 0.1f, 0.1f);
-       vec3 PointLightColor1 = 2 * vec3(1.0f, 1.0f, 1.0f);
+       vec3 PointLightColor1 = vec3(2.0f, 2.0f, 2.0f);
 
        vec3 cameraVec = normalize(eyePosition);
        vec3 worldPointLightDir1 = PointLightPosition1 - eyePosition;