diff options
| author | KonAki <konaki@anokonaki.org> | 2026-10-11 04:37:19 +0800 |
|---|---|---|
| committer | KonAki <konaki@anokonaki.org> | 2026-10-11 04:37:19 +0800 |
| commit | d3b6458db0c189d23100331c0e9e5001ff96c2f1 (patch) | |
| tree | ee8a7a8f0dd344f8416d78e85c1157ef0579498f /examples | |
| parent | d621bc659b49f358b2846cbbcc0373af3bc969bd (diff) | |
3d: smooth terrain light, hills uses fog and mips
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/hills.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/examples/hills.c b/examples/hills.c index c56ab70..a6f36c5 100644 --- a/examples/hills.c +++ b/examples/hills.c @@ -22,6 +22,7 @@ #define SIZE 128 #define MARKERS 24 #define BRUSH 3.0f +#define FOG_END 80.0f #define COL_SKY 0xFF1B1826u #define COL_DIM 0xFF9A93B3u @@ -35,6 +36,7 @@ typedef struct state { kon_terrain_t *terrain; kon_material_t grass; kon_image *ground, *marker; + kon_mipmaps_t *mips; kon_fp_t fp; int raise, lower; double time; @@ -82,6 +84,9 @@ static void draw(kon_program_t *program, kon_framebuffer_t *game, void *user) kon_clearFramebuffer(game, COL_SKY); light.direction = KON_VEC3(-0.4f, -1.0f, -0.3f); light.ambient = 0.45f; + light.fogColor = COL_SKY; + light.fogStart = 25.0f; + light.fogEnd = FOG_END; kon_drawTerrain(game, &camera, state->terrain, &light); for (i = 0; i < MARKERS; i++) { @@ -151,6 +156,8 @@ static int init(kon_program_t *program, void *user) } } state->grass = kon_materialTexture(state->ground); + state->mips = kon_createMipmaps(state->ground); + state->grass.mips = state->mips; state->terrain->material = &state->grass; state->map.columns = SIZE; @@ -172,7 +179,7 @@ static int init(kon_program_t *program, void *user) } kon_fpInit(&state->fp, &state->map, SIZE / 2, SIZE / 2); - state->fp.farZ = 90.0f; + state->fp.farZ = FOG_END; kon_fpPlace(&state->fp, &state->map, state->terrain); kon_fpDebug(&state->fp, program->debug); kon_terrainDebug(state->terrain, program->debug); @@ -185,6 +192,7 @@ static void shutdown(kon_program_t *program, void *user) (void)program; kon_terrainFree(state->terrain); + kon_freeMipmaps(state->mips); kon_freeFramebuffer(state->ground); kon_freeFramebuffer(state->marker); } |
