diff --git a/Source/Editor/Windows/GraphicsQualityWindow.cs b/Source/Editor/Windows/GraphicsQualityWindow.cs index 27b131404..02e2da9bf 100644 --- a/Source/Editor/Windows/GraphicsQualityWindow.cs +++ b/Source/Editor/Windows/GraphicsQualityWindow.cs @@ -98,10 +98,10 @@ namespace FlaxEditor.Windows [NoSerialize, DefaultValue(1.0f), Limit(0.05f, 5, 0)] [EditorOrder(1400), EditorDisplay("Quality")] [Tooltip("The scale of the rendering resolution relative to the output dimensions. If lower than 1 the scene and postprocessing will be rendered at a lower resolution and upscaled to the output backbuffer.")] - public float RenderingPercentage + public float RenderScale { - get => MainRenderTask.Instance.RenderingPercentage; - set => MainRenderTask.Instance.RenderingPercentage = value; + get => MainRenderTask.Instance.RenderScale; + set => MainRenderTask.Instance.RenderScale = value; } [NoSerialize, DefaultValue(RenderingUpscaleLocation.AfterAntiAliasingPass), VisibleIf(nameof(UpscaleLocation_Visible))] @@ -113,7 +113,7 @@ namespace FlaxEditor.Windows set => MainRenderTask.Instance.UpscaleLocation = value; } - private bool UpscaleLocation_Visible => MainRenderTask.Instance.RenderingPercentage < 1.0f; + private bool UpscaleLocation_Visible => MainRenderTask.Instance.RenderScale < 1.0f; [NoSerialize, DefaultValue(1.0f), Limit(0, 1)] [EditorOrder(1500), EditorDisplay("Quality"), Tooltip("The global density scale for all foliage instances. The default value is 1. Use values from range 0-1. Lower values decrease amount of foliage instances in-game. Use it to tweak game performance for slower devices.")] diff --git a/Source/Engine/Graphics/RenderTask.cpp b/Source/Engine/Graphics/RenderTask.cpp index 94fdb11ac..31639c39d 100644 --- a/Source/Engine/Graphics/RenderTask.cpp +++ b/Source/Engine/Graphics/RenderTask.cpp @@ -353,8 +353,11 @@ Viewport SceneRenderTask::GetViewport() const viewport = Buffers->GetViewport(); else viewport = Viewport(0, 0, 1280, 720); - viewport.Width *= RenderingPercentage; - viewport.Height *= RenderingPercentage; +PRAGMA_DISABLE_DEPRECATION_WARNINGS + float renderScale = RenderingPercentage * RenderScale; +PRAGMA_ENABLE_DEPRECATION_WARNINGS + viewport.Width *= renderScale; + viewport.Height *= renderScale; return viewport; } @@ -394,13 +397,16 @@ void SceneRenderTask::OnBegin(GPUContext* context) } // Setup render buffers for the output rendering resolution +PRAGMA_DISABLE_DEPRECATION_WARNINGS + float renderScale = RenderingPercentage * RenderScale; +PRAGMA_ENABLE_DEPRECATION_WARNINGS if (Output) { - Buffers->Init((int32)((float)Output->Width() * RenderingPercentage), (int32)((float)Output->Height() * RenderingPercentage)); + Buffers->Init((int32)((float)Output->Width() * renderScale), (int32)((float)Output->Height() * renderScale)); } else if (SwapChain) { - Buffers->Init((int32)((float)SwapChain->GetWidth() * RenderingPercentage), (int32)((float)SwapChain->GetHeight() * RenderingPercentage)); + Buffers->Init((int32)((float)SwapChain->GetWidth() * renderScale), (int32)((float)SwapChain->GetHeight() * renderScale)); } } @@ -434,7 +440,10 @@ bool SceneRenderTask::Resize(int32 width, int32 height) PROFILE_MEM(Graphics); if (Output && Output->Resize(width, height)) return true; - if (Buffers && Buffers->Init((int32)((float)width * RenderingPercentage), (int32)((float)height * RenderingPercentage))) +PRAGMA_DISABLE_DEPRECATION_WARNINGS + float renderScale = RenderingPercentage * RenderScale; +PRAGMA_ENABLE_DEPRECATION_WARNINGS + if (Buffers && Buffers->Init((int32)((float)width * renderScale), (int32)((float)height * renderScale))) return true; return false; } @@ -477,12 +486,6 @@ void MainRenderTask::OnBegin(GPUContext* context) // Use the main camera for the game (can be later overriden in Begin event by external code) Camera = Camera::GetMainCamera(); -#if !USE_EDITOR - // Sync render buffers size with the backbuffer - const auto size = Screen::GetSize(); - Buffers->Init((int32)(size.X * RenderingPercentage), (int32)(size.Y * RenderingPercentage)); -#endif - SceneRenderTask::OnBegin(context); } diff --git a/Source/Engine/Graphics/RenderTask.h b/Source/Engine/Graphics/RenderTask.h index db1332bba..a4dbb5151 100644 --- a/Source/Engine/Graphics/RenderTask.h +++ b/Source/Engine/Graphics/RenderTask.h @@ -268,8 +268,14 @@ public: /// /// The scale of the rendering resolution relative to the output dimensions. If lower than 1 the scene and postprocessing will be rendered at a lower resolution and upscaled to the output backbuffer. + /// [Deprecated in v1.13] /// - API_FIELD() float RenderingPercentage = 1.0f; + API_FIELD() DEPRECATED("Use RenderScale instead.") float RenderingPercentage = 1.0f; + + /// + /// The scale of the rendering resolution relative to the output dimensions. If lower than 1 the scene and postprocessing will be rendered at a lower resolution and upscaled to the output backbuffer. + /// + API_FIELD() float RenderScale = 1.0f; /// /// The image resolution upscale location within rendering pipeline. Unused if RenderingPercentage is 1. diff --git a/Source/Engine/Renderer/Renderer.cpp b/Source/Engine/Renderer/Renderer.cpp index 1098692cc..6173a1f5a 100644 --- a/Source/Engine/Renderer/Renderer.cpp +++ b/Source/Engine/Renderer/Renderer.cpp @@ -733,7 +733,9 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont } // Upscaling after scene rendering but before post processing - bool useUpscaling = task->RenderingPercentage < 1.0f; +PRAGMA_DISABLE_DEPRECATION_WARNINGS + bool useUpscaling = task->RenderingPercentage * task->RenderScale < 1.0f; +PRAGMA_ENABLE_DEPRECATION_WARNINGS const Viewport outputViewport = task->GetOutputViewport(); if (useUpscaling && setup.UpscaleLocation == RenderingUpscaleLocation::BeforePostProcessingPass) {