/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #pragma once #include #include #include #include #include #include #include #include // for education purposes #include #include namespace AZ { namespace Render { class PostProcessSettings; // The post process sub-settings class for the exposure control feature over // full screen deferred fog. // The fog is calculated using the linear depth and turbulence texture with two blended // octaves that emulate the fog thickness and motion along the view ray direction. // // [GFX TODO] most methods in this class can be auto generated using a reflection mechanism // based on the PerPass Srg. Currently we don't have such a reflection system in place // and so, a temporary approach demonstrating partial reflection through preprocessor // macros is used. class DeferredFogSettings final : public DeferredFogSettingsInterface, public PostProcessBase { friend class DeferredFogPass; friend class PostProcessSettings; friend class PostProcessFeatureProcessor; public: AZ_RTTI(DeferredFogSettings, "{FD822CC5-4E7B-4471-AA7D-1FCDF6CAC979}", AZ::Render::DeferredFogSettingsInterface, AZ::Render::PostProcessBase); AZ_CLASS_ALLOCATOR(AZ::Render::DeferredFogSettings, SystemAllocator, 0); DeferredFogSettings(PostProcessFeatureProcessor* featureProcessor); DeferredFogSettings(); ~DeferredFogSettings() = default; // DeferredFogSettingsInterface overrides... void OnSettingsChanged(); bool GetSettingsNeedUpdate() { return m_needUpdate; } void SetSettingsNeedUpdate(bool needUpdate) { m_needUpdate = needUpdate; } void SetEnabled(bool value); virtual bool GetEnabled() const override { return m_enabled; } virtual void SetInitialized(bool isInitialized) override { m_isInitialized = isInitialized; } virtual bool IsInitialized() override { return m_isInitialized; } virtual void SetUseNoiseTextureShaderOption(bool value) override { m_useNoiseTextureShaderOption = value; } virtual bool GetUseNoiseTextureShaderOption() override { return m_useNoiseTextureShaderOption; } virtual void SetEnableFogLayerShaderOption(bool value) override { m_enableFogLayerShaderOption = value; } virtual bool GetEnableFogLayerShaderOption() override { return m_enableFogLayerShaderOption; } // Called by the post effects feature processor for doing per frame prep if required void Simulate([[maybe_unused]]float deltaTime) {}; // Applies settings from this onto target using override settings and passed alpha value for blending void ApplySettingsTo(DeferredFogSettings* target, float alpha) const; Data::Instance LoadStreamingImage(const char* textureFilePath, const char* sampleName); //--------------------------------------------------------- // Generate Get / Set override methods #define AZ_GFX_COMMON_PARAM(ValueType, Name, MemberName, DefaultValue) \ ValueType Get##Name() const override; \ void Set##Name(ValueType val) override; \ #include #include #include private: //--------------------------------------------------------- // SRG constants #define AZ_GFX_COMMON_PARAM(ValueType, Name, MemberName, DefaultValue) \ ValueType MemberName = DefaultValue; \ #include #include #include //--------------------------------------------------------- // SRG constants binding indices #define AZ_GFX_COMMON_PARAM(ValueType, Name, MemberName, DefaultValue) \ RHI::ShaderInputConstantIndex MemberName##SrgIndex; \ #include // Change the handling for texture handles #undef AZ_GFX_TEXTURE2D_PARAM #define AZ_GFX_TEXTURE2D_PARAM(Name, MemberName, DefaultValue) \ RHI::ShaderInputImageIndex MemberName##SrgIndex; \ #include #include //--------------------------------------------------------- // Generate all Image members instances // Set all macros to be empty, but override the texture for defining image members #include // Macro to replace only the image macro for defining only image resources #undef AZ_GFX_TEXTURE2D_PARAM #define AZ_GFX_TEXTURE2D_PARAM(Name, MemberName, DefaultValue) \ Data::Instance MemberName##Image; \ #include #include PostProcessSettings* m_parentSettings = nullptr; // 'm_enabled' indicates if the pass should be enabled. By default this is set to true since if the // pass is data driven enabled, the default settings should not disable it. If it is driven by // an engine component, these settings will be replaced by the component's settings controlled by // the user. bool m_enabled = true; // Indication if the SRG indices were set bool m_isInitialized = false; // Indicates that the srg indices were set bool m_needUpdate = true; bool m_useNoiseTextureShaderOption = true; bool m_enableFogLayerShaderOption = true; }; } }