Agrarsense
AgrarsenseSettings.cpp
Go to the documentation of this file.
1// Copyright (c) 2023 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
7
16
17#include "Misc/CommandLine.h"
18#include "GenericPlatform/GenericPlatformMisc.h"
19#include "Kismet/GameplayStatics.h"
20#include "GameFramework/GameUserSettings.h"
21#include "Misc/CoreDelegates.h"
22#include "Misc/CommandLine.h"
23#include "Misc/Parse.h"
24#include "Misc/App.h"
25#include "Engine/Engine.h"
26#include "Engine/GameViewportClient.h"
27#include "UObject/ObjectPtr.h"
28#include "LandscapeSubsystem.h"
29#include "Engine/World.h"
30#include "Engine/GameInstance.h"
31#include "Kismet/GameplayStatics.h"
32#include "TimerManager.h"
33
34#include "RHI.h"
35#include "RHIDefinitions.h"
36#include "Engine/Engine.h"
37
40
42{
43}
44
45void UAgrarsenseSettings::Setup(UWorld* World)
46{
47#if WITH_EDITOR
48 // In case the simulator was shutdown when it was paused,
49 // reset this static variable
51#endif
52
53 CurrentWorld = World;
54
55 UWorld* GameWorld = CurrentWorld.Get();
56
57 CurrentMapName = GameWorld->GetMapName().ToLower();
58 IsMainMenu = CurrentMapName.Contains("mainmenu");
59
60 if (GameWorld)
61 {
62 // Prioritize grass creation
63 // This allows turning grass on faster if it was turned off.
64 ULandscapeSubsystem* LandscapeSubsystem = CurrentWorld->GetSubsystem<ULandscapeSubsystem>();
65 if (LandscapeSubsystem)
66 {
67 LandscapeSubsystem->PrioritizeGrassCreation(true);
68 }
69 }
70
71 // Apply Graphics and Simulation settings when Simulator is started
72 ApplySettings(true);
73
74 // Apply few console commands. One time setup.
75 if (GEngine && World)
76 {
77 // Set OptimizedWPO to 1 to allow disabling WPO runtime for foliage (see InstancedRenderer.cpp)
78 GEngine->Exec(World, TEXT("r.OptimizedWPO 1"));
79
80 GEngine->Exec(World, TEXT("g.TimeoutForBlockOnRenderFence 600000"));
81 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0"));
82 GEngine->Exec(World, TEXT("r.CustomDepth 0"));
83
84 // Disable application starting to throttle performance if Window loses focus
85 GEngine->Exec(World, TEXT("t.IdleWhenNotForeground 0"));
86 }
87
89 if (Manager)
90 {
91 Manager->OnSensorSpawned.AddUniqueDynamic(this, &UAgrarsenseSettings::OnSensorSpawned);
92 Manager->OnSensorDestroyed.AddUniqueDynamic(this, &UAgrarsenseSettings::OnSensorDestroyed);
93 }
94 else
95 {
96 // Else failed to get SensorManager and listen Sensor spawning, always render custom depth
97 RenderCustomDepth = true;
98 }
99
100#if UE_BUILD_SHIPPING
101 // In Shipping mode check for Fullscreen and WindowedFullscreen launch args,
102 // Otherwise set window to windowed by default.
103 if (FParse::Param(FCommandLine::Get(), TEXT("Fullscreen")))
104 {
105 SetWindowMode(EWindowMode::Type::Fullscreen);
106 }
107 else if (FParse::Param(FCommandLine::Get(), TEXT("WindowedFullscreen")))
108 {
109 SetWindowMode(EWindowMode::Type::WindowedFullscreen);
110 }
111 else
112 {
113 SetWindowMode(EWindowMode::Type::Windowed);
114 }
115#endif
116}
117
119{
120 Super::PostInitProperties();
121
122#if UE_BUILD_SHIPPING || UE_BUILD_DEVELOPMENT
124 {
125 SaveConfig();
126 }
127#endif
128}
129
131{
132 return Cast<UAgrarsenseSettings>(UGameUserSettings::GetGameUserSettings());
133}
134
136{
137 Super::LoadSettings(bForceReload);
138}
139
140void UAgrarsenseSettings::ApplySettings(bool bCheckForCommandLineOverrides)
141{
142 Super::ApplySettings(bCheckForCommandLineOverrides);
143
146}
147
149{
150 bool SettingsWereChanged = false;
151
152 // Check -map= launch argument
153 FString AntiAliasingString;
154 if (FParse::Value(FCommandLine::Get(), TEXT("-antialiasing="), AntiAliasingString))
155 {
156 // Convert incoming string to int and then EAntiAliasing enum
157 int32 AntiAliasingInt;
158 if (AntiAliasingString.IsNumeric())
159 {
160 AntiAliasingInt = FCString::Atoi(*AntiAliasingString);
161 EAntiAliasing NewAntiAliasingMethod = static_cast<EAntiAliasing>(AntiAliasingInt);
162 GraphicsSettings.AntiAliasingMethod = NewAntiAliasingMethod;
163 SettingsWereChanged = true;
164 }
165 }
166
167 // Check -no-world-rendering launch argument
168 if (FParse::Param(FCommandLine::Get(), TEXT("-no-spectator-rendering")))
169 {
171 SettingsWereChanged = true;
172 }
173
174 // Check -start-camerawindows-minimized launch argument
175 if (FParse::Param(FCommandLine::Get(), TEXT("-start-camerawindows-minimized")))
176 {
178 SettingsWereChanged = true;
179 }
180
181 // Check -quality-level= launch argument
182 FString QualityLevelString;
183 if (FParse::Value(FCommandLine::Get(), TEXT("-quality-level="), QualityLevelString))
184 {
186 SettingsWereChanged = true;
187 }
188
189 return SettingsWereChanged;
190}
191
193{
194 return FPlatformMisc::NumberOfWorkerThreadsToSpawn();
195}
196
197FString UAgrarsenseSettings::GetConsoleVariableValueString(const FString& VariableName) const
198{
199 IConsoleVariable* ConsoleVariable = IConsoleManager::Get().FindConsoleVariable(*VariableName);
200 if (ConsoleVariable)
201 {
202 FString VariableValue = ConsoleVariable->GetString();
203 return VariableValue;
204 }
205 else
206 {
207 return FString();
208 }
209}
210
212{
213 GraphicsSettings = NewSettings;
214
221}
222
223void UAgrarsenseSettings::SetWindowMode(EWindowMode::Type WindowType)
224{
225 if (GEngine)
226 {
227 UGameUserSettings* UserSettings = GEngine->GetGameUserSettings();
228 if (UserSettings)
229 {
230 UserSettings->SetFullscreenMode(WindowType);
231 UserSettings->ApplySettings(false);
232 }
233 }
234}
235
237{
238 SimulationSettings = NewSettings;
239
244}
245
247{
249}
250
252{
253 if (GraphicsSettings.RenderGrass == Visible)
254 {
255 return;
256 }
257
258 UWorld* World = CurrentWorld.Get();
259
260 if (!GEngine || !World)
261 {
262 return;
263 }
264
266
268 {
269 GEngine->Exec(World, TEXT("grass.enable 0"));
270 GEngine->Exec(World, TEXT("grass.FlushCache"));
271 }
272 else
273 {
274 GEngine->Exec(World, TEXT("grass.enable 1"));
275 }
276
278}
279
281{
283}
284
286{
287 if (GraphicsSettings.ShadowCSMCaching == CacheShadowCSM)
288 {
289 return;
290 }
291
292 UWorld* World = CurrentWorld.Get();
293 if (GEngine && World)
294 {
295 GraphicsSettings.ShadowCSMCaching = CacheShadowCSM;
296
298 {
299 GEngine->Exec(World, TEXT("r.Shadow.CSMCaching 1"));
300 }
301 else
302 {
303 GEngine->Exec(World, TEXT("r.Shadow.CSMCaching 0"));
304 }
305
307 }
308}
309
311{
312 UWorld* World = CurrentWorld.Get();
313
314 if (World)
315 {
317 if (InstanceRenderer)
318 {
319 InstanceRenderer->SetInstancedRendering(Visible);
320 }
321 }
322}
323
325{
326 GraphicsSettings.WorldPositionOffsetDistance = WorldPositionOffsetDistance;
328}
329
331{
332 UWorld* World = CurrentWorld.Get();
333 if (GEngine && World)
334 {
335 MaxPixelsPerEdge = FMath::Clamp(MaxPixelsPerEdge, 0.1f, 10.0f);
336
337 FString Command = FString::Printf(TEXT("r.Nanite.MaxPixelsPerEdge %f"), MaxPixelsPerEdge);
338 GEngine->Exec(World, *Command);
339
340 GraphicsSettings.NaniteMaxPixelsPerEdge = MaxPixelsPerEdge;
342 }
343}
344
345void UAgrarsenseSettings::SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior Behaviour)
346{
348 {
351 }
352}
353
355{
356 FString BehaviourStringToLower = BehaviourString.ToLower();
357
358 if (BehaviourStringToLower == "auto")
359 {
360 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Auto);
361 }
362 else if (BehaviourStringToLower == "rigid")
363 {
364 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
365 }
366 else if (BehaviourStringToLower == "always")
367 {
368 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Always);
369 }
370 else if (BehaviourStringToLower == "static")
371 {
372 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Static);
373 }
374}
375
377{
379}
380
382{
384}
385
386EShadowCacheInvalidationBehavior UAgrarsenseSettings::GetShadowCacheInvalidationBehavior() const
387{
389}
390
392{
394}
395
397{
399}
400
401void UAgrarsenseSettings::SetRenderCustomDepthPass(bool RenderCustomDepthPass)
402{
403 UWorld* World = CurrentWorld.Get();
404 if (GEngine || World)
405 {
406 RenderCustomDepth = RenderCustomDepthPass;
407 if (RenderCustomDepthPass)
408 {
409 GEngine->Exec(World, TEXT("r.CustomDepth 3"));
410 }
411 else
412 {
413 GEngine->Exec(World, TEXT("r.CustomDepth 0"));
414 }
415 }
416}
417
418void UAgrarsenseSettings::SetUseVirtualShadowMaps(bool UseVirtualShadowMaps)
419{
420 UWorld* World = CurrentWorld.Get();
421 if (GEngine || World)
422 {
423 GraphicsSettings.UseVirtualShadowMaps = UseVirtualShadowMaps;
424
426 {
427 GEngine->Exec(World, TEXT("r.Shadow.Virtual.Enable 1"));
428 }
429 else
430 {
431 GEngine->Exec(World, TEXT("r.Shadow.Virtual.Enable 0"));
432 }
433
435 }
436}
437
439{
441}
442
444{
445 return RenderCustomDepth;
446}
447
449{
451}
452
454{
455
456 UWorld* World = CurrentWorld.Get();
457
458 if (!GEngine || !World)
459 {
460 return;
461 }
462
463 GraphicsSettings.AntiAliasingMethod = AntiAliasingMethod;
464
465 FString ExecCommand;
466 switch (AntiAliasingMethod)
467 {
469 ExecCommand = TEXT("r.AntiAliasingMethod 0");
470 break;
471
473 ExecCommand = TEXT("r.AntiAliasingMethod 1");
474 break;
475
477 ExecCommand = TEXT("r.AntiAliasingMethod 2");
478 break;
479
480 // MSAA ("r.AntiAliasingMethod 3) is not supported on Deferred rendering
481
483 ExecCommand = TEXT("r.AntiAliasingMethod 4");
484 break;
485
486 default:
487 return;
488 }
489
490 GEngine->Exec(World, *ExecCommand);
491
493}
494
495void UAgrarsenseSettings::SetAntiAliasingMethodFromString(const FString& AntiAliasingMethodString)
496{
497 EAntiAliasing NewMethod = UEnumUtilities::ConvertStringToAntiAliasingMethod(AntiAliasingMethodString);
498 SetAntiAliasingMethod(NewMethod);
499}
500
502{
503 if (GEngine && GEngine->GameViewport)
504 {
505 GEngine->GameViewport->bDisableWorldRendering = !enabled;
507
508 FString msg = FString::Printf(TEXT("World rendering: %s"), enabled ? TEXT("On") : TEXT("Off"));
510
512 }
513}
514
516{
517 GraphicsSettings.QualityLevel = newQualityLevel;
518
520 {
523 break;
524
527 break;
528
531 break;
532
535 break;
536 }
537
539 FString Msg = FString::Printf(TEXT("Graphics settings: %s"), *QualityLevelString);
541
543}
544
545void UAgrarsenseSettings::SetQualityLevelFromString(const FString& QualityLevelString)
546{
548}
549
551{
552 return GetFrameRateLimit();
553}
554
556{
557 SetFrameRateLimit(NewTargetFrameRate);
558 ApplySettings(false);
559}
560
562{
563 UWorld* World = CurrentWorld.Get();
564
565 if (!World)
566 {
568 }
569
570 return UGameplayStatics::GetGlobalTimeDilation(World);
571}
572
574{
575 UWorld* World = CurrentWorld.Get();
576 if (!World)
577 {
578 return;
579 }
580
581 SimulationSettings.TimeDilation = TimeDilation;
582 UGameplayStatics::SetGlobalTimeDilation(World, TimeDilation);
583
584 FString msg = FString::Printf(TEXT("Global time dilation: %f"), TimeDilation);
586}
587
589{
590 UWorld* World = CurrentWorld.Get();
591 if (!World)
592 {
593 return;
594 }
595
597 if (IsValid(Spectator))
598 {
599 Spectator->SetMaxSpeed(MaxSpeed);
601 }
602}
603
605{
606 UWorld* World = CurrentWorld.Get();
607 if (!World)
608 {
609 return;
610 }
611
613
614 if (IsValid(Spectator))
615 {
616 Spectator->SetNiagaraComponentVisibility(Show);
618 }
619}
620
622{
623 UWorld* World = CurrentWorld.Get();
625 {
626 UGameplayStatics::SetGlobalTimeDilation(World, 0.0f);
627 UGameplayStatics::SetGamePaused(World, true);
629
630 SimulatorLog::Log("Simulator paused");
631 }
632}
633
635{
636 UWorld* World = CurrentWorld.Get();
638 {
639 UGameplayStatics::SetGlobalTimeDilation(World, SimulationSettings.TimeDilation);
640 UGameplayStatics::SetGamePaused(World, false);
642
643 SimulatorLog::Log("Simulator unpaused");
644 }
645}
646
648{
650 {
651 return;
652 }
653
654 // Subscribe to Unreal Engine end of frame callback
655 EndOfFrameHandle = FCoreDelegates::OnEndFrame.AddLambda([this]()
656 {
657 // After receiving the event, unsubcribe from the event and pause the simulation.
658 if (IsValid(this))
659 {
660 if (EndOfFrameHandle.IsValid())
661 {
662 FCoreDelegates::OnEndFrame.Remove(EndOfFrameHandle);
663 EndOfFrameHandle.Reset();
664 }
665
667 }
668 });
669}
670
671void UAgrarsenseSettings::AdvanceFrameCount(int32 FramesToAdvance)
672{
673 if (FramesToAdvance == 0)
674 {
675 return;
676 }
677
678 if (AdvanceFramesHandle.IsValid())
679 {
680 // Already running this, return
681 return;
682 }
683
684 if (EndOfFrameHandle.IsValid())
685 {
686 // If PauseSimulationEndOfThisFrame was called, unsubribe
687 FCoreDelegates::OnEndFrame.Remove(EndOfFrameHandle);
688 EndOfFrameHandle.Reset();
689 }
690
691 // Unpause simulation now
693
694 FrameCount = 0;
695
696 // Subscribe to Unreal Engine end of frame callback
697 AdvanceFramesHandle = FCoreDelegates::OnEndFrame.AddLambda([this, FramesToAdvance]()
698 {
699 ++FrameCount;
700 if (FrameCount == FramesToAdvance)
701 {
702 // After given number of frames,
703 // unsubscribe from the event and pause simulation again at the end of that frame
704 if (IsValid(this))
705 {
706 FCoreDelegates::OnEndFrame.Remove(AdvanceFramesHandle);
707 AdvanceFramesHandle.Reset();
708 FrameCount = 0;
709
711 }
712 }
713 });
714}
715
716void UAgrarsenseSettings::AdvanceTime(float TimeToAdvance)
717{
718 UWorld* World = CurrentWorld.Get();
719 if (!World)
720 {
721 return;
722 }
723
724 // Unpause simulation now
726
727 // Pause simulation again after TimeToAdvance
728 FTimerHandle AdvanceTimeTimer;
729 World->GetTimerManager().SetTimer(AdvanceTimeTimer, FTimerDelegate::CreateLambda([this]
730 {
731 if (IsValid(this))
732 {
734 }
735
736 }), TimeToAdvance, false);
737}
738
740{
741 // Make the map name to lower
742 // This is because ROSCommands.cpp uses this and all the messages are in lower case.
743 MapName = MapName.ToLower();
744
745 bool FoundMap = false;
746 for (int32 i = 0; i < MapNames.Num(); i++)
747 {
748 if (MapName == MapNames[i])
749 {
750 FoundMap = true;
751 FString msg = FString::Printf(TEXT("Changing map to: %s"), *MapName);
753
755 break;
756 }
757 }
758
759 if (!FoundMap)
760 {
761 FString msg = FString::Printf(TEXT("Couldn't find map: %s"), *MapName);
763 }
764}
765
767{
768 UWorld* World = CurrentWorld.Get();
769 if (World)
770 {
771 UGameplayStatics::OpenLevel(World, *Path, TRAVEL_Absolute);
772 }
773}
774
776{
777 if (!SensorPtr)
778 {
779 return;
780 }
781
782 ESensorTypes type = SensorPtr->GetSensorType();
784 {
785 // If the the sensor uses CustomDepthPass to color objects, enable custom depth pass
788 }
789}
790
792{
793 if (!SensorPtr)
794 {
795 return;
796 }
797
798 ESensorTypes type = SensorPtr->GetSensorType();
800 {
803 {
804 // If there's no more sensors that need CustomDepthPass to work,
805 // disable it to save rendering performance
807 }
808 }
809}
810
812{
814 {
817 }
818 else
819 {
820 SimulatorLog::Log("Graphics settings: Ray tracing not supported on this hardware.");
821 }
822}
823
825{
826 bool RayTracingSupported = false;
827
828 // Check if the hardware supports ray tracing
829 IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing"));
830 if (CVar && CVar->GetInt() > 0 && GRHISupportsRayTracing)
831 {
832 RayTracingSupported = true;
833 }
834
835#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 3 // Check Engine version. In UE 5.4 Vulkan also supports raytracing.
836 #if PLATFORM_WINDOWS
837 {
838 // DirectX Raytracing support check
839 if (!GDynamicRHI && GDynamicRHI->GetName() == FString(TEXT("D3D12")))
840 {
841 RayTracingSupported = false;
842 }
843 }
844 #endif
845#endif
846
847 return RayTracingSupported;
848}
849
851{
852 UWorld* World = CurrentWorld.Get();
853 if (!World || !GEngine)
854 {
855 return;
856 }
857
858 GEngine->Exec(World, TEXT("r.Lumen.HardwareRayTracing 1")); // Enable lumen raytracing
859 GEngine->Exec(World, TEXT("r.RayTracing.Geometry 1")); // Enable ray tracing geometry
860 GEngine->Exec(World, TEXT("r.RayTracing.Shadows 1")); // Enable ray tracing shadows
861 GEngine->Exec(World, TEXT("r.RayTracing.Reflections 1")); // Enable ray tracing reflections
862 GEngine->Exec(World, TEXT("r.RayTracing.AmbientOcclusion 1")); // Enable ray tracing ambient occlusion
863 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination 1")); // Enable ray tracing global illumination
864 GEngine->Exec(World, TEXT("r.RayTracing.Translucency 1")); // Enable ray tracing translucency
865 GEngine->Exec(World, TEXT("r.RayTracing.SkyLight 1")); // Enable ray tracing sky light
866}
867
869{
870 UWorld* World = CurrentWorld.Get();
871 if (!World || !GEngine)
872 {
873 return;
874 }
875
876 GEngine->Exec(World, TEXT("r.Lumen.HardwareRayTracing 0"));
877 GEngine->Exec(World, TEXT("r.RayTracing.Geometry 0"));
878 GEngine->Exec(World, TEXT("r.RayTracing.Shadows 0"));
879 GEngine->Exec(World, TEXT("r.RayTracing.Reflections 0"));
880 GEngine->Exec(World, TEXT("r.RayTracing.AmbientOcclusion 0"));
881 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination 0"));
882 GEngine->Exec(World, TEXT("r.RayTracing.Translucency 0"));
883 GEngine->Exec(World, TEXT("r.RayTracing.SkyLight 0"));
884}
885
887{
888 UWorld* World = CurrentWorld.Get();
889 if (!World || !GEngine)
890 {
891 return;
892 }
893
895
896 // https://dev.epicgames.com/documentation/en-us/unreal-engine/scalability-reference-for-unreal-engine?application_version=5.3
897 GEngine->Exec(World, TEXT("sg.PostProcessQuality 3"));
898 GEngine->Exec(World, TEXT("sg.ShadowQuality 3"));
899 GEngine->Exec(World, TEXT("sg.TextureQuality 4"));
900 GEngine->Exec(World, TEXT("sg.EffectsQuality 4"));
901 GEngine->Exec(World, TEXT("sg.FoliageQuality 4"));
902
903 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.03"));
904 GEngine->Exec(World, TEXT("r.SeparateTranslucency 1"));
905 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 2"));
906 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 1"));
907 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 64"));
908 GEngine->Exec(World, TEXT("r.MaxAnisotropy 8"));
909 GEngine->Exec(World, TEXT("r.LensFlareQuality 2"));
910 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 1"));
911 GEngine->Exec(World, TEXT("r.FastBlurThreshold 7"));
912 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
913 GEngine->Exec(World, TEXT("r.ShadowQuality 5"));
914 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 1"));
915 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 2"));
916 GEngine->Exec(World, TEXT("r.DetailMode 2"));
917 GEngine->Exec(World, TEXT("foliage.DensityScale 1"));
918 GEngine->Exec(World, TEXT("grass.DensityScale 1"));
919 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
920 GEngine->Exec(World, TEXT("r.Shadow.RadiusThreshold 0.00"));
921
922 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Auto);
923}
924
926{
927 UWorld* World = CurrentWorld.Get();
928 if (!World || !GEngine)
929 {
930 return;
931 }
932
934
935 GEngine->Exec(World, TEXT("sg.PostProcessQuality 3"));
936 GEngine->Exec(World, TEXT("sg.TextureQuality 3"));
937 GEngine->Exec(World, TEXT("sg.EffectsQuality 3"));
938 GEngine->Exec(World, TEXT("sg.FoliageQuality 3"));
939
940 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.03"));
941 GEngine->Exec(World, TEXT("r.SeparateTranslucency 1"));
942 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 2"));
943 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 1"));
944 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 64"));
945 GEngine->Exec(World, TEXT("r.MaxAnisotropy 8"));
946 GEngine->Exec(World, TEXT("r.LensFlareQuality 2"));
947 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 1"));
948 GEngine->Exec(World, TEXT("r.FastBlurThreshold 7"));
949 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
950 GEngine->Exec(World, TEXT("r.ShadowQuality 3"));
951 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 1"));
952 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 2"));
953 GEngine->Exec(World, TEXT("r.DetailMode 2"));
954 GEngine->Exec(World, TEXT("r.BloomQuality 4"));
955 GEngine->Exec(World, TEXT("foliage.DensityScale 1"));
956 GEngine->Exec(World, TEXT("grass.DensityScale 1"));
957 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
958 GEngine->Exec(World, TEXT("r.Shadow.RadiusThreshold 0.01"));
959
960 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
961}
962
964{
965 UWorld* World = CurrentWorld.Get();
966 if (!World || !GEngine)
967 {
968 return;
969 }
970
972
973 GEngine->Exec(World, TEXT("sg.PostProcessQuality 0"));
974 GEngine->Exec(World, TEXT("sg.ShadowQuality 0"));
975 GEngine->Exec(World, TEXT("sg.TextureQuality 0"));
976 GEngine->Exec(World, TEXT("sg.EffectsQuality 0"));
977 GEngine->Exec(World, TEXT("sg.FoliageQuality 0"));
978
979 GEngine->Exec(World, TEXT("r.DefaultFeature.MotionBlur 0"));
980 GEngine->Exec(World, TEXT("r.DefaultFeature.Bloom 0"));
981 GEngine->Exec(World, TEXT("r.DefaultFeature.AmbientOcclusion 0"));
982 GEngine->Exec(World, TEXT("r.DefaultFeature.AmbientOcclusionStaticFraction 0"));
983 GEngine->Exec(World, TEXT("r.HZBOcclusion 0"));
984 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.01"));
985 GEngine->Exec(World, TEXT("r.SeparateTranslucency 0"));
986 GEngine->Exec(World, TEXT("r.FinishCurrentFrame 0"));
987 GEngine->Exec(World, TEXT("r.MotionBlurQuality 0"));
988 GEngine->Exec(World, TEXT("r.BloomQuality 1"));
989 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 0"));
990 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 0"));
991 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 4"));
992 GEngine->Exec(World, TEXT("r.MaxAnisotropy 4"));
993 GEngine->Exec(World, TEXT("r.LensFlareQuality 0"));
994 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 0"));
995 GEngine->Exec(World, TEXT("r.FastBlurThreshold 0"));
996 GEngine->Exec(World, TEXT("r.SSR 0"));
997 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
998 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 0"));
999 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 4"));
1000 GEngine->Exec(World, TEXT("r.OcclusionQueryLocation 1"));
1001 GEngine->Exec(World, TEXT("foliage.DensityScale 0"));
1002 GEngine->Exec(World, TEXT("grass.DensityScale 0"));
1003 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
1004
1005 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
1006}
EAntiAliasing
Definition: AntiAliasing.h:15
EQualityLevel
Definition: QualityLevel.h:16
ESensorTypes
Definition: SensorTypes.h:15
@ SemanticSegmentationCamera
void SetInstancedRendering(bool ShouldRender)
Definition: Sensor.h:44
virtual ESensorTypes GetSensorType() const
Definition: Sensor.h:64
void SetMaxSpeed(float MaxSpeed=1500.0f)
Definition: Spectator.cpp:195
bool IsNiagaraComponentVisible()
Definition: Spectator.h:100
float GetMaxSpeed()
Definition: Spectator.cpp:204
void SetNiagaraComponentVisibility(bool Visible)
Definition: Spectator.cpp:187
static void Log(const FString &Message, bool LogToTextFile=true, bool LogToROS=true)
void ApplySettings(bool bCheckForCommandLineOverrides) override
EAntiAliasing GetAntiAliasingMethod() const
void OnSensorSpawned(ASensor *SensorPtr)
void SetStartWindowInitiallyMinimized(bool Minimized)
void SetQualityLevelFromString(const FString &QualityLevelString)
EShadowCacheInvalidationBehavior GetShadowCacheInvalidationBehavior() const
void SetSpectatorMaxSpeed(float MaxSpeed)
bool GetIsUsingVirtualShadowMaps() const
int32 GetWorldPositionOffsetRenderDistance() const
void SetShowSpectatorRainAndSnowfall(bool Show)
bool GetStartWindowInitiallyMinimized() const
FDelegateHandle AdvanceFramesHandle
FDelegateHandle EndOfFrameHandle
void SetSimulationSettings(FGlobalSimulationSettings NewSettings)
void AdvanceTime(float TimeToAdvance)
void ChangeMapByName(FString MapName)
void AdvanceFrameCount(int32 FramesToAdvance)
FGraphicsSettingsDelegate OnGraphicsSettingsChanged
void SetAntiAliasingMethod(EAntiAliasing AntiAliasingMethod)
int GetGlobalTargetFrameRate() const
const TArray< FString > MapPaths
void SetInstancedRenderingVisibility(bool Visible)
virtual void PostInitProperties() override
float GetGlobalTimeDilation() const
void SetShadowCSMCache(bool CacheShadowCSM)
void SetAntiAliasingMethodFromString(const FString &AntiAliasingMethodString)
FGlobalSimulationSettings SimulationSettings
void SetUseVirtualShadowMaps(bool UseVirtualShadowMaps)
void SetGraphicsSettings(FGlobalGraphicsSettings NewSettings)
TWeakObjectPtr< UWorld > CurrentWorld
void LoadSettings(bool bForceReload=false) override
void SetQualityLevel(EQualityLevel newQualityLevel)
void Setup(UWorld *World)
int32 GetNumberOfWorkerThreads() const
float GetNaniteMaxPixelsPerEdge() const
void SetGlobalTimeDilation(float TimeDilation)
static FString CurrentMapName
void SetWindowMode(EWindowMode::Type WindowType)
void SetGlobalTargetFrameRate(int NewTargetFrameRate)
void SetRenderCustomDepthPass(bool RenderCustomDepthPass)
bool GetIsRenderingCustomDepthPass() const
void OnSensorDestroyed(ASensor *SensorPtr)
void SetGrassVisibility(bool Visible)
void SetShadowCacheInvalidationBehaviorFromString(const FString &BehaviourString)
void SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior Behaviour=EShadowCacheInvalidationBehavior::Rigid)
void ChangeMapByMapPath(const FString &Path)
FString GetConsoleVariableValueString(const FString &VariableName) const
static UAgrarsenseSettings * GetAgrarsenseSettings()
void SetWorldPositionOffsetRenderDistance(int32 WorldPositionOffsetDistance)
FGlobalGraphicsSettings GraphicsSettings
const TArray< FString > MapNames
void SetWorldRendering(bool enabled)
void SetNaniteMaxPixelsPerEdge(float MaxPixelsPerEdge=1.0f)
bool IsRaytracingSupported() const
static ASpectator * GetSpectator(const UObject *WorldContextObject)
static AInstancedRenderer * GetInstancedRenderer(const UObject *WorldContextObject)
static FString ConvertQualityLevelToString(EQualityLevel QualityLevel)
static EQualityLevel ConvertStringToQualityLevel(const FString &String)
static EAntiAliasing ConvertStringToAntiAliasingMethod(const FString &String)
static USensorManager * Get()
FSensorDestroyedDelegate OnSensorDestroyed
Definition: SensorManager.h:68
FSensorSpawnedDelegate OnSensorSpawned
Definition: SensorManager.h:61
EShadowCacheInvalidationBehavior FoliageShadowCacheInvalidationBehaviour