// Copyright (c) Wojciech Figat. All rights reserved. #pragma once #include "Engine/Scripting/ScriptingType.h" #include "PostProcessSettings.h" #include "Enums.h" /// /// Graphics device manager that creates, manages and releases graphics device and related objects. /// API_CLASS(Static, Attributes="DebugCommand") class FLAXENGINE_API Graphics { DECLARE_SCRIPTING_TYPE_NO_SPAWN(Graphics); public: /// /// Enables rendering synchronization with the refresh rate of the display device to avoid "tearing" artifacts. /// API_FIELD() static bool UseVSync; /// /// Anti Aliasing quality setting. Available values are: Low, Medium, High, Ultra (or 0, 1, 2, 3). /// API_FIELD() static Quality AAQuality; /// /// Screen Space Reflections quality setting. Available values are: Low, Medium, High, Ultra (or 0, 1, 2, 3). /// API_FIELD() static Quality SSRQuality; /// /// Screen Space Ambient Occlusion quality setting. Available values are: Low, Medium, High, Ultra (or 0, 1, 2, 3). /// API_FIELD() static Quality SSAOQuality; /// /// Volumetric Fog quality setting. Available values are: Low, Medium, High, Ultra (or 0, 1, 2, 3). /// API_FIELD() static Quality VolumetricFogQuality; /// /// The shadows filtering quality (sampling). Available values are: Low, Medium, High, Ultra (or 0, 1, 2, 3). /// API_FIELD() static Quality ShadowsQuality; /// /// The shadow maps quality (textures resolution). Available values are: Low, Medium, High, Ultra (or 0, 1, 2, 3). /// API_FIELD() static Quality ShadowMapsQuality; /// /// The global scale for all shadow maps update rate. Can be used to slow down shadows rendering frequency on lower quality settings or low-end platforms. Default 1. /// API_FIELD() static float ShadowUpdateRate; /// /// Enables cascades splits blending for directional light shadows. /// API_FIELD() static bool AllowCSMBlending; /// /// The Global SDF quality. Controls the volume texture resolution and amount of cascades to use. Available values are: Low, Medium, High, Ultra (or 0, 1, 2, 3). /// API_FIELD() static Quality GlobalSDFQuality; /// /// The Global Illumination quality. Controls the quality of the GI effect. Available values are: Low, Medium, High, Ultra (or 0, 1, 2, 3). /// API_FIELD() static Quality GIQuality; /// /// The Global Illumination probes spacing distance (in world units). Defines the quality of the GI resolution. Adjust to 200-500 to improve performance and lower frequency GI data. /// API_FIELD() static float GIProbesSpacing; /// /// Enables cascades splits blending for Global Illumination. /// API_FIELD() static bool GICascadesBlending; /// /// The Global Surface Atlas resolution. Adjust it if atlas `flickers` due to overflow (eg. to 4096). /// API_FIELD() static int32 GlobalSurfaceAtlasResolution; /// /// The default Post Process settings. Can be overriden by PostFxVolume on a level locally, per camera or for a whole map. /// API_FIELD() static PostProcessSettings PostProcessSettings; /// /// Enables Gamma color space workflow (instead of Linear). Gamma color space defines colors with an applied a gamma curve (sRGB) so they are perceptually linear. /// This makes sense when the output of the rendering represent final color values that will be presented to a non-HDR screen. /// API_FIELD(ReadOnly) static bool GammaColorSpace; public: /// /// Debug utility to toggle graphics workloads amortization over several frames by systems such as shadows mapping, global illumination or surface atlas. Can be used to test performance in the worst-case scenario (eg. camera-cut). /// API_FIELD() static bool SpreadWorkload; #if BUILD_RELEASE && !USE_EDITOR /// Unused. API_FIELD() static constexpr float TestValue = 0.0f; #else /// /// Debug utility to control visual or rendering features during development. For example, can be used to branch different code paths in shaders for A/B testing (perf or quality). /// API_FIELD() static float TestValue; #endif public: // Shadows rendering configuration. API_CLASS(Static, Attributes="DebugCommand") class FLAXENGINE_API Shadows { DECLARE_SCRIPTING_TYPE_MINIMAL(Shadows); // The minimum size in pixels of objects to cast shadows. Improves performance by skipping too small objects (eg. sub-pixel) from rendering into shadow maps. API_FIELD() static float MinObjectPixelSize; #if COMPILE_WITH_PROFILER /// /// Dumps active shadow projections info to the log (the next frame). Can be used to inspect what lights are casting shadows (for optimization). /// API_FUNCTION(Attributes="DebugCommand") static void Dump(); #endif }; // Motion Vectors rendering configuration. API_CLASS(Static, Attributes="DebugCommand") class FLAXENGINE_API MotionVectors { DECLARE_SCRIPTING_TYPE_MINIMAL(MotionVectors); // The minimum screen size of objects to draw motion vectors. Improves performance by skipping too small objects (eg. sub-pixel) from rendering motion vectors. API_FIELD() static float MinObjectScreenSize; }; // Post Processing effects rendering configuration. API_CLASS(Static, Attributes="DebugCommand") class FLAXENGINE_API PostProcessing { DECLARE_SCRIPTING_TYPE_MINIMAL(PostProcessing); // Toggles between 2D and 3D LUT texture for Color Grading. API_FIELD() static bool ColorGradingVolumeLUT; }; // Global Illumination rendering configuration and API. API_CLASS(Static, Attributes="DebugCommand") class FLAXENGINE_API GI { DECLARE_SCRIPTING_TYPE_MINIMAL(GI); // Gets the normalized 0-1 progress of the Global Illumination lighting bounces convergence (0 = no GI, 1 = full GI convergence). Can be used to continue displaying loading screen after scene load to ensure indirect lighting has been evaluated. Non-zero value means GI has started to be calculated. API_FUNCTION(Attributes="DebugCommand(Hide=true)") static float GetConvergence(const RenderBuffers* buffers); #if COMPILE_WITH_PROFILER /// /// Dumps Global Illumination rendering info to the log (the next frame). Can be used to inspect DDGI, Global Surface Atlas and Global SDF memory and usage (for optimization). Prints info about the number of probes, cascades and draw state. /// API_FUNCTION(Attributes="DebugCommand") static void Dump(); #endif }; public: /// /// Disposes the device. /// static void DisposeDevice(); }; // Skip disabling workload spreading in Release builds #if BUILD_RELEASE #define GPU_SPREAD_WORKLOAD true #else #define GPU_SPREAD_WORKLOAD Graphics::SpreadWorkload #endif