summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--application/main.cpp2
-rw-r--r--gfx/gl/shaders/basicShader.fs4
2 files changed, 5 insertions, 1 deletions
diff --git a/application/main.cpp b/application/main.cpp
index 7e23a16..bf40f1c 100644
--- a/application/main.cpp
+++ b/application/main.cpp
@@ -85,6 +85,8 @@ public:
camera.RotateY(0.7854);
shader.setView(camera.GetViewProjection());
shader.setUniform("lightDirection", glm::normalize(glm::vec3 {1, -1, 0}));
+ shader.setUniform("lightColor", {.6, .6, .6});
+ shader.setUniform("ambientColor", {0.5, 0.5, 0.5});
auto t_start = std::chrono::high_resolution_clock::now();
const auto framelen = std::chrono::milliseconds {1000} / 120;
diff --git a/gfx/gl/shaders/basicShader.fs b/gfx/gl/shaders/basicShader.fs
index 7d79575..b6c011d 100644
--- a/gfx/gl/shaders/basicShader.fs
+++ b/gfx/gl/shaders/basicShader.fs
@@ -5,9 +5,11 @@ in vec3 normal0;
uniform sampler2D sampler;
uniform vec3 lightDirection;
+uniform vec3 lightColor;
+uniform vec3 ambientColor;
void main()
{
gl_FragColor = texture(sampler, texCoord0);
- gl_FragColor.xyz *= clamp(dot(-lightDirection, normal0), 0.0, 1.0);
+ gl_FragColor.xyz *= clamp(ambientColor + (dot(-lightDirection, normal0) * lightColor), 0.0, 1.0);
}