add trees to scenery, disable mipmapping by default, increase index buffer size again
This commit is contained in:
parent
8c0f43ec34
commit
6812c7c13d
@ -17,6 +17,7 @@
|
|||||||
#define TERRAIN_DISTANCE (TERRAIN_RADIUS * 2)
|
#define TERRAIN_DISTANCE (TERRAIN_RADIUS * 2)
|
||||||
#define HALF_TERRAIN_DISTANCE ((float)TERRAIN_DISTANCE / 2)
|
#define HALF_TERRAIN_DISTANCE ((float)TERRAIN_DISTANCE / 2)
|
||||||
#define PLAYER_HEIGHT 0.6f
|
#define PLAYER_HEIGHT 0.6f
|
||||||
|
#define TREE_DENSITY 0.02f
|
||||||
|
|
||||||
/* TODO: pregenerate grid of levels of detail */
|
/* TODO: pregenerate grid of levels of detail */
|
||||||
static float heightmap[TERRAIN_DISTANCE][TERRAIN_DISTANCE];
|
static float heightmap[TERRAIN_DISTANCE][TERRAIN_DISTANCE];
|
||||||
@ -26,7 +27,7 @@ static void process_fly_mode(State *state) {
|
|||||||
SceneIngame *scn = (SceneIngame *)state->scene;
|
SceneIngame *scn = (SceneIngame *)state->scene;
|
||||||
|
|
||||||
DrawCameraFromPrincipalAxesResult dir_and_up =
|
DrawCameraFromPrincipalAxesResult dir_and_up =
|
||||||
draw_camera_from_principal_axes(scn->pos, scn->roll, scn->pitch, scn->yaw, (float)M_PI_2 * 0.8f, 1, TERRAIN_RADIUS * M_SQRT2f);
|
draw_camera_from_principal_axes(scn->pos, scn->roll, scn->pitch, scn->yaw, (float)M_PI_2 * 0.8f, 1, TERRAIN_RADIUS * sqrtf(3));
|
||||||
|
|
||||||
const Vec3 right = m_vec_norm(m_vec_cross(dir_and_up.direction, dir_and_up.up));
|
const Vec3 right = m_vec_norm(m_vec_cross(dir_and_up.direction, dir_and_up.up));
|
||||||
const float speed = 0.04f; /* TODO: put this in a better place */
|
const float speed = 0.04f; /* TODO: put this in a better place */
|
||||||
@ -83,7 +84,7 @@ static void process_ground_mode(State *state) {
|
|||||||
SceneIngame *scn = (SceneIngame *)state->scene;
|
SceneIngame *scn = (SceneIngame *)state->scene;
|
||||||
|
|
||||||
DrawCameraFromPrincipalAxesResult dir_and_up =
|
DrawCameraFromPrincipalAxesResult dir_and_up =
|
||||||
draw_camera_from_principal_axes(scn->pos, scn->roll, scn->pitch, scn->yaw, (float)M_PI_2 * 0.8f, 1, TERRAIN_RADIUS * M_SQRT2f);
|
draw_camera_from_principal_axes(scn->pos, scn->roll, scn->pitch, scn->yaw, (float)M_PI_2 * 0.8f, 1, TERRAIN_RADIUS * sqrtf(3));
|
||||||
|
|
||||||
dir_and_up.direction.y = 0;
|
dir_and_up.direction.y = 0;
|
||||||
dir_and_up.direction = vec3_norm(dir_and_up.direction);
|
dir_and_up.direction = vec3_norm(dir_and_up.direction);
|
||||||
@ -153,6 +154,20 @@ static int32_t ceil_sqrt(int32_t const n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t adler32(const void *buf, size_t buflength) {
|
||||||
|
const uint8_t *buffer = (const uint8_t*)buf;
|
||||||
|
|
||||||
|
uint32_t s1 = 1;
|
||||||
|
uint32_t s2 = 0;
|
||||||
|
|
||||||
|
for (size_t n = 0; n < buflength; n++) {
|
||||||
|
s1 = (s1 + buffer[n]) % 65521;
|
||||||
|
s2 = (s2 + s1) % 65521;
|
||||||
|
}
|
||||||
|
return (s2 << 16) | s1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void draw_terrain(SceneIngame *scn) {
|
static void draw_terrain(SceneIngame *scn) {
|
||||||
/* draw terrain in circle */
|
/* draw terrain in circle */
|
||||||
int32_t const rsi = (int32_t)TERRAIN_RADIUS * (int32_t)TERRAIN_RADIUS;
|
int32_t const rsi = (int32_t)TERRAIN_RADIUS * (int32_t)TERRAIN_RADIUS;
|
||||||
@ -177,7 +192,14 @@ static void draw_terrain(SceneIngame *scn) {
|
|||||||
(Vec3){ (float)x, d3, (float)y - 1 },
|
(Vec3){ (float)x, d3, (float)y - 1 },
|
||||||
(Rect){ .w = 128, .h = 128 },
|
(Rect){ .w = 128, .h = 128 },
|
||||||
(Color){255, 255, 255, 255});
|
(Color){255, 255, 255, 255});
|
||||||
}
|
|
||||||
|
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 },
|
||||||
|
(Vec2){2.f, 2.f},
|
||||||
|
(Rect){0},
|
||||||
|
(Color){255, 255, 255, 255}, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t const rsi_g = (int32_t)GRASS_RADIUS * (int32_t)GRASS_RADIUS;
|
int32_t const rsi_g = (int32_t)GRASS_RADIUS * (int32_t)GRASS_RADIUS;
|
||||||
|
BIN
data/assets/trreez.png
(Stored with Git LFS)
Normal file
BIN
data/assets/trreez.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -24,7 +24,7 @@ extern float camera_2d_zoom;
|
|||||||
|
|
||||||
extern double depth_range_low, depth_range_high;
|
extern double depth_range_low, depth_range_high;
|
||||||
|
|
||||||
#define QUAD_ELEMENT_BUFFER_LENGTH ((65536 * 4) / 6)
|
#define QUAD_ELEMENT_BUFFER_LENGTH ((65536 * 8) / 6)
|
||||||
#define CIRCLE_VERTICES_MAX 2048
|
#define CIRCLE_VERTICES_MAX 2048
|
||||||
|
|
||||||
/* TODO: limit to only most necessary */
|
/* TODO: limit to only most necessary */
|
||||||
|
@ -242,7 +242,7 @@ static void add_new_atlas(TextureCache *cache) {
|
|||||||
/* TODO: create a PBO surface if possible, reducing duplication */
|
/* TODO: create a PBO surface if possible, reducing duplication */
|
||||||
SDL_Surface *new_atlas = create_surface((int)ctx.texture_atlas_size, (int)ctx.texture_atlas_size);
|
SDL_Surface *new_atlas = create_surface((int)ctx.texture_atlas_size, (int)ctx.texture_atlas_size);
|
||||||
arrput(cache->atlas_surfaces, new_atlas);
|
arrput(cache->atlas_surfaces, new_atlas);
|
||||||
arrput(cache->atlas_textures, create_gpu_texture(TEXTURE_FILTER_NEAREAST, true, 4, (int)ctx.texture_atlas_size, (int)ctx.texture_atlas_size));
|
arrput(cache->atlas_textures, create_gpu_texture(TEXTURE_FILTER_NEAREAST, false, 4, (int)ctx.texture_atlas_size, (int)ctx.texture_atlas_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user