// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #pragma once #include "BoxVolume.h" #include "Engine/Graphics/PostProcessSettings.h" #include "Engine/Level/Scene/SceneRendering.h" /// /// A special type of volume that blends custom set of post process settings into the rendering. /// API_CLASS() class FLAXENGINE_API PostFxVolume : public BoxVolume, public IPostFxSettingsProvider { DECLARE_SCENE_OBJECT(PostFxVolume); private: int32 _priority; float _blendRadius; float _blendWeight; bool _isBounded; public: /// /// The ambient occlusion effect settings. /// API_FIELD(Attributes="EditorDisplay(\"Ambient Occlusion\"), EditorOrder(100)") AmbientOcclusionSettings AmbientOcclusion; /// /// The bloom effect settings. /// API_FIELD(Attributes="EditorDisplay(\"Bloom\"), EditorOrder(200)") BloomSettings Bloom; /// /// The tone mapping effect settings. /// API_FIELD(Attributes="EditorDisplay(\"Tone Mapping\"), EditorOrder(300)") ToneMappingSettings ToneMapping; /// /// The color grading effect settings. /// API_FIELD(Attributes="EditorDisplay(\"Color Grading\"), EditorOrder(400)") ColorGradingSettings ColorGrading; /// /// The eye adaptation effect settings. /// API_FIELD(Attributes="EditorDisplay(\"Eye Adaptation\"), EditorOrder(500)") EyeAdaptationSettings EyeAdaptation; /// /// The camera artifacts effect settings. /// API_FIELD(Attributes="EditorDisplay(\"Camera Artifacts\"), EditorOrder(600)") CameraArtifactsSettings CameraArtifacts; /// /// The lens flares effect settings. /// API_FIELD(Attributes="EditorDisplay(\"Lens Flares\"), EditorOrder(700)") LensFlaresSettings LensFlares; /// /// The depth of field effect settings. /// API_FIELD(Attributes="EditorDisplay(\"Depth Of Field\"), EditorOrder(800)") DepthOfFieldSettings DepthOfField; /// /// The motion blur effect settings. /// API_FIELD(Attributes="EditorDisplay(\"Motion Blur\"), EditorOrder(900)") MotionBlurSettings MotionBlur; /// /// The screen space reflections effect settings. /// API_FIELD(Attributes="EditorDisplay(\"Screen Space Reflections\"), EditorOrder(1000)") ScreenSpaceReflectionsSettings ScreenSpaceReflections; /// /// The anti-aliasing effect settings. /// API_FIELD(Attributes="EditorDisplay(\"Anti Aliasing\"), EditorOrder(1100)") AntiAliasingSettings AntiAliasing; /// /// The PostFx materials rendering settings. /// API_FIELD(Attributes="EditorDisplay(\"PostFx Materials\"), NoAnimate, EditorOrder(1200)") PostFxMaterialsSettings PostFxMaterials; public: /// /// Gets the order in which multiple volumes are blended together. /// The volume with the highest priority takes precedence over all other overlapping volumes. /// /// The result. API_PROPERTY(Attributes="EditorDisplay(\"PostFx Volume\"), EditorOrder(60)") FORCE_INLINE int32 GetPriority() const { return _priority; } /// /// Sets the order in which multiple volumes are blended together. /// The volume with the highest priority takes precedence over all other overlapping volumes. /// /// The value. API_PROPERTY() FORCE_INLINE void SetPriority(int32 value) { _priority = value; } /// /// Gets the distance inside the volume at which blending with the volume's settings occurs. /// /// The result. API_PROPERTY(Attributes="EditorDisplay(\"PostFx Volume\"), EditorOrder(70)") FORCE_INLINE float GetBlendRadius() const { return _blendRadius; } /// /// Sets the distance inside the volume at which blending with the volume's settings occurs. /// /// The value. API_PROPERTY() void SetBlendRadius(float value) { _blendRadius = Math::Clamp(value, 0.0f, 1000.0f); } /// /// Gets the amount of influence the volume's properties have. 0 is no effect; 1 is full effect. /// /// The result. API_PROPERTY(Attributes="EditorDisplay(\"PostFx Volume\"), EditorOrder(80)") FORCE_INLINE float GetBlendWeight() const { return _blendWeight; } /// /// Sets the amount of influence the volume's properties have. 0 is no effect; 1 is full effect. /// /// The value. API_PROPERTY() void SetBlendWeight(float value) { _blendWeight = Math::Saturate(value); } /// /// Gets the value indicating whether the bounds of the volume are taken into account. /// If false, the volume affects the entire world, regardless of its bounds. /// If true, the volume only has an effect within its bounds. /// /// The result. API_PROPERTY(Attributes="EditorDisplay(\"PostFx Volume\"), EditorOrder(90)") FORCE_INLINE bool GetIsBounded() const { return _isBounded; } /// /// Sets the value indicating whether the bounds of the volume are taken into account. /// If false, the volume affects the entire world, regardless of its bounds. /// If true, the volume only has an effect within its bounds. /// /// The value. API_PROPERTY() FORCE_INLINE void SetIsBounded(bool value) { _isBounded = value; } public: /// /// Adds the post fx material to the settings. /// /// The material. API_FUNCTION() void AddPostFxMaterial(MaterialBase* material); /// /// Removes the post fx material from the settings. /// /// The material. API_FUNCTION() void RemovePostFxMaterial(MaterialBase* material); public: // [BoxVolume] bool HasContentLoaded() const override; void Serialize(SerializeStream& stream, const void* otherObj) override; void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override; // [IPostFxSettingsProvider] void Collect(RenderContext& renderContext) override; void Blend(PostProcessSettings& other, float weight) override; protected: // [BoxVolume] void OnEnable() override; void OnDisable() override; #if USE_EDITOR Color GetWiresColor() override; #endif };