diff --git a/Common/Settings.h b/Common/Settings.h
index 5f395a1f..ea8b0cbf 100644
--- a/Common/Settings.h
+++ b/Common/Settings.h
@@ -362,7 +362,6 @@ extern HMODULE m_hModule;
extern CFGDATA ConfigData;
extern bool CustomExeStrSet;
extern bool EnableCustomShaders;
-extern bool ShadersReady;
extern bool IsUpdating;
extern bool m_StopThreadFlag;
extern bool AutoScaleImages;
diff --git a/Common/Settings.ini b/Common/Settings.ini
index 7ef5574c..abb8e054 100644
--- a/Common/Settings.ini
+++ b/Common/Settings.ini
@@ -48,9 +48,6 @@ DisableMaximizedWindowedMode = 1
ForceHybridEnumeration = 1
[Shaders]
-; Restores the ability to adjust the brightness level in the game's options menu, regardless if playing in windowed or fullscreen mode.
-RestoreBrightnessSelector = 1
-
; Enables subpixel morphological anti-aliasing (SMAA). Note: It is recommended to disable this if using GPU-based anti-aliasing.
EnableSMAA = 0
@@ -243,6 +240,9 @@ LockScreenPosition = 1
; Disables changing the Speaker Configuration feature in the game's Options > Advanced Options menu as, after Windows XP, this change must be done through Windows' Sound Control panel and can no longer be changed within applications (such as this game). If you try to change this through the game's Options menu, it will just revert back to what is being used through Windows' Sound Control panel. Note: .\sh2e\resources\r_menu_*.res must be present in the game's directory for this feature to work.
LockSpeakerConfig = 1
+; Restores the ability to adjust the brightness level in the game's options menu, regardless if playing in windowed or fullscreen mode.
+RestoreBrightnessSelector = 1
+
[Game Fixes]
; Corrects color level values for the Catacomb's meat cold rooms.
CatacombsMeatRoomFix = 1
diff --git a/Launcher/config.xml b/Launcher/config.xml
index 417fa867..ab9571aa 100644
--- a/Launcher/config.xml
+++ b/Launcher/config.xml
@@ -152,15 +152,6 @@
-
- Restore brightness selector functionality
- Restores the ability to adjust the brightness level in the game's options menu, regardless if playing in windowed or fullscreen mode.
-
- 0
- 1
-
-
-
SMAA (anti-aliasing)
Enables subpixel morphological anti-aliasing (SMAA).
Note: It is recommended to disable this if using GPU-based anti-aliasing.
@@ -786,6 +777,15 @@
+
+ Restore brightness selector functionality
+ Restores the ability to adjust the brightness level in the game's options menu, regardless if playing in windowed or fullscreen mode.
+
+ 0
+ 1
+
+
+
diff --git a/Launcher/config_br.xml b/Launcher/config_br.xml
index 031b00fc..1637591f 100644
--- a/Launcher/config_br.xml
+++ b/Launcher/config_br.xml
@@ -152,15 +152,6 @@
-
- Restaurar funcionalidade do regulador de brilho
- Restaura a capacidade de ajustar o nível de brilho no menu de opções do jogo, independentemente de jogar no modo janela ou tela cheia.
-
- 0
- 1
-
-
-
SMAA (anti-aliasing)
Ativa o anti-aliasing (antisserrilhamento) morfológico de subpixel (SMAA).
Nota: Recomenda-se desativar isso se estiver usando anti-aliasing baseado em GPU.
@@ -786,6 +777,15 @@
+
+ Restaurar funcionalidade do regulador de brilho
+ Restaura a capacidade de ajustar o nível de brilho no menu de opções do jogo, independentemente de jogar no modo janela ou tela cheia.
+
+ 0
+ 1
+
+
+
diff --git a/Launcher/config_es.xml b/Launcher/config_es.xml
index bdd2865f..cbc819f3 100644
--- a/Launcher/config_es.xml
+++ b/Launcher/config_es.xml
@@ -152,15 +152,6 @@
-
- Restaurar la funcionalidad del selector de brillo
- Restaura la capacidad de ajustar el nivel del brillo dentro del menú de opciones del juego, sin importar si estás jugando en el modo de ventana o a pantalla completa.
-
- 0
- 1
-
-
-
SMAA (suavizado de bordes)
Activa el SMAA (subpixel morphological anti-aliasing, o suavizado de bordes morfológico por subpíxeles).
Nota: se recomienda desactivar esta opción si has activado un suavizado de bordes a través de la GPU.
@@ -786,6 +777,15 @@
+
+ Restaurar la funcionalidad del selector de brillo
+ Restaura la capacidad de ajustar el nivel del brillo dentro del menú de opciones del juego, sin importar si estás jugando en el modo de ventana o a pantalla completa.
+
+ 0
+ 1
+
+
+
diff --git a/Launcher/config_it.xml b/Launcher/config_it.xml
index 412d5e88..f0df7961 100644
--- a/Launcher/config_it.xml
+++ b/Launcher/config_it.xml
@@ -152,15 +152,6 @@
-
- Ripristina la funzionalità dell'opzione luminosità
- Ripristina la funzionalità dell'opzione luminosità nel menu opzioni in gioco, sia in modalità finestra che schermo intero.
-
- 0
- 1
-
-
-
SMAA (anti-aliasing)
Abilita anti-aliasing morfologico subpixel (SMAA).
Nota: E' raccomandato disabilitare questa opzione se si sta usando un anti aliasing GPU.
@@ -786,6 +777,15 @@
+
+ Ripristina la funzionalità dell'opzione luminosità
+ Ripristina la funzionalità dell'opzione luminosità nel menu opzioni in gioco, sia in modalità finestra che schermo intero.
+
+ 0
+ 1
+
+
+
diff --git a/Resources/LiftGammaGain.fx b/Resources/LiftGammaGain.fx
deleted file mode 100644
index 309b6b95..00000000
--- a/Resources/LiftGammaGain.fx
+++ /dev/null
@@ -1,374 +0,0 @@
-/**
- * Lift Gamma Gain version 1.1
- * by 3an and CeeJay.dk
- */
-
-//-------------------------------------------------------------
-// BEGIN "ReShadeUI.fxh"
-//
-#if !defined(__RESHADE__) || __RESHADE__ < 30000
-#error "ReShade 3.0+ is required to use this header file"
-#endif
-
-#define RESHADE_VERSION(major,minor,build) (10000 * (major) + 100 * (minor) + (build))
-#define SUPPORTED_VERSION(major,minor,build) (__RESHADE__ >= RESHADE_VERSION(major,minor,build))
-
-// Since 3.0.0
-// Commit current in-game user interface status
-// https://github.com/crosire/reshade/commit/302bacc49ae394faedc2e29a296c1cebf6da6bb2#diff-82cf230afdb2a0d5174111e6f17548a5R1183
-// Added various GUI related uniform variable annotations
-// https://reshade.me/forum/releases/2341-3-0
-#define __UNIFORM_INPUT_ANY ui_type = "input";
-
-#define __UNIFORM_INPUT_BOOL1 __UNIFORM_INPUT_ANY // It is unsupported on all version
-#define __UNIFORM_INPUT_BOOL2 __UNIFORM_INPUT_ANY // It is unsupported on all version
-#define __UNIFORM_INPUT_BOOL3 __UNIFORM_INPUT_ANY // It is unsupported on all version
-#define __UNIFORM_INPUT_BOOL4 __UNIFORM_INPUT_ANY // It is unsupported on all version
-#define __UNIFORM_INPUT_INT1 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_INPUT_INT2 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_INPUT_INT3 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_INPUT_INT4 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_INPUT_FLOAT1 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_INPUT_FLOAT2 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_INPUT_FLOAT3 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_INPUT_FLOAT4 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
-
-// Since 4.0.1
-// Change slider widget to be used with new "slider" instead of a "drag" type annotation
-// https://github.com/crosire/reshade/commit/746229f31cd6f311a3e72a543e4f1f23faa23f11#diff-59405a313bd8cbfb0ca6dd633230e504R1701
-// Changed slider widget to be used with < ui_type = "slider"; > instead of < ui_type = "drag"; >
-// https://reshade.me/forum/releases/4772-4-0
-#if SUPPORTED_VERSION(4,0,1)
-#define __UNIFORM_DRAG_ANY ui_type = "drag";
-
-// Since 4.0.0
-// Rework statistics tab and add drag widgets back
-// https://github.com/crosire/reshade/commit/1b2c38795f00efd66c007da1f483f1441b230309
-// Changed drag widget to a slider widget (old one is still available via < ui_type = "drag2"; >)
-// https://reshade.me/forum/releases/4772-4-0
-#elif SUPPORTED_VERSION(4,0,0)
-#define __UNIFORM_DRAG_ANY ui_type = "drag2";
-
-// Since 3.0.0
-// Commit current in-game user interface status
-// https://github.com/crosire/reshade/commit/302bacc49ae394faedc2e29a296c1cebf6da6bb2#diff-82cf230afdb2a0d5174111e6f17548a5R1187
-// Added various GUI related uniform variable annotations
-// https://reshade.me/forum/releases/2341-3-0
-#else
-#define __UNIFORM_DRAG_ANY ui_type = "drag";
-#endif
-
-#define __UNIFORM_DRAG_BOOL1 __UNIFORM_DRAG_ANY // It is unsupported on all version
-#define __UNIFORM_DRAG_BOOL2 __UNIFORM_DRAG_ANY // It is unsupported on all version
-#define __UNIFORM_DRAG_BOOL3 __UNIFORM_DRAG_ANY // It is unsupported on all version
-#define __UNIFORM_DRAG_BOOL4 __UNIFORM_DRAG_ANY // It is unsupported on all version
-#define __UNIFORM_DRAG_INT1 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_DRAG_INT2 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_DRAG_INT3 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_DRAG_INT4 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_DRAG_FLOAT1 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_DRAG_FLOAT2 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_DRAG_FLOAT3 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_DRAG_FLOAT4 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
-
-// Since 4.0.1
-// Change slider widget to be used with new "slider" instead of a "drag" type annotation
-// https://github.com/crosire/reshade/commit/746229f31cd6f311a3e72a543e4f1f23faa23f11#diff-59405a313bd8cbfb0ca6dd633230e504R1699
-// Changed slider widget to be used with < ui_type = "slider"; > instead of < ui_type = "drag"; >
-// https://reshade.me/forum/releases/4772-4-0
-#if SUPPORTED_VERSION(4,0,1)
-#define __UNIFORM_SLIDER_ANY ui_type = "slider";
-
-// Since 4.0.0
-// Rework statistics tab and add drag widgets back
-// https://github.com/crosire/reshade/commit/1b2c38795f00efd66c007da1f483f1441b230309
-// Changed drag widget to a slider widget (old one is still available via < ui_type = "drag2"; >)
-// https://reshade.me/forum/releases/4772-4-0
-#elif SUPPORTED_VERSION(4,0,0)
-#define __UNIFORM_SLIDER_ANY ui_type = "drag";
-#else
-#define __UNIFORM_SLIDER_ANY __UNIFORM_DRAG_ANY
-#endif
-
-#define __UNIFORM_SLIDER_BOOL1 __UNIFORM_SLIDER_ANY // It is unsupported on all version
-#define __UNIFORM_SLIDER_BOOL2 __UNIFORM_SLIDER_ANY // It is unsupported on all version
-#define __UNIFORM_SLIDER_BOOL3 __UNIFORM_SLIDER_ANY // It is unsupported on all version
-#define __UNIFORM_SLIDER_BOOL4 __UNIFORM_SLIDER_ANY // It is unsupported on all version
-#define __UNIFORM_SLIDER_INT1 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_SLIDER_INT2 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_SLIDER_INT3 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_SLIDER_INT4 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_SLIDER_FLOAT1 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_SLIDER_FLOAT2 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_SLIDER_FLOAT3 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_SLIDER_FLOAT4 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
-
-// Since 3.0.0
-// Add combo box display type for uniform variables and fix displaying of integer variable under Direct3D 9
-// https://github.com/crosire/reshade/commit/b025bfae5f7343509ec0cacf6df0cff537c499f2#diff-82cf230afdb2a0d5174111e6f17548a5R1631
-// Added various GUI related uniform variable annotations
-// https://reshade.me/forum/releases/2341-3-0
-#define __UNIFORM_COMBO_ANY ui_type = "combo";
-
-// __UNIFORM_COMBO_BOOL1
-#define __UNIFORM_COMBO_BOOL2 __UNIFORM_COMBO_ANY // It is unsupported on all version
-#define __UNIFORM_COMBO_BOOL3 __UNIFORM_COMBO_ANY // It is unsupported on all version
-#define __UNIFORM_COMBO_BOOL4 __UNIFORM_COMBO_ANY // It is unsupported on all version
-#define __UNIFORM_COMBO_INT1 __UNIFORM_COMBO_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_COMBO_INT2 __UNIFORM_COMBO_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_COMBO_INT3 __UNIFORM_COMBO_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_COMBO_INT4 __UNIFORM_COMBO_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_COMBO_FLOAT1 __UNIFORM_COMBO_ANY // It is unsupported on all version
-#define __UNIFORM_COMBO_FLOAT2 __UNIFORM_COMBO_ANY // It is unsupported on all version
-#define __UNIFORM_COMBO_FLOAT3 __UNIFORM_COMBO_ANY // It is unsupported on all version
-#define __UNIFORM_COMBO_FLOAT4 __UNIFORM_COMBO_ANY // It is unsupported on all version
-
-// Since 4.0.0 (but the ui_items force set "Off\0On\0"), and if less than it force converted to checkbox
-// Add option to display boolean values as combo box instead of checkbox
-// https://github.com/crosire/reshade/commit/aecb757c864c9679e77edd6f85a1521c49e489c1#diff-59405a313bd8cbfb0ca6dd633230e504R1147
-// https://github.com/crosire/reshade/blob/v4.0.0/source/gui.cpp
-// Added option to display boolean values as combo box instead of checkbox (via < ui_type = "combo"; >)
-// https://reshade.me/forum/releases/4772-4-0
-#define __UNIFORM_COMBO_BOOL1 __UNIFORM_COMBO_ANY
-
-// Since 4.0.0
-// Cleanup GUI code and rearrange some widgets
-// https://github.com/crosire/reshade/commit/6751f7bd50ea7c0556cf0670f10a4b4ba912ee7d#diff-59405a313bd8cbfb0ca6dd633230e504R1711
-// Added radio button widget (via < ui_type = "radio"; ui_items = "Button 1\0Button 2\0...\0"; >)
-// https://reshade.me/forum/releases/4772-4-0
-#if SUPPORTED_VERSION(4,0,0)
-#define __UNIFORM_RADIO_ANY ui_type = "radio";
-#else
-#define __UNIFORM_RADIO_ANY __UNIFORM_COMBO_ANY
-#endif
-
-#define __UNIFORM_RADIO_BOOL1 __UNIFORM_RADIO_ANY // It is unsupported on all version
-#define __UNIFORM_RADIO_BOOL2 __UNIFORM_RADIO_ANY // It is unsupported on all version
-#define __UNIFORM_RADIO_BOOL3 __UNIFORM_RADIO_ANY // It is unsupported on all version
-#define __UNIFORM_RADIO_BOOL4 __UNIFORM_RADIO_ANY // It is unsupported on all version
-#define __UNIFORM_RADIO_INT1 __UNIFORM_RADIO_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_RADIO_INT2 __UNIFORM_RADIO_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_RADIO_INT3 __UNIFORM_RADIO_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_RADIO_INT4 __UNIFORM_RADIO_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_RADIO_FLOAT1 __UNIFORM_RADIO_ANY // It is unsupported on all version
-#define __UNIFORM_RADIO_FLOAT2 __UNIFORM_RADIO_ANY // It is unsupported on all version
-#define __UNIFORM_RADIO_FLOAT3 __UNIFORM_RADIO_ANY // It is unsupported on all version
-#define __UNIFORM_RADIO_FLOAT4 __UNIFORM_RADIO_ANY // It is unsupported on all version
-
-// Since 4.1.0
-// Fix floating point uniforms with unknown "ui_type" not showing up in UI
-// https://github.com/crosire/reshade/commit/50e5bf44dfc84bc4220c2b9f19d5f50c7a0fda66#diff-59405a313bd8cbfb0ca6dd633230e504R1788
-// Fixed floating point uniforms with unknown "ui_type" not showing up in UI
-// https://reshade.me/forum/releases/5021-4-1
-#define __UNIFORM_COLOR_ANY ui_type = "color";
-
-// Since 3.0.0
-// Move technique list to preset configuration file
-// https://github.com/crosire/reshade/blob/84bba3aa934c1ebe4c6419b69dfe1690d9ab9d34/source/runtime.cpp#L1328
-// Added various GUI related uniform variable annotations
-// https://reshade.me/forum/releases/2341-3-0
-
-// If empty, these versions before 4.1.0 are decide that the type is color from the number of components
-
-#define __UNIFORM_COLOR_BOOL1 __UNIFORM_COLOR_ANY // It is unsupported on all version
-#define __UNIFORM_COLOR_BOOL2 __UNIFORM_COLOR_ANY // It is unsupported on all version
-#define __UNIFORM_COLOR_BOOL3 __UNIFORM_COLOR_ANY // It is unsupported on all version
-#define __UNIFORM_COLOR_BOOL4 __UNIFORM_COLOR_ANY // It is unsupported on all version
-#define __UNIFORM_COLOR_INT1 __UNIFORM_COLOR_ANY // It is unsupported on all version
-#define __UNIFORM_COLOR_INT2 __UNIFORM_COLOR_ANY // It is unsupported on all version
-#define __UNIFORM_COLOR_INT3 __UNIFORM_COLOR_ANY // It is unsupported on all version
-#define __UNIFORM_COLOR_INT4 __UNIFORM_COLOR_ANY // It is unsupported on all version
-// __UNIFORM_COLOR_FLOAT1
-#define __UNIFORM_COLOR_FLOAT2 __UNIFORM_COLOR_ANY // It is unsupported on all version
-#define __UNIFORM_COLOR_FLOAT3 __UNIFORM_COLOR_ANY // If it was not supported in someday or now, please add information
-#define __UNIFORM_COLOR_FLOAT4 __UNIFORM_COLOR_ANY // If it was not supported in someday or now, please add information
-
-// Since 4.2.0
-// Add alpha slider widget for single component uniform variables (#86)
-// https://github.com/crosire/reshade/commit/87a740a8e3c4dcda1dd4eeec8d5cff7fa35fe829#diff-59405a313bd8cbfb0ca6dd633230e504R1820
-// Added alpha slider widget for single component uniform variables
-// https://reshade.me/forum/releases/5150-4-2
-#if SUPPORTED_VERSION(4,2,0)
-#define __UNIFORM_COLOR_FLOAT1 __UNIFORM_COLOR_ANY
-#else
-#define __UNIFORM_COLOR_FLOAT1 __UNIFORM_SLIDER_ANY
-#endif
-
-// Since 4.3.0
-// Add new "list" GUI widget (#103)
-// https://github.com/crosire/reshade/commit/515287d20ce615c19cf3d4c21b49f83896f04ddc#diff-59405a313bd8cbfb0ca6dd633230e504R1894
-// Added new "list" GUI widget
-// https://reshade.me/forum/releases/5417-4-3
-#if SUPPORTED_VERSION(4,3,0)
-#define __UNIFORM_LIST_ANY ui_type = "list";
-#else
-#define __UNIFORM_LIST_ANY __UNIFORM_COMBO_ANY
-#endif
-
-// __UNIFORM_LIST_BOOL1
-#define __UNIFORM_LIST_BOOL2 __UNIFORM_LIST_ANY // Not supported in all versions
-#define __UNIFORM_LIST_BOOL3 __UNIFORM_LIST_ANY // Not supported in all versions
-#define __UNIFORM_LIST_BOOL4 __UNIFORM_LIST_ANY // Not supported in all versions
-#define __UNIFORM_LIST_INT1 __UNIFORM_LIST_ANY // Supported in 4.3.0
-#define __UNIFORM_LIST_INT2 __UNIFORM_LIST_ANY // Not supported in all versions
-#define __UNIFORM_LIST_INT3 __UNIFORM_LIST_ANY // Not supported in all versions
-#define __UNIFORM_LIST_INT4 __UNIFORM_LIST_ANY // Not supported in all versions
-#define __UNIFORM_LIST_FLOAT1 __UNIFORM_LIST_ANY // Not supported in all versions
-#define __UNIFORM_LIST_FLOAT2 __UNIFORM_LIST_ANY // Not supported in all versions
-#define __UNIFORM_LIST_FLOAT3 __UNIFORM_LIST_ANY // Not supported in all versions
-#define __UNIFORM_LIST_FLOAT4 __UNIFORM_LIST_ANY // Not supported in all versions
-
-// For compatible with ComboBox
-#define __UNIFORM_LIST_BOOL1 __UNIFORM_COMBO_ANY
-//
-// End "ReShadeUI.fxh"
-//-------------------------------------------------------------
-
-uniform float3 RGB_Lift < __UNIFORM_SLIDER_FLOAT3
- ui_min = 0.0; ui_max = 2.0;
- ui_label = "RGB Lift";
- ui_tooltip = "Adjust shadows for red, green and blue.";
-> = float3(1.0, 1.0, 1.0);
-uniform float3 RGB_Gamma < __UNIFORM_SLIDER_FLOAT3
- ui_min = 0.0; ui_max = 2.0;
- ui_label = "RGB Gamma";
- ui_tooltip = "Adjust midtones for red, green and blue.";
-> = float3(1.0, 1.0, 1.0);
-uniform float3 RGB_Gain < __UNIFORM_SLIDER_FLOAT3
- ui_min = 0.0; ui_max = 2.0;
- ui_label = "RGB Gain";
- ui_tooltip = "Adjust highlights for red, green and blue.";
-> = float3(1.0, 1.0, 1.0);
-
-
-//-------------------------------------------------------------
-//
-// End "ReShade.fxh"
-//
-#if !defined(__RESHADE__) || __RESHADE__ < 30000
- #error "ReShade 3.0+ is required to use this header file"
-#endif
-
-#ifndef RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
- #define RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN 0
-#endif
-#ifndef RESHADE_DEPTH_INPUT_IS_REVERSED
- #define RESHADE_DEPTH_INPUT_IS_REVERSED 1
-#endif
-#ifndef RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
- #define RESHADE_DEPTH_INPUT_IS_LOGARITHMIC 0
-#endif
-
-#ifndef RESHADE_DEPTH_MULTIPLIER
- #define RESHADE_DEPTH_MULTIPLIER 1
-#endif
-#ifndef RESHADE_DEPTH_LINEARIZATION_FAR_PLANE
- #define RESHADE_DEPTH_LINEARIZATION_FAR_PLANE 1000.0
-#endif
-
-// Above 1 expands coordinates, below 1 contracts and 1 is equal to no scaling on any axis
-#ifndef RESHADE_DEPTH_INPUT_Y_SCALE
- #define RESHADE_DEPTH_INPUT_Y_SCALE 1
-#endif
-#ifndef RESHADE_DEPTH_INPUT_X_SCALE
- #define RESHADE_DEPTH_INPUT_X_SCALE 1
-#endif
-// An offset to add to the Y coordinate, (+) = move up, (-) = move down
-#ifndef RESHADE_DEPTH_INPUT_Y_OFFSET
- #define RESHADE_DEPTH_INPUT_Y_OFFSET 0
-#endif
-// An offset to add to the X coordinate, (+) = move right, (-) = move left
-#ifndef RESHADE_DEPTH_INPUT_X_OFFSET
- #define RESHADE_DEPTH_INPUT_X_OFFSET 0
-#endif
-
-#define BUFFER_PIXEL_SIZE float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
-#define BUFFER_SCREEN_SIZE float2(BUFFER_WIDTH, BUFFER_HEIGHT)
-#define BUFFER_ASPECT_RATIO (BUFFER_WIDTH * BUFFER_RCP_HEIGHT)
-
-namespace ReShade
-{
-#if defined(__RESHADE_FXC__)
- float GetAspectRatio() { return BUFFER_WIDTH * BUFFER_RCP_HEIGHT; }
- float2 GetPixelSize() { return float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT); }
- float2 GetScreenSize() { return float2(BUFFER_WIDTH, BUFFER_HEIGHT); }
- #define AspectRatio GetAspectRatio()
- #define PixelSize GetPixelSize()
- #define ScreenSize GetScreenSize()
-#else
- // These are deprecated and will be removed eventually.
- static const float AspectRatio = BUFFER_WIDTH * BUFFER_RCP_HEIGHT;
- static const float2 PixelSize = float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT);
- static const float2 ScreenSize = float2(BUFFER_WIDTH, BUFFER_HEIGHT);
-#endif
-
- // Global textures and samplers
- texture BackBufferTex : COLOR;
- texture DepthBufferTex : DEPTH;
-
- sampler BackBuffer { Texture = BackBufferTex; };
- sampler DepthBuffer { Texture = DepthBufferTex; };
-
- // Helper functions
- float GetLinearizedDepth(float2 texcoord)
- {
-#if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
- texcoord.y = 1.0 - texcoord.y;
-#endif
- texcoord.x /= RESHADE_DEPTH_INPUT_X_SCALE;
- texcoord.y /= RESHADE_DEPTH_INPUT_Y_SCALE;
- texcoord.x -= RESHADE_DEPTH_INPUT_X_OFFSET / 2.000000001;
- texcoord.y += RESHADE_DEPTH_INPUT_Y_OFFSET / 2.000000001;
- float depth = tex2Dlod(DepthBuffer, float4(texcoord, 0, 0)).x * RESHADE_DEPTH_MULTIPLIER;
-
-#if RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
- const float C = 0.01;
- depth = (exp(depth * log(C + 1.0)) - 1.0) / C;
-#endif
-#if RESHADE_DEPTH_INPUT_IS_REVERSED
- depth = 1.0 - depth;
-#endif
- const float N = 1.0;
- depth /= RESHADE_DEPTH_LINEARIZATION_FAR_PLANE - depth * (RESHADE_DEPTH_LINEARIZATION_FAR_PLANE - N);
-
- return depth;
- }
-}
-
-// Vertex shader generating a triangle covering the entire screen
-void PostProcessVS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
-{
- texcoord.x = (id == 2) ? 2.0 : 0.0;
- texcoord.y = (id == 1) ? 2.0 : 0.0;
- position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
-}
-//
-// End "ReShade.fxh"
-//-------------------------------------------------------------
-
-float3 LiftGammaGainPass(float4 position : SV_Position, float2 texcoord : TexCoord) : SV_Target
-{
- float3 color = tex2D(ReShade::BackBuffer, texcoord).rgb;
-
- // -- Lift --
- color = color * (1.5 - 0.5 * RGB_Lift) + 0.5 * RGB_Lift - 0.5;
- color = saturate(color); // Is not strictly necessary, but does not cost performance
-
- // -- Gain --
- color *= RGB_Gain;
-
- // -- Gamma --
- color = pow(abs(color), 1.0 / RGB_Gamma);
-
- return saturate(color);
-}
-
-
-technique LiftGammaGain
-{
- pass
- {
- VertexShader = PostProcessVS;
- PixelShader = LiftGammaGainPass;
- }
-}
diff --git a/Resources/ReShade.ini b/Resources/ReShade.ini
index a6d9499f..a7d25112 100644
--- a/Resources/ReShade.ini
+++ b/Resources/ReShade.ini
@@ -1,5 +1,5 @@
-Techniques=SMAA,LiftGammaGain,Pirate_Bloom,CRTFrutbunn,CRT_Lottes,CRTRefresh
-TechniqueSorting=SMAA,LiftGammaGain,Pirate_Bloom,CRTFrutbunn,CRT_Lottes,CRTRefresh
+Techniques=SMAA,Pirate_Bloom,CRTFrutbunn,CRT_Lottes,CRTRefresh
+TechniqueSorting=SMAA,Pirate_Bloom,CRTFrutbunn,CRT_Lottes,CRTRefresh
PreprocessorDefinitions=ENABLE_HISTOGRAM=0
[D3D9]
@@ -81,43 +81,3 @@ PredicationEnabled=0
PredicationScale=2.000000
PredicationStrength=0.400000
PredicationThreshold=0.010000
-
-[GammaLevel7]
-RGB_Lift=1.000000,1.000000,1.000000
-RGB_Gamma=1.250000,1.250000,1.250000
-RGB_Gain=1.700000,1.700000,1.700000
-
-[GammaLevel6]
-RGB_Lift=1.000000,1.000000,1.000000
-RGB_Gamma=1.225000,1.225000,1.225000
-RGB_Gain=1.475000,1.475000,1.475000
-
-[GammaLevel5]
-RGB_Lift=1.000000,1.000000,1.000000
-RGB_Gamma=1.200000,1.200000,1.200000
-RGB_Gain=1.300000,1.300000,1.300000
-
-[GammaLevel4]
-RGB_Lift=1.000000,1.000000,1.000000
-RGB_Gamma=1.100000,1.100000,1.100000
-RGB_Gain=1.125000,1.125000,1.125000
-
-[GammaLevel3]
-RGB_Lift=1.000000,1.000000,1.000000
-RGB_Gamma=1.000000,1.000000,1.000000
-RGB_Gain=1.000000,1.000000,1.000000
-
-[GammaLevel2]
-RGB_Lift=1.000000,1.000000,1.000000
-RGB_Gamma=0.950000,0.950000,0.950000
-RGB_Gain=0.900000,0.900000,0.900000
-
-[GammaLevel1]
-RGB_Lift=1.000000,1.000000,1.000000
-RGB_Gamma=0.900000,0.900000,0.900000
-RGB_Gain=0.800000,0.800000,0.800000
-
-[GammaLevel0]
-RGB_Lift=1.000000,1.000000,1.000000
-RGB_Gamma=0.850000,0.850000,0.850000
-RGB_Gain=0.700000,0.700000,0.700000
diff --git a/Resources/Resource.h b/Resources/Resource.h
index a86118aa..fc33caff 100644
--- a/Resources/Resource.h
+++ b/Resources/Resource.h
@@ -10,7 +10,6 @@
#define IDR_ALSOFT_INI 103
#define IDR_SMAA_FX 201
-#define IDR_GAMMAGAIN_FX 203
#define IDR_PIRATEBLOOM_FX 204
#define IDR_FRUTBUNN_FX 205
#define IDR_LOTTES_FX 206
@@ -75,7 +74,6 @@ namespace
std::vector shaderList{
{ &EnableSMAA, IDR_SMAA_FX, "SMAA.fx" },
- { &RestoreBrightnessSelector, IDR_GAMMAGAIN_FX, "LiftGammaGain.fx" },
{ &EnableCRTShader, IDR_PIRATEBLOOM_FX, "PirateBloom.fx" },
{ &CRTNonCurveShader, IDR_FRUTBUNN_FX, "FrutbunnNonCurve.fx" },
{ &CRTCurveShader, IDR_FRUTBUNN_FX, "FrutbunnCurve.fx" },
diff --git a/Resources/UALx86.rc b/Resources/UALx86.rc
index f22e5b9a..92b0b0bb 100644
Binary files a/Resources/UALx86.rc and b/Resources/UALx86.rc differ
diff --git a/Wrappers/d3d8/IDirect3DDevice8.cpp b/Wrappers/d3d8/IDirect3DDevice8.cpp
index b4ff211a..61c5ed34 100644
--- a/Wrappers/d3d8/IDirect3DDevice8.cpp
+++ b/Wrappers/d3d8/IDirect3DDevice8.cpp
@@ -18,6 +18,7 @@
#include "d3d8wrapper.h"
#include
#include
+#include
#include
#include
#include
@@ -61,6 +62,70 @@ static double TimeGetNowSec() {
return static_cast(qpcNow.QuadPart) / static_cast(sQPCFreq.QuadPart);
}
+// brightness (gamma) shader
+/*
+ps.1.4
+ def c0, 1, 1, 1, 1
+
+ // load backbuffer
+ texld r0, t0
+ // now separate colour into channels
+ mov_sat r1, r0.x
+ mov_sat r2, r0.y
+ mov_sat r3, r0.z
+
+phase
+
+ // now look up in our 1D LUT using separate colour channels as texcoords
+ texld r1, r1
+ texld r2, r2
+ texld r3, r3
+
+ mov r0, c0
+ mov_sat r0.x, r1.w
+ mov_sat r0.y, r2.w
+ mov_sat r0.z, r3.w
+*/
+const DWORD g_GammaLUTShaderCodePS[] = {
+ 0xffff0104, 0x0009fffe, 0x58443344, 0x68532038,
+ 0x72656461, 0x73734120, 0x6c626d65, 0x56207265,
+ 0x69737265, 0x30206e6f, 0x0031392e, 0x00000051,
+ 0xa00f0000, 0x3f800000, 0x3f800000, 0x3f800000,
+ 0x3f800000, 0x00000042, 0x800f0000, 0xb0e40000,
+ 0x00000001, 0x801f0001, 0x80000000, 0x00000001,
+ 0x801f0002, 0x80550000, 0x00000001, 0x801f0003,
+ 0x80aa0000, 0x0000fffd, 0x00000042, 0x800f0001,
+ 0x80e40001, 0x00000042, 0x800f0002, 0x80e40002,
+ 0x00000042, 0x800f0003, 0x80e40003, 0x00000001,
+ 0x800f0000, 0xa0e40000, 0x00000001, 0x80110000,
+ 0x80ff0001, 0x00000001, 0x80120000, 0x80ff0002,
+ 0x00000001, 0x80140000, 0x80ff0003, 0x0000ffff
+};
+DWORD g_GammaPSHandle = 0u;
+
+/*
+vs.1.1
+// simple pass-through
+mov oPos, v0
+mov oT0, v7
+*/
+const DWORD g_GammaLUTShaderCodeVS[] = {
+ 0xfffe0101, 0x0009fffe, 0x58443344, 0x68532038,
+ 0x72656461, 0x73734120, 0x6c626d65, 0x56207265,
+ 0x69737265, 0x30206e6f, 0x0031392e, 0x00000001,
+ 0xc00f0000, 0x90e40000, 0x00000001, 0xe00f0000,
+ 0x90e40007, 0x0000ffff
+};
+DWORD g_GammaVSHandle = 0u;
+
+DWORD vsDeclFullScreenQuad[] = {
+ D3DVSD_STREAM(0),
+ D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT4),
+ D3DVSD_REG(D3DVSDE_TEXCOORD0, D3DVSDT_FLOAT2),
+ D3DVSD_END()
+};
+
+
bool DeviceLost = false;
bool DetectAltTab = false;
bool DisableShaderOnPresent = false;
@@ -274,6 +339,17 @@ HRESULT m_IDirect3DDevice8::Reset(D3DPRESENT_PARAMETERS *pPresentationParameters
ReleaseInterface(&ScaleVertexBuffer);
}
+ if (GammaRampLUT)
+ {
+ ReleaseInterface(&GammaRampLUT);
+ BrightnessLevel = ~0u;
+ }
+
+ if (ScreenCopy)
+ {
+ ReleaseInterface(&ScreenCopy);
+ }
+
WaterEnhancedReleaseScreenCopy();
OverlayRef.ResetFont();
@@ -930,6 +1006,12 @@ void m_IDirect3DDevice8::GetGammaRamp(THIS_ D3DGAMMARAMP* pRamp)
{
Logging::LogDebug() << __FUNCTION__;
+ if (RestoreBrightnessSelector)
+ {
+ memcpy(pRamp, &CachedRamp, sizeof(D3DGAMMARAMP));
+ return;
+ }
+
ProxyInterface->GetGammaRamp(pRamp);
}
@@ -937,10 +1019,22 @@ void m_IDirect3DDevice8::SetGammaRamp(THIS_ DWORD Flags, CONST D3DGAMMARAMP* pRa
{
Logging::LogDebug() << __FUNCTION__;
- // Don't enable shaders until the game calls SetGamma to make sure all the shader settings are initialized
- ShadersReady = EnableCustomShaders;
-
- if (ScreenMode != WINDOWED || (RestoreBrightnessSelector && IsUsingD3d8to9))
+ if (RestoreBrightnessSelector)
+ {
+ memcpy(&CachedRamp, pRamp, sizeof(D3DGAMMARAMP));
+
+ GammaLevel = (pRamp->red[127] == 19018) ? 0 :
+ (pRamp->red[127] == 22873) ? 1 :
+ (pRamp->red[127] == 28013) ? 2 :
+ (pRamp->red[127] == 32639) ? 3 :
+ (pRamp->red[127] == 35466) ? 4 :
+ (pRamp->red[127] == 39321) ? 5 :
+ (pRamp->red[127] == 45746) ? 6 :
+ (pRamp->red[127] == 56026) ? 7 : 3;
+
+ OnSetBrightnessLevel(GammaLevel);
+ }
+ else if (ScreenMode != WINDOWED)
{
ProxyInterface->SetGammaRamp(Flags, pRamp);
}
@@ -1173,6 +1267,11 @@ HRESULT m_IDirect3DDevice8::CreatePixelShader(THIS_ CONST DWORD* pFunction, DWOR
ProxyInterface->CreatePixelShader(g_WaterPSBytecode, &g_WaterPSHandle);
}
+ if (!g_GammaPSHandle)
+ {
+ ProxyInterface->CreatePixelShader(g_GammaLUTShaderCodePS, &g_GammaPSHandle);
+ }
+
return ProxyInterface->CreatePixelShader(pFunction, pHandle);
}
@@ -1255,8 +1354,91 @@ static void CalculateFPS()
Logging::LogDebug() << "Frames: " << frameTimes.size() << " Average time: " << averageFrameTime << " FPS: " << AverageFPSCounter;
}
-HRESULT m_IDirect3DDevice8::DrawScaledSurface()
+// repeats CUSTOMVERTEX_TEX1 layout
+const float g_FullScreenQuadVertices[6 * 4] = {
+ 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f,
+ -1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f,
+ 1.0f,-1.0f, 0.0f, 1.0f, 1.0f, 1.0f,
+ -1.0f,-1.0f, 0.0f, 1.0f, 0.0f, 1.0f
+};
+HRESULT m_IDirect3DDevice8::DrawShadersAndScaledSurface()
{
+ HRESULT hr;
+
+ IDirect3DSurface8* pBackBuffer = nullptr, * pStencilBuffer = nullptr;
+ IDirect3DTexture8* pTexture = nullptr;
+
+ // Backup current render target (backbuffer) and stencil buffer
+ if (IsScaledResolutionsEnabled())
+ {
+ if (SUCCEEDED(ProxyInterface->GetRenderTarget(&pBackBuffer)) && pBackBuffer)
+ {
+ if (SUCCEEDED(pBackBuffer->GetContainer(IID_IDirect3DTexture8, (void**)&pTexture)))
+ {
+ pTexture->Release();
+ }
+ else
+ {
+ D3DSURFACE_DESC Desc = {};
+ pBackBuffer->GetDesc(&Desc);
+ Logging::Log() << __FUNCTION__ << " Error: Failed to get surface for render target! " << Desc.Width << "x" << Desc.Height;
+ }
+ pBackBuffer->Release();
+ }
+ pRenderSurfaceLast = pBackBuffer;
+
+ if (SUCCEEDED(ProxyInterface->GetDepthStencilSurface(&pStencilBuffer)) && pStencilBuffer)
+ {
+ pStencilBuffer->Release();
+ }
+
+ // Use the custom render target texture as a source texture
+ ProxyInterface->SetTexture(0, pTexture);
+
+ // Set original back buffer as render target
+ ProxyInterface->SetRenderTarget(pAutoRenderTarget, nullptr);
+ }
+ // Create texture of current backbuffer
+ else
+ {
+ hr = ProxyInterface->GetRenderTarget(&pBackBuffer);
+ if (FAILED(hr) || !pBackBuffer)
+ {
+ Logging::Log() << __FUNCTION__ << " Error: Failed to get backbuffer surface!";
+ return hr;
+ }
+
+ // to not forget
+ pBackBuffer->Release();
+
+ if (!ScreenCopy)
+ {
+ D3DSURFACE_DESC bbDesc{};
+ pBackBuffer->GetDesc(&bbDesc);
+
+ // Create render texture
+ if (FAILED(ProxyInterface->CreateTexture(bbDesc.Width, bbDesc.Height, 1, 0, bbDesc.Format, D3DPOOL_DEFAULT, &ScreenCopy)))
+ {
+ Logging::Log() << __FUNCTION__ << " Error: Failed to create ScreenCopy target!";
+ return D3DERR_INVALIDCALL;
+ }
+ }
+
+ IDirect3DSurface8* copySurface = nullptr;
+ hr = ScreenCopy->GetSurfaceLevel(0, ©Surface);
+ if (FAILED(hr) || !copySurface)
+ {
+ Logging::Log() << __FUNCTION__ << " Error: Failed to get ScreenCopy surface!";
+ return hr;
+ }
+
+ ProxyInterface->CopyRects(pBackBuffer, nullptr, 0, copySurface, nullptr);
+ copySurface->Release();
+
+ // Use the custom render target texture as a source texture
+ ProxyInterface->SetTexture(0, ScreenCopy);
+ }
+
// Get render states
DWORD rsLighting, rsAlphaTestEnable, rsAlphaBlendEnable, rsFogEnable, rsZEnable, rsZWriteEnable, reStencilEnable;
ProxyInterface->GetRenderState(D3DRS_LIGHTING, &rsLighting);
@@ -1268,13 +1450,18 @@ HRESULT m_IDirect3DDevice8::DrawScaledSurface()
ProxyInterface->GetRenderState(D3DRS_STENCILENABLE, &reStencilEnable);
// Get texture states
- DWORD tsColorOP, tsColorArg1, tsColorArg2, tsAlphaOP, tsMinFilter, tsMagFilter;
+ DWORD tsColorOP, tsColorArg1, tsColorArg2, tsAlphaOP, tsMinFilter, tsMagFilter, addressU[4], addressV[4];
ProxyInterface->GetTextureStageState(0, D3DTSS_COLOROP, &tsColorOP);
ProxyInterface->GetTextureStageState(0, D3DTSS_COLORARG1, &tsColorArg1);
ProxyInterface->GetTextureStageState(0, D3DTSS_COLORARG2, &tsColorArg2);
ProxyInterface->GetTextureStageState(0, D3DTSS_ALPHAOP, &tsAlphaOP);
ProxyInterface->GetTextureStageState(0, D3DTSS_MINFILTER, &tsMinFilter);
ProxyInterface->GetTextureStageState(0, D3DTSS_MAGFILTER, &tsMagFilter);
+ for (DWORD i = 0; i < 4; ++i)
+ {
+ ProxyInterface->GetTextureStageState(i, D3DTSS_ADDRESSU, &addressU[i]);
+ ProxyInterface->GetTextureStageState(i, D3DTSS_ADDRESSV, &addressV[i]);
+ }
// Set render states
ProxyInterface->SetRenderState(D3DRS_LIGHTING, FALSE);
@@ -1292,72 +1479,57 @@ HRESULT m_IDirect3DDevice8::DrawScaledSurface()
ProxyInterface->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
ProxyInterface->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
ProxyInterface->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
+ for (DWORD i = 0; i < 4; ++i)
+ {
+ ProxyInterface->SetTextureStageState(i, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
+ ProxyInterface->SetTextureStageState(i, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
+ }
- IDirect3DSurface8* pBackBuffer = nullptr, * pStencilBuffer = nullptr;
- IDirect3DTexture8* pTexture = nullptr;
-
- // Back up current render target (backbuffer) and stencil buffer
- if (SUCCEEDED(ProxyInterface->GetRenderTarget(&pBackBuffer)) && pBackBuffer)
+ // Set texture for gamma shader
+ if (RestoreBrightnessSelector)
{
- if (SUCCEEDED(pBackBuffer->GetContainer(IID_IDirect3DTexture8, (void**)&pTexture)))
+ if (!GammaRampLUT || BrightnessLevel == ~0u)
{
- pTexture->Release();
+ OnSetBrightnessLevel(GammaLevel);
}
- else
+
+ ProxyInterface->SetTexture(1, GammaRampLUT);
+ ProxyInterface->SetTexture(2, GammaRampLUT);
+ ProxyInterface->SetTexture(3, GammaRampLUT);
+ for (int x = 4; x < 8; x++)
{
- D3DSURFACE_DESC Desc = {};
- pBackBuffer->GetDesc(&Desc);
- Logging::Log() << __FUNCTION__ << " Error: Failed to get surface for render target! " << Desc.Width << "x" << Desc.Height;
+ ProxyInterface->SetTexture(x, nullptr);
}
- pBackBuffer->Release();
- }
- pRenderSurfaceLast = pBackBuffer;
- if (SUCCEEDED(ProxyInterface->GetDepthStencilSurface(&pStencilBuffer)) && pStencilBuffer)
- {
- pStencilBuffer->Release();
+ ProxyInterface->SetVertexShader(g_GammaVSHandle);
+ ProxyInterface->SetPixelShader(g_GammaPSHandle);
}
-
- // Set original back buffer as render target
- ProxyInterface->SetRenderTarget(pAutoRenderTarget, nullptr);
-
- // Use the custom render target texture as a source texture
- ProxyInterface->SetTexture(0, pTexture);
- for (int x = 1; x < 8; x++)
+ // Set texture
+ else
{
- ProxyInterface->SetTexture(x, nullptr);
- }
-
- ProxyInterface->SetPixelShader(NULL);
- ProxyInterface->SetVertexShader(NULL);
-
- // Set vertex declaration
- ProxyInterface->SetVertexShader(D3DFVF_XYZRHW | D3DFVF_TEX1);
-
- // Set stream source
- ProxyInterface->SetStreamSource(0, ScaleVertexBuffer, sizeof(CUSTOMVERTEX_TEX1));
+ for (int x = 1; x < 8; x++)
+ {
+ ProxyInterface->SetTexture(x, nullptr);
+ }
- // Draw the full-screen quad with updated vertices
- HRESULT hr = ProxyInterface->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
+ ProxyInterface->SetPixelShader(0);
+ ProxyInterface->SetVertexShader(0);
+ }
- D3DSURFACE_DESC Desc = {};
- pAutoRenderTarget->GetDesc(&Desc);
+ if (IsScaledResolutionsEnabled())
+ {
+ // Set vertex declaration
+ ProxyInterface->SetVertexShader(D3DFVF_XYZRHW | D3DFVF_TEX1);
- // Set the render target texture (pRenderTexture) back to nullptr
- ProxyInterface->SetTexture(0, nullptr);
+ // Set stream source
+ ProxyInterface->SetStreamSource(0, ScaleVertexBuffer, sizeof(CUSTOMVERTEX_TEX1));
- // Swap scaled render targets
- if (pBackBuffer == pRenderSurface1)
- {
- ProxyInterface->SetRenderTarget(pRenderSurface2, pStencilBuffer);
- }
- else if (pBackBuffer == pRenderSurface2)
- {
- ProxyInterface->SetRenderTarget(pRenderSurface1, pStencilBuffer);
+ // Draw the full-screen quad with updated vertices
+ hr = ProxyInterface->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
}
else
{
- ProxyInterface->SetRenderTarget(pBackBuffer, pStencilBuffer);
+ hr = ProxyInterface->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_FullScreenQuadVertices, sizeof(CUSTOMVERTEX_TEX1));
}
// Reset render states
@@ -1376,6 +1548,42 @@ HRESULT m_IDirect3DDevice8::DrawScaledSurface()
ProxyInterface->SetTextureStageState(0, D3DTSS_ALPHAOP, tsAlphaOP);
ProxyInterface->SetTextureStageState(0, D3DTSS_MINFILTER, tsMinFilter);
ProxyInterface->SetTextureStageState(0, D3DTSS_MAGFILTER, tsMagFilter);
+ for (DWORD i = 0; i < 4; ++i)
+ {
+ ProxyInterface->SetTextureStageState(i, D3DTSS_ADDRESSU, addressU[i]);
+ ProxyInterface->SetTextureStageState(i, D3DTSS_ADDRESSV, addressV[i]);
+ }
+
+ ProxyInterface->SetVertexShader(0);
+ ProxyInterface->SetPixelShader(0);
+
+ ProxyInterface->SetTexture(0, nullptr);
+ ProxyInterface->SetTexture(1, nullptr);
+ ProxyInterface->SetTexture(2, nullptr);
+ ProxyInterface->SetTexture(3, nullptr);
+
+ // Call function
+ RunPresentCode(ProxyInterface, ScaledBufferWidth, ScaledBufferHeight);
+
+ // Draw Overlays
+ OverlayRef.DrawOverlays(ProxyInterface, ScaledBufferWidth, ScaledBufferHeight);
+
+ // Swap scaled render targets
+ if (IsScaledResolutionsEnabled())
+ {
+ if (pBackBuffer == pRenderSurface1)
+ {
+ ProxyInterface->SetRenderTarget(pRenderSurface2, pStencilBuffer);
+ }
+ else if (pBackBuffer == pRenderSurface2)
+ {
+ ProxyInterface->SetRenderTarget(pRenderSurface1, pStencilBuffer);
+ }
+ else
+ {
+ ProxyInterface->SetRenderTarget(pBackBuffer, pStencilBuffer);
+ }
+ }
return hr;
}
@@ -1503,23 +1711,20 @@ HRESULT m_IDirect3DDevice8::Present(CONST RECT* pSourceRect, CONST RECT* pDestRe
OverlayRef.RenderMouseCursor();
}
- // Call function
- RunPresentCode(ProxyInterface, BufferWidth, BufferHeight);
+ // Fix pause menu before drawing scaled surface
+ bool PauseMenuFlag = FixPauseMenuOnPresent();
- // Draw Overlays
- if (IsScaledResolutionsEnabled() || GetEventIndex() != EVENT_PAUSE_MENU)
+ // Draw shader and scaled surface, inlcuding Overalys
+ if (IsScaledResolutionsEnabled() || RestoreBrightnessSelector)
{
- OverlayRef.DrawOverlays(ProxyInterface, BufferWidth, BufferHeight);
+ DrawShadersAndScaledSurface();
}
-
- bool PauseMenuFlag = false;
- if (IsScaledResolutionsEnabled())
+ // Draw Overlays
+ else if (GetEventIndex() != EVENT_PAUSE_MENU)
{
- // Fix pause menu before drawing scaled surface
- PauseMenuFlag = FixPauseMenuOnPresent();
+ RunPresentCode(ProxyInterface, BufferWidth, BufferHeight);
- // Draw scaled surface, inlcuding Overalys
- DrawScaledSurface();
+ OverlayRef.DrawOverlays(ProxyInterface, BufferWidth, BufferHeight);
}
// Endscene
@@ -1533,38 +1738,25 @@ HRESULT m_IDirect3DDevice8::Present(CONST RECT* pSourceRect, CONST RECT* pDestRe
if (ClearScreen)
{
ClearScreen = false;
- if (LimitPerFrameFPS && ScreenMode != EXCLUSIVE_FULLSCREEN)
- {
- LimitFrameRate();
- }
-
- HRESULT hr = ProxyInterface->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
- if (SUCCEEDED(hr))
- {
- CalculateFPS();
- }
+ // Just drawing a blank screen
+ ProxyInterface->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}
return D3D_OK;
}
ClearScreen = true;
- // Fix pause menu before Present if not using a scaled surface
- if (!IsScaledResolutionsEnabled())
- {
- PauseMenuFlag = FixPauseMenuOnPresent();
- }
-
// Check if shader needs to be disabled
- if (EnableCustomShaders && !PauseMenuFlag)
+ if ((EnableCustomShaders || RestoreBrightnessSelector) && !PauseMenuFlag)
{
// Get variables
static BYTE LastEvent = 0;
IsGetFrontBufferCalled = (GetTransitionState() == FADE_TO_BLACK || GetLoadingScreen() != 0) ? IsGetFrontBufferCalled : false;
// Set shader disable flag
- DisableShaderOnPresent = !IsScaledResolutionsEnabled() && (IsGetFrontBufferCalled || (PauseScreenFix && (GetEventIndex() == EVENT_PAUSE_MENU || (LastEvent == EVENT_PAUSE_MENU && IsSnapshotTextureSet))));
+ const bool DontDisableShaders = ((IsScaledResolutionsEnabled() && pRenderSurfaceLast) || (RestoreBrightnessSelector && ScreenCopy));
+ DisableShaderOnPresent = !DontDisableShaders && (IsGetFrontBufferCalled || (PauseScreenFix && (GetEventIndex() == EVENT_PAUSE_MENU || (LastEvent == EVENT_PAUSE_MENU && IsSnapshotTextureSet))));
// Reset variables
LastEvent = GetEventIndex();
@@ -2964,6 +3156,11 @@ HRESULT m_IDirect3DDevice8::CreateVertexShader(THIS_ CONST DWORD* pDeclaration,
ProxyInterface->CreateVertexShader(vsDeclWater, g_WaterPondVSBytecode, &g_WaterPondVSHandle, 0);
}
+ if (!g_GammaVSHandle)
+ {
+ ProxyInterface->CreateVertexShader(vsDeclFullScreenQuad, g_GammaLUTShaderCodeVS, &g_GammaVSHandle, 0);
+ }
+
return ProxyInterface->CreateVertexShader(pDeclaration, pFunction, pHandle, Usage);
}
@@ -3331,6 +3528,32 @@ HRESULT m_IDirect3DDevice8::FakeGetFrontBuffer(THIS_ IDirect3DSurface8* pDestSur
}
return D3D_OK;
}
+ else if (RestoreBrightnessSelector && ScreenCopy)
+ {
+ LPDIRECT3DSURFACE8 pLastRenderSurface = nullptr;
+ if (ScreenCopy && !IsScaledResolutionsEnabled())
+ {
+ if (SUCCEEDED(ScreenCopy->GetSurfaceLevel(0, &pLastRenderSurface)))
+ {
+ D3DSURFACE_DESC SrcDesc = {};
+ pLastRenderSurface->GetDesc(&SrcDesc);
+ if (SrcDesc.Width != DestDesc.Width || SrcDesc.Height != DestDesc.Height)
+ {
+ LOG_ONCE(__FUNCTION__ << " Error: Surface size does not match render target!");
+ return D3DERR_INVALIDCALL;
+ }
+ POINT PointDest = { 0, 0 };
+ RECT SrcRect = { 0, 0, (LONG)SrcDesc.Width, (LONG)SrcDesc.Height };
+ if (FAILED(ProxyInterface->CopyRects(pLastRenderSurface, &SrcRect, 1, pDestSurface, &PointDest)))
+ {
+ LOG_ONCE(__FUNCTION__ << " Error: Failed to copy surface!");
+ return D3DERR_INVALIDCALL;
+ }
+ }
+ pLastRenderSurface->Release();
+ return D3D_OK;
+ }
+ }
// Get source rect size
RECT SrcRect = {};
@@ -3561,6 +3784,54 @@ void m_IDirect3DDevice8::AddSurfaceToVector(m_IDirect3DSurface8 *pSourceTarget,
}
}
+void m_IDirect3DDevice8::OnSetBrightnessLevel(const DWORD level)
+{
+ Logging::Log() << __FUNCTION__;
+
+ constexpr DWORD kGammaRampLUTDim = 256;
+
+ if (level != BrightnessLevel)
+ {
+ BrightnessLevel = min(level, 7);
+
+ Logging::Log() << __FUNCTION__ << " New BrightnessLevel = " << BrightnessLevel;
+
+ const float gammaValues[8] = { 0.85f, 0.9f, 0.95f, 1.0f, 1.1f, 1.2f, 1.225f, 1.25f };
+ const float gainValues[8] = { 0.7f, 0.8f, 0.9f, 1.0f, 1.125f, 1.3f, 1.475f, 1.7f };
+
+ HRESULT hr;
+ if (!GammaRampLUT)
+ {
+ hr = ProxyInterface->CreateTexture(kGammaRampLUTDim, 1, 1, 0, D3DFMT_A8, D3DPOOL_MANAGED, &GammaRampLUT);
+ if (FAILED(hr))
+ {
+ GammaRampLUT = nullptr;
+
+ Logging::Log() << __FUNCTION__ << " Failed to create GammaRampLUT ! hr = " << hr;
+ return;
+ }
+ }
+
+ D3DLOCKED_RECT lockedRect{};
+ hr = GammaRampLUT->LockRect(0u, &lockedRect, nullptr, 0u);
+ if (SUCCEEDED(hr)) {
+ const float gamma = 1.0f / gammaValues[BrightnessLevel];
+ const float gain = gainValues[BrightnessLevel];
+
+ BYTE* rampValues = reinterpret_cast(lockedRect.pBits);
+ for (UINT i = 0; i < kGammaRampLUTDim; ++i) {
+ float value = static_cast(i) / static_cast(kGammaRampLUTDim - 1);
+ value = powf(fabs(value * gain), gamma);
+ rampValues[i] = static_cast((std::min)(255.0f, (std::max)(0.0f, value * 255.0f)));
+ }
+
+ GammaRampLUT->UnlockRect(0u);
+ } else {
+ Logging::Log() << "Failed to GammaRampLUT->LockRect !";
+ }
+ }
+}
+
void m_IDirect3DDevice8::EnableAntiAliasing()
{
// Set MultiSample
@@ -4083,6 +4354,9 @@ void m_IDirect3DDevice8::SetShadowFading()
void m_IDirect3DDevice8::SetScaledBackbuffer()
{
+ ScaledBufferWidth = BufferWidth;
+ ScaledBufferHeight = BufferHeight;
+
if (!IsScaledResolutionsEnabled())
{
return;
@@ -4154,6 +4428,9 @@ void m_IDirect3DDevice8::SetScaledBackbuffer()
D3DSURFACE_DESC Desc = {};
pAutoRenderTarget->GetDesc(&Desc);
+ ScaledBufferWidth = Desc.Width;
+ ScaledBufferHeight = Desc.Height;
+
ScaledPresentVertex[2].x = (float)Desc.Width - 0.5f;
ScaledPresentVertex[3].x = (float)Desc.Width - 0.5f;
diff --git a/Wrappers/d3d8/IDirect3DDevice8.h b/Wrappers/d3d8/IDirect3DDevice8.h
index 9c9f8088..e68ab253 100644
--- a/Wrappers/d3d8/IDirect3DDevice8.h
+++ b/Wrappers/d3d8/IDirect3DDevice8.h
@@ -30,6 +30,9 @@ class m_IDirect3DDevice8 : public IDirect3DDevice8
bool isInScene = false;
+ DWORD ScaledBufferWidth = 0;
+ DWORD ScaledBufferHeight = 0;
+
bool AnisotropyFlag = (bool)AnisotropicFiltering;
DWORD MaxAnisotropy = 0;
bool IsAntiAliasingEnabled = false;
@@ -89,6 +92,12 @@ class m_IDirect3DDevice8 : public IDirect3DDevice8
bool NeedToGrabScreenForWater = true;
// Cockroaches replacement
int RoachesDrawingCounter = 0;
+ // GammaRamp stuff
+ DWORD GammaLevel = 0;
+ DWORD BrightnessLevel = ~0u;
+ IDirect3DTexture8* GammaRampLUT = nullptr;
+ IDirect3DTexture8* ScreenCopy = nullptr;
+ D3DGAMMARAMP CachedRamp = {};
IDirect3DTexture8 *pInTexture = nullptr;
IDirect3DSurface8 *pInSurface = nullptr;
@@ -280,7 +289,7 @@ class m_IDirect3DDevice8 : public IDirect3DDevice8
STDMETHOD_(BOOL, ShowCursor)(THIS_ BOOL bShow);
STDMETHOD(CreateAdditionalSwapChain)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain8** pSwapChain);
STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters);
- STDMETHOD(DrawScaledSurface)(THIS_);
+ STDMETHOD(DrawShadersAndScaledSurface)(THIS_);
STDMETHOD_(bool, FixPauseMenuOnPresent)(THIS_);
STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion);
STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer);
@@ -371,4 +380,6 @@ class m_IDirect3DDevice8 : public IDirect3DDevice8
// Extra functions
void m_IDirect3DDevice8::AddSurfaceToVector(m_IDirect3DSurface8 *pSourceTarget, IDirect3DSurface8 *pRenderTarget);
+
+ void OnSetBrightnessLevel(const DWORD level);
};
diff --git a/Wrappers/d3d9/IDirect3DDevice9.cpp b/Wrappers/d3d9/IDirect3DDevice9.cpp
index 2bd7dd93..1da2b9ea 100644
--- a/Wrappers/d3d9/IDirect3DDevice9.cpp
+++ b/Wrappers/d3d9/IDirect3DDevice9.cpp
@@ -21,7 +21,6 @@
extern bool DisableShaderOnPresent;
-bool ShadersReady = false;
DWORD GammaLevel = 3;
HRESULT m_IDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj)
@@ -253,11 +252,9 @@ HRESULT m_IDirect3DDevice9::Reset(D3DPRESENT_PARAMETERS *pPresentationParameters
HRESULT m_IDirect3DDevice9::Present(const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion)
{
- bool SkipScene = false;
// Only call into runtime if the entire surface is presented, to avoid partial updates messing up effects and the GUI
- if (ShadersReady && !DisableShaderOnPresent && m_IDirect3DSwapChain9::is_presenting_entire_surface(pSourceRect, hDestWindowOverride))
+ if (!DisableShaderOnPresent && m_IDirect3DSwapChain9::is_presenting_entire_surface(pSourceRect, hDestWindowOverride))
{
- SkipScene = _implicit_swapchain->_runtime->get_gamma();
_implicit_swapchain->_runtime->on_present();
}
@@ -267,12 +264,6 @@ HRESULT m_IDirect3DDevice9::Present(const RECT *pSourceRect, const RECT *pDestRe
_buffer_detection.reset(false);
- if (SkipScene)
- {
- Logging::Log() << __FUNCTION__ << " Skipping frame after gamma change!";
- return D3D_OK;
- }
-
return ProxyInterface->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}
@@ -311,26 +302,6 @@ void m_IDirect3DDevice9::SetGammaRamp(UINT iSwapChain, DWORD Flags, const D3DGAM
return;
}
- if (RestoreBrightnessSelector)
- {
- memcpy(&Ramp, pRamp, sizeof(D3DGAMMARAMP));
-
- GammaLevel = (pRamp->red[127] == 19018) ? 0 :
- (pRamp->red[127] == 22873) ? 1 :
- (pRamp->red[127] == 28013) ? 2 :
- (pRamp->red[127] == 32639) ? 3 :
- (pRamp->red[127] == 35466) ? 4 :
- (pRamp->red[127] == 39321) ? 5 :
- (pRamp->red[127] == 45746) ? 6 :
- (pRamp->red[127] == 56026) ? 7 : 3;
-
- const auto runtime = _implicit_swapchain->_runtime;
-
- runtime->reset_gamma(true);
-
- return;
- }
-
return ProxyInterface->SetGammaRamp(0, Flags, pRamp);
}
@@ -342,12 +313,6 @@ void m_IDirect3DDevice9::GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP *pRamp)
return;
}
- if (RestoreBrightnessSelector)
- {
- memcpy(pRamp, &Ramp, sizeof(D3DGAMMARAMP));
- return;
- }
-
return ProxyInterface->GetGammaRamp(0, pRamp);
}
diff --git a/Wrappers/d3d9/IDirect3DDevice9.h b/Wrappers/d3d9/IDirect3DDevice9.h
index 35a08f51..123926e1 100644
--- a/Wrappers/d3d9/IDirect3DDevice9.h
+++ b/Wrappers/d3d9/IDirect3DDevice9.h
@@ -30,7 +30,6 @@ class m_IDirect3DDevice9 : public IDirect3DDevice9
LPDIRECT3DDEVICE9 ProxyInterface;
bool isInScene = false;
bool UseSoftwareRendering;
- D3DGAMMARAMP Ramp = {};
public:
m_IDirect3DSwapChain9 *_implicit_swapchain = nullptr;
diff --git a/Wrappers/d3d9/runtime_d3d9.cpp b/Wrappers/d3d9/runtime_d3d9.cpp
index 26b9223f..5331ac54 100644
--- a/Wrappers/d3d9/runtime_d3d9.cpp
+++ b/Wrappers/d3d9/runtime_d3d9.cpp
@@ -167,26 +167,6 @@ bool reshade::d3d9::runtime_d3d9::on_init(const D3DPRESENT_PARAMETERS &pp)
return runtime::on_init(pp.hDeviceWindow);
}
-bool reshade::d3d9::runtime_d3d9::get_gamma()
-{
- return _gamma_set;
-}
-void reshade::d3d9::runtime_d3d9::reset_gamma(bool reload)
-{
- subscribe_to_save_config([this, reload](ini_file &config) {
-
- config.reset_config();
-
- if (reload)
- {
- _gamma_set = true;
-
- runtime::on_reset(false);
-
- runtime::on_init(nullptr);
- }
- });
-}
void reshade::d3d9::runtime_d3d9::on_reset()
{
runtime::on_reset();
@@ -270,8 +250,6 @@ bool reshade::d3d9::runtime_d3d9::init_effect(size_t index)
{
effect &effect = _effects[index];
- bool is_gamma = (_gamma_set && effect.source_file.compare(GammaEffectName + ".fx") == 0);
-
// Add specialization constant defines to source code
effect.preamble +=
"#define COLOR_PIXEL_SIZE 1.0 / " + std::to_string(_width) + ", 1.0 / " + std::to_string(_height) + "\n"
@@ -315,7 +293,7 @@ bool reshade::d3d9::runtime_d3d9::init_effect(size_t index)
HRESULT hr = D3D_OK;
- if (_compile_cache[entry_index].size() == 0 || is_gamma)
+ if (_compile_cache[entry_index].size() == 0)
{
hr = D3DCompile(
hlsl, hlsl_size,
@@ -377,11 +355,6 @@ bool reshade::d3d9::runtime_d3d9::init_effect(size_t index)
++loop_count;
}
- if (is_gamma)
- {
- _gamma_set = false;
- }
-
d3d9_technique_data technique_init;
assert(effect.module.num_texture_bindings == 0);
assert(effect.module.num_storage_bindings == 0);
diff --git a/Wrappers/d3d9/runtime_d3d9.hpp b/Wrappers/d3d9/runtime_d3d9.hpp
index 6e59ae8f..a90bd10e 100644
--- a/Wrappers/d3d9/runtime_d3d9.hpp
+++ b/Wrappers/d3d9/runtime_d3d9.hpp
@@ -32,8 +32,6 @@ namespace reshade::d3d9
~runtime_d3d9();
bool on_init(const D3DPRESENT_PARAMETERS &pp);
- bool get_gamma();
- void reset_gamma(bool reload);
void on_reset();
void on_present();
@@ -77,7 +75,6 @@ namespace reshade::d3d9
com_ptr _depth_texture;
com_ptr _depth_surface;
- bool _gamma_set = false;
bool _disable_intz = false;
bool _reset_buffer_detection = false;
bool _filter_aspect_ratio = true;