Skip to content

Commit

Permalink
Separable post-processing resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
andon authored and andon committed Feb 19, 2017
1 parent 16a4afb commit 21576c5
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 116 deletions.
4 changes: 2 additions & 2 deletions include/DLL_VERSION.H
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#define TBF_MAJOR 0
#define TBF_MINOR 9
#define TBF_BUILD 8
#define TBF_REV 6
#define TBF_BUILD 9
#define TBF_REV 0



Expand Down
33 changes: 18 additions & 15 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,24 @@ struct tbf_config_t
} steam;

struct {
float fovy = 0.785398f;
float aspect_ratio = 1.777778f;
uintptr_t aspect_addr = 0x00D56494ULL;//0x00D52398;
uintptr_t fovy_addr = 0x00D56498ULL;//0x00D5239C;
bool blackbar_videos = false; // OBSOLETE
bool aspect_correction = false;
float postproc_ratio = 0.5f;
bool clear_blackbars = false;
int32_t shadow_rescale = -2;
int32_t env_shadow_rescale = 1;
bool half_float_shadows = false;
bool dump_shaders = false;
bool fix_map_res = false;
bool osd_disclaimer = true;
bool auto_apply_changes = false;
float fovy = 0.785398f;
float aspect_ratio = 1.777778f;
uintptr_t aspect_addr = 0x00D56494ULL;//0x00D52398;
uintptr_t fovy_addr = 0x00D56498ULL;//0x00D5239C;
bool blackbar_videos = false; // OBSOLETE
bool aspect_correction = false;
float postproc_ratio = 0.5f;
bool clear_blackbars = false;
int32_t shadow_rescale = -2;
int32_t env_shadow_rescale = 1;
bool half_float_shadows = false;
bool dump_shaders = false;
bool force_post_mips = false; // Mipmap generation on post-processing
bool fix_map_res = true;
bool high_res_reflection = false;
bool high_res_bloom = false;
bool osd_disclaimer = true;
bool auto_apply_changes = false;

struct {
int quality_preset = 3;
Expand Down
3 changes: 3 additions & 0 deletions include/render.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ namespace tbf
std::string code;
std::string footer;
};

extern std::unordered_set <IDirect3DBaseTexture9 *> ui_map_rts;
extern bool ui_map_active;
}
}

Expand Down
8 changes: 6 additions & 2 deletions include/textures.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ namespace RenderFix {

std::vector <IDirect3DBaseTexture9 *>
getUsedRenderTargets (void);
uint32_t getRenderTargetCreationTime
(IDirect3DBaseTexture9* rt);
void trackRenderTarget (IDirect3DBaseTexture9* rt);
bool isRenderTarget (IDirect3DBaseTexture9* rt);
bool isUsedRenderTarget (IDirect3DBaseTexture9* rt);
Expand Down Expand Up @@ -236,11 +238,13 @@ namespace RenderFix {

private:
struct {
std::unordered_set <IDirect3DBaseTexture9*> render_targets;
// In lieu of actually wrapping render targets with a COM interface, just add the creation time
// as the mapped parameter
std::unordered_map <IDirect3DBaseTexture9 *, uint32_t> render_targets;
} known;

struct {
std::unordered_set <IDirect3DBaseTexture9*> render_targets;
std::unordered_set <IDirect3DBaseTexture9 *> render_targets;
} used;

std::unordered_map <uint32_t, tbf::RenderFix::Texture*> textures;
Expand Down
67 changes: 49 additions & 18 deletions src/ImGui/control_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,17 +633,6 @@ TBFix_DrawConfigUI (void)
{
ImGui::TreePush ("");

tbf::RenderFix::need_reset.graphics |=
ImGui::Checkbox ("Enable map menu resolution fix", &config.render.fix_map_res);

if (ImGui::IsItemHovered ())
{
ImGui::BeginTooltip ();
ImGui::Text ( "This feature is experimental and only works at 16:9 resolutions, I am not positive that it"
" will not break something unrelated." );
ImGui::EndTooltip ();
}

ImGui::Checkbox ("Clamp Non-Power-Of-Two Texture Coordinates", &config.textures.clamp_npot_coords);

if (ImGui::IsItemHovered ())
Expand All @@ -652,8 +641,8 @@ TBFix_DrawConfigUI (void)
}

ImGui::Checkbox ("Clamp Skit Texture Coordinates", &config.textures.clamp_skit_coords); ImGui::SameLine ();
ImGui::Checkbox ("Clamp Map Texture Coordinates", &config.textures.clamp_map_coords); ImGui::SameLine ();
ImGui::Checkbox ("Clamp Text Texture Coordinates", &config.textures.clamp_text_coords);
//ImGui::Checkbox ("Clamp Map Texture Coordinates", &config.textures.clamp_map_coords); ImGui::SameLine ();
//ImGui::Checkbox ("Clamp Text Texture Coordinates", &config.textures.clamp_text_coords);

ImGui::Checkbox ("Keep UI Textures Sharp", &config.textures.keep_ui_sharp);

Expand Down Expand Up @@ -1057,11 +1046,11 @@ TBFix_DrawConfigUI (void)
sel = 3;
}

if ( ImGui::Combo ( "Post-Processing Resolution", &sel,
" Game Default -- Will cause shimmering\0"
" 50% Screen Resolution\0"
" 100% Screen Resolution\0"
" 200% Screen Resolution\0\0", 4 ) )
if ( ImGui::Combo ( "Depth of Field", &sel,
" Normal (Game Default: Variable) -- Will cause shimmering\0"
" Low ( 50% Screen Resolution)\0"
" Medium (100% Screen Resolution)\0"
" High (200% Screen Resolution)\0\0", 4 ) )
{
switch (sel) {
case 0:
Expand Down Expand Up @@ -1095,6 +1084,48 @@ TBFix_DrawConfigUI (void)
ImGui::EndTooltip ();
}

sel = config.render.high_res_bloom ? 1 : 0;

if ( ImGui::Combo ( "Bloom", &sel,
" Normal ( 25% Screen Resolution) -- May Flicker\0"
" High ( 50% Screen Resolution)\0\0", 2 ) )
{
config.render.high_res_bloom = (sel == 1);
tbf::RenderFix::need_reset.textures = true;
}

sel = config.render.high_res_reflection ? 1 : 0;

if ( ImGui::Combo ( "Reflection", &sel,
" Normal ( 50% Screen Resolution)\0"
" High (100% Screen Resolution)\0\0", 2 ) )
{
config.render.high_res_reflection = (sel == 1);
tbf::RenderFix::need_reset.textures = true;
}

tbf::RenderFix::need_reset.graphics |=
ImGui::Checkbox ("Fix Blocky Map Menu", &config.render.fix_map_res);

if (ImGui::IsItemHovered ())
{
ImGui::BeginTooltip ();
ImGui::Text ("This feature is a work-in-progress and generally only works at 16:9 resolutions.");
ImGui::EndTooltip ();
}

tbf::RenderFix::need_reset.graphics |=
ImGui::Checkbox ("Force Mipmap Filtering on Post-Processed Render Passes", &config.render.force_post_mips);

if (ImGui::IsItemHovered ())
{
ImGui::BeginTooltip ();
ImGui::Text ("Reduce Aliasing AND Increase Performance on Post-Processing");
ImGui::BulletText ("Slight performance gain assuming drivers / third-party software / untested render passes do not explode.");
ImGui::BulletText ("Still extremely experimental; not saved in config file.");
ImGui::EndTooltip ();
}

ImGui::TreePop ();
}

Expand Down
46 changes: 40 additions & 6 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,18 @@ struct {
tbf::ParameterFloat* aspect_ratio;
tbf::ParameterBool* aspect_correct_vids;
tbf::ParameterBool* aspect_correction;
tbf::ParameterFloat* postproc_ratio;
tbf::ParameterBool* clear_blackbars;

tbf::ParameterFloat* postproc_ratio;
tbf::ParameterBool* fix_map_res;
tbf::ParameterBool* high_res_bloom;
tbf::ParameterBool* high_res_reflection;

tbf::ParameterInt* rescale_shadows;
tbf::ParameterInt* rescale_env_shadows;
tbf::ParameterBool* half_precision_shadows;

tbf::ParameterBool* dump_shaders;
tbf::ParameterBool* fix_map_res;
tbf::ParameterBool* pause_on_ui;
tbf::ParameterBool* show_osd_disclaimer;
tbf::ParameterFloat* ui_scale;
Expand Down Expand Up @@ -435,18 +438,38 @@ TBF_LoadConfig (std::wstring name)
);
render.fix_map_res->register_to_ini (
render_ini,
L"Resolution.Experimental",
L"Resolution.PostProcess",
L"FixMap" );

render.high_res_bloom =
static_cast <tbf::ParameterBool *>
(g_ParameterFactory.create_parameter <bool>(
L"Increase Resolution of Bloom Effects")
);
render.high_res_bloom->register_to_ini (
render_ini,
L"Resolution.PostProcess",
L"HighResBloom" );

render.high_res_reflection =
static_cast <tbf::ParameterBool *>
(g_ParameterFactory.create_parameter <bool>(
L"Increase Resolution of Reflections")
);
render.high_res_reflection->register_to_ini (
render_ini,
L"Resolution.PostProcess",
L"HighResReflection" );

render.postproc_ratio =
static_cast <tbf::ParameterFloat *>
(g_ParameterFactory.create_parameter <float> (
L"Post-Process Ratio")
);
render.postproc_ratio->register_to_ini (
render_ini,
L"Resolution.Experimental",
L"PostProcessRatio" );
L"Resolution.PostProcess",
L"DepthOfField" );

render.pause_on_ui =
static_cast <tbf::ParameterBool *>
Expand Down Expand Up @@ -820,6 +843,8 @@ TBF_LoadConfig (std::wstring name)

render.dump_shaders->load (config.render.dump_shaders);
render.fix_map_res->load (config.render.fix_map_res);
render.high_res_bloom->load (config.render.high_res_bloom);
render.high_res_reflection->load (config.render.high_res_reflection);
render.postproc_ratio->load (config.render.postproc_ratio);
render.pause_on_ui->load (config.input.ui.pause);
render.show_osd_disclaimer->load (config.render.osd_disclaimer);
Expand All @@ -840,6 +865,9 @@ TBF_LoadConfig (std::wstring name)

std::wstring sgssaa;

int original_sgssaa = config.render.nv.sgssaa_mode;
std::wstring original_bits = config.render.nv.compat_bits;

render.nvidia_sgssaa->load (sgssaa);
render.nvidia_aa_compat_bits->load (config.render.nv.compat_bits
);
Expand All @@ -858,7 +886,11 @@ TBF_LoadConfig (std::wstring name)
else if (sgssaa == L"off")
config.render.nv.sgssaa_mode = 0;

tbf::RenderFix::InstallSGSSAA ();
// Only change the driver profile if settings change in-game or
// if a non-off mode is selected.
if ( config.render.nv.sgssaa_mode != 0 ||
config.render.nv.sgssaa_mode != config.render.nv.sgssaa_mode )
tbf::RenderFix::InstallSGSSAA ();
}

config.input.ui.scale = std::min (std::max (1.0f, config.input.ui.scale), 3.0f);
Expand Down Expand Up @@ -913,6 +945,8 @@ TBF_SaveConfig (std::wstring name, bool close_config)
render.rescale_env_shadows->store (config.render.env_shadow_rescale);
render.half_precision_shadows->store (config.render.half_float_shadows);
render.fix_map_res->store (config.render.fix_map_res);
render.high_res_bloom->store (config.render.high_res_bloom);
render.high_res_reflection->store (config.render.high_res_reflection);
render.postproc_ratio->store (config.render.postproc_ratio);
render.pause_on_ui->store (config.input.ui.pause);
render.show_osd_disclaimer->store (config.render.osd_disclaimer);
Expand Down
Loading

0 comments on commit 21576c5

Please sign in to comment.