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
86 if (Manager)
87 {
88 Manager->OnSensorSpawned.AddUniqueDynamic(this, &UAgrarsenseSettings::OnSensorSpawned);
89 Manager->OnSensorDestroyed.AddUniqueDynamic(this, &UAgrarsenseSettings::OnSensorDestroyed);
90 }
91 else
92 {
93 // Else failed to get SensorManager and listen Sensor spawning, always render custom depth
94 RenderCustomDepth = true;
95 }
96
97#if UE_BUILD_SHIPPING
98 // In Shipping mode check for Fullscreen and WindowedFullscreen launch args,
99 // Otherwise set window to windowed by default.
100 if (FParse::Param(FCommandLine::Get(), TEXT("Fullscreen")))
101 {
102 SetWindowMode(EWindowMode::Type::Fullscreen);
103 }
104 else if (FParse::Param(FCommandLine::Get(), TEXT("WindowedFullscreen")))
105 {
106 SetWindowMode(EWindowMode::Type::WindowedFullscreen);
107 }
108 else
109 {
110 SetWindowMode(EWindowMode::Type::Windowed);
111 }
112#endif
113}
114
116{
117 Super::PostInitProperties();
118
119#if UE_BUILD_SHIPPING || UE_BUILD_DEVELOPMENT
121 {
122 SaveConfig();
123 }
124#endif
125}
126
128{
129 return Cast<UAgrarsenseSettings>(UGameUserSettings::GetGameUserSettings());
130}
131
133{
134 Super::LoadSettings(bForceReload);
135}
136
137void UAgrarsenseSettings::ApplySettings(bool bCheckForCommandLineOverrides)
138{
139 Super::ApplySettings(bCheckForCommandLineOverrides);
140
143}
144
146{
147 bool SettingsWereChanged = false;
148
149 // Check -map= launch argument
150 FString AntiAliasingString;
151 if (FParse::Value(FCommandLine::Get(), TEXT("-antialiasing="), AntiAliasingString))
152 {
153 // Convert incoming string to int and then EAntiAliasing enum
154 int32 AntiAliasingInt;
155 if (AntiAliasingString.IsNumeric())
156 {
157 AntiAliasingInt = FCString::Atoi(*AntiAliasingString);
158 EAntiAliasing NewAntiAliasingMethod = static_cast<EAntiAliasing>(AntiAliasingInt);
159 GraphicsSettings.AntiAliasingMethod = NewAntiAliasingMethod;
160 SettingsWereChanged = true;
161 }
162 }
163
164 // Check -no-world-rendering launch argument
165 if (FParse::Param(FCommandLine::Get(), TEXT("-no-spectator-rendering")))
166 {
168 SettingsWereChanged = true;
169 }
170
171 // Check -start-camerawindows-minimized launch argument
172 if (FParse::Param(FCommandLine::Get(), TEXT("-start-camerawindows-minimized")))
173 {
175 SettingsWereChanged = true;
176 }
177
178 // Check -quality-level= launch argument
179 FString QualityLevelString;
180 if (FParse::Value(FCommandLine::Get(), TEXT("-quality-level="), QualityLevelString))
181 {
183 SettingsWereChanged = true;
184 }
185
186 return SettingsWereChanged;
187}
188
190{
191 return FPlatformMisc::NumberOfWorkerThreadsToSpawn();
192}
193
194FString UAgrarsenseSettings::GetConsoleVariableValueString(const FString& VariableName) const
195{
196 IConsoleVariable* ConsoleVariable = IConsoleManager::Get().FindConsoleVariable(*VariableName);
197 if (ConsoleVariable)
198 {
199 FString VariableValue = ConsoleVariable->GetString();
200 return VariableValue;
201 }
202 else
203 {
204 return FString();
205 }
206}
207
209{
210 GraphicsSettings = NewSettings;
211
218}
219
220void UAgrarsenseSettings::SetWindowMode(EWindowMode::Type WindowType)
221{
222 if (GEngine)
223 {
224 UGameUserSettings* UserSettings = GEngine->GetGameUserSettings();
225 if (UserSettings)
226 {
227 UserSettings->SetFullscreenMode(WindowType);
228 UserSettings->ApplySettings(false);
229 }
230 }
231}
232
234{
235 SimulationSettings = NewSettings;
236
241}
242
244{
246}
247
249{
250 if (GraphicsSettings.RenderGrass == Visible)
251 {
252 return;
253 }
254
255 UWorld* World = CurrentWorld.Get();
256
257 if (!GEngine || !World)
258 {
259 return;
260 }
261
263
265 {
266 GEngine->Exec(World, TEXT("grass.enable 0"));
267 GEngine->Exec(World, TEXT("grass.FlushCache"));
268 }
269 else
270 {
271 GEngine->Exec(World, TEXT("grass.enable 1"));
272 }
273
275}
276
278{
280}
281
283{
284 if (GraphicsSettings.ShadowCSMCaching == CacheShadowCSM)
285 {
286 return;
287 }
288
289 UWorld* World = CurrentWorld.Get();
290 if (GEngine && World)
291 {
292 GraphicsSettings.ShadowCSMCaching = CacheShadowCSM;
293
295 {
296 GEngine->Exec(World, TEXT("r.Shadow.CSMCaching 1"));
297 }
298 else
299 {
300 GEngine->Exec(World, TEXT("r.Shadow.CSMCaching 0"));
301 }
302
304 }
305}
306
308{
309 UWorld* World = CurrentWorld.Get();
310
311 if (World)
312 {
314 if (InstanceRenderer)
315 {
316 InstanceRenderer->SetInstancedRendering(Visible);
317 }
318 }
319}
320
322{
323 GraphicsSettings.WorldPositionOffsetDistance = WorldPositionOffsetDistance;
325}
326
328{
329 UWorld* World = CurrentWorld.Get();
330 if (GEngine && World)
331 {
332 MaxPixelsPerEdge = FMath::Clamp(MaxPixelsPerEdge, 0.1f, 10.0f);
333
334 FString Command = FString::Printf(TEXT("r.Nanite.MaxPixelsPerEdge %f"), MaxPixelsPerEdge);
335 GEngine->Exec(World, *Command);
336
337 GraphicsSettings.NaniteMaxPixelsPerEdge = MaxPixelsPerEdge;
339 }
340}
341
342void UAgrarsenseSettings::SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior Behaviour)
343{
345 {
348 }
349}
350
352{
353 FString BehaviourStringToLower = BehaviourString.ToLower();
354
355 if (BehaviourStringToLower == "auto")
356 {
357 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Auto);
358 }
359 else if (BehaviourStringToLower == "rigid")
360 {
361 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
362 }
363 else if (BehaviourStringToLower == "always")
364 {
365 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Always);
366 }
367 else if (BehaviourStringToLower == "static")
368 {
369 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Static);
370 }
371}
372
374{
376}
377
379{
381}
382
383EShadowCacheInvalidationBehavior UAgrarsenseSettings::GetShadowCacheInvalidationBehavior() const
384{
386}
387
389{
391}
392
394{
396}
397
398void UAgrarsenseSettings::SetRenderCustomDepthPass(bool RenderCustomDepthPass)
399{
400 UWorld* World = CurrentWorld.Get();
401 if (GEngine || World)
402 {
403 RenderCustomDepth = RenderCustomDepthPass;
404 if (RenderCustomDepthPass)
405 {
406 GEngine->Exec(World, TEXT("r.CustomDepth 3"));
407 }
408 else
409 {
410 GEngine->Exec(World, TEXT("r.CustomDepth 0"));
411 }
412 }
413}
414
415void UAgrarsenseSettings::SetUseVirtualShadowMaps(bool UseVirtualShadowMaps)
416{
417 UWorld* World = CurrentWorld.Get();
418 if (GEngine || World)
419 {
420 GraphicsSettings.UseVirtualShadowMaps = UseVirtualShadowMaps;
421
423 {
424 GEngine->Exec(World, TEXT("r.Shadow.Virtual.Enable 1"));
425 }
426 else
427 {
428 GEngine->Exec(World, TEXT("r.Shadow.Virtual.Enable 0"));
429 }
430
432 }
433}
434
436{
438}
439
441{
442 return RenderCustomDepth;
443}
444
446{
448}
449
451{
452
453 UWorld* World = CurrentWorld.Get();
454
455 if (!GEngine || !World)
456 {
457 return;
458 }
459
460 GraphicsSettings.AntiAliasingMethod = AntiAliasingMethod;
461
462 FString ExecCommand;
463 switch (AntiAliasingMethod)
464 {
466 ExecCommand = TEXT("r.AntiAliasingMethod 0");
467 break;
468
470 ExecCommand = TEXT("r.AntiAliasingMethod 1");
471 break;
472
474 ExecCommand = TEXT("r.AntiAliasingMethod 2");
475 break;
476
477 // MSAA ("r.AntiAliasingMethod 3) is not supported on Deferred rendering
478
480 ExecCommand = TEXT("r.AntiAliasingMethod 4");
481 break;
482
483 default:
484 return;
485 }
486
487 GEngine->Exec(World, *ExecCommand);
488
490}
491
492void UAgrarsenseSettings::SetAntiAliasingMethodFromString(const FString& AntiAliasingMethodString)
493{
494 EAntiAliasing NewMethod = UEnumUtilities::ConvertStringToAntiAliasingMethod(AntiAliasingMethodString);
495 SetAntiAliasingMethod(NewMethod);
496}
497
499{
500 if (GEngine && GEngine->GameViewport)
501 {
502 GEngine->GameViewport->bDisableWorldRendering = !enabled;
504
505 FString msg = FString::Printf(TEXT("World rendering: %s"), enabled ? TEXT("On") : TEXT("Off"));
507
509 }
510}
511
513{
514 GraphicsSettings.QualityLevel = newQualityLevel;
515
517 {
520 break;
521
524 break;
525
528 break;
529
532 break;
533 }
534
536 FString Msg = FString::Printf(TEXT("Graphics settings: %s"), *QualityLevelString);
538
540}
541
542void UAgrarsenseSettings::SetQualityLevelFromString(const FString& QualityLevelString)
543{
545}
546
548{
549 return GetFrameRateLimit();
550}
551
553{
554 SetFrameRateLimit(NewTargetFrameRate);
555 ApplySettings(false);
556}
557
559{
560 UWorld* World = CurrentWorld.Get();
561
562 if (!World)
563 {
565 }
566
567 return UGameplayStatics::GetGlobalTimeDilation(World);
568}
569
571{
572 UWorld* World = CurrentWorld.Get();
573 if (!World)
574 {
575 return;
576 }
577
578 SimulationSettings.TimeDilation = TimeDilation;
579 UGameplayStatics::SetGlobalTimeDilation(World, TimeDilation);
580
581 FString msg = FString::Printf(TEXT("Global time dilation: %f"), TimeDilation);
583}
584
586{
587 UWorld* World = CurrentWorld.Get();
588 if (!World)
589 {
590 return;
591 }
592
594 if (IsValid(Spectator))
595 {
596 Spectator->SetMaxSpeed(MaxSpeed);
598 }
599}
600
602{
603 UWorld* World = CurrentWorld.Get();
604 if (!World)
605 {
606 return;
607 }
608
610
611 if (IsValid(Spectator))
612 {
613 Spectator->SetNiagaraComponentVisibility(Show);
615 }
616}
617
619{
620 UWorld* World = CurrentWorld.Get();
622 {
623 UGameplayStatics::SetGlobalTimeDilation(World, 0.0f);
624 UGameplayStatics::SetGamePaused(World, true);
626
627 SimulatorLog::Log("Simulator paused");
628 }
629}
630
632{
633 UWorld* World = CurrentWorld.Get();
635 {
636 UGameplayStatics::SetGlobalTimeDilation(World, SimulationSettings.TimeDilation);
637 UGameplayStatics::SetGamePaused(World, false);
639
640 SimulatorLog::Log("Simulator unpaused");
641 }
642}
643
645{
647 {
648 return;
649 }
650
651 // Subscribe to Unreal Engine end of frame callback
652 EndOfFrameHandle = FCoreDelegates::OnEndFrame.AddLambda([this]()
653 {
654 // After receiving the event, unsubcribe from the event and pause the simulation.
655 if (IsValid(this))
656 {
657 if (EndOfFrameHandle.IsValid())
658 {
659 FCoreDelegates::OnEndFrame.Remove(EndOfFrameHandle);
660 EndOfFrameHandle.Reset();
661 }
662
664 }
665 });
666}
667
668void UAgrarsenseSettings::AdvanceFrameCount(int32 FramesToAdvance)
669{
670 if (FramesToAdvance == 0)
671 {
672 return;
673 }
674
675 if (AdvanceFramesHandle.IsValid())
676 {
677 // Already running this, return
678 return;
679 }
680
681 if (EndOfFrameHandle.IsValid())
682 {
683 // If PauseSimulationEndOfThisFrame was called, unsubribe
684 FCoreDelegates::OnEndFrame.Remove(EndOfFrameHandle);
685 EndOfFrameHandle.Reset();
686 }
687
688 // Unpause simulation now
690
691 FrameCount = 0;
692
693 // Subscribe to Unreal Engine end of frame callback
694 AdvanceFramesHandle = FCoreDelegates::OnEndFrame.AddLambda([this, FramesToAdvance]()
695 {
696 ++FrameCount;
697 if (FrameCount == FramesToAdvance)
698 {
699 // After given number of frames,
700 // unsubscribe from the event and pause simulation again at the end of that frame
701 if (IsValid(this))
702 {
703 FCoreDelegates::OnEndFrame.Remove(AdvanceFramesHandle);
704 AdvanceFramesHandle.Reset();
705 FrameCount = 0;
706
708 }
709 }
710 });
711}
712
713void UAgrarsenseSettings::AdvanceTime(float TimeToAdvance)
714{
715 UWorld* World = CurrentWorld.Get();
716 if (!World)
717 {
718 return;
719 }
720
721 // Unpause simulation now
723
724 // Pause simulation again after TimeToAdvance
725 FTimerHandle AdvanceTimeTimer;
726 World->GetTimerManager().SetTimer(AdvanceTimeTimer, FTimerDelegate::CreateLambda([this]
727 {
728 if (IsValid(this))
729 {
731 }
732
733 }), TimeToAdvance, false);
734}
735
737{
738 // Make the map name to lower
739 // This is because ROSCommands.cpp uses this and all the messages are in lower case.
740 MapName = MapName.ToLower();
741
742 bool FoundMap = false;
743 for (int32 i = 0; i < MapNames.Num(); i++)
744 {
745 if (MapName == MapNames[i])
746 {
747 FoundMap = true;
748 FString msg = FString::Printf(TEXT("Changing map to: %s"), *MapName);
750
752 break;
753 }
754 }
755
756 if (!FoundMap)
757 {
758 FString msg = FString::Printf(TEXT("Couldn't find map: %s"), *MapName);
760 }
761}
762
764{
765 UWorld* World = CurrentWorld.Get();
766 if (World)
767 {
768 UGameplayStatics::OpenLevel(World, *Path, TRAVEL_Absolute);
769 }
770}
771
773{
774 if (!SensorPtr)
775 {
776 return;
777 }
778
779 ESensorTypes type = SensorPtr->GetSensorType();
781 {
782 // If the the sensor uses CustomDepthPass to color objects, enable custom depth pass
785 }
786}
787
789{
790 if (!SensorPtr)
791 {
792 return;
793 }
794
795 ESensorTypes type = SensorPtr->GetSensorType();
797 {
800 {
801 // If there's no more sensors that need CustomDepthPass to work,
802 // disable it to save rendering performance
804 }
805 }
806}
807
809{
811 {
814 }
815 else
816 {
817 SimulatorLog::Log("Graphics settings: Ray tracing not supported on this hardware.");
818 }
819}
820
822{
823 bool RayTracingSupported = false;
824
825 // Check if the hardware supports ray tracing
826 IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing"));
827 if (CVar && CVar->GetInt() > 0 && GRHISupportsRayTracing)
828 {
829 RayTracingSupported = true;
830 }
831
832#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 3 // Check Engine version. In UE 5.4 Vulkan also supports raytracing.
833 #if PLATFORM_WINDOWS
834 {
835 // DirectX Raytracing support check
836 if (!GDynamicRHI && GDynamicRHI->GetName() == FString(TEXT("D3D12")))
837 {
838 RayTracingSupported = false;
839 }
840 }
841 #endif
842#endif
843
844 return RayTracingSupported;
845}
846
848{
849 UWorld* World = CurrentWorld.Get();
850 if (!World || !GEngine)
851 {
852 return;
853 }
854
855 GEngine->Exec(World, TEXT("r.Lumen.HardwareRayTracing 1")); // Enable lumen raytracing
856 GEngine->Exec(World, TEXT("r.RayTracing.Geometry 1")); // Enable ray tracing geometry
857 GEngine->Exec(World, TEXT("r.RayTracing.Shadows 1")); // Enable ray tracing shadows
858 GEngine->Exec(World, TEXT("r.RayTracing.Reflections 1")); // Enable ray tracing reflections
859 GEngine->Exec(World, TEXT("r.RayTracing.AmbientOcclusion 1")); // Enable ray tracing ambient occlusion
860 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination 1")); // Enable ray tracing global illumination
861 GEngine->Exec(World, TEXT("r.RayTracing.Translucency 1")); // Enable ray tracing translucency
862 GEngine->Exec(World, TEXT("r.RayTracing.SkyLight 1")); // Enable ray tracing sky light
863}
864
866{
867 UWorld* World = CurrentWorld.Get();
868 if (!World || !GEngine)
869 {
870 return;
871 }
872
873 GEngine->Exec(World, TEXT("r.Lumen.HardwareRayTracing 0"));
874 GEngine->Exec(World, TEXT("r.RayTracing.Geometry 0"));
875 GEngine->Exec(World, TEXT("r.RayTracing.Shadows 0"));
876 GEngine->Exec(World, TEXT("r.RayTracing.Reflections 0"));
877 GEngine->Exec(World, TEXT("r.RayTracing.AmbientOcclusion 0"));
878 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination 0"));
879 GEngine->Exec(World, TEXT("r.RayTracing.Translucency 0"));
880 GEngine->Exec(World, TEXT("r.RayTracing.SkyLight 0"));
881}
882
884{
885 UWorld* World = CurrentWorld.Get();
886 if (!World || !GEngine)
887 {
888 return;
889 }
890
892
893 // https://dev.epicgames.com/documentation/en-us/unreal-engine/scalability-reference-for-unreal-engine?application_version=5.3
894 GEngine->Exec(World, TEXT("sg.PostProcessQuality 3"));
895 GEngine->Exec(World, TEXT("sg.ShadowQuality 3"));
896 GEngine->Exec(World, TEXT("sg.TextureQuality 4"));
897 GEngine->Exec(World, TEXT("sg.EffectsQuality 4"));
898 GEngine->Exec(World, TEXT("sg.FoliageQuality 4"));
899
900 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.03"));
901 GEngine->Exec(World, TEXT("r.SeparateTranslucency 1"));
902 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 2"));
903 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 1"));
904 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 64"));
905 GEngine->Exec(World, TEXT("r.MaxAnisotropy 8"));
906 GEngine->Exec(World, TEXT("r.LensFlareQuality 2"));
907 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 1"));
908 GEngine->Exec(World, TEXT("r.FastBlurThreshold 7"));
909 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
910 GEngine->Exec(World, TEXT("r.ShadowQuality 5"));
911 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 1"));
912 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 2"));
913 GEngine->Exec(World, TEXT("r.DetailMode 2"));
914 GEngine->Exec(World, TEXT("foliage.DensityScale 1"));
915 GEngine->Exec(World, TEXT("grass.DensityScale 1"));
916 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
917 GEngine->Exec(World, TEXT("r.Shadow.RadiusThreshold 0.00"));
918
919 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Auto);
920}
921
923{
924 UWorld* World = CurrentWorld.Get();
925 if (!World || !GEngine)
926 {
927 return;
928 }
929
931
932 GEngine->Exec(World, TEXT("sg.PostProcessQuality 3"));
933 GEngine->Exec(World, TEXT("sg.TextureQuality 3"));
934 GEngine->Exec(World, TEXT("sg.EffectsQuality 3"));
935 GEngine->Exec(World, TEXT("sg.FoliageQuality 3"));
936
937 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.03"));
938 GEngine->Exec(World, TEXT("r.SeparateTranslucency 1"));
939 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 2"));
940 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 1"));
941 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 64"));
942 GEngine->Exec(World, TEXT("r.MaxAnisotropy 8"));
943 GEngine->Exec(World, TEXT("r.LensFlareQuality 2"));
944 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 1"));
945 GEngine->Exec(World, TEXT("r.FastBlurThreshold 7"));
946 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
947 GEngine->Exec(World, TEXT("r.ShadowQuality 3"));
948 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 1"));
949 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 2"));
950 GEngine->Exec(World, TEXT("r.DetailMode 2"));
951 GEngine->Exec(World, TEXT("r.BloomQuality 4"));
952 GEngine->Exec(World, TEXT("foliage.DensityScale 1"));
953 GEngine->Exec(World, TEXT("grass.DensityScale 1"));
954 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
955 GEngine->Exec(World, TEXT("r.Shadow.RadiusThreshold 0.01"));
956
957 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
958}
959
961{
962 UWorld* World = CurrentWorld.Get();
963 if (!World || !GEngine)
964 {
965 return;
966 }
967
969
970 GEngine->Exec(World, TEXT("sg.PostProcessQuality 0"));
971 GEngine->Exec(World, TEXT("sg.ShadowQuality 0"));
972 GEngine->Exec(World, TEXT("sg.TextureQuality 0"));
973 GEngine->Exec(World, TEXT("sg.EffectsQuality 0"));
974 GEngine->Exec(World, TEXT("sg.FoliageQuality 0"));
975
976 GEngine->Exec(World, TEXT("r.DefaultFeature.MotionBlur 0"));
977 GEngine->Exec(World, TEXT("r.DefaultFeature.Bloom 0"));
978 GEngine->Exec(World, TEXT("r.DefaultFeature.AmbientOcclusion 0"));
979 GEngine->Exec(World, TEXT("r.DefaultFeature.AmbientOcclusionStaticFraction 0"));
980 GEngine->Exec(World, TEXT("r.HZBOcclusion 0"));
981 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.01"));
982 GEngine->Exec(World, TEXT("r.SeparateTranslucency 0"));
983 GEngine->Exec(World, TEXT("r.FinishCurrentFrame 0"));
984 GEngine->Exec(World, TEXT("r.MotionBlurQuality 0"));
985 GEngine->Exec(World, TEXT("r.BloomQuality 1"));
986 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 0"));
987 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 0"));
988 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 4"));
989 GEngine->Exec(World, TEXT("r.MaxAnisotropy 4"));
990 GEngine->Exec(World, TEXT("r.LensFlareQuality 0"));
991 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 0"));
992 GEngine->Exec(World, TEXT("r.FastBlurThreshold 0"));
993 GEngine->Exec(World, TEXT("r.SSR 0"));
994 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
995 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 0"));
996 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 4"));
997 GEngine->Exec(World, TEXT("r.OcclusionQueryLocation 1"));
998 GEngine->Exec(World, TEXT("foliage.DensityScale 0"));
999 GEngine->Exec(World, TEXT("grass.DensityScale 0"));
1000 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
1001
1002 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
1003}
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:191
bool IsNiagaraComponentVisible()
Definition: Spectator.h:93
float GetMaxSpeed()
Definition: Spectator.cpp:200
void SetNiagaraComponentVisibility(bool Visible)
Definition: Spectator.cpp:183
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:58
FSensorSpawnedDelegate OnSensorSpawned
Definition: SensorManager.h:51
EShadowCacheInvalidationBehavior FoliageShadowCacheInvalidationBehaviour