Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output: fix texture edges when bilinear filter off #1488

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- fixed console commands causing improper ring shutdown with selected inventory item (#1460, regression from 3.0)
- fixed console input immediately ending demo (#1480, regression from 4.1)
- changed `/tp` console command to look for the closest place to teleport to when targeting items (#1484)
- improved appearance of textures around edges when bilinear filter is off (#1483)
Since this removes the seams on pushblocks, this was made optional.
- improved level load times
- improved logs module names readability
- improved crash debug information on Windows
Expand Down
1 change: 1 addition & 0 deletions data/ship/cfg/TR1X_gameflow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@
"DETAIL_LEVEL_LOW": "Low",
"DETAIL_FPS": "FPS",
"DETAIL_PERSPECTIVE": "Perspective",
"DETAIL_PRETTY_PIXELS": "Pretty pixels",
"DETAIL_BILINEAR": "Bilinear",
"DETAIL_TEXTURE_FILTER": "Texture filter",
"DETAIL_FBO_FILTER": "FBO filter",
Expand Down
1 change: 1 addition & 0 deletions data/ship/cfg/TR1X_gameflow_demo_pc.json5
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"DETAIL_LEVEL_LOW": "Low",
"DETAIL_FPS": "FPS",
"DETAIL_PERSPECTIVE": "Perspective",
"DETAIL_PRETTY_PIXELS": "Pretty pixels",
"DETAIL_BILINEAR": "Bilinear",
"DETAIL_TEXTURE_FILTER": "Texture filter",
"DETAIL_FBO_FILTER": "FBO filter",
Expand Down
1 change: 1 addition & 0 deletions data/ship/cfg/TR1X_gameflow_ub.json5
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
"DETAIL_LEVEL_LOW": "Low",
"DETAIL_FPS": "FPS",
"DETAIL_PERSPECTIVE": "Perspective",
"DETAIL_PRETTY_PIXELS": "Pretty pixels",
"DETAIL_BILINEAR": "Bilinear",
"DETAIL_TEXTURE_FILTER": "Texture filter",
"DETAIL_FBO_FILTER": "FBO filter",
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ typedef struct {
bool enable_fps_counter;
float anisotropy_filter;
int32_t turbo_speed;
bool pretty_pixels;
} rendering;

struct {
Expand Down
1 change: 1 addition & 0 deletions src/config_map.def
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ CFG_BOOL(g_Config, rendering.enable_wireframe, false)
CFG_DOUBLE(g_Config, rendering.wireframe_width, 2.5)
CFG_BOOL(g_Config, rendering.enable_perspective_filter, true)
CFG_BOOL(g_Config, rendering.enable_vsync, true)
CFG_BOOL(g_Config, rendering.pretty_pixels, true)
CFG_INT32(g_Config, music_volume, 8)
CFG_INT32(g_Config, sound_volume, 8)
CFG_INT32(g_Config, input.layout, 0)
Expand Down
1 change: 1 addition & 0 deletions src/game/game_string.def
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ GS_DEFINE(DETAIL_LEVEL_MEDIUM, "Medium")
GS_DEFINE(DETAIL_LEVEL_LOW, "Low")
GS_DEFINE(DETAIL_FPS, "FPS")
GS_DEFINE(DETAIL_PERSPECTIVE, "Perspective")
GS_DEFINE(DETAIL_PRETTY_PIXELS, "Pretty pixels")
GS_DEFINE(DETAIL_BILINEAR, "Bilinear")
GS_DEFINE(DETAIL_TEXTURE_FILTER, "Texture filter")
GS_DEFINE(DETAIL_FBO_FILTER, "FBO filter")
Expand Down
42 changes: 34 additions & 8 deletions src/game/option/option_graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ typedef enum GRAPHICS_OPTION_NAME {
OPTION_RENDER_MODE,
OPTION_RESOLUTION,
OPTION_PERSPECTIVE,
OPTION_PRETTY_PIXELS,
OPTION_NUMBER_OF,
OPTION_MIN = OPTION_FPS,
OPTION_MAX = OPTION_PERSPECTIVE,
OPTION_MAX = OPTION_PRETTY_PIXELS,
} GRAPHICS_OPTION_NAME;

typedef struct GRAPHICS_OPTION_ROW {
Expand Down Expand Up @@ -83,6 +84,7 @@ static const GRAPHICS_OPTION_ROW m_GfxOptionRows[] = {
{ OPTION_RENDER_MODE, GS_DETAIL_RENDER_MODE, GS_DETAIL_STRING_FMT },
{ OPTION_RESOLUTION, GS_DETAIL_RESOLUTION, GS_DETAIL_RESOLUTION_FMT },
{ OPTION_PERSPECTIVE, GS_DETAIL_PERSPECTIVE, GS_MISC_ON },
{ OPTION_PRETTY_PIXELS, GS_DETAIL_PRETTY_PIXELS, GS_MISC_ON },
// end
{ OPTION_NUMBER_OF, 0, 0 },
};
Expand Down Expand Up @@ -110,13 +112,13 @@ static int16_t Option_Graphics_PlaceColumns(bool create);

static void Option_Graphics_InitMenu(void)
{
m_GraphicsMenu.first_option = &m_GfxOptionRows[OPTION_FPS];
m_GraphicsMenu.last_option = &m_GfxOptionRows[OPTION_PERSPECTIVE];
m_GraphicsMenu.cur_option = &m_GfxOptionRows[OPTION_FPS];
m_GraphicsMenu.first_option = &m_GfxOptionRows[OPTION_MIN];
m_GraphicsMenu.last_option = &m_GfxOptionRows[OPTION_MAX];
m_GraphicsMenu.cur_option = &m_GfxOptionRows[OPTION_MIN];
m_GraphicsMenu.row_num = 0;
m_GraphicsMenu.num_vis_options = 0;
m_GraphicsMenu.first_visible = &m_GfxOptionRows[OPTION_FPS];
m_GraphicsMenu.last_visible = &m_GfxOptionRows[OPTION_FPS];
m_GraphicsMenu.first_visible = &m_GfxOptionRows[OPTION_MIN];
m_GraphicsMenu.last_visible = &m_GfxOptionRows[OPTION_MIN];
}

static void Option_Graphics_UpdateMenuVisible(void)
Expand All @@ -132,9 +134,9 @@ static void Option_Graphics_UpdateMenuVisible(void)
visible_lines = 16;
}
m_GraphicsMenu.num_vis_options = MIN(OPTION_NUMBER_OF, visible_lines);
m_GraphicsMenu.first_visible = &m_GfxOptionRows[OPTION_FPS];
m_GraphicsMenu.first_visible = &m_GfxOptionRows[OPTION_MIN];
m_GraphicsMenu.last_visible =
&m_GfxOptionRows[OPTION_FPS] + m_GraphicsMenu.num_vis_options - 1;
&m_GfxOptionRows[OPTION_MIN] + m_GraphicsMenu.num_vis_options - 1;
}

static void Option_Graphics_Reinitialize(GRAPHICS_OPTION_NAME starting_option)
Expand Down Expand Up @@ -296,6 +298,10 @@ static void Option_Graphics_UpdateArrows(
m_HideArrowLeft = !g_Config.rendering.enable_perspective_filter;
m_HideArrowRight = g_Config.rendering.enable_perspective_filter;
break;
case OPTION_PRETTY_PIXELS:
m_HideArrowLeft = !g_Config.rendering.pretty_pixels;
m_HideArrowRight = g_Config.rendering.pretty_pixels;
break;

case OPTION_NUMBER_OF:
default:
Expand Down Expand Up @@ -435,6 +441,12 @@ static void Option_Graphics_ChangeTextOption(
break;
}

case OPTION_PRETTY_PIXELS: {
bool is_enabled = g_Config.rendering.pretty_pixels;
Text_ChangeText(value_text, is_enabled ? GS(MISC_ON) : GS(MISC_OFF));
break;
}

case OPTION_NUMBER_OF:
default:
break;
Expand Down Expand Up @@ -538,6 +550,13 @@ void Option_Graphics(INVENTORY_ITEM *inv_item)
}
break;

case OPTION_PRETTY_PIXELS:
if (!g_Config.rendering.pretty_pixels) {
g_Config.rendering.pretty_pixels = true;
reset = OPTION_PRETTY_PIXELS;
}
break;

case OPTION_NUMBER_OF:
default:
break;
Expand Down Expand Up @@ -618,6 +637,13 @@ void Option_Graphics(INVENTORY_ITEM *inv_item)
}
break;

case OPTION_PRETTY_PIXELS:
if (g_Config.rendering.pretty_pixels) {
g_Config.rendering.pretty_pixels = false;
reset = OPTION_PRETTY_PIXELS;
}
break;

case OPTION_NUMBER_OF:
default:
break;
Expand Down
26 changes: 16 additions & 10 deletions src/specific/s_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ static int32_t S_Output_VisibleZClip(
static int32_t S_Output_ZedClipper(
int32_t vertex_count, POINT_INFO *pts, GFX_3D_Vertex *vertices);

static inline float S_Output_GetUV(const uint16_t uv)
{
return g_Config.rendering.pretty_pixels
&& g_Config.rendering.texture_filter == GFX_TF_NN
? uv / 256.0f
: ((uv & 0xFF00) + 127) / 256.0f;
}

static void S_Output_ReleaseTextures(void)
{
if (!m_Renderer3D) {
Expand Down Expand Up @@ -962,10 +970,10 @@ void S_Output_DrawTexturedTriangle(
vertices[i].z = src_vbuf[i]->zv * 0.0001f;

vertices[i].w = 65536.0f / src_vbuf[i]->zv;
vertices[i].s = (((src_uv[i]->u & 0xFF00) + 127) / 256.0f)
* (vertices[i].w / 256.0f);
vertices[i].t = (((src_uv[i]->v & 0xFF00) + 127) / 256.0f)
* (vertices[i].w / 256.0f);
vertices[i].s =
S_Output_GetUV(src_uv[i]->u) * (vertices[i].w / 256.0f);
vertices[i].t =
S_Output_GetUV(src_uv[i]->v) * (vertices[i].w / 256.0f);

vertices[i].r = vertices[i].g = vertices[i].b =
(8192.0f - src_vbuf[i]->g) * multiplier;
Expand All @@ -990,8 +998,8 @@ void S_Output_DrawTexturedTriangle(
points[i].xs = src_vbuf[i]->xs;
points[i].ys = src_vbuf[i]->ys;
points[i].g = src_vbuf[i]->g;
points[i].u = (((src_uv[i]->u & 0xFF00) + 127) / 256.0f);
points[i].v = (((src_uv[i]->v & 0xFF00) + 127) / 256.0f);
points[i].u = S_Output_GetUV(src_uv[i]->u);
points[i].v = S_Output_GetUV(src_uv[i]->v);
}

vertex_count = S_Output_ZedClipper(vertex_count, points, vertices);
Expand Down Expand Up @@ -1068,10 +1076,8 @@ void S_Output_DrawTexturedQuad(
vertices[i].z = src_vbuf[i]->zv * 0.0001f;

vertices[i].w = 65536.0f / src_vbuf[i]->zv;
vertices[i].s = (((src_uv[i]->u & 0xFF00) + 127) / 256.0f)
* (vertices[i].w / 256.0f);
vertices[i].t = (((src_uv[i]->v & 0xFF00) + 127) / 256.0f)
* (vertices[i].w / 256.0f);
vertices[i].s = S_Output_GetUV(src_uv[i]->u) * (vertices[i].w / 256.0f);
vertices[i].t = S_Output_GetUV(src_uv[i]->v) * (vertices[i].w / 256.0f);

vertices[i].r = vertices[i].g = vertices[i].b =
(8192.0f - src_vbuf[i]->g) * multiplier;
Expand Down
Loading