Add RenderColorFormat option to graphics settings for rendering pipeline buffer format
#3618
This commit is contained in:
@@ -242,6 +242,15 @@ namespace FlaxEditor.GUI
|
||||
{
|
||||
FieldInfo[] fields = type.GetFields();
|
||||
entries.Capacity = Mathf.Max(fields.Length - 1, entries.Capacity);
|
||||
if (formatMode == EnumDisplayAttribute.FormatMode.Default)
|
||||
{
|
||||
// Override display mode from enum itself
|
||||
var attr = type.GetCustomAttribute<EnumDisplayAttribute>();
|
||||
if (attr != null)
|
||||
{
|
||||
formatMode = attr.Mode;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
|
||||
@@ -16,6 +16,21 @@ API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings", NoConstructor) class
|
||||
API_AUTO_SERIALIZATION();
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(GraphicsSettings);
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// List of pixel formats that can be used by the rendering pipeline (for light buffer and post-processing).
|
||||
/// </summary>
|
||||
API_ENUM(Attributes="EnumDisplay(EnumDisplayAttribute.FormatMode.None)")
|
||||
enum class RenderColorFormats
|
||||
{
|
||||
// HDR 32-bit buffer without alpha channel support. Offers good performance but might result in colors banding or shift towards yellowish colors due to low data precision.
|
||||
R11G11B10,
|
||||
// LDR 32-bit buffer with alpha channel support. Offers good performance but doesn't support High Dynamic Range rendering.
|
||||
R8G8B8A8,
|
||||
// HDR 64-bit buffer with alpha channel support. Offers very good quality for wide range of colors but requires more memory.
|
||||
R16G16B16A16,
|
||||
};
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Enables rendering synchronization with the refresh rate of the display device to avoid "tearing" artifacts.
|
||||
@@ -135,6 +150,12 @@ public:
|
||||
API_FIELD(Attributes="EditorOrder(3000), EditorDisplay(\"Colors\")")
|
||||
bool GammaColorSpace = true;
|
||||
|
||||
/// <summary>
|
||||
/// Pixel format used by the rendering pipeline (for light buffer and post-processing).
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(3010), EditorDisplay(\"Colors\")")
|
||||
RenderColorFormats RenderColorFormat = RenderColorFormats::R11G11B10;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// The default Post Process settings. Can be overriden by PostFxVolume on a level locally, per camera or for a whole map.
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright (c) Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "RenderBuffers.h"
|
||||
#include "Engine/Core/Config/GraphicsSettings.h"
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Renderer/Utils/MultiScaler.h"
|
||||
#include "Engine/Graphics/GPULimits.h"
|
||||
#include "Engine/Graphics/RenderTargetPool.h"
|
||||
#include "Engine/Renderer/Utils/MultiScaler.h"
|
||||
#include "Engine/Engine/Engine.h"
|
||||
|
||||
// How many frames keep cached buffers for temporal or optional effects?
|
||||
@@ -113,8 +114,29 @@ GPUTexture* RenderBuffers::RequestHalfResDepth(GPUContext* context)
|
||||
|
||||
PixelFormat RenderBuffers::GetOutputFormat() const
|
||||
{
|
||||
auto colorFormat = GraphicsSettings::Get()->RenderColorFormat;
|
||||
// TODO: fix incorrect alpha leaking into reflections on PS5 with R11G11B10_Float
|
||||
return _useAlpha || PLATFORM_PS5 ? PixelFormat::R16G16B16A16_Float : PixelFormat::R11G11B10_Float;
|
||||
if (_useAlpha || PLATFORM_PS5)
|
||||
{
|
||||
// Promote to format when alpha when needed
|
||||
switch (colorFormat)
|
||||
{
|
||||
case GraphicsSettings::RenderColorFormats::R11G11B10:
|
||||
colorFormat = GraphicsSettings::RenderColorFormats::R16G16B16A16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (colorFormat)
|
||||
{
|
||||
case GraphicsSettings::RenderColorFormats::R11G11B10:
|
||||
return PixelFormat::R11G11B10_Float;
|
||||
case GraphicsSettings::RenderColorFormats::R8G8B8A8:
|
||||
return PixelFormat::R8G8B8A8_UNorm;
|
||||
case GraphicsSettings::RenderColorFormats::R16G16B16A16:
|
||||
return PixelFormat::R16G16B16A16_Float;
|
||||
default:
|
||||
return PixelFormat::R32G32B32A32_Float;
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderBuffers::GetUseAlpha() const
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace FlaxEngine
|
||||
/// Allows to change enum type field or property display mode in the editor.
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Attribute" />
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Enum)]
|
||||
public sealed class EnumDisplayAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user