commit 36b1d7c0255932142f25ee5739dff422dda324e0
parent b38efbe89fe34a0fac796e76d1ad340aae00ef33
Author: William Casarin <jb55@jb55.com>
Date: Thu, 26 Apr 2018 09:52:24 -0700
terrain color
Diffstat:
4 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/etc/shaders/test.f.glsl b/etc/shaders/test.f.glsl
@@ -6,10 +6,10 @@ precision mediump float;
uniform float fade_factor;
flat in vec3 v_norm;
flat in float v_dot;
+flat in vec4 v_hcol;
out vec4 fragmentColor;
void main() {
- vec4 color = vec4(0.4, 0.4, 0.8, 1.0);
- fragmentColor = vec4(color.xyz * v_dot, 1.0);
+ fragmentColor = vec4(v_hcol * v_dot);
}
diff --git a/etc/shaders/test.v.glsl b/etc/shaders/test.v.glsl
@@ -9,6 +9,7 @@ uniform mat4 normal_matrix;
flat out float v_dot;
flat out vec3 v_norm;
+flat out vec4 v_hcol;
uniform vec3 light_dir;
@@ -17,5 +18,15 @@ void main()
vec4 trans_normal = normal_matrix * vec4(normal, 1);
gl_Position = mvp * local * vec4(position.xyz, 1.0);
v_dot = dot(trans_normal, vec4(light_dir, 0));
- v_norm = normal;
+
+ if (position.z <= 0.1)
+ v_hcol = vec4(0.0, 0.5, 0.79, 1.0);
+ else if (position.z <= 0.2)
+ v_hcol = vec4(0.9176, 0.8156, 0.6588, 1.0);
+ else if (position.z <= 2.0)
+ v_hcol = vec4(0.6274, 0.749, 0.156, 1.0);
+ else if (position.z <= 10.0)
+ v_hcol = vec4(0.5, 0.5, 0.5, 1.0);
+ else
+ v_hcol = vec4(1.0, 1.0, 1.0, 1.0);
}
diff --git a/src/terrain.c b/src/terrain.c
@@ -46,7 +46,7 @@ void
terrain_create(struct terrain *terrain, struct perlin_settings *perlin) {
u32 i;
const double size = 200;
- const double hsize = size/2;
+ const double hsize = size;
int num_verts = hsize*hsize;
static int first = 1;
static float samples_x[40000];
diff --git a/src/update.c b/src/update.c
@@ -90,8 +90,8 @@ void update (struct game *game, u32 dt) {
/* terrain_settings.o2s = fabs(cos(n+2) * 0.5); */
/* terrain_settings.o2 = fabs(sin(n*0.02) * 2); */
/* terrain_settings.freq = fabs(-sin(n)*0.002 * cos(-n)) + 0.02; */
- terrain_settings.exp = fabs(cos(n)*2.0*cos(n)) + 5.0;
- terrain_settings.amplitude = cos(1/n)*2.0*cos(n) + 0.5;
+ /* terrain_settings.exp = fabs(cos(n)*2.0*cos(n)) + 5.0; */
+ /* terrain_settings.amplitude = cos(1/n)*2.0*cos(n) + 0.5; */
terrain_destroy(game->terrain);
terrain_init(game->terrain);