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

FF7: allow filtering of internal textures that were originally filtered. #764

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## FF7

- Core: added option to filter what the original game filtered when still using internal textures.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put this section in the right order after the Next. See other PR examples.

# Next

- Full commit list since last stable release: https://github.com/julianxhokaxhiu/FFNx/compare/1.21.2...master
Expand Down
6 changes: 5 additions & 1 deletion misc/FFNx.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ enable_anisotropic = true
#[BILINEAR]
# Enable bilinear filtering on 3D textures. For FF7, textures in menu are also filtered.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~
enable_bilinear = false
enable_bilinear = false

#[INTERNAL TEXTURES]
# Enable filtering on internal textures that were filtered in original release, and that can be filtered without glitches.
filter_internal_textures = true

#[LIGHTING]
# Enable advanced lighting mode with real-time shadows.
Expand Down
6 changes: 4 additions & 2 deletions src/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ bool mdef_fix;
long enable_antialiasing;
bool enable_anisotropic;
bool enable_bilinear;
bool filter_internal_textures;
bool enable_lighting;
bool prefer_lighting_cpu_calculations;
long game_lighting;
Expand Down Expand Up @@ -256,8 +257,9 @@ void read_cfg()
mdef_fix = config["mdef_fix"].value_or(true);
enable_antialiasing = config["enable_antialiasing"].value_or(0);
enable_anisotropic = config["enable_anisotropic"].value_or(true);
enable_bilinear = config["enable_bilinear"].value_or(false);
enable_lighting = config["enable_lighting"].value_or(false);
enable_bilinear = config["enable_bilinear"].value_or(false);
filter_internal_textures = config["filter_internal_textures"].value_or(true);
enable_lighting = config["enable_lighting"].value_or(false);
prefer_lighting_cpu_calculations = config["prefer_lighting_cpu_calculations"].value_or(true);
game_lighting = config["game_lighting"].value_or(GAME_LIGHTING_PER_VERTEX);
enable_time_cycle = config["enable_time_cycle"].value_or(false);
Expand Down
1 change: 1 addition & 0 deletions src/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ extern bool mdef_fix;
extern long enable_antialiasing;
extern bool enable_anisotropic;
extern bool enable_bilinear;
extern bool filter_internal_textures;
extern bool enable_lighting;
extern bool prefer_lighting_cpu_calculations;
extern long game_lighting;
Expand Down
49 changes: 43 additions & 6 deletions src/gl/special_case.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,18 @@ uint32_t gl_special_case(uint32_t primitivetype, uint32_t vertextype, struct nve
if(ff8) current_state.texture_filter = enable_bilinear && vertextype != TLVERTEX && current_state.texture_set;
else if (enable_bilinear && (vertextype != TLVERTEX || mode == MODE_MENU || (current_state.texture_set && VREF(texture_set, ogl.gl_set->force_filter)))) current_state.texture_filter = true;

// some modpath textures have z-sort forced on
// since we are no longer disabling all filtering on interal textures, we need to shut it off for the ones that filtering breaks.
// don't filter original textures in submarine minigame
if (current_state.texture_set && (mode == MODE_SUBMARINE) && !(VREF(texture_set, ogl.external))) // only ff7 has a submarine mode.
{
current_state.texture_filter = false; // don't filter original submarine textures, this causes thin lines, and original did not.
}
// or coaster minigame
if (current_state.texture_set && (mode == MODE_COASTER) && !(VREF(texture_set, ogl.external))) // only ff7 has coaster minigame.
{
current_state.texture_filter = false; // don't filter original coaster textures
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For both conditions even though we know it's only for ff7, I'd appreciate if we could add !ff8 nevertheless in the condition check. Additionally, please avoid over commenting ( stuff like // only ff7 has a submarine mode. is literally noise while looking at the code ), as well as // don't filter original ... textures,, just add notes of what it breaks in case it is set to true. No need to state the obvious :)

// some modpath textures have z-sort forced on
if(current_state.texture_set && VREF(texture_set, ogl.gl_set->force_zsort) && VREF(texture_set, ogl.external)) defer = true;

// z-sort by default in menu, unnecessary sorting will be avoided by defer logic
Expand Down Expand Up @@ -101,11 +112,37 @@ uint32_t gl_special_case(uint32_t primitivetype, uint32_t vertextype, struct nve
{
VOBJ(tex_header, tex_header, VREF(texture_set, tex_header));

if((uint32_t)VREF(tex_header, file.pc_name) > 32)
{
// avoid filtering window borders
if(!_strnicmp(VREF(tex_header, file.pc_name), "menu/btl_win_c_", strlen("menu/btl_win_c_") - 1) && VREF(texture_set, palette_index) == 0) current_state.texture_filter = false;
}
if ((uint32_t)VREF(tex_header, file.pc_name) > 32)
{
// avoid filtering window borders
if (!_strnicmp(VREF(tex_header, file.pc_name), "menu/btl_win_c_", strlen("menu/btl_win_c_") - 1) && VREF(texture_set, palette_index) == 0) current_state.texture_filter = false;

// don't filter original menu textures in ff7, because it introduces glitches
if ((VREF(texture_set, ogl.external)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe do the opposite check so you avoid having this huge empty block of nothing?

{

}
else
{
if (!ff8 && (!_strnicmp(VREF(tex_header, file.pc_name), "menu/btl_win_", strlen("menu/btl_win_") - 1)))
{
current_state.texture_filter = false; // don't filter original btl_win.
}
if (!ff8 && (!_strnicmp(VREF(tex_header, file.pc_name), "menu/usfont_", strlen("menu/usfont_") - 1)))
{
current_state.texture_filter = false; // or the us menu font.
}
if (!ff8 && (!_strnicmp(VREF(tex_header, file.pc_name), "menu/jafont_", strlen("menu/jafont_") - 1)))
{
current_state.texture_filter = false; // or the japanese menu font either..
}
if (!ff8 && (!_strnicmp(VREF(tex_header, file.pc_name), "flevel/hand", strlen("flevel/hand") - 1)))
{
current_state.texture_filter = false; // or the field cursor.
}

}
}
}

// z-sort select menu elements everywhere
Expand Down
4 changes: 2 additions & 2 deletions src/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,8 @@ void Renderer::bindTextures()
if (internalState.bDoMirrorTextureWrap) flags |= BGFX_SAMPLER_U_MIRROR | BGFX_SAMPLER_V_MIRROR | BGFX_SAMPLER_W_CLAMP;

if (internalState.bIsMovie) flags |= BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP | BGFX_SAMPLER_W_CLAMP;

if (!internalState.bDoTextureFiltering || !internalState.bIsExternalTexture) flags |= BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT;
if (!internalState.bDoTextureFiltering || (!internalState.bIsExternalTexture && !filter_internal_textures)) flags |= BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT;
}
break;
case RendererTextureSlot::TEX_S:
Expand Down