Enable fog in physical sky component to blend with deferred fog (#1320)
This commit is contained in:
@@ -40,6 +40,11 @@ partial ShaderResourceGroup SceneSrg
|
||||
ConstantBuffer<PhysicalSkyData> m_physicalSkyData;
|
||||
bool m_physicalSky;
|
||||
|
||||
float m_fogTopHeight;
|
||||
float m_fogBottomHeight;
|
||||
float4 m_fogColor;
|
||||
bool m_fogEnable;
|
||||
|
||||
TextureCube m_skyboxCubemap;
|
||||
float4x4 m_cubemapRotationMatrix;
|
||||
float m_cubemapExposure;
|
||||
|
||||
@@ -152,6 +152,18 @@ PSOutput MainPS(VSOutput input)
|
||||
float3 srgbColor = Z * HosekWilkie(cosGamma, gamma, cosTheta) * SceneSrg::m_physicalSkyData.m_physicalSkyAndSunIntensity.x;
|
||||
color = TransformColor(srgbColor, ColorSpaceId::LinearSRGB, ColorSpaceId::ACEScg);
|
||||
}
|
||||
}
|
||||
|
||||
if (SceneSrg::m_fogEnable)
|
||||
{
|
||||
if (input.m_cubemapCoord.z >= 0.0 && input.m_cubemapCoord.z <= SceneSrg::m_fogTopHeight)
|
||||
{
|
||||
color = lerp(SceneSrg::m_fogColor.rgb, color, input.m_cubemapCoord.z > 0.0 ? input.m_cubemapCoord.z/SceneSrg::m_fogTopHeight : 0.0);
|
||||
}
|
||||
else if (input.m_cubemapCoord.z < 0.0 && input.m_cubemapCoord.z >= -SceneSrg::m_fogBottomHeight)
|
||||
{
|
||||
color = SceneSrg::m_fogColor.rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
+10
-1
@@ -16,6 +16,7 @@
|
||||
#include <Atom/RPI.Reflect/Image/Image.h>
|
||||
#include <Atom/Feature/CoreLights/PhotometricValue.h>
|
||||
#include <AzCore/Math/Matrix4x4.h>
|
||||
#include <SkyBox/SkyBoxFogSettings.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -49,8 +50,9 @@ namespace AZ
|
||||
AZ_RTTI(AZ::Render::SkyBoxFeatureProcessorInterface, "{71061869-1190-4451-A337-E9CFF16441B4}");
|
||||
|
||||
virtual void Enable(bool enable) = 0;
|
||||
virtual bool IsEnable() = 0;
|
||||
virtual bool IsEnabled() = 0;
|
||||
virtual void SetSkyboxMode(SkyBoxMode mode) = 0;
|
||||
virtual void SetFogSettings(const SkyBoxFogSettings& fogSettings) = 0;
|
||||
|
||||
// HDRiSkyBox
|
||||
virtual void SetCubemap(Data::Instance<RPI::Image> cubemap) = 0;
|
||||
@@ -64,6 +66,13 @@ namespace AZ
|
||||
virtual void SetSkyIntensity(float intensity, PhotometricUnit type) = 0;
|
||||
virtual void SetSunIntensity(float intensity, PhotometricUnit type) = 0;
|
||||
virtual void SetSunRadiusFactor(float factor) = 0;
|
||||
|
||||
// Fog Settings
|
||||
virtual void SetFogEnabled(bool enable) = 0;
|
||||
virtual bool IsFogEnabled() = 0;
|
||||
virtual void SetFogColor(const AZ::Color &color) = 0;
|
||||
virtual void SetFogTopHeight(float topHeight) = 0;
|
||||
virtual void SetFogBottomHeight(float bottomHeight) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 <AzCore/Component/ComponentBus.h>
|
||||
#include <AzCore/Math/Color.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
// EBus to get and set fog settings rendered with the sky
|
||||
class SkyBoxFogRequests
|
||||
: public ComponentBus
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(AZ::Render::SkyBoxFogRequests, "{4D477566-54B1-49EC-B8FE-4264EA228482}");
|
||||
|
||||
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
|
||||
virtual ~SkyBoxFogRequests() {}
|
||||
|
||||
virtual void SetEnabled(bool enable) = 0;
|
||||
virtual bool IsEnabled() const = 0;
|
||||
virtual void SetColor(const AZ::Color& color) = 0;
|
||||
virtual const AZ::Color& GetColor() const = 0;
|
||||
// Set and Get the height upwards from the horizon
|
||||
virtual void SetTopHeight(float topHeight) = 0;
|
||||
virtual float GetTopHeight() const = 0;
|
||||
// Set and Get the height downwards from the horizon
|
||||
virtual void SetBottomHeight(float bottomHeight) = 0;
|
||||
virtual float GetBottomHeight() const = 0;
|
||||
};
|
||||
|
||||
typedef AZ::EBus<SkyBoxFogRequests> SkyBoxFogRequestBus;
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@
|
||||
#include <PostProcessing/BloomCompositePass.h>
|
||||
#include <ScreenSpace/DeferredFogPass.h>
|
||||
#include <Shadows/ProjectedShadowFeatureProcessor.h>
|
||||
|
||||
#include <SkyBox/SkyBoxFogSettings.h>
|
||||
#include <SkyBox/SkyBoxFeatureProcessor.h>
|
||||
|
||||
#include <Atom/RPI.Public/Pass/PassSystemInterface.h>
|
||||
@@ -117,6 +117,7 @@ namespace AZ
|
||||
TransformServiceFeatureProcessor::Reflect(context);
|
||||
ProjectedShadowFeatureProcessor::Reflect(context);
|
||||
SkyBoxFeatureProcessor::Reflect(context);
|
||||
SkyBoxFogSettings::Reflect(context);
|
||||
UseTextureFunctor::Reflect(context);
|
||||
DrawListFunctor::Reflect(context);
|
||||
SubsurfaceTransmissionParameterFunctor::Reflect(context);
|
||||
|
||||
@@ -89,6 +89,10 @@ namespace AZ
|
||||
m_cubemapIndex.Reset();
|
||||
m_cubemapRotationMatrixIndex.Reset();
|
||||
m_cubemapExposureIndex.Reset();
|
||||
m_fogEnableIndex.Reset();
|
||||
m_fogColorIndex.Reset();
|
||||
m_fogTopHeightIndex.Reset();
|
||||
m_fogBottomHeightIndex.Reset();
|
||||
|
||||
if (m_buffer)
|
||||
{
|
||||
@@ -160,6 +164,14 @@ namespace AZ
|
||||
m_mapBuffer = false;
|
||||
}
|
||||
|
||||
m_sceneSrg->SetConstant(m_fogEnableIndex, m_fogSettings.m_enable);
|
||||
if (m_fogSettings.m_enable)
|
||||
{
|
||||
m_sceneSrg->SetConstant(m_fogTopHeightIndex, m_fogSettings.m_topHeight);
|
||||
m_sceneSrg->SetConstant(m_fogBottomHeightIndex, m_fogSettings.m_bottomHeight);
|
||||
m_sceneSrg->SetConstant(m_fogColorIndex, m_fogSettings.m_color);
|
||||
}
|
||||
|
||||
m_sceneSrg->SetConstant(m_physicalSkyIndex, true);
|
||||
break;
|
||||
}
|
||||
@@ -213,7 +225,7 @@ namespace AZ
|
||||
m_enable = enable;
|
||||
}
|
||||
|
||||
bool SkyBoxFeatureProcessor::IsEnable()
|
||||
bool SkyBoxFeatureProcessor::IsEnabled()
|
||||
{
|
||||
return m_enable;
|
||||
}
|
||||
@@ -238,6 +250,36 @@ namespace AZ
|
||||
m_skyboxMode = mode;
|
||||
}
|
||||
|
||||
void SkyBoxFeatureProcessor::SetFogSettings(const SkyBoxFogSettings& fogSettings)
|
||||
{
|
||||
m_fogSettings = fogSettings;
|
||||
}
|
||||
|
||||
void SkyBoxFeatureProcessor::SetFogEnabled(bool enable)
|
||||
{
|
||||
m_fogSettings.m_enable = enable;
|
||||
}
|
||||
|
||||
bool SkyBoxFeatureProcessor::IsFogEnabled()
|
||||
{
|
||||
return m_fogSettings.m_enable;
|
||||
}
|
||||
|
||||
void SkyBoxFeatureProcessor::SetFogColor(const AZ::Color& color)
|
||||
{
|
||||
m_fogSettings.m_color = color;
|
||||
}
|
||||
|
||||
void SkyBoxFeatureProcessor::SetFogTopHeight(float topHeight)
|
||||
{
|
||||
m_fogSettings.m_topHeight = topHeight;
|
||||
}
|
||||
|
||||
void SkyBoxFeatureProcessor::SetFogBottomHeight(float bottomHeight)
|
||||
{
|
||||
m_fogSettings.m_bottomHeight = bottomHeight;
|
||||
}
|
||||
|
||||
void SkyBoxFeatureProcessor::SetSunPosition(SunPosition sunPosition)
|
||||
{
|
||||
m_skyNeedUpdate = true;
|
||||
|
||||
@@ -67,8 +67,14 @@ namespace AZ
|
||||
|
||||
// SkyBoxFeatureProcessorInterface overrides ...
|
||||
void Enable(bool enable) override;
|
||||
bool IsEnable() override;
|
||||
bool IsEnabled() override;
|
||||
void SetSkyboxMode(SkyBoxMode mode) override;
|
||||
void SetFogSettings(const SkyBoxFogSettings& fogSettings) override;
|
||||
void SetFogEnabled(bool enable) override;
|
||||
bool IsFogEnabled() override;
|
||||
void SetFogColor(const AZ::Color& color) override;
|
||||
void SetFogTopHeight(float topHeight) override;
|
||||
void SetFogBottomHeight(float bottomHeight) override;
|
||||
|
||||
void SetCubemapRotationMatrix(AZ::Matrix4x4 matrix) override;
|
||||
void SetCubemap(Data::Instance<RPI::Image> cubemap) override;
|
||||
@@ -145,6 +151,10 @@ namespace AZ
|
||||
RHI::ShaderInputNameIndex m_cubemapIndex = "m_skyboxCubemap";
|
||||
RHI::ShaderInputNameIndex m_cubemapRotationMatrixIndex = "m_cubemapRotationMatrix";
|
||||
RHI::ShaderInputNameIndex m_cubemapExposureIndex = "m_cubemapExposure";
|
||||
RHI::ShaderInputNameIndex m_fogEnableIndex = "m_fogEnable";
|
||||
RHI::ShaderInputNameIndex m_fogColorIndex = "m_fogColor";
|
||||
RHI::ShaderInputNameIndex m_fogTopHeightIndex = "m_fogTopHeight";
|
||||
RHI::ShaderInputNameIndex m_fogBottomHeightIndex = "m_fogBottomHeight";
|
||||
|
||||
bool m_skyNeedUpdate = true;
|
||||
bool m_sunNeedUpdate = true;
|
||||
@@ -152,6 +162,7 @@ namespace AZ
|
||||
|
||||
bool m_enable = false;
|
||||
SkyBoxMode m_skyboxMode = SkyBoxMode::None;
|
||||
SkyBoxFogSettings m_fogSettings;
|
||||
Data::Instance<RPI::ShaderResourceGroup> m_sceneSrg = nullptr;
|
||||
|
||||
Data::Instance<RPI::Image> m_cubemapTexture = nullptr;
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <SkyBox/SkyBoxFogSettings.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <Atom/Feature/SkyBox/SkyBoxFogBus.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
void SkyBoxFogSettings::Reflect(ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<SkyBoxFogSettings>()
|
||||
->Version(1)
|
||||
->Field("Enable", &SkyBoxFogSettings::m_enable)
|
||||
->Field("Color", &SkyBoxFogSettings::m_color)
|
||||
->Field("TopHeight", &SkyBoxFogSettings::m_topHeight)
|
||||
->Field("BottomHeight", &SkyBoxFogSettings::m_bottomHeight)
|
||||
;
|
||||
|
||||
if (auto editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<SkyBoxFogSettings>("SkyBoxFogSettings", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &SkyBoxFogSettings::m_enable, "Enable Fog", "Toggle fog on or off")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &SkyBoxFogSettings::m_color, "Fog Color", "Color of the fog")
|
||||
->Attribute(AZ::Edit::Attributes::ReadOnly, &SkyBoxFogSettings::IsFogDisabled)
|
||||
->DataElement(AZ::Edit::UIHandlers::Slider, &SkyBoxFogSettings::m_topHeight, "Fog Top Height", "Height of the fog upwards from the horizon")
|
||||
->Attribute(AZ::Edit::Attributes::ReadOnly, &SkyBoxFogSettings::IsFogDisabled)
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.0)
|
||||
->Attribute(AZ::Edit::Attributes::Max, 0.5)
|
||||
->Attribute(AZ::Edit::Attributes::Step, 0.01)
|
||||
->DataElement(AZ::Edit::UIHandlers::Slider, &SkyBoxFogSettings::m_bottomHeight, "Fog Bottom Height", "Height of the fog downwards from the horizon")
|
||||
->Attribute(AZ::Edit::Attributes::ReadOnly, &SkyBoxFogSettings::IsFogDisabled)
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.0)
|
||||
->Attribute(AZ::Edit::Attributes::Max, 0.3)
|
||||
->Attribute(AZ::Edit::Attributes::Step, 0.01)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<SkyBoxFogRequestBus>("SkyBoxFogRequestBus")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Category, "render")
|
||||
->Attribute(AZ::Script::Attributes::Module, "render")
|
||||
->Event("SetEnabled", &SkyBoxFogRequestBus::Events::SetEnabled)
|
||||
->Event("IsEnabled", &SkyBoxFogRequestBus::Events::IsEnabled)
|
||||
->Event("SetColor", &SkyBoxFogRequestBus::Events::SetColor)
|
||||
->Event("GetColor", &SkyBoxFogRequestBus::Events::GetColor)
|
||||
->Event("SetTopHeight", &SkyBoxFogRequestBus::Events::SetTopHeight)
|
||||
->Event("GetTopHeight", &SkyBoxFogRequestBus::Events::GetTopHeight)
|
||||
->Event("SetBottomHeight", &SkyBoxFogRequestBus::Events::SetBottomHeight)
|
||||
->Event("GetBottomHeight", &SkyBoxFogRequestBus::Events::GetBottomHeight)
|
||||
->VirtualProperty("Enable", "IsEnabled", "SetEnabled")
|
||||
->VirtualProperty("Color", "GetColor", "SetColor")
|
||||
->VirtualProperty("TopHeight", "GetTopHeight", "SetTopHeight")
|
||||
->VirtualProperty("BottomHeight", "GetTopHeight", "SetBottomHeight")
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
bool SkyBoxFogSettings::IsFogDisabled() const
|
||||
{
|
||||
return !m_enable;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 <AzCore/Math/Color.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
struct SkyBoxFogSettings final
|
||||
{
|
||||
AZ_RTTI(AZ::Render::SkyBoxFogSettings, "{DB13027C-BA92-4E46-B428-BB77C2A80C51}");
|
||||
|
||||
static void Reflect(ReflectContext* context);
|
||||
|
||||
SkyBoxFogSettings() = default;
|
||||
|
||||
bool IsFogDisabled() const;
|
||||
|
||||
AZ::Color m_color = AZ::Color::CreateOne();
|
||||
bool m_enable = false;
|
||||
float m_topHeight = 0.01;
|
||||
float m_bottomHeight = 0.0;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ set(FILES
|
||||
Include/Atom/Feature/PostProcessing/SMAAFeatureProcessorInterface.h
|
||||
Include/Atom/Feature/PostProcess/PostFxLayerCategoriesConstants.h
|
||||
Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h
|
||||
Include/Atom/Feature/SkyBox/SkyBoxFogBus.h
|
||||
Include/Atom/Feature/SkyBox/SkyboxConstants.h
|
||||
Include/Atom/Feature/SkyBox/SkyBoxLUT.h
|
||||
Include/Atom/Feature/SphericalHarmonics/SphericalHarmonicsUtility.h
|
||||
@@ -297,6 +298,8 @@ set(FILES
|
||||
Source/SkinnedMesh/SkinnedMeshVertexStreamProperties.h
|
||||
Source/SkyBox/SkyBoxFeatureProcessor.cpp
|
||||
Source/SkyBox/SkyBoxFeatureProcessor.h
|
||||
Source/SkyBox/SkyBoxFogSettings.h
|
||||
Source/SkyBox/SkyBoxFogSettings.cpp
|
||||
Source/TransformService/TransformServiceFeatureProcessor.cpp
|
||||
Source/Utils/GpuBufferHandler.cpp
|
||||
Source/LuxCore/LuxCoreTexturePass.cpp
|
||||
|
||||
+5
@@ -15,6 +15,7 @@
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <Atom/Feature/CoreLights/PhotometricValue.h>
|
||||
#include <Atom/Feature/SkyBox/SkyboxConstants.h>
|
||||
#include <SkyBox/SkyBoxFogSettings.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -35,6 +36,8 @@ namespace AZ
|
||||
int m_turbidity = 1;
|
||||
float m_sunRadiusFactor = 1.0f;
|
||||
|
||||
SkyBoxFogSettings m_skyBoxFogSettings;
|
||||
|
||||
//! Returns characters for a suffix for the light type including a space. " lm" for lumens for example.
|
||||
const char* GetIntensitySuffix() const;
|
||||
|
||||
@@ -45,6 +48,8 @@ namespace AZ
|
||||
//! Returns the maximum intensity value allowed depending on the m_intensityMode
|
||||
float GetSkyIntensityMax() const;
|
||||
float GetSunIntensityMax() const;
|
||||
|
||||
bool IsFogDisabled() const { return !m_skyBoxFogSettings.m_enable; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -68,13 +68,17 @@ namespace AZ
|
||||
->Attribute(AZ::Edit::Attributes::Min, 1)
|
||||
->Attribute(AZ::Edit::Attributes::Max, 10)
|
||||
->Attribute(AZ::Edit::Attributes::Step, 1)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &PhysicalSkyComponentConfig::m_skyBoxFogSettings, "Fog", "Fog settings for rendering on top of physical sky")
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<EditorPhysicalSkyComponent>()->RequestBus("PhysicalSkyRequestBus");
|
||||
behaviorContext->Class<EditorPhysicalSkyComponent>()
|
||||
->RequestBus("PhysicalSkyRequestBus")
|
||||
->RequestBus("SkyBoxFogRequestBus");
|
||||
|
||||
behaviorContext->ConstantProperty("EditorPhysicalSkyComponentTypeId", BehaviorConstant(Uuid(EditorPhysicalSkyComponentTypeId)))
|
||||
->Attribute(AZ::Script::Attributes::Module, "render")
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ namespace AZ
|
||||
m_featureProcessorInterface = RPI::Scene::GetFeatureProcessorForEntity<SkyBoxFeatureProcessorInterface>(entityId);
|
||||
|
||||
// only activate if there is no other skybox activate
|
||||
if (!m_featureProcessorInterface->IsEnable())
|
||||
if (!m_featureProcessorInterface->IsEnabled())
|
||||
{
|
||||
m_featureProcessorInterface->SetSkyboxMode(SkyBoxMode::Cubemap);
|
||||
m_featureProcessorInterface->Enable(true);
|
||||
|
||||
@@ -34,7 +34,9 @@ namespace AZ
|
||||
|
||||
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->Class<PhysicalSkyComponent>()->RequestBus("PhysicalSkyRequestBus");
|
||||
behaviorContext->Class<PhysicalSkyComponent>()
|
||||
->RequestBus("PhysicalSkyRequestBus")
|
||||
->RequestBus("SkyBoxFogRequestBus");
|
||||
|
||||
behaviorContext->ConstantProperty("PhysicalSkyComponentTypeId", BehaviorConstant(Uuid(PhysicalSkyComponentTypeId)))
|
||||
->Attribute(AZ::Script::Attributes::Module, "render")
|
||||
|
||||
+1
@@ -29,6 +29,7 @@ namespace AZ
|
||||
->Field("SunIntensity", &PhysicalSkyComponentConfig::m_sunIntensity)
|
||||
->Field("Turbidity", &PhysicalSkyComponentConfig::m_turbidity)
|
||||
->Field("SunRadiusFactor", &PhysicalSkyComponentConfig::m_sunRadiusFactor)
|
||||
->Field("FogSettings", &PhysicalSkyComponentConfig::m_skyBoxFogSettings)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
+53
-5
@@ -12,8 +12,6 @@
|
||||
|
||||
#include <SkyBox/PhysicalSkyComponentController.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
|
||||
#include <Atom/RPI.Public/Scene.h>
|
||||
|
||||
namespace AZ
|
||||
@@ -34,6 +32,9 @@ namespace AZ
|
||||
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<PhysicalSkyRequestBus>("PhysicalSkyRequestBus")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Category, "render")
|
||||
->Attribute(AZ::Script::Attributes::Module, "render")
|
||||
->Event("SetTurbidity", &PhysicalSkyRequestBus::Events::SetTurbidity)
|
||||
->Event("GetTurbidity", &PhysicalSkyRequestBus::Events::GetTurbidity)
|
||||
->Event("SetSunRadiusFactor", &PhysicalSkyRequestBus::Events::SetSunRadiusFactor)
|
||||
@@ -76,7 +77,7 @@ namespace AZ
|
||||
m_featureProcessorInterface = RPI::Scene::GetFeatureProcessorForEntity<SkyBoxFeatureProcessorInterface>(entityId);
|
||||
|
||||
// only activate if there is no other skybox activate
|
||||
if (!m_featureProcessorInterface->IsEnable())
|
||||
if (!m_featureProcessorInterface->IsEnabled())
|
||||
{
|
||||
m_featureProcessorInterface->SetSkyboxMode(SkyBoxMode::PhysicalSky);
|
||||
m_featureProcessorInterface->Enable(true);
|
||||
@@ -95,8 +96,10 @@ namespace AZ
|
||||
|
||||
const AZ::Transform& transform = m_transformInterface ? m_transformInterface->GetWorldTM() : Transform::Identity();
|
||||
m_featureProcessorInterface->SetSunPosition(GetSunTransform(transform));
|
||||
m_featureProcessorInterface->SetFogSettings(m_configuration.m_skyBoxFogSettings);
|
||||
|
||||
PhysicalSkyRequestBus::Handler::BusConnect(m_entityId);
|
||||
SkyBoxFogRequestBus::Handler::BusConnect(m_entityId);
|
||||
TransformNotificationBus::Handler::BusConnect(m_entityId);
|
||||
|
||||
m_isActive = true;
|
||||
@@ -113,8 +116,9 @@ namespace AZ
|
||||
// Run deactivate if this skybox is activate
|
||||
if (m_isActive)
|
||||
{
|
||||
PhysicalSkyRequestBus::Handler::BusDisconnect(m_entityId);
|
||||
TransformNotificationBus::Handler::BusDisconnect(m_entityId);
|
||||
PhysicalSkyRequestBus::Handler::BusDisconnect();
|
||||
SkyBoxFogRequestBus::Handler::BusDisconnect();
|
||||
TransformNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
m_featureProcessorInterface->Enable(false);
|
||||
m_featureProcessorInterface = nullptr;
|
||||
@@ -229,5 +233,49 @@ namespace AZ
|
||||
|
||||
return SunPosition(atan2(sunPosition.GetZ(), sunPosition.GetX()), asin(sunPosition.GetY()));
|
||||
}
|
||||
|
||||
void PhysicalSkyComponentController::SetEnabled(bool enable)
|
||||
{
|
||||
m_configuration.m_skyBoxFogSettings.m_enable = enable;
|
||||
m_featureProcessorInterface->SetFogEnabled(enable);
|
||||
}
|
||||
|
||||
bool PhysicalSkyComponentController::IsEnabled() const
|
||||
{
|
||||
return m_configuration.m_skyBoxFogSettings.m_enable;
|
||||
}
|
||||
|
||||
void PhysicalSkyComponentController::SetColor(const AZ::Color& color)
|
||||
{
|
||||
m_configuration.m_skyBoxFogSettings.m_color = color;
|
||||
m_featureProcessorInterface->SetFogColor(color);
|
||||
}
|
||||
|
||||
const AZ::Color& PhysicalSkyComponentController::GetColor() const
|
||||
{
|
||||
return m_configuration.m_skyBoxFogSettings.m_color;
|
||||
}
|
||||
|
||||
void PhysicalSkyComponentController::SetTopHeight(float topHeight)
|
||||
{
|
||||
m_configuration.m_skyBoxFogSettings.m_topHeight = topHeight;
|
||||
m_featureProcessorInterface->SetFogTopHeight(topHeight);
|
||||
}
|
||||
|
||||
float PhysicalSkyComponentController::GetTopHeight() const
|
||||
{
|
||||
return m_configuration.m_skyBoxFogSettings.m_topHeight;
|
||||
}
|
||||
|
||||
void PhysicalSkyComponentController::SetBottomHeight(float bottomHeight)
|
||||
{
|
||||
m_configuration.m_skyBoxFogSettings.m_bottomHeight = bottomHeight;
|
||||
m_featureProcessorInterface->SetFogBottomHeight(bottomHeight);
|
||||
}
|
||||
|
||||
float PhysicalSkyComponentController::GetBottomHeight() const
|
||||
{
|
||||
return m_configuration.m_skyBoxFogSettings.m_bottomHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-1
@@ -16,6 +16,7 @@
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AtomLyIntegration/CommonFeatures/SkyBox/PhysicalSkyComponentConfig.h>
|
||||
#include <AtomLyIntegration/CommonFeatures/SkyBox/PhysicalSkyBus.h>
|
||||
#include <Atom/Feature/SkyBox/SkyBoxFogBus.h>
|
||||
#include <Atom/Feature/SkyBox/SkyBoxFeatureProcessorInterface.h>
|
||||
|
||||
namespace AZ
|
||||
@@ -25,6 +26,7 @@ namespace AZ
|
||||
class PhysicalSkyComponentController final
|
||||
: public TransformNotificationBus::Handler
|
||||
, public PhysicalSkyRequestBus::Handler
|
||||
, public SkyBoxFogRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
friend class EditorPhysicalSkyComponent;
|
||||
@@ -63,7 +65,17 @@ namespace AZ
|
||||
float GetSunIntensity(PhotometricUnit unit) override;
|
||||
float GetSunIntensity() override;
|
||||
|
||||
//! Get Sun azimuth and altitude from entity transfom, without scale
|
||||
// SkyBoxFogRequestBus::Handler overrides ...
|
||||
void SetEnabled(bool enable) override;
|
||||
bool IsEnabled() const override;
|
||||
void SetColor(const AZ::Color& color) override;
|
||||
const AZ::Color& GetColor() const override;
|
||||
void SetTopHeight(float topHeight) override;
|
||||
float GetTopHeight() const override;
|
||||
void SetBottomHeight(float bottomHeight) override;
|
||||
float GetBottomHeight() const override;
|
||||
|
||||
//! Get Sun azimuth and altitude from entity transform, without scale
|
||||
SunPosition GetSunTransform(const AZ::Transform& world);
|
||||
|
||||
TransformInterface* m_transformInterface = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user