commit a261e6002203df4c9540f07cf92d90d652710ae7
parent 8c09c328a4217e9cda18e597960ee312b3386775
Author: William Casarin <jb55@jb55.com>
Date: Tue, 30 Oct 2018 17:34:20 -0700
fix diffuse a bit
Diffstat:
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/etc/shaders/lighting.glsl b/etc/shaders/lighting.glsl
@@ -12,7 +12,6 @@ vec3 standard_light(vec3 color, vec3 position) {
vec3 N = normalize(trans_normal.xyz);
const float ambient_str = 0.1;
- const float shiny = 0.0001;
const float spec_str = 0.5;
float cloud_speed = 20000.0;
@@ -23,17 +22,18 @@ vec3 standard_light(vec3 color, vec3 position) {
clouds *= max(0.0, dot(light_dir, vec3(0.0,0.0,1.0)));
clouds *= 0.35 * exp(clouds * -0.3);
- float brightness = max(0.0, dot(L,N)) * sun_color;
+ float brightness = max(0.0, dot(L,N));
// brightness += clouds;
// brightness = clamp(brightness, 0.0, 1.0);
+ vec3 diffuse = brightness * sun_color;
+ vec3 ambient = ambient_str * sun_color;
+
vec3 view_dir = normalize(camera_position - v_frag_pos);
vec3 reflect_dir = reflect(-light_dir, v_normal);
float spec = pow(max(dot(view_dir, reflect_dir), 0.0), 32.0);
- vec3 diffuse = brightness * sun_color;
- vec3 ambient = ambient_str * sun_color;
vec3 specular = spec_str * spec * sun_color;
return (ambient + diffuse + specular) * color;
diff --git a/src/update.c b/src/update.c
@@ -241,9 +241,9 @@ void resize_fbos(struct game *game, int width, int height) {
// TODO: match based on some real concept of time
static void day_night_cycle(float time, struct resources *res) {
- float val = 51.0;
+ float val = time * 50.0;
float intensity = vec3_dot(res->light_dir, V3(0.0, 0.0, 1.0));
- intensity = clamp(intensity, 0.4, 1.0);
+ intensity = clamp(intensity, 0.0, 0.9);
float light_pos[3];
res->sun_color[0] = 1.0;
@@ -260,8 +260,8 @@ static void day_night_cycle(float time, struct resources *res) {
/* vec3_normalize(res->light_intensity, res->light_intensity); */
res->light_dir[0] = 0.0;
- res->light_dir[1] = -fabs(sin(val));
- res->light_dir[2] = fabs(cos(val));
+ res->light_dir[1] = -sin(val);
+ res->light_dir[2] = -cos(val);
vec3_normalize(res->light_dir, res->light_dir);