/apps/demos/scenery: narrower cull, new assets used

This commit is contained in:
veclavtalica 2025-02-26 19:57:38 +03:00
parent da5bdb4fae
commit 1c3973c6a2
4 changed files with 21 additions and 8 deletions

View File

@ -175,7 +175,7 @@ static uint32_t adler32(const void *buf, size_t buflength) {
static void draw_terrain(SceneIngame *scn) {
/* used to cull invisible tiles over field of view (to horizon) */
Vec2 const d = vec2_norm((Vec2){ .x = scn->looking_direction.x, .y = scn->looking_direction.z });
float const c = cosf((float)M_PI_2 * 0.8f);
float const c = cosf((float)M_PI_2 * 0.8f * 0.8f);
/* draw terrain in circle */
int32_t const rsi = (int32_t)TERRAIN_RADIUS * (int32_t)TERRAIN_RADIUS;
@ -197,7 +197,7 @@ static void draw_terrain(SceneIngame *scn) {
float d2 = heightmap[lx + 1][ly - 1];
float d3 = heightmap[lx][ly - 1];
draw_quad("/assets/grass.png",
draw_quad("/assets/grass2.png",
(Vec3){ (float)x, d0, (float)y },
(Vec3){ (float)x + 1, d1, (float)y },
(Vec3){ (float)x + 1, d2, (float)y - 1 },
@ -207,7 +207,7 @@ static void draw_terrain(SceneIngame *scn) {
if (((float)(adler32(&((Vec2){x, y}), sizeof (Vec2)) % 100) / 100) <= TREE_DENSITY)
draw_billboard("/assets/trreez.png",
(Vec3){ (float)x, d0 + 2.f, (float)y },
(Vec3){ (float)x, d0 + 1.95f, (float)y },
(Vec2){2.f, 2.f},
(Rect){0},
(Color){255, 255, 255, 255}, true);
@ -224,11 +224,15 @@ static void draw_terrain(SceneIngame *scn) {
float x = (float)(floorf(scn->pos.x - HALF_TERRAIN_DISTANCE + (float)lx));
float y = (float)(floorf(scn->pos.z - HALF_TERRAIN_DISTANCE + (float)ly));
float d0 = heightmap[lx][ly];
float d = heightmap[lx][ly];
draw_billboard("/assets/grasses/10.png",
(Vec3){ (float)x, d0 + 0.15f, (float)y },
(Vec2){0.3f, 0.3f},
draw_billboard("/assets/grasses/25.png",
(Vec3){
(float)x + (float)((adler32(&((Vec2){x, y}), sizeof (Vec2))) % 32) / 64.0f,
d + 0.2f,
(float)y + (float)((adler32(&((Vec2){y, x}), sizeof (Vec2))) % 32) / 64.0f
},
(Vec2){0.4f, 0.4f},
(Rect){0},
(Color){255, 255, 255, 255}, true);
}
@ -298,7 +302,7 @@ Scene *ingame_scene(State *state) {
new_scene->mouse_captured = true;
m_audio(m_set(path, "music/mod65.xm"),
m_audio(m_set(path, "music/woah.ogg"),
m_opt(channel, "soundtrack"),
m_opt(repeat, true));

BIN
data/assets/grass2.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
data/assets/grasses/25.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
data/music/woah.ogg (Stored with Git LFS) Normal file

Binary file not shown.