From cb75c48a80c7e596381340404b81d5cae40e5152 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Mon, 23 Sep 2024 02:00:55 -0400 Subject: [PATCH] Sand --- terrain.c | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/terrain.c b/terrain.c index 3ddb906..12787cc 100644 --- a/terrain.c +++ b/terrain.c @@ -93,12 +93,12 @@ #define CLOUDTRANSMAX 0.2 #define CLOUDHEIGHT 2 #define CLOUDSTRETCH 2 -#define CLOUDCHANCE 0.1 +#define CLOUDCHANCE 0.12 #define INIT_LIGHTPITCH (MPI_2 * 1.65) #define INIT_LIGHTYAW (MPI_2 * 0.65) #define INIT_MINLIGHT 0.2 #define INIT_DITHEREND (VIEWDISTANCE - 1.0) -#define INIT_DITHERSTART (INIT_DITHEREND * 0.33) +#define INIT_DITHERSTART (INIT_DITHEREND * 0.5) #define MAXTREEPERCELL 9 #define MAXTREEACROSS 3 #define MAXTREECLOSENESS 0.2 @@ -215,13 +215,15 @@ uint16_t gen_terrain(struct vec3i pos, haloo3d_obj *model, tecs *ecs, // Don't allow the model to have more than some amount of faces/vertices. haloo3d_obj_resetfixed(model, H3D_OBJ_MAXFACES, H3D_OBJ_MAXVERTICES); #define LCOLSTEP 8 + // uint16_t sandcol = COMCOL(model, 0xFFF7); uint16_t landcols[(LCOLSTEP + 1) * 2]; for (int i = 0; i <= LCOLSTEP; i++) { landcols[i] = COMCOL(model, haloo3d_col_lerp(LANDCOL, FLANDCOL, (float)i / LCOLSTEP)); // 0xF2C0); landcols[i + LCOLSTEP + 1] = - COMCOL(model, haloo3d_col_lerp(LANDCOL, UWLANDCOL, + // 0xFDE6 + COMCOL(model, haloo3d_col_lerp(0xFCD5, UWLANDCOL, (float)i / LCOLSTEP)); // 0xF2C0); } fnl_state ns = fnlCreateState(); @@ -283,7 +285,7 @@ uint16_t gen_terrain(struct vec3i pos, haloo3d_obj *model, tecs *ecs, float nlayer = fnlGetNoise2D(&ns, noisex + model->vertices[tfvi].x, noisey + model->vertices[tfvi].z); int landcol; - if (highys[t] < 0) { + if (highys[t] < 0.085) { landcol = LCOLSTEP + 1 + LCOLSTEP * fabs(highys[t]); } else { landcol = LCOLSTEP * fabs(lowys[t]) * (1 + nlayer) * 0.5; @@ -652,12 +654,6 @@ void sys_placement_lock(ecs_placement_lock *lock, ecs_placement *pl) { } } -// void sys_chunk(ecs_chunk *ch, ecs_object *o, tecs **ecs) { -// // Is it really ok to have this check every single time? Seems kinda -// wasteful if (ch->generation == 1) { -// } -// } - // --------------------------------------------------- // Setup functions // --------------------------------------------------- @@ -687,8 +683,6 @@ ecs_eid setup_sea(tecs *ecs, render_context *ctx, ecs_placement *playerpos, haloo3d_obj_resetfixed(model, 2, 4); struct vec3 seacol = haloo3d_gen_paletteuv(SEACOL); // 0xF26F); int seauv = haloo3d_obj_addvtexture(model, seacol); - // struct vec3 seacol2 = haloo3d_gen_paletteuv(0xF008); - // haloo3d_obj_addvtexture(model, seacol2); // clang-format off // REMEMBER: NEGATIVE Z IS FORWARD int tl = haloo3d_obj_addvertex(model, (struct vec4){.x = -1, .y = 0, .z = -1, .w = 1}); @@ -699,7 +693,6 @@ ecs_eid setup_sea(tecs *ecs, render_context *ctx, ecs_placement *playerpos, haloo3d_facei face; fastface(face, seauv, bl, br, tl); haloo3d_obj_addface(model, face); - // model->faces[0][0].texi++; fastface(face, seauv, br, tr, tl); haloo3d_obj_addface(model, face); ECS_SETCOMPONENT(ecs, seaid, ecs_object){ @@ -742,7 +735,6 @@ void draw_gradient(haloo3d_fb *buf, uint16_t topcol, uint16_t botcol, for (int b = 0; b < 8; b++) { haloo3d_fb_set(buf, b, r, (df & 1) ? col[band + 1] : col[band]); df >>= 1; - // haloo3d_col_lerp(topcol, botcol, (float)y / (height - 1))); } uint16_t *bufstart = buf->buffer + r * buf->width; // Then, a repeated growing copy to minimize copies? IDK @@ -752,20 +744,6 @@ void draw_gradient(haloo3d_fb *buf, uint16_t topcol, uint16_t botcol, } } } - // int band = 0; - // for (int y = 0; y < height; y++) { - // // Calculate dither between the two colors - // // Fill the initial section - // haloo3d_fb_set(buf, 0, y, - // haloo3d_col_lerp(topcol, botcol, (float)y / (height - - // 1))); - // uint16_t *bufstart = buf->buffer + y * buf->width; - // // Then, a repeated growing copy to minimize copies? IDK - // for (int size = 1; size < buf->width; size <<= 1) { - // memcpy(bufstart + size, bufstart, - // sizeof(uint16_t) * MIN(size, buf->width - size)); - // } - // } } // ---------------------------------------------------