polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

commit fb137e83bb103e25e325cbcb3486654438d355e2
parent 8ffc82c975c7cbf989c7622c386b030d25a318ad
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 31 Oct 2018 12:22:51 -0700

this is fine

Diffstat:
Metc/shaders/lighting.glsl | 5+++--
Metc/shaders/terrain.glsl | 2+-
Msrc/render.c | 3+--
Msrc/update.c | 6+++---
4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/etc/shaders/lighting.glsl b/etc/shaders/lighting.glsl @@ -21,8 +21,8 @@ vec3 standard_light(vec3 color, vec3 position) { vec4 trans_normal = normal_matrix * v4_normal; const float pi = 3.14159265; - const float shiny = 16.0; - float ambient_str = 0.1 + light_intensity * 0.1; + const float shiny = 8.0; + float ambient_str = 0.2; float spec_str = 0.5 * light_intensity; vec3 ray = camera_position - position; @@ -48,6 +48,7 @@ vec3 standard_light(vec3 color, vec3 position) { vec3 halfway_dir = normalize(light_dir + view_dir); // blinn-phong spec = energy_conservation * pow(max(dot(v_normal, halfway_dir), 0.0), shiny); } + else { const float energy_conservation = ( 2.0 + shiny ) / ( 2.0 * pi ); vec3 reflect_dir = reflect(-light_dir, v_normal); // phong diff --git a/etc/shaders/terrain.glsl b/etc/shaders/terrain.glsl @@ -25,7 +25,7 @@ const int nlands = 6; const vec4 land[nlands] = vec4[]( vec4(0.0, 0.5, 0.79, 0.0), // 0 - water vec4(0.9176, 0.8156, 0.6588, 1.0), // 1 - sand - vec4(0.6274, 0.749, 0.156, 2.0), // 2 - grass + vec4(0.6274, 0.5, 0.156, 2.0), // 2 - grass vec4(0.4627, 0.3333, 0.1686, 20.0), // 3 - dirt vec4(0.5, 0.5, 0.5, 80.0), // 4 - stone vec4(1.0, 1.0, 1.0, 380.0) // 5 - snow diff --git a/src/render.c b/src/render.c @@ -189,9 +189,8 @@ void render (struct game *game, struct render_config *config) { glEnable(GL_DEPTH_TEST); - gamma_correct(res->sun_color, gtmp); float sky_intensity = clamp(res->light_intensity, 0.2, 1.0); - vec3_scale(gtmp, sky_intensity, gtmp); + vec3_scale(res->sun_color, sky_intensity, gtmp); glClearColor( gtmp[0], gtmp[1], gtmp[2], 1.0 ); //clear background screen to black /* glClearColor( 0.5294f * adjust, 0.8078f * adjust, 0.9216f * adjust, 1.0f ); //clear background screen to black */ diff --git a/src/update.c b/src/update.c @@ -239,9 +239,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 = time; - float intensity = vec3_dot(res->light_dir, V3(0.0, 0.0, 1.0)); - intensity = clamp(intensity, 0.0, 0.6); + float val = time * 10000.0; + float intensity = vec3_dot(res->light_dir, V3(0.0, 0.0, 0.8)); + float light_pos[3]; res->sun_color[0] = 1.0;