Skip to content

Commit

Permalink
Use separate cvar for skybox texture filter.
Browse files Browse the repository at this point in the history
Skybox textures are typically very low-res, and having them nearest
filtered can be undesirable even if the rest of textures are.
  • Loading branch information
skullernet committed Nov 8, 2024
1 parent 289fb23 commit 5813712
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions doc/client.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,9 @@ gl_bilerp_pics::
- 1 — enabled for large pictures that don't fit into the scrap
- 2 — enabled for all pictures, including the scrap texture itself

gl_bilerp_skies::
Enables bilinear filtering of skybox textures. Default value is 1 (enabled).

gl_upscale_pcx::
Enables upscaling of PCX images using HQ2x and HQ4x filters. This improves
rendering quality when screen scaling is used. Default value is 0.
Expand Down
21 changes: 16 additions & 5 deletions src/refresh/texture.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static cvar_t *gl_downsample_skins;
static cvar_t *gl_gamma_scale_pics;
static cvar_t *gl_bilerp_chars;
static cvar_t *gl_bilerp_pics;
static cvar_t *gl_bilerp_skies;
static cvar_t *gl_upscale_pcx;
static cvar_t *gl_texturemode;
static cvar_t *gl_texturebits;
Expand Down Expand Up @@ -161,6 +162,12 @@ static void gl_bilerp_pics_changed(cvar_t *self)
GL_InitRawTexture();
}

static void gl_bilerp_skies_changed(cvar_t *self)
{
// change all the existing sky texture objects
update_image_params(BIT(IT_SKY));
}

static void gl_texturebits_changed(cvar_t *self)
{
if (!(gl_config.caps & QGL_CAP_TEXTURE_BITS)) {
Expand Down Expand Up @@ -620,9 +627,6 @@ static void GL_SetFilterAndRepeat(imagetype_t type, imageflags_t flags)
if (type == IT_WALL || type == IT_SKIN) {
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
} else if (type == IT_SKY) {
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
} else {
bool nearest;

Expand All @@ -635,6 +639,8 @@ static void GL_SetFilterAndRepeat(imagetype_t type, imageflags_t flags)
nearest = (gl_bilerp_pics->integer == 0 || gl_bilerp_pics->integer == 1);
else
nearest = (gl_bilerp_pics->integer == 0);
} else if (type == IT_SKY) {
nearest = (gl_bilerp_skies->integer == 0);
} else {
nearest = false;
}
Expand Down Expand Up @@ -693,8 +699,10 @@ static const byte gl_env_ofs[6][14] = {

static void GL_SetCubemapFilterAndRepeat(void)
{
qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, gl_filter_max);
qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, gl_filter_max);
GLenum filter = gl_bilerp_skies->integer ? GL_LINEAR : GL_NEAREST;

qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, filter);
qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, filter);

qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
Expand Down Expand Up @@ -1232,6 +1240,8 @@ void GL_InitImages(void)
gl_bilerp_chars->changed = gl_bilerp_chars_changed;
gl_bilerp_pics = Cvar_Get("gl_bilerp_pics", "1", 0);
gl_bilerp_pics->changed = gl_bilerp_pics_changed;
gl_bilerp_skies = Cvar_Get("gl_bilerp_skies", "1", 0);
gl_bilerp_skies->changed = gl_bilerp_skies_changed;
gl_texturemode = Cvar_Get("gl_texturemode", "GL_LINEAR_MIPMAP_LINEAR", CVAR_ARCHIVE);
gl_texturemode->changed = gl_texturemode_changed;
gl_texturemode->generator = gl_texturemode_g;
Expand Down Expand Up @@ -1319,6 +1329,7 @@ void GL_ShutdownImages(void)
{
gl_bilerp_chars->changed = NULL;
gl_bilerp_pics->changed = NULL;
gl_bilerp_skies->changed = NULL;
gl_texturemode->changed = NULL;
gl_texturemode->generator = NULL;
gl_anisotropy->changed = NULL;
Expand Down

0 comments on commit 5813712

Please sign in to comment.