Skip to content

Commit e50822a

Browse files
Add "Motion Blur" video option (#2519)
* Add "Motion Blur" video option Co-authored-by: Uladzislau Nikalayevich <thenormalnij@gmail.com>
1 parent 3f6dac6 commit e50822a

File tree

14 files changed

+76
-20
lines changed

14 files changed

+76
-20
lines changed

Client/core/CClientVariables.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ void CClientVariables::LoadDefaults()
329329
DEFAULT("tyre_smoke_enabled", 1); // Enable tyre smoke
330330
DEFAULT("high_detail_vehicles", 0); // Disable rendering high detail vehicles all the time
331331
DEFAULT("high_detail_peds", 0); // Disable rendering high detail peds all the time
332+
DEFAULT("blur", 1); // Enable blur
332333
DEFAULT("corona_reflections", 0); // Disable corona rain reflections
333334
DEFAULT("dynamic_ped_shadows", 0); // Disable dynamic ped shadows
334335
DEFAULT("fast_clothes_loading", 1); // 0-off 1-auto 2-on

Client/core/CCore.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ void CCore::ApplyGameSettings()
574574
CVARS_GET("tyre_smoke_enabled", bVal);
575575
m_pMultiplayer->SetTyreSmokeEnabled(bVal);
576576
pGameSettings->UpdateFieldOfViewFromSettings();
577+
pGameSettings->ResetBlurEnabled();
577578
pGameSettings->ResetVehiclesLODDistance();
578579
pGameSettings->ResetPedsLODDistance();
579580
pGameSettings->ResetCoronaReflectionsEnabled();

Client/core/CSettings.cpp

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -808,13 +808,13 @@ void CSettings::CreateGUI()
808808
m_pCheckBoxTyreSmokeParticles->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 90.0f));
809809
m_pCheckBoxTyreSmokeParticles->AutoSize(NULL, 20.0f);
810810

811-
m_pCheckBoxHighDetailVehicles = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Render vehicles always in high detail"), true));
812-
m_pCheckBoxHighDetailVehicles->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 110.0f));
813-
m_pCheckBoxHighDetailVehicles->AutoSize(NULL, 20.0f);
811+
m_pCheckBoxDynamicPedShadows = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Dynamic ped shadows"), true));
812+
m_pCheckBoxDynamicPedShadows->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 110.0f));
813+
m_pCheckBoxDynamicPedShadows->AutoSize(NULL, 20.0f);
814814

815-
m_pCheckBoxHighDetailPeds = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Render peds always in high detail"), true));
816-
m_pCheckBoxHighDetailPeds->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 130.0f));
817-
m_pCheckBoxHighDetailPeds->AutoSize(NULL, 20.0f);
815+
m_pCheckBoxBlur = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Motion blur"), true));
816+
m_pCheckBoxBlur->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 130.0f));
817+
m_pCheckBoxBlur->AutoSize(NULL, 20.0f);
818818

819819
float fPosY = vecTemp.fY;
820820
m_pCheckBoxMinimize = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Full Screen Minimize"), true));
@@ -853,14 +853,18 @@ void CSettings::CreateGUI()
853853
}
854854
#endif
855855

856+
m_pCheckBoxHighDetailVehicles = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Render vehicles always in high detail"), true));
857+
m_pCheckBoxHighDetailVehicles->SetPosition(CVector2D(vecTemp.fX + 245.0f, fPosY + 90.0f));
858+
m_pCheckBoxHighDetailVehicles->AutoSize(NULL, 20.0f);
859+
860+
m_pCheckBoxHighDetailPeds = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Render peds always in high detail"), true));
861+
m_pCheckBoxHighDetailPeds->SetPosition(CVector2D(vecTemp.fX + 245.0f, fPosY + 110.0f));
862+
m_pCheckBoxHighDetailPeds->AutoSize(NULL, 20.0f);
863+
856864
m_pCheckBoxCoronaReflections = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Corona rain reflections"), true));
857-
m_pCheckBoxCoronaReflections->SetPosition(CVector2D(vecTemp.fX + 245.0f, fPosY + 90.0f));
865+
m_pCheckBoxCoronaReflections->SetPosition(CVector2D(vecTemp.fX + 245.0f, fPosY + 130.0f));
858866
m_pCheckBoxCoronaReflections->AutoSize(NULL, 20.0f);
859867

860-
m_pCheckBoxDynamicPedShadows = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Dynamic ped shadows"), true));
861-
m_pCheckBoxDynamicPedShadows->SetPosition(CVector2D(vecTemp.fX + 245.0f, fPosY + 110.0f));
862-
m_pCheckBoxDynamicPedShadows->AutoSize(NULL, 20.0f);
863-
864868
vecTemp.fY += 10;
865869

866870
m_pTabs->GetSize(vecTemp);
@@ -1567,6 +1571,11 @@ void CSettings::UpdateVideoTab()
15671571
CVARS_GET("high_detail_peds", bHighDetailPeds);
15681572
m_pCheckBoxHighDetailPeds->SetSelected(bHighDetailPeds);
15691573

1574+
// Blur
1575+
bool bBlur;
1576+
CVARS_GET("blur", bBlur);
1577+
m_pCheckBoxBlur->SetSelected(bBlur);
1578+
15701579
// Corona rain reflections
15711580
bool bCoronaReflections;
15721581
CVARS_GET("corona_reflections", bCoronaReflections);
@@ -1804,6 +1813,7 @@ bool CSettings::OnVideoDefaultClick(CGUIElement* pElement)
18041813
CVARS_SET("tyre_smoke_enabled", true);
18051814
CVARS_SET("high_detail_vehicles", false);
18061815
CVARS_SET("high_detail_peds", false);
1816+
CVARS_SET("blur", true);
18071817
CVARS_SET("corona_reflections", false);
18081818
CVARS_SET("dynamic_ped_shadows", false);
18091819
gameSettings->UpdateFieldOfViewFromSettings();
@@ -3452,6 +3462,11 @@ void CSettings::SaveData()
34523462
CVARS_SET("high_detail_peds", bHighDetailPeds);
34533463
gameSettings->ResetPedsLODDistance(false);
34543464

3465+
// Blur
3466+
bool bBlur = m_pCheckBoxBlur->GetSelected();
3467+
CVARS_SET("blur", bBlur);
3468+
gameSettings->ResetBlurEnabled();
3469+
34553470
// Corona rain reflections
34563471
bool bCoronaReflections = m_pCheckBoxCoronaReflections->GetSelected();
34573472
CVARS_SET("corona_reflections", bCoronaReflections);

Client/core/CSettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class CSettings
160160
CGUICheckBox* m_pCheckBoxTyreSmokeParticles;
161161
CGUICheckBox* m_pCheckBoxHighDetailVehicles;
162162
CGUICheckBox* m_pCheckBoxHighDetailPeds;
163+
CGUICheckBox* m_pCheckBoxBlur;
163164
CGUICheckBox* m_pCheckBoxCoronaReflections;
164165
CGUICheckBox* m_pCheckBoxDynamicPedShadows;
165166
CGUILabel* m_pFieldOfViewLabel;

Client/core/Graphics/CRenderItemManager.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ void CRenderItemManager::GetDxStatus(SDxStatus& outStatus)
784784
outStatus.settings.fFieldOfView = 70;
785785
outStatus.settings.bHighDetailVehicles = false;
786786
outStatus.settings.bHighDetailPeds = false;
787+
outStatus.settings.bBlur = true;
787788
outStatus.settings.bCoronaReflections = false;
788789
outStatus.settings.bDynamicPedShadows = false;
789790

@@ -797,6 +798,7 @@ void CRenderItemManager::GetDxStatus(SDxStatus& outStatus)
797798
CVARS_GET("fov", outStatus.settings.fFieldOfView);
798799
CVARS_GET("high_detail_vehicles", outStatus.settings.bHighDetailVehicles);
799800
CVARS_GET("high_detail_peds", outStatus.settings.bHighDetailPeds);
801+
CVARS_GET("blur", outStatus.settings.bBlur);
800802
CVARS_GET("corona_reflections", outStatus.settings.bCoronaReflections);
801803
CVARS_GET("dynamic_ped_shadows", outStatus.settings.bDynamicPedShadows);
802804

Client/game_sa/CSettingsSA.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ CSettingsSA::CSettingsSA()
5252
m_pInterface->bFrameLimiter = false;
5353
m_bVolumetricShadowsEnabled = false;
5454
m_bVolumetricShadowsSuspended = false;
55+
m_bBlurViaScript = false;
5556
m_bDynamicPedShadowsEnabled = false;
5657
m_bCoronaReflectionsViaScript = false;
5758
SetAspectRatio(ASPECT_RATIO_4_3);
@@ -659,6 +660,27 @@ float CSettingsSA::GetPedsLODDistance()
659660

660661
////////////////////////////////////////////////
661662
//
663+
// Blur
664+
//
665+
// When blur is controlled by script changing this option
666+
// in settings doesn't produce any effect
667+
//
668+
////////////////////////////////////////////////
669+
void CSettingsSA::ResetBlurEnabled()
670+
{
671+
if (m_bBlurViaScript)
672+
return;
673+
674+
bool bEnabled;
675+
g_pCore->GetCVars()->Get("blur", bEnabled);
676+
pGame->SetBlurLevel(bEnabled ? DEFAULT_BLUR_LEVEL : 0);
677+
}
678+
679+
void CSettingsSA::SetBlurControlledByScript(bool bByScript)
680+
{
681+
m_bBlurViaScript = bByScript;
682+
}
683+
662684
// Corona rain reflections
663685
//
664686
// When corona reflections are controlled by script changing this option

Client/game_sa/CSettingsSA.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#define TRAIN_LOD_DISTANCE_MULTIPLIER ( 2.14f )
3939
#define MAX_VEHICLE_LOD_DISTANCE ( 500.0f )
4040
#define MAX_PEDS_LOD_DISTANCE ( 500.0f )
41+
#define DEFAULT_BLUR_LEVEL ( 36 )
4142

4243
struct CSettingsSAInterface // see code around 0x57CE9A for where these are
4344
{
@@ -89,6 +90,7 @@ class CSettingsSA : public CGameSettings
8990
eAspectRatio m_AspectRatio;
9091
int m_iDesktopWidth;
9192
int m_iDesktopHeight;
93+
bool m_bBlurViaScript;
9294
bool m_bCoronaReflectionsViaScript;
9395

9496
public:
@@ -166,6 +168,9 @@ class CSettingsSA : public CGameSettings
166168
void ResetVehiclesLODDistance(bool bForceDefault = false);
167169
void GetVehiclesLODDistance(float& fVehiclesLODDistance, float& fTrainsPlanesLODDistance);
168170

171+
void ResetBlurEnabled();
172+
void SetBlurControlledByScript(bool bByScript);
173+
169174
void ResetCoronaReflectionsEnabled();
170175
void SetCoronaReflectionsControlledByScript(bool bViaScript);
171176

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ CVector g_vecBulletFireEndPosition;
6262

6363
#define DEFAULT_GRAVITY 0.008f
6464
#define DEFAULT_GAME_SPEED 1.0f
65-
#define DEFAULT_BLUR_LEVEL 36
6665
#define DEFAULT_JETPACK_MAXHEIGHT 100
6766
#define DEFAULT_AIRCRAFT_MAXHEIGHT 800
6867
#define DEFAULT_AIRCRAFT_MAXVELOCITY 1.5f
@@ -5312,6 +5311,10 @@ void CClientGame::ResetMapInfo()
53125311
// Peds LOD distance
53135312
g_pGame->GetSettings()->ResetPedsLODDistance(true);
53145313

5314+
// Blur
5315+
g_pGame->GetSettings()->SetBlurControlledByScript(false);
5316+
g_pGame->GetSettings()->ResetBlurEnabled();
5317+
53155318
// Corona rain reflections
53165319
g_pGame->GetSettings()->SetCoronaReflectionsControlledByScript(false);
53175320
g_pGame->GetSettings()->ResetCoronaReflectionsEnabled();
@@ -5375,13 +5378,6 @@ void CClientGame::ResetMapInfo()
53755378
// Disable the change of any player stats
53765379
g_pMultiplayer->SetLocalStatsStatic(true);
53775380

5378-
// Restore blur
5379-
#ifdef MTA_DEBUG
5380-
g_pGame->SetBlurLevel(0);
5381-
#else
5382-
g_pGame->SetBlurLevel(DEFAULT_BLUR_LEVEL);
5383-
#endif
5384-
53855381
// Close all garages
53865382
CGarage* pGarage = NULL;
53875383
CGarages* pGarages = g_pCore->GetGame()->GetGarages();

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <game/CHandlingManager.h>
2222
#include <game/CPlayerInfo.h>
2323
#include <game/CRopes.h>
24+
#include <game/CSettings.h>
2425
#include <game/CTaskManager.h>
2526
#include <game/CWanted.h>
2627
#include <game/CWeapon.h>
@@ -6554,6 +6555,7 @@ bool CStaticFunctionDefinitions::GetGarageBoundingBox(unsigned char ucGarageID,
65546555

65556556
bool CStaticFunctionDefinitions::SetBlurLevel(unsigned char ucLevel)
65566557
{
6558+
g_pGame->GetSettings()->SetBlurControlledByScript(true);
65576559
g_pGame->SetBlurLevel(ucLevel);
65586560
return true;
65596561
}

Client/mods/deathmatch/logic/luadefs/CLuaDrawingDefs.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,10 @@ int CLuaDrawingDefs::DxGetStatus(lua_State* luaVM)
17121712
lua_pushboolean(luaVM, dxStatus.settings.bHighDetailPeds);
17131713
lua_settable(luaVM, -3);
17141714

1715+
lua_pushstring(luaVM, "SettingBlur");
1716+
lua_pushboolean(luaVM, dxStatus.settings.bBlur);
1717+
lua_settable(luaVM, -3);
1718+
17151719
lua_pushstring(luaVM, "SettingCoronaReflections");
17161720
lua_pushboolean(luaVM, dxStatus.settings.bCoronaReflections);
17171721
lua_settable(luaVM, -3);

0 commit comments

Comments
 (0)