From 21463876760d8a77872b7d89f932754e90743ec3 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 18 Apr 2022 00:46:10 +0200 Subject: [PATCH] Use bilinear filter for skybox textures --- src/client/model.c | 2 +- src/client/sky.c | 4 ++-- src/client/texture.c | 6 +++--- src/client/texture.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/client/model.c b/src/client/model.c index 5f7dd17..3a8ba6c 100644 --- a/src/client/model.c +++ b/src/client/model.c @@ -289,7 +289,7 @@ Model *model_load(const char *path, const char *textures_path, Mesh *cube, Model char filepath[strlen(textures_path) + 1 + strlen(texture) + 1]; sprintf(filepath, "%s/%s", textures_path, texture); - Texture *texture = texture_load_cubemap(filepath); + Texture *texture = texture_load_cubemap(filepath, false); model_node_add_mesh(node, &(ModelMesh) { .mesh = cube, diff --git a/src/client/sky.c b/src/client/sky.c index e648d8d..2268f51 100644 --- a/src/client/sky.c +++ b/src/client/sky.c @@ -95,8 +95,8 @@ bool sky_init() skybox_loc_VP = glGetUniformLocation(skybox_prog, "VP"); GL_DEBUG skybox_loc_daylight = glGetUniformLocation(skybox_prog, "daylight"); GL_DEBUG - skybox_texture_day = texture_load_cubemap(RESSOURCE_PATH "textures/skybox/day")->txo; - skybox_texture_night = texture_load_cubemap(RESSOURCE_PATH "textures/skybox/night")->txo; + skybox_texture_day = texture_load_cubemap(RESSOURCE_PATH "textures/skybox/day", true)->txo; + skybox_texture_night = texture_load_cubemap(RESSOURCE_PATH "textures/skybox/night", true)->txo; skybox_mesh.data = skybox_vertices; mesh_upload(&skybox_mesh); diff --git a/src/client/texture.c b/src/client/texture.c index a80738f..525b2aa 100644 --- a/src/client/texture.c +++ b/src/client/texture.c @@ -90,7 +90,7 @@ static inline int least_common_multiple(int a, int b) return lcm; } -Texture *texture_load_cubemap(char *path) +Texture *texture_load_cubemap(char *path, bool bilinear_filter) { Texture *texture; if (lookup_texture(path, &texture)) @@ -153,8 +153,8 @@ Texture *texture_load_cubemap(char *path) stbi_image_free(data); } - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST); GL_DEBUG - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); GL_DEBUG + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, bilinear_filter ? GL_LINEAR : GL_NEAREST); GL_DEBUG + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, bilinear_filter ? GL_LINEAR : GL_NEAREST); GL_DEBUG glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); GL_DEBUG glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); GL_DEBUG glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); GL_DEBUG diff --git a/src/client/texture.h b/src/client/texture.h index 933fe72..25111f7 100644 --- a/src/client/texture.h +++ b/src/client/texture.h @@ -10,7 +10,7 @@ typedef struct { } Texture; Texture *texture_load(char *path, bool mipmap); -Texture *texture_load_cubemap(char *path); +Texture *texture_load_cubemap(char *path, bool linear_filter); void texture_upload(Texture *texture, unsigned char *data, GLenum format, bool mipmap); void texture_destroy(Texture *texture); -- 2.44.0