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/Parse.h"
23#include "Misc/App.h"
24#include "Engine/Engine.h"
25#include "Engine/GameViewportClient.h"
26#include "UObject/ObjectPtr.h"
27#include "LandscapeSubsystem.h"
28#include "Engine/World.h"
29#include "Engine/GameInstance.h"
30#include "TimerManager.h"
31
32#include "RHI.h"
33#include "RHIDefinitions.h"
34
37
39{
40}
41
42void UAgrarsenseSettings::Setup(UWorld* World)
43{
44#if WITH_EDITOR
45 // In case the simulator was shutdown when it was paused,
46 // reset this static variable
48#endif
49
50 CurrentWorld = World;
51
52 UWorld* GameWorld = CurrentWorld.Get();
53
54 CurrentMapName = GameWorld->GetMapName().ToLower();
55 IsMainMenu = CurrentMapName.Contains("mainmenu");
56
57 if (GameWorld)
58 {
59 // Prioritize grass creation
60 // This allows turning grass on faster if it was turned off.
61 ULandscapeSubsystem* LandscapeSubsystem = CurrentWorld->GetSubsystem<ULandscapeSubsystem>();
62 if (LandscapeSubsystem)
63 {
64 LandscapeSubsystem->PrioritizeGrassCreation(true);
65 }
66 }
67
68 // Apply Graphics and Simulation settings when Simulator is started
69 ApplySettings(true);
70
71 // Apply few console commands. One time setup.
72 if (GEngine && World)
73 {
74 GEngine->Exec(World, TEXT("g.TimeoutForBlockOnRenderFence 600000"));
75 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0"));
76 GEngine->Exec(World, TEXT("r.CustomDepth 0"));
77
78 // Disable application starting to throttle performance if Window loses focus
79 GEngine->Exec(World, TEXT("t.IdleWhenNotForeground 0"));
80 }
81
83 if (Manager)
84 {
85 Manager->OnSensorSpawned.AddUniqueDynamic(this, &UAgrarsenseSettings::OnSensorSpawned);
86 Manager->OnSensorDestroyed.AddUniqueDynamic(this, &UAgrarsenseSettings::OnSensorDestroyed);
87 }
88 else
89 {
90 // Else failed to get SensorManager and listen Sensor spawning, always render custom depth
91 RenderCustomDepth = true;
92 }
93
94#if UE_BUILD_SHIPPING
95 // In Shipping mode check for Fullscreen and WindowedFullscreen launch args,
96 // Otherwise set window to windowed by default.
97 if (FParse::Param(FCommandLine::Get(), TEXT("Fullscreen")))
98 {
99 SetWindowMode(EWindowMode::Type::Fullscreen);
100 }
101 else if (FParse::Param(FCommandLine::Get(), TEXT("WindowedFullscreen")))
102 {
103 SetWindowMode(EWindowMode::Type::WindowedFullscreen);
104 }
105 else
106 {
107 SetWindowMode(EWindowMode::Type::Windowed);
108 }
109#endif
110}
111
113{
114 Super::PostInitProperties();
115
116#if UE_BUILD_SHIPPING || UE_BUILD_DEVELOPMENT
118 {
119 SaveConfig();
120 }
121#endif
122}
123
125{
126 return Cast<UAgrarsenseSettings>(UGameUserSettings::GetGameUserSettings());
127}
128
130{
131 Super::LoadSettings(bForceReload);
132}
133
134void UAgrarsenseSettings::ApplySettings(bool bCheckForCommandLineOverrides)
135{
136 Super::ApplySettings(bCheckForCommandLineOverrides);
137
140}
141
143{
144 bool SettingsWereChanged = false;
145
146 // Check -map= launch argument
147 FString AntiAliasingString;
148 if (FParse::Value(FCommandLine::Get(), TEXT("-antialiasing="), AntiAliasingString))
149 {
150 // Convert incoming string to int and then EAntiAliasing enum
151 int32 AntiAliasingInt;
152 if (AntiAliasingString.IsNumeric())
153 {
154 AntiAliasingInt = FCString::Atoi(*AntiAliasingString);
155 EAntiAliasing NewAntiAliasingMethod = static_cast<EAntiAliasing>(AntiAliasingInt);
156 GraphicsSettings.AntiAliasingMethod = NewAntiAliasingMethod;
157 SettingsWereChanged = true;
158 }
159 }
160
161 // Check -no-world-rendering launch argument
162 if (FParse::Param(FCommandLine::Get(), TEXT("-no-spectator-rendering")))
163 {
165 SettingsWereChanged = true;
166 }
167
168 // Check -start-camerawindows-minimized launch argument
169 if (FParse::Param(FCommandLine::Get(), TEXT("-start-camerawindows-minimized")))
170 {
172 SettingsWereChanged = true;
173 }
174
175 // Check -quality-level= launch argument
176 FString QualityLevelString;
177 if (FParse::Value(FCommandLine::Get(), TEXT("-quality-level="), QualityLevelString))
178 {
180 SettingsWereChanged = true;
181 }
182
183 return SettingsWereChanged;
184}
185
187{
188 return FPlatformMisc::NumberOfWorkerThreadsToSpawn();
189}
190
191FString UAgrarsenseSettings::GetConsoleVariableValueString(const FString& VariableName) const
192{
193 IConsoleVariable* ConsoleVariable = IConsoleManager::Get().FindConsoleVariable(*VariableName);
194 if (ConsoleVariable)
195 {
196 FString VariableValue = ConsoleVariable->GetString();
197 return VariableValue;
198 }
199 else
200 {
201 return FString();
202 }
203}
204
206{
207 GraphicsSettings = NewSettings;
208
215}
216
217void UAgrarsenseSettings::SetWindowMode(EWindowMode::Type WindowType)
218{
219 if (GEngine)
220 {
221 UGameUserSettings* UserSettings = GEngine->GetGameUserSettings();
222 if (UserSettings)
223 {
224 UserSettings->SetFullscreenMode(WindowType);
225 UserSettings->ApplySettings(false);
226 }
227 }
228}
229
231{
232 SimulationSettings = NewSettings;
233
238}
239
241{
243}
244
246{
247 if (GraphicsSettings.RenderGrass == Visible)
248 {
249 return;
250 }
251
252 UWorld* World = CurrentWorld.Get();
253
254 if (!GEngine || !World)
255 {
256 return;
257 }
258
260
262 {
263 GEngine->Exec(World, TEXT("grass.enable 0"));
264 GEngine->Exec(World, TEXT("grass.FlushCache"));
265 }
266 else
267 {
268 GEngine->Exec(World, TEXT("grass.enable 1"));
269 }
270
272}
273
275{
277}
278
280{
281 if (GraphicsSettings.ShadowCSMCaching == CacheShadowCSM)
282 {
283 return;
284 }
285
286 UWorld* World = CurrentWorld.Get();
287 if (GEngine && World)
288 {
289 GraphicsSettings.ShadowCSMCaching = CacheShadowCSM;
290
292 {
293 GEngine->Exec(World, TEXT("r.Shadow.CSMCaching 1"));
294 }
295 else
296 {
297 GEngine->Exec(World, TEXT("r.Shadow.CSMCaching 0"));
298 }
299
301 }
302}
303
305{
306 UWorld* World = CurrentWorld.Get();
307
308 if (World)
309 {
311 if (InstanceRenderer)
312 {
313 InstanceRenderer->SetInstancedRendering(Visible);
314 }
315 }
316}
317
319{
320 GraphicsSettings.WorldPositionOffsetDistance = WorldPositionOffsetDistance;
322}
323
325{
326 UWorld* World = CurrentWorld.Get();
327 if (GEngine && World)
328 {
329 MaxPixelsPerEdge = FMath::Clamp(MaxPixelsPerEdge, 0.1f, 10.0f);
330
331 FString Command = FString::Printf(TEXT("r.Nanite.MaxPixelsPerEdge %f"), MaxPixelsPerEdge);
332 GEngine->Exec(World, *Command);
333
334 GraphicsSettings.NaniteMaxPixelsPerEdge = MaxPixelsPerEdge;
336 }
337}
338
339void UAgrarsenseSettings::SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior Behaviour)
340{
342 {
345 }
346}
347
349{
350 FString BehaviourStringToLower = BehaviourString.ToLower();
351
352 if (BehaviourStringToLower == "auto")
353 {
354 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Auto);
355 }
356 else if (BehaviourStringToLower == "rigid")
357 {
358 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
359 }
360 else if (BehaviourStringToLower == "always")
361 {
362 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Always);
363 }
364 else if (BehaviourStringToLower == "static")
365 {
366 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Static);
367 }
368}
369
371{
373}
374
376{
378}
379
380EShadowCacheInvalidationBehavior UAgrarsenseSettings::GetShadowCacheInvalidationBehavior() const
381{
383}
384
386{
388}
389
391{
393}
394
395void UAgrarsenseSettings::SetRenderCustomDepthPass(bool RenderCustomDepthPass)
396{
397 UWorld* World = CurrentWorld.Get();
398 if (GEngine || World)
399 {
400 RenderCustomDepth = RenderCustomDepthPass;
401 if (RenderCustomDepthPass)
402 {
403 GEngine->Exec(World, TEXT("r.CustomDepth 3"));
404 }
405 else
406 {
407 GEngine->Exec(World, TEXT("r.CustomDepth 0"));
408 }
409 }
410}
411
412void UAgrarsenseSettings::SetUseVirtualShadowMaps(bool UseVirtualShadowMaps)
413{
414 UWorld* World = CurrentWorld.Get();
415 if (GEngine || World)
416 {
417 GraphicsSettings.UseVirtualShadowMaps = UseVirtualShadowMaps;
418
420 {
421 GEngine->Exec(World, TEXT("r.Shadow.Virtual.Enable 1"));
422 }
423 else
424 {
425 GEngine->Exec(World, TEXT("r.Shadow.Virtual.Enable 0"));
426 }
427
429 }
430}
431
433{
435}
436
438{
439 return RenderCustomDepth;
440}
441
443{
445}
446
448{
449
450 UWorld* World = CurrentWorld.Get();
451
452 if (!GEngine || !World)
453 {
454 return;
455 }
456
457 GraphicsSettings.AntiAliasingMethod = AntiAliasingMethod;
458
459 FString ExecCommand;
460 switch (AntiAliasingMethod)
461 {
463 ExecCommand = TEXT("r.AntiAliasingMethod 0");
464 break;
465
467 ExecCommand = TEXT("r.AntiAliasingMethod 1");
468 break;
469
471 ExecCommand = TEXT("r.AntiAliasingMethod 2");
472 break;
473
474 // MSAA ("r.AntiAliasingMethod 3) is not supported on Deferred rendering
475
477 ExecCommand = TEXT("r.AntiAliasingMethod 4");
478 break;
479
480 default:
481 return;
482 }
483
484 GEngine->Exec(World, *ExecCommand);
485
487}
488
489void UAgrarsenseSettings::SetAntiAliasingMethodFromString(const FString& AntiAliasingMethodString)
490{
491 EAntiAliasing NewMethod = UEnumUtilities::ConvertStringToAntiAliasingMethod(AntiAliasingMethodString);
492 SetAntiAliasingMethod(NewMethod);
493}
494
496{
497 if (GEngine && GEngine->GameViewport)
498 {
499 GEngine->GameViewport->bDisableWorldRendering = !enabled;
501
502 FString msg = FString::Printf(TEXT("World rendering: %s"), enabled ? TEXT("On") : TEXT("Off"));
504
506 }
507}
508
510{
511 GraphicsSettings.QualityLevel = newQualityLevel;
512
514 {
517 break;
518
521 break;
522
525 break;
526
529 break;
530 }
531
533 FString Msg = FString::Printf(TEXT("Graphics settings: %s"), *QualityLevelString);
535
537}
538
539void UAgrarsenseSettings::SetQualityLevelFromString(const FString& QualityLevelString)
540{
542}
543
545{
546 return GetFrameRateLimit();
547}
548
550{
551 SetFrameRateLimit(NewTargetFrameRate);
552 ApplySettings(false);
553}
554
556{
557 UWorld* World = CurrentWorld.Get();
558
559 if (!World)
560 {
562 }
563
564 return UGameplayStatics::GetGlobalTimeDilation(World);
565}
566
568{
569 UWorld* World = CurrentWorld.Get();
570 if (!World)
571 {
572 return;
573 }
574
575 SimulationSettings.TimeDilation = TimeDilation;
576 UGameplayStatics::SetGlobalTimeDilation(World, TimeDilation);
577
578 FString msg = FString::Printf(TEXT("Global time dilation: %f"), TimeDilation);
580}
581
583{
584 UWorld* World = CurrentWorld.Get();
585 if (!World)
586 {
587 return;
588 }
589
591 if (IsValid(Spectator))
592 {
593 Spectator->SetMaxSpeed(MaxSpeed);
595 }
596}
597
599{
600 UWorld* World = CurrentWorld.Get();
601 if (!World)
602 {
603 return;
604 }
605
607
608 if (IsValid(Spectator))
609 {
610 Spectator->SetNiagaraComponentVisibility(Show);
612 }
613}
614
616{
617 UWorld* World = CurrentWorld.Get();
619 {
620 UGameplayStatics::SetGlobalTimeDilation(World, 0.0f);
621 UGameplayStatics::SetGamePaused(World, true);
623
624 SimulatorLog::Log("Simulator paused");
625 }
626}
627
629{
630 UWorld* World = CurrentWorld.Get();
632 {
633 UGameplayStatics::SetGlobalTimeDilation(World, SimulationSettings.TimeDilation);
634 UGameplayStatics::SetGamePaused(World, false);
636
637 SimulatorLog::Log("Simulator unpaused");
638 }
639}
640
642{
644 {
645 return;
646 }
647
648 // Subscribe to Unreal Engine end of frame callback
649 EndOfFrameHandle = FCoreDelegates::OnEndFrame.AddLambda([this]()
650 {
651 // After receiving the event, unsubcribe from the event and pause the simulation.
652 if (IsValid(this))
653 {
654 if (EndOfFrameHandle.IsValid())
655 {
656 FCoreDelegates::OnEndFrame.Remove(EndOfFrameHandle);
657 EndOfFrameHandle.Reset();
658 }
659
661 }
662 });
663}
664
665void UAgrarsenseSettings::AdvanceFrameCount(int32 FramesToAdvance)
666{
667 if (FramesToAdvance == 0)
668 {
669 return;
670 }
671
672 if (AdvanceFramesHandle.IsValid())
673 {
674 // Already running this, return
675 return;
676 }
677
678 if (EndOfFrameHandle.IsValid())
679 {
680 // If PauseSimulationEndOfThisFrame was called, unsubribe
681 FCoreDelegates::OnEndFrame.Remove(EndOfFrameHandle);
682 EndOfFrameHandle.Reset();
683 }
684
685 // Unpause simulation now
687
688 FrameCount = 0;
689
690 // Subscribe to Unreal Engine end of frame callback
691 AdvanceFramesHandle = FCoreDelegates::OnEndFrame.AddLambda([this, FramesToAdvance]()
692 {
693 ++FrameCount;
694 if (FrameCount == FramesToAdvance)
695 {
696 // After given number of frames,
697 // unsubscribe from the event and pause simulation again at the end of that frame
698 if (IsValid(this))
699 {
700 FCoreDelegates::OnEndFrame.Remove(AdvanceFramesHandle);
701 AdvanceFramesHandle.Reset();
702 FrameCount = 0;
703
705 }
706 }
707 });
708}
709
710void UAgrarsenseSettings::AdvanceTime(float TimeToAdvance)
711{
712 UWorld* World = CurrentWorld.Get();
713 if (!World)
714 {
715 return;
716 }
717
718 // Unpause simulation now
720
721 // Pause simulation again after TimeToAdvance
722 FTimerHandle AdvanceTimeTimer;
723 World->GetTimerManager().SetTimer(AdvanceTimeTimer, FTimerDelegate::CreateLambda([this]
724 {
725 if (IsValid(this))
726 {
728 }
729
730 }), TimeToAdvance, false);
731}
732
734{
735 // Make the map name to lower
736 // This is because ROSCommands.cpp uses this and all the messages are in lower case.
737 MapName = MapName.ToLower();
738
739 bool FoundMap = false;
740 for (int32 i = 0; i < MapNames.Num(); i++)
741 {
742 if (MapName == MapNames[i])
743 {
744 FoundMap = true;
745 FString msg = FString::Printf(TEXT("Changing map to: %s"), *MapName);
747
749 break;
750 }
751 }
752
753 if (!FoundMap)
754 {
755 FString msg = FString::Printf(TEXT("Couldn't find map: %s"), *MapName);
757 }
758}
759
761{
762 UWorld* World = CurrentWorld.Get();
763 if (World)
764 {
765 UGameplayStatics::OpenLevel(World, *Path, TRAVEL_Absolute);
766 }
767}
768
770{
771 if (!SensorPtr)
772 {
773 return;
774 }
775
776 ESensorTypes type = SensorPtr->GetSensorType();
778 {
779 // If the the sensor uses CustomDepthPass to color objects, enable custom depth pass
782 }
783}
784
786{
787 if (!SensorPtr)
788 {
789 return;
790 }
791
792 ESensorTypes type = SensorPtr->GetSensorType();
794 {
797 {
798 // If there's no more sensors that need CustomDepthPass to work,
799 // disable it to save rendering performance
801 }
802 }
803}
804
806{
808 {
811 }
812 else
813 {
814 SimulatorLog::Log("Graphics settings: Ray tracing not supported on this hardware.");
815 }
816}
817
819{
820 bool RayTracingSupported = false;
821
822 // Check if the hardware supports ray tracing
823 IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing"));
824 if (CVar && CVar->GetInt() > 0 && GRHISupportsRayTracing)
825 {
826 RayTracingSupported = true;
827 }
828
829 return RayTracingSupported;
830}
831
833{
834 UWorld* World = CurrentWorld.Get();
835 if (!World || !GEngine)
836 {
837 return;
838 }
839
840
841#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION == 6)
842 // Due to UE 5.6 bug where ISM nanite proxies with WPO enabled cause shadows not working properly
843 GEngine->Exec(World, TEXT("r.RayTracing.Geometry.NaniteProxies.WPO 0"));
844#endif
845
846 GEngine->Exec(World, TEXT("r.RayTracing 1"));
847 GEngine->Exec(World, TEXT("r.Lumen.HardwareRayTracing 1")); // Enable lumen raytracing
848 GEngine->Exec(World, TEXT("r.RayTracing.Geometry 1")); // Enable ray tracing geometry
849 GEngine->Exec(World, TEXT("r.RayTracing.Reflections 1")); // Enable ray tracing reflections
850 GEngine->Exec(World, TEXT("r.RayTracing.AmbientOcclusion 1")); // Enable ray tracing ambient occlusion
851 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination 1")); // Enable ray tracing global illumination
852 GEngine->Exec(World, TEXT("r.RayTracing.Translucency 1")); // Enable ray tracing translucency
853 GEngine->Exec(World, TEXT("r.RayTracing.SkyLight 1")); // Enable ray tracing sky light
854
855 // Couldn't get Nanite trees with WPO to work with Raytracing
856 //GEngine->Exec(World, TEXT("r.RayTracing.Shadows 1")); // Enable ray tracing shadows
857 //GEngine->Exec(World, TEXT("r.RayTracing.Shadows.SoftShadows 1"));
858 //GEngine->Exec(World, TEXT("r.RayTracing.Shadows.SamplesPerPixel 4"));
859
860 GEngine->Exec(World, TEXT("r.RayTracing.Reflections.MaxRoughness 1.0")); // Enable reflections on all surfaces
861 GEngine->Exec(World, TEXT("r.RayTracing.Reflections.Shadows 1")); // Enable ray-traced shadows in reflections
862 GEngine->Exec(World, TEXT("r.RayTracing.Reflections.SortTiles 1")); // Optimized tile sorting for performance
863 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination.Quality 4")); // Increase RT GI quality (0-4)
864 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination.SamplesPerPixel 4")); // Improve GI smoothness
865
866 GEngine->Exec(World, TEXT("r.Lumen.Reflections 1")); // Enable Lumen reflections
867 GEngine->Exec(World, TEXT("r.Lumen.ScreenProbeGather.ScreenTraces 1")); // Improve Lumen probe accuracy
868
869 GEngine->Exec(World, TEXT("r.RayTracing.Denoiser 1")); // Enable denoiser
870 GEngine->Exec(World, TEXT("r.RayTracing.Denoiser.TemporalAccumulation 1")); // Temporal stability
871 GEngine->Exec(World, TEXT("r.RayTracing.Denoiser.ReuseRadiance 1")); // Improves light reuse
872}
873
875{
876 UWorld* World = CurrentWorld.Get();
877 if (!World || !GEngine)
878 {
879 return;
880 }
881
882#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION == 6)
883 GEngine->Exec(World, TEXT("r.RayTracing.Geometry.NaniteProxies.WPO 1"));
884#endif
885
886 GEngine->Exec(World, TEXT("r.RayTracing 0"));
887 GEngine->Exec(World, TEXT("r.RayTracing.Denoiser 0"));
888 GEngine->Exec(World, TEXT("r.Lumen.HardwareRayTracing 0"));
889 GEngine->Exec(World, TEXT("r.RayTracing.Geometry 0"));
890 GEngine->Exec(World, TEXT("r.RayTracing.Reflections 0"));
891 GEngine->Exec(World, TEXT("r.RayTracing.AmbientOcclusion 0"));
892 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination 0"));
893 GEngine->Exec(World, TEXT("r.RayTracing.Translucency 0"));
894 GEngine->Exec(World, TEXT("r.RayTracing.SkyLight 0"));
895 GEngine->Exec(World, TEXT("r.RayTracing.Shadows 0"));
896}
897
899{
900 UWorld* World = CurrentWorld.Get();
901 if (!World || !GEngine)
902 {
903 return;
904 }
905
907
908 // https://dev.epicgames.com/documentation/en-us/unreal-engine/scalability-reference-for-unreal-engine?application_version=5.3
909 GEngine->Exec(World, TEXT("sg.PostProcessQuality 3"));
910 GEngine->Exec(World, TEXT("sg.ShadowQuality 3"));
911 GEngine->Exec(World, TEXT("sg.TextureQuality 4"));
912 GEngine->Exec(World, TEXT("sg.EffectsQuality 4"));
913 GEngine->Exec(World, TEXT("sg.FoliageQuality 4"));
914
915 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.03"));
916 GEngine->Exec(World, TEXT("r.SeparateTranslucency 1"));
917 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 2"));
918 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 1"));
919 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 64"));
920 GEngine->Exec(World, TEXT("r.MaxAnisotropy 8"));
921 GEngine->Exec(World, TEXT("r.LensFlareQuality 2"));
922 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 1"));
923 GEngine->Exec(World, TEXT("r.FastBlurThreshold 7"));
924 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
925 GEngine->Exec(World, TEXT("r.ShadowQuality 5"));
926 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 1"));
927 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 2"));
928 GEngine->Exec(World, TEXT("r.DetailMode 2"));
929 GEngine->Exec(World, TEXT("foliage.DensityScale 1"));
930 GEngine->Exec(World, TEXT("grass.DensityScale 1"));
931 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
932 GEngine->Exec(World, TEXT("r.Shadow.RadiusThreshold 0.00"));
933
934 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Auto);
935}
936
938{
939 UWorld* World = CurrentWorld.Get();
940 if (!World || !GEngine)
941 {
942 return;
943 }
944
946
947 GEngine->Exec(World, TEXT("sg.PostProcessQuality 3"));
948 GEngine->Exec(World, TEXT("sg.TextureQuality 3"));
949 GEngine->Exec(World, TEXT("sg.EffectsQuality 3"));
950 GEngine->Exec(World, TEXT("sg.FoliageQuality 3"));
951
952 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.03"));
953 GEngine->Exec(World, TEXT("r.SeparateTranslucency 1"));
954 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 2"));
955 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 1"));
956 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 64"));
957 GEngine->Exec(World, TEXT("r.MaxAnisotropy 8"));
958 GEngine->Exec(World, TEXT("r.LensFlareQuality 2"));
959 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 1"));
960 GEngine->Exec(World, TEXT("r.FastBlurThreshold 7"));
961 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
962 GEngine->Exec(World, TEXT("r.ShadowQuality 3"));
963 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 1"));
964 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 2"));
965 GEngine->Exec(World, TEXT("r.DetailMode 2"));
966 GEngine->Exec(World, TEXT("r.BloomQuality 4"));
967 GEngine->Exec(World, TEXT("foliage.DensityScale 1"));
968 GEngine->Exec(World, TEXT("grass.DensityScale 1"));
969 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
970 GEngine->Exec(World, TEXT("r.Shadow.RadiusThreshold 0.01"));
971
972 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
973}
974
976{
977 UWorld* World = CurrentWorld.Get();
978 if (!World || !GEngine)
979 {
980 return;
981 }
982
984
985 GEngine->Exec(World, TEXT("sg.PostProcessQuality 0"));
986 GEngine->Exec(World, TEXT("sg.ShadowQuality 0"));
987 GEngine->Exec(World, TEXT("sg.TextureQuality 0"));
988 GEngine->Exec(World, TEXT("sg.EffectsQuality 0"));
989 GEngine->Exec(World, TEXT("sg.FoliageQuality 0"));
990
991 GEngine->Exec(World, TEXT("r.DefaultFeature.MotionBlur 0"));
992 GEngine->Exec(World, TEXT("r.DefaultFeature.Bloom 0"));
993 GEngine->Exec(World, TEXT("r.DefaultFeature.AmbientOcclusion 0"));
994 GEngine->Exec(World, TEXT("r.DefaultFeature.AmbientOcclusionStaticFraction 0"));
995 GEngine->Exec(World, TEXT("r.HZBOcclusion 0"));
996 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.01"));
997 GEngine->Exec(World, TEXT("r.SeparateTranslucency 0"));
998 GEngine->Exec(World, TEXT("r.FinishCurrentFrame 0"));
999 GEngine->Exec(World, TEXT("r.MotionBlurQuality 0"));
1000 GEngine->Exec(World, TEXT("r.BloomQuality 1"));
1001 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 0"));
1002 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 0"));
1003 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 4"));
1004 GEngine->Exec(World, TEXT("r.MaxAnisotropy 4"));
1005 GEngine->Exec(World, TEXT("r.LensFlareQuality 0"));
1006 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 0"));
1007 GEngine->Exec(World, TEXT("r.FastBlurThreshold 0"));
1008 GEngine->Exec(World, TEXT("r.SSR 0"));
1009 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
1010 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 0"));
1011 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 4"));
1012 GEngine->Exec(World, TEXT("r.OcclusionQueryLocation 1"));
1013 GEngine->Exec(World, TEXT("foliage.DensityScale 0"));
1014 GEngine->Exec(World, TEXT("grass.DensityScale 0"));
1015 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
1016
1017 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
1018}
EAntiAliasing
Definition: AntiAliasing.h:15
EQualityLevel
Definition: QualityLevel.h:16
ESensorTypes
Definition: SensorTypes.h:15
@ SemanticSegmentationCamera
Definition: Sensor.h:45
virtual ESensorTypes GetSensorType() const
Definition: Sensor.h:65
void SetMaxSpeed(float MaxSpeed=1500.0f)
Definition: Spectator.cpp:222
bool IsNiagaraComponentVisible()
Definition: Spectator.h:102
float GetMaxSpeed()
Definition: Spectator.cpp:231
void SetNiagaraComponentVisibility(bool Visible)
Definition: Spectator.cpp:214
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)
int32 GetGlobalTargetFrameRate() const
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)
const TArray< FString > MapPaths
void SetInstancedRenderingVisibility(bool Visible)
virtual void PostInitProperties() override
float GetGlobalTimeDilation() const
void SetShadowCSMCache(bool CacheShadowCSM)
void SetGlobalTargetFrameRate(int32 NewTargetFrameRate)
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 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 AInstancedRendererManager * 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