Add default Post Process options to Graphics Settings
This commit is contained in:
@@ -127,15 +127,9 @@ namespace FlaxEditor.Scripting
|
||||
return ChannelMask.Red;
|
||||
if (type.Type == typeof(MaterialSceneTextures))
|
||||
return MaterialSceneTextures.BaseColor;
|
||||
if (type.IsValueType)
|
||||
{
|
||||
var value = type.CreateInstance();
|
||||
Utilities.Utils.InitDefaultValues(value);
|
||||
return value;
|
||||
}
|
||||
if (ScriptType.Object.IsAssignableFrom(type))
|
||||
return null;
|
||||
if (type.CanCreateInstance)
|
||||
if (type.IsValueType || type.CanCreateInstance)
|
||||
{
|
||||
var value = type.CreateInstance();
|
||||
Utilities.Utils.InitDefaultValues(value);
|
||||
|
||||
@@ -16,4 +16,5 @@ void GraphicsSettings::Apply()
|
||||
Graphics::GlobalSDFQuality = GlobalSDFQuality;
|
||||
Graphics::GIQuality = GIQuality;
|
||||
Graphics::GlobalSurfaceAtlasResolution = GlobalSurfaceAtlasResolution;
|
||||
Graphics::PostProcessSettings = PostProcessSettings;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
#include "Engine/Core/Config/Settings.h"
|
||||
#include "Engine/Serialization/Serialization.h"
|
||||
#include "Engine/Graphics/Enums.h"
|
||||
#include "Engine/Graphics/PostProcessSettings.h"
|
||||
|
||||
/// <summary>
|
||||
/// Graphics rendering settings.
|
||||
/// </summary>
|
||||
API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API GraphicsSettings : public SettingsBase
|
||||
API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings", NoConstructor) class FLAXENGINE_API GraphicsSettings : public SettingsBase
|
||||
{
|
||||
API_AUTO_SERIALIZATION();
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(GraphicsSettings);
|
||||
@@ -94,6 +95,12 @@ public:
|
||||
API_FIELD(Attributes="EditorOrder(2130), Limit(256, 8192), EditorDisplay(\"Global Illumination\")")
|
||||
int32 GlobalSurfaceAtlasResolution = 2048;
|
||||
|
||||
/// <summary>
|
||||
/// The default Post Process settings. Can be overriden by PostFxVolume on a level locally, per camera or for a whole map.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(10000), EditorDisplay(\"Post Process Settings\", EditorDisplayAttribute.InlineStyle)")
|
||||
PostProcessSettings PostProcessSettings;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use.
|
||||
|
||||
@@ -17,6 +17,7 @@ bool Graphics::AllowCSMBlending = false;
|
||||
Quality Graphics::GlobalSDFQuality = Quality::High;
|
||||
Quality Graphics::GIQuality = Quality::High;
|
||||
int32 Graphics::GlobalSurfaceAtlasResolution = 2048;
|
||||
PostProcessSettings Graphics::PostProcessSettings;
|
||||
|
||||
#if GRAPHICS_API_NULL
|
||||
extern GPUDevice* CreateGPUDeviceNull();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Scripting/ScriptingType.h"
|
||||
#include "PostProcessSettings.h"
|
||||
#include "Enums.h"
|
||||
|
||||
/// <summary>
|
||||
@@ -68,6 +69,11 @@ public:
|
||||
/// </summary>
|
||||
API_FIELD() static int32 GlobalSurfaceAtlasResolution;
|
||||
|
||||
/// <summary>
|
||||
/// The default Post Process settings. Can be overriden by PostFxVolume on a level locally, per camera or for a whole map.
|
||||
/// </summary>
|
||||
API_FIELD() static PostProcessSettings PostProcessSettings;
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "Engine/Content/Assets/Texture.h"
|
||||
#include "Engine/Content/Assets/MaterialBase.h"
|
||||
|
||||
API_INJECT_CODE(csharp, "using Newtonsoft.Json;");
|
||||
|
||||
/// <summary>
|
||||
/// Global Illumination effect rendering modes.
|
||||
/// </summary>
|
||||
@@ -1910,79 +1912,79 @@ API_STRUCT() struct FLAXENGINE_API PostProcessSettings : ISerializable
|
||||
/// <summary>
|
||||
/// The ambient occlusion effect settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"Ambient Occlusion\"), EditorOrder(100), JsonProperty(\"AO\")")
|
||||
AmbientOcclusionSettings AmbientOcclusion;
|
||||
|
||||
/// <summary>
|
||||
/// The global illumination effect settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"Global Illumination\"), EditorOrder(150), JsonProperty(\"GI\")")
|
||||
GlobalIlluminationSettings GlobalIllumination;
|
||||
|
||||
/// <summary>
|
||||
/// The bloom effect settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"Bloom\"), EditorOrder(200)")
|
||||
BloomSettings Bloom;
|
||||
|
||||
/// <summary>
|
||||
/// The tone mapping effect settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"Tone Mapping\"), EditorOrder(300)")
|
||||
ToneMappingSettings ToneMapping;
|
||||
|
||||
/// <summary>
|
||||
/// The color grading effect settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"Color Grading\"), EditorOrder(400)")
|
||||
ColorGradingSettings ColorGrading;
|
||||
|
||||
/// <summary>
|
||||
/// The eye adaptation effect settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"Eye Adaptation\"), EditorOrder(500)")
|
||||
EyeAdaptationSettings EyeAdaptation;
|
||||
|
||||
/// <summary>
|
||||
/// The camera artifacts effect settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"Camera Artifacts\"), EditorOrder(600)")
|
||||
CameraArtifactsSettings CameraArtifacts;
|
||||
|
||||
/// <summary>
|
||||
/// The lens flares effect settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"Lens Flares\"), EditorOrder(700)")
|
||||
LensFlaresSettings LensFlares;
|
||||
|
||||
/// <summary>
|
||||
/// The depth of field effect settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"Depth Of Field\"), EditorOrder(800)")
|
||||
DepthOfFieldSettings DepthOfField;
|
||||
|
||||
/// <summary>
|
||||
/// The motion blur effect settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"Motion Blur\"), EditorOrder(900)")
|
||||
MotionBlurSettings MotionBlur;
|
||||
|
||||
/// <summary>
|
||||
/// The screen space reflections effect settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"Screen Space Reflections\"), EditorOrder(1000), JsonProperty(\"SSR\")")
|
||||
ScreenSpaceReflectionsSettings ScreenSpaceReflections;
|
||||
|
||||
/// <summary>
|
||||
/// The anti-aliasing effect settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"Anti Aliasing\"), EditorOrder(1100), JsonProperty(\"AA\")")
|
||||
AntiAliasingSettings AntiAliasing;
|
||||
|
||||
/// <summary>
|
||||
/// The PostFx materials rendering settings.
|
||||
/// </summary>
|
||||
API_FIELD()
|
||||
API_FIELD(Attributes="EditorDisplay(\"PostFx Materials\"), NoAnimate, EditorOrder(1200)")
|
||||
PostFxMaterialsSettings PostFxMaterials;
|
||||
|
||||
public:
|
||||
|
||||
@@ -8,4 +8,41 @@ namespace FlaxEditor.Content.Settings
|
||||
public abstract class SettingsBase
|
||||
{
|
||||
}
|
||||
|
||||
partial class GraphicsSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GraphicsSettings"/>.
|
||||
/// </summary>
|
||||
public GraphicsSettings()
|
||||
{
|
||||
// Initialize PostFx settings with default options (C# structs doesn't support it)
|
||||
PostProcessSettings = FlaxEngine.PostProcessSettings.Default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace FlaxEngine
|
||||
{
|
||||
partial struct PostProcessSettings
|
||||
{
|
||||
private static PostProcessSettings _default;
|
||||
|
||||
/// <summary>
|
||||
/// The default <see cref="PostProcessSettings"/>.
|
||||
/// </summary>
|
||||
public static PostProcessSettings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_default.AmbientOcclusion.Enabled)
|
||||
{
|
||||
object obj = _default;
|
||||
Utils.InitStructure(obj, typeof(PostProcessSettings));
|
||||
_default = (PostProcessSettings)obj;
|
||||
}
|
||||
return _default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ bool GlobalSignDistanceFieldPass::Render(RenderContext& renderContext, GPUContex
|
||||
auto& cascade = sdfData.Cascades[cascadeIndex];
|
||||
const float cascadeDistance = distanceExtent * cascadesDistanceScales[cascadeIndex];
|
||||
const float cascadeMaxDistance = cascadeDistance * 2;
|
||||
const float cascadeVoxelSize = cascadeMaxDistance / resolution;
|
||||
const float cascadeVoxelSize = cascadeMaxDistance / (float)resolution;
|
||||
const float cascadeChunkSize = cascadeVoxelSize * GLOBAL_SDF_RASTERIZE_CHUNK_SIZE;
|
||||
static_assert(GLOBAL_SDF_RASTERIZE_CHUNK_SIZE % GLOBAL_SDF_RASTERIZE_MIP_FACTOR == 0, "Adjust chunk size to match the mip factor scale.");
|
||||
const Vector3 center = Vector3::Floor(viewOrigin / cascadeChunkSize) * cascadeChunkSize;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "Engine/Graphics/RenderTools.h"
|
||||
#include "Engine/Profiler/Profiler.h"
|
||||
#include "Engine/Content/Assets/CubeTexture.h"
|
||||
#include "Engine/Graphics/Graphics.h"
|
||||
#include "Engine/Level/Scene/Lightmap.h"
|
||||
#include "Engine/Level/Actors/PostFxVolume.h"
|
||||
|
||||
@@ -192,9 +193,8 @@ void RenderList::AddSettingsBlend(IPostFxSettingsProvider* provider, float weigh
|
||||
void RenderList::BlendSettings()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
|
||||
Sorting::QuickSort(Blendable.Get(), Blendable.Count());
|
||||
|
||||
Settings = Graphics::PostProcessSettings;
|
||||
for (auto& b : Blendable)
|
||||
{
|
||||
b.Provider->Blend(Settings, b.Weight);
|
||||
|
||||
@@ -927,5 +927,29 @@ namespace FlaxEngine
|
||||
else
|
||||
stream.Write(0);
|
||||
}
|
||||
|
||||
internal static void InitStructure(object obj, Type type)
|
||||
{
|
||||
var fields = type.GetFields(BindingFlags.Default | BindingFlags.Instance | BindingFlags.Public);
|
||||
for (var i = 0; i < fields.Length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
var fieldType = field.FieldType;
|
||||
var attr = field.GetCustomAttribute<System.ComponentModel.DefaultValueAttribute>();
|
||||
if (attr != null)
|
||||
{
|
||||
var value = attr.Value;
|
||||
if (value != null && value.GetType() != fieldType)
|
||||
value = Convert.ChangeType(value, fieldType);
|
||||
field.SetValue(obj, value);
|
||||
}
|
||||
else if (fieldType.IsValueType)
|
||||
{
|
||||
var fieldValue = Activator.CreateInstance(fieldType);
|
||||
InitStructure(fieldValue, fieldType);
|
||||
field.SetValue(obj, fieldValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user