Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,4 @@
[RC PostFxLayerCategories]
glob=*.postfxlayercategories
params=copy
productAssetType={A18B1B11-4C1E-4C1B-9643-178E8ED27019}
@@ -0,0 +1,130 @@
{
"configurations": [
{
"autoSelect": false,
"displayName": "Photo Studio 01",
"skyboxImageAsset": {
"assetId": {
"guid": "{B78C84E9-45BE-5A50-8898-177B33B8DA84}",
"subId": 1000
},
"assetHint": "envhdri/photo_studio_01_4k_iblskyboxcm.exr.streamingimage"
},
"iblSpecularImageAsset": {
"assetId": {
"guid": "{B78C84E9-45BE-5A50-8898-177B33B8DA84}",
"subId": 2000
},
"assetHint": "envhdri/photo_studio_01_4k_iblskyboxcm_iblspecular.exr.streamingimage"
},
"iblDiffuseImageAsset": {
"assetId": {
"guid": "{B78C84E9-45BE-5A50-8898-177B33B8DA84}",
"subId": 3000
},
"assetHint": "envhdri/photo_studio_01_4k_iblskyboxcm_ibldiffuse.exr.streamingimage"
},
"iblExposure": 0.0,
"skyboxExposure": 0.0,
"exposure": {
"compensateValue": 0.0,
"exposureControlType": 0,
"lightAdaptationSensitivity": 0.949999988079071,
"lightAdaptationScale": 0.8500000238418579,
"lightAdaptationSpeedLimit": 8.0,
"darkAdaptationSensitivity": 0.949999988079071,
"darkAdaptationScale": 0.8500000238418579,
"darkAdaptationSpeedLimit": 8.0,
"lightDarkExposureBorder": 0.0,
"autoExposureMin": -10.0,
"autoExposureMax": 10.0,
"eyeAdaptationDelayTime": 0.5
},
"lights": [
{
"direction": [
0.15000000596046449,
-0.15000000596046449,
-1.0
],
"color": [
1.0,
1.0,
1.0,
1.0
],
"intensity": 1.0,
"shadowCascadeCount": 4,
"shadowRatioLogarithmUniform": 1.0,
"shadowFarClipDistance": 20.0,
"shadowmapSize": "Size2048",
"enableShadowDebugColoring": false
}
],
"shadowCatcherOpacity": 0.25
},
{
"autoSelect": false,
"displayName": "Photo Studio 01 (Alt)",
"skyboxImageAsset": {
"assetId": {
"guid": "{B78C84E9-45BE-5A50-8898-177B33B8DA84}",
"subId": 3000
},
"assetHint": "envhdri/photo_studio_01_4k_iblskyboxcm_ibldiffuse.exr.streamingimage"
},
"iblSpecularImageAsset": {
"assetId": {
"guid": "{B78C84E9-45BE-5A50-8898-177B33B8DA84}",
"subId": 2000
},
"assetHint": "envhdri/photo_studio_01_4k_iblskyboxcm_iblspecular.exr.streamingimage"
},
"iblDiffuseImageAsset": {
"assetId": {
"guid": "{B78C84E9-45BE-5A50-8898-177B33B8DA84}",
"subId": 3000
},
"assetHint": "envhdri/photo_studio_01_4k_iblskyboxcm_ibldiffuse.exr.streamingimage"
},
"iblExposure": 0.0,
"skyboxExposure": 0.0,
"exposure": {
"compensateValue": 0.0,
"exposureControlType": 0,
"lightAdaptationSensitivity": 0.949999988079071,
"lightAdaptationScale": 0.8500000238418579,
"lightAdaptationSpeedLimit": 8.0,
"darkAdaptationSensitivity": 0.949999988079071,
"darkAdaptationScale": 0.8500000238418579,
"darkAdaptationSpeedLimit": 8.0,
"lightDarkExposureBorder": 0.0,
"autoExposureMin": -10.0,
"autoExposureMax": 10.0,
"eyeAdaptationDelayTime": 0.5
},
"lights": [
{
"direction": [
0.15000000596046449,
-0.15000000596046449,
-1.0
],
"color": [
1.0,
1.0,
1.0,
1.0
],
"intensity": 1.0,
"shadowCascadeCount": 4,
"shadowRatioLogarithmUniform": 1.0,
"shadowFarClipDistance": 20.0,
"shadowmapSize": "Size2048",
"enableShadowDebugColoring": false
}
],
"shadowCatcherOpacity": 0.15000000596046449
}
]
}
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3791948b506c80c89ab9524f30a96514fb20d855d2391740707f48e1515effcd
size 50364729
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b96d93f587d8d4d97912e7b84f147f830bc3437fa2ae1fcb5455e0401245d347
size 31264
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6fea35d103f199d8cf44f14bc08092ddce76ad1882569b9d068309bc40f73a43
size 5794788
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:95b46ba4980344b6121603f0f24bba91bafac99f6c907ead78dc2b0aeb969e57
size 2479648
@@ -0,0 +1,19 @@
<ObjectStream version="3">
<Class name="EditorPostFxLayerCategoriesAsset" type="{A18B1B11-4C1E-4C1B-9643-178E8ED27019}">
<Class name="AZStd::map" field="Layer Categories" type="{5B4970CC-26DE-51A3-83E7-1BC3A7E8E3C3}">
<Class name="AZStd::pair" field="element" type="{279D3EEE-F9CE-57FA-986E-D24E57211795}">
<Class name="AZStd::string" field="value1" value="Camera" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="int" field="value2" value="100" type="{72039442-EB38-4D42-A1AD-CB68F7E0EEF6}"/>
</Class>
<Class name="AZStd::pair" field="element" type="{279D3EEE-F9CE-57FA-986E-D24E57211795}">
<Class name="AZStd::string" field="value1" value="Level" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="int" field="value2" value="1000" type="{72039442-EB38-4D42-A1AD-CB68F7E0EEF6}"/>
</Class>
<Class name="AZStd::pair" field="element" type="{279D3EEE-F9CE-57FA-986E-D24E57211795}">
<Class name="AZStd::string" field="value1" value="Volume" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="int" field="value2" value="10" type="{72039442-EB38-4D42-A1AD-CB68F7E0EEF6}"/>
</Class>
</Class>
</Class>
</ObjectStream>
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:513f47f6fea5105f603170a8881b7e3b1cd2c4258636d64a6399c725032b500d
size 38689
@@ -0,0 +1,12 @@
#
# 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.
#
add_subdirectory(Code)
@@ -0,0 +1,97 @@
#
# 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.
#
ly_get_list_relative_pal_filename(pal_source_dir ${CMAKE_CURRENT_LIST_DIR}/Source/Platform/${PAL_PLATFORM_NAME})
ly_get_list_relative_pal_filename(common_source_dir ${CMAKE_CURRENT_LIST_DIR}/Source/Platform/Common)
ly_add_target(
NAME AtomLyIntegration_CommonFeatures.Public HEADERONLY
NAMESPACE Gem
FILES_CMAKE
atomlyintegration_commonfeatures_public_files.cmake
INCLUDE_DIRECTORIES
INTERFACE
Include
BUILD_DEPENDENCIES
INTERFACE
Gem::Atom_Feature_Common.Public
)
ly_add_target(
NAME AtomLyIntegration_CommonFeatures.Static STATIC
NAMESPACE Gem
FILES_CMAKE
atomlyintegration_commonfeatures_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
.
Source
PUBLIC
Include
BUILD_DEPENDENCIES
PUBLIC
AZ::AzCore
AZ::AzFramework
Gem::AtomLyIntegration_CommonFeatures.Public
Gem::LmbrCentral.Static
Gem::GradientSignal.Static
Gem::Atom_Feature_Common.Static
Gem::Atom_Bootstrap.Headers
)
ly_add_target(
NAME AtomLyIntegration_CommonFeatures ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
NAMESPACE Gem
OUTPUT_NAME Gem.AtomLyIntegration_CommonFeatures.4e981f3b17394f5d84d674fff0f54f4f.v0.1.0
FILES_CMAKE
atomlyintegration_commonfeatures_shared_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
Include
BUILD_DEPENDENCIES
PRIVATE
Gem::AtomLyIntegration_CommonFeatures.Static
)
if(PAL_TRAIT_BUILD_HOST_TOOLS)
ly_add_target(
NAME AtomLyIntegration_CommonFeatures.Editor MODULE
NAMESPACE Gem
OUTPUT_NAME Gem.AtomLyIntegration_CommonFeatures.Editor.4e981f3b17394f5d84d674fff0f54f4f.v0.1.0
AUTOUIC
AUTOMOC
AUTORCC
FILES_CMAKE
atomlyintegration_commonfeatures_editor_files.cmake
${pal_source_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
.
Source
PUBLIC
Include
COMPILE_DEFINITIONS
PRIVATE
ATOMLYINTEGRATION_FEATURE_COMMON_EDITOR
BUILD_DEPENDENCIES
PRIVATE
Gem::AtomLyIntegration_CommonFeatures.Static
Gem::Atom_RPI.Edit
Gem::AtomToolsFramework.Static
Gem::AtomToolsFramework.Editor
AZ::SceneCore
AZ::SceneData
Legacy::EditorLib
Legacy::CryCommon
)
endif()
@@ -0,0 +1,125 @@
/*
* 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>
#include <AtomLyIntegration/CommonFeatures/CoreLights/AreaLightComponentConfig.h>
namespace AZ
{
namespace Render
{
class AreaLightRequests
: public ComponentBus
{
public:
AZ_RTTI(AZ::Render::AreaLightRequests, "{BC54532C-F3C8-4942-99FC-58D2E3D3DD54}");
//! Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~AreaLightRequests() {}
//! Gets an area light's color. This value is indepedent from its intensity.
virtual const Color& GetColor() const = 0;
//! Sets an area light's color. This value is indepedent from its intensity.
virtual void SetColor(const Color& color) = 0;
//! Gets an area light's intensity. This value is indepedent from its color.
virtual float GetIntensity() const = 0;
//! Gets whether an area light emits light in both directions from a 2D surface. Only applies to 2D shape types.
virtual bool GetLightEmitsBothDirections() const = 0;
//! Sets whether an area light emits light in both directions from a 2D surface. Only applies to 2D shape types.
virtual void SetLightEmitsBothDirections(bool value) = 0;
//! Gets whether the light is using the default high quality linearly transformed cosine lights (false) or a faster approximation (true).
virtual bool GetUseFastApproximation() const = 0;
//! Sets whether the light should use the default high quality linearly transformed cosine lights (false) or a faster approximation (true).
virtual void SetUseFastApproximation(bool useFastApproximation) = 0;
//! Gets an area light's photometric type.
virtual PhotometricUnit GetIntensityMode() const = 0;
//! Sets an area light's intensity and intensity mode. This value is indepedent from its color.
virtual void SetIntensity(float intensity, PhotometricUnit intensityMode) = 0;
//! Sets an area light's intensity. This value is indepedent from its color.
//! Assumes no change in the current photometric unit of the intensity.
virtual void SetIntensity(float intensity) = 0;
//! Gets the distance at which the area light will no longer affect lighting.
virtual float GetAttenuationRadius() const = 0;
//! Set the distance and which an area light will no longer affect lighitng. Setting this forces the RadiusCalculation to Explicit mode.
virtual void SetAttenuationRadius(float radius) = 0;
/*
* If this is set to Automatic, the radius will immediately be recalculated based on the intensity.
* If this is set to Explicit, the radius value will be unchanged from its previous value.
*/
virtual void SetAttenuationRadiusMode(LightAttenuationRadiusMode attenuationRadiusMode) = 0;
//! Sets the photometric unit to the one provided and converts the intensity to the photometric unit so actual light intensity remains constant.
virtual void ConvertToIntensityMode(PhotometricUnit intensityMode) = 0;
};
//! The EBus for requests to for setting and getting light component properties.
typedef AZ::EBus<AreaLightRequests> AreaLightRequestBus;
class AreaLightNotifications
: public ComponentBus
{
public:
AZ_RTTI(AZ::Render::AreaLightNotifications, "{7363728D-E3EE-4AC8-AAA7-C299782763F0}");
virtual ~AreaLightNotifications() {}
/**
* Signals that the color of the light changed.
* @param color A reference to the new color of the light.
*/
virtual void OnColorChanged(const Color& /*color*/) { }
/**
* Signals that the intensity of the light changed.
* @param intensity A reference to the new intensity of the light.
* @param intenstiyMode A reference to the intensity mode of the light (lux or lumens).
*/
virtual void OnIntensityChanged(float /*intensity*/, PhotometricUnit /*intenstiyMode*/) { }
/**
* Signals that the color or intensity of the light changed. This is useful when both the color and intensity are need in the same call.
* @param color A reference to the new color of the light.
* @param color A reference to the new intensity of the light.
*/
virtual void OnColorOrIntensityChanged(const Color& /*color*/, float /*intensity*/) { }
/**
* Signals that the attenuation radius of the light changed.
* @param attenuationRadius The distance at which this light no longer affects lighting.
*/
virtual void OnAttenutationRadiusChanged(float /*attenuationRadius*/) { }
};
//! The EBus for light notification events.
typedef AZ::EBus<AreaLightNotifications> AreaLightNotificationBus;
} // namespace Render
} // namespace AZ
@@ -0,0 +1,70 @@
/*
* 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/Component.h>
#include <AzCore/Math/Color.h>
#include <Atom/Feature/CoreLights/PhotometricValue.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/CoreLightsConstants.h>
#include <AzCore/Serialization/EditContext.h>
namespace AZ
{
namespace Render
{
struct AreaLightComponentConfig final
: public ComponentConfig
{
AZ_RTTI(AZ::Render::AreaLightComponentConfig, "{11C08FED-7F94-4926-8517-46D08E4DD837}", ComponentConfig);
static void Reflect(AZ::ReflectContext* context);
static constexpr float CutoffIntensity = 0.1f;
AZ::Color m_color = AZ::Color::CreateOne();
float m_intensity = 100.0f;
float m_attenuationRadius = 0.0f;
PhotometricUnit m_intensityMode = PhotometricUnit::Lumen;
LightAttenuationRadiusMode m_attenuationRadiusMode = LightAttenuationRadiusMode::Automatic;
bool m_lightEmitsBothDirections = false;
bool m_useFastApproximation = false;
AZ::Crc32 m_shapeType;
// The following functions provide information to an EditContext...
//! Returns true if m_attenuationRadiusMode is set to LightAttenuationRadiusMode::Automatic
bool IsAttenuationRadiusModeAutomatic() const;
//! Returns true if the shape type is a 2D surface
bool Is2DSurface() const;
//! Returns true if the light type supports a faster and less accurate approximation for the lighting algorithm.
bool SupportsFastApproximation() const;
//! Returns characters for a suffix for the light type including a space. " lm" for lumens for example.
const char* GetIntensitySuffix() const;
//! Returns the minimum intensity value allowed depending on the m_intensityMode
float GetIntensityMin() const;
//! Returns the maximum intensity value allowed depending on the m_intensityMode
float GetIntensityMax() const;
//! Returns the minimum intensity value for UI depending on the m_intensityMode, but users may still type in a lesser value depending on GetIntensityMin().
float GetIntensitySoftMin() const;
//! Returns the maximum intensity value for UI depending on the m_intensityMode, but users may still type in a greater value depending on GetIntensityMin().
float GetIntensitySoftMax() const;
};
}
}
@@ -0,0 +1,50 @@
/*
* 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/MathUtils.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <Atom/Feature/CoreLights/CoreLightsConstants.h>
namespace AZ
{
namespace Render
{
static constexpr const char* const AreaLightComponentTypeId = "{744B3961-6242-4461-983F-2817D9D29C30}";
static constexpr const char* const EditorAreaLightComponentTypeId = "{8B605C0C-9027-4E0B-BA8C-19E396F8F262}";
static constexpr const char* const PointLightComponentTypeId = "{0A0E44AB-F583-481F-8AE8-68C4B1F9CD05}";
static constexpr const char* const EditorPointLightComponentTypeId = "{C4D354BE-5247-41FD-9A8D-550C6772EE5B}";
static constexpr const char* const SpotLightComponentTypeId = "{441DF0EC-6B70-451E-AEBE-6452A17BB852}";
static constexpr const char* const EditorSpotLightComponentTypeId = "{9A32D37B-C5D2-43A7-B574-E2EA1CDC7D64}";
static constexpr const char* const DirectionalLightComponentTypeId = "{13054592-2753-46C2-B19E-59670D4CE03D}";
static constexpr const char* const EditorDirectionalLightComponentTypeId = "{45B97527-6E72-411B-BC23-00068CF01580}";
enum class LightAttenuationRadiusMode : uint8_t
{
Explicit,
Automatic,
};
inline void CoreLightConstantsReflect(ReflectContext* context)
{
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext
->Enum<(int)LightAttenuationRadiusMode::Automatic>("LightAttenuationRadiusMode_Automatic")
->Enum<(int)LightAttenuationRadiusMode::Explicit>("LightAttenuationRadiusMode_Explicit")
;
}
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,189 @@
/*
* 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/Component/EntityId.h>
#include <AzCore/Math/Color.h>
#include <Atom/Feature/CoreLights/PhotometricValue.h>
#include <Atom/Feature/CoreLights/ShadowConstants.h>
namespace AZ
{
namespace Render
{
class DirectionalLightRequests
: public ComponentBus
{
public:
//! Gets a directional light's color. This value is independent from its intensity.
//! @return directional light's color
virtual const Color& GetColor() const = 0;
//! Sets a directional light's color. This value is independent from its intensity.
//! @param color directional light's color
virtual void SetColor(const Color& color) = 0;
//! Gets a directional light's intensity. This value is independent from its color.
//! @return directional light's intensity
virtual float GetIntensity() const = 0;
//! Sets a directional light's intensity. This value is independent from its color.
//! @param intensity directional light's intensity
//! @param type The photometric unit of the intensity.
virtual void SetIntensity(float intensity, PhotometricUnit unit) = 0;
//! Sets a directional light's intensity. This value is independent from its color.
//! Assumes no change in the current photometric unit of the intensity.
//! @param intensity directional light's intensity
virtual void SetIntensity(float intensity) = 0;
//! Gets a directional light's angular diameter.
//! @return directional light's angular diameter in degrees.
virtual float GetAngularDiameter() const = 0;
//! Sets a directional light's angular diameter. This value should be small, for instance the sun is 0.5 degrees across.
//! @param angularDiameter Directional light's angular diameter in degrees.
virtual void SetAngularDiameter(float angularDiameter) = 0;
//! This gets shadowmap size (width/height).
//! @return shadowmap size.
virtual ShadowmapSize GetShadowmapSize() const = 0;
//! This specifies the size of shadowmaps (for each cascade) to size x size.
virtual void SetShadowmapSize(ShadowmapSize size) = 0;
//! This gets cascade count of the shadowmap.
//! @return cascade count
virtual uint32_t GetCascadeCount() const = 0;
//! This sets cascade count of the shadowmap
//! @param cascadeCount cascade count
virtual void SetCascadeCount(uint32_t cascadeCount) = 0;
//! This gets ratio between logarithm/uniform scheme to split view frustum.
//! @return the ratio (in [0,1]) between uniform scheme and logarithm scheme for splitting the view frustum into cascades.
//! ratio==0 means uniform and ratio==1 means logarithm.
//! uniform: the most detailed cascade covers wider area but less detailed.
//! logarithm: the most detailed cascade covers narrower area but more detailed.
//! The least detailed cascade is not affected by this parameter.
virtual float GetShadowmapFrustumSplitSchemeRatio() const = 0;
//! This sets ratio between logarithm/uniform scheme to split view frustum.
//! If this is called, frustum splitting becomes automatic
//! and the far depths given by SetCascadeFarDepth() is discarded.
//! @param ratio the ratio (in [0,1])
virtual void SetShadowmapFrustumSplitSchemeRatio(float ratio) = 0;
//! This gets the far depth of the cascade.
//! @return the far depth for each cascade.
virtual const Vector4& GetCascadeFarDepth() = 0;
//! This sets the far depth of the cascade.
//! If this is called, the ratio of frustum split scheme will be ignored.
//! @param farDepth the far depth to be set.
virtual void SetCascadeFarDepth(const Vector4& farDepth) = 0;
//! This gets the flag split of shadowmap frustum is automatic.
//! @return it is automatic if true, and it is manual if false.
virtual bool GetShadowmapFrustumSplitAutomatic() const = 0;
//! This sets the flag split of shadowmap frustum is automatic.
//! @param isAutomatic the flag to be set.
virtual void SetShadowmapFrustumSplitAutomatic(bool isAutomatic) = 0;
//! This gets the entity ID of the camera used for specifying view frustum to create shadowmaps.
//! @return camera entity ID.
virtual EntityId GetCameraEntityId() const = 0;
//! This sets the entity ID of the camera used for specifying view frustum to create shadowmaps.
//! @param entityId camera entity ID.
virtual void SetCameraEntityId(EntityId entityId) = 0;
//! This gets shadow specific far clip distance.
//! Pixels further than this value won't have shadows
//! Smaller values result in higher quality shadows
//! @return far clip distance
virtual float GetShadowFarClipDistance() const = 0;
//! This sets shadow specific far clip distance.
//! @param farDist the far clip distance for each cascade.
virtual void SetShadowFarClipDistance(float farDist) = 0;
//! This gets the height of the ground.
//! The position of view frustum is corrected using ground height
//! to get better quality of shadow around the area close to the camera.
//! To enable the correction, SetViewFrustumCorrectionEnabled(true) is required.
//! @return ground height
virtual float GetGroundHeight() const = 0;
//! This specifies the height of the ground.
//! @param groundHeight height of the ground
virtual void SetGroundHeight(float groundHeight) = 0;
//! This gets the flag whether view frustum correction is enabled not not.
//! The calculation of it is caused when position or configuration of the camera is changed.
//! @return flag of view frustum correction is enbled or not
virtual bool GetViewFrustumCorrectionEnabled() const = 0;
//! This specifies whether view frustum correction is enabled or not.
//! @param enabled flag specifying whether view frustum positions are corrected.
virtual void SetViewFrustumCorrectionEnabled(bool enabled) = 0;
//! This gets the flag whether debug coloring is enabled or not.
//! By debug coloring, we can see how cascading of shadowmaps works.
//! @return the flag whether debug coloring is enabled or not.
virtual bool GetDebugColoringEnabled() const = 0;
//! This specifies whether debug coloring is enabled or not.
//! @param enabled flag specifying whether debug coloring is added.
virtual void SetDebugColoringEnabled(bool enabled) = 0;
//! This gets the filter method of shadows.
//! @return filter method
virtual ShadowFilterMethod GetShadowFilterMethod() const = 0;
//! This specifies filter method of shadows.
//! @param method filter method.
virtual void SetShadowFilterMethod(ShadowFilterMethod method) = 0;
//! This gets the width of boundary between shadowed area and lit area.
//! @return Boundary width. The shadow is gradually changed the degree of shadowed.
virtual float GetSofteningBoundaryWidth() const = 0;
//! This specifies the width of boundary between shadowed area and lit area.
//! @param width Boundary width. The shadow is gradually changed the degree of shadowed.
//! If width == 0, softening edge is disabled. Units are in meters.
virtual void SetSofteningBoundaryWidth(float width) = 0;
//! This gets sample count to predict boundary of shadow.
//! @return Sample Count for prediction of whether the pixel is on the boundary (up to 16)
virtual uint32_t GetPredictionSampleCount() const = 0;
//! This sets sample count to predict boundary of shadow.
//! @param count Sample Count for prediction of whether the pixel is on the boundary (up to 16)
//! The value should be less than or equal to m_filteringSampleCount.
virtual void SetPredictionSampleCount(uint32_t count) = 0;
//! This gets the sample count for filtering of the shadow boundary.
//! @return Sample Count for filtering (up to 64)
virtual uint32_t GetFilteringSampleCount() const = 0;
//! This sets the sample count for filtering of the shadow boundary.
//! @param count Sample Count for filtering (up to 64)
virtual void SetFilteringSampleCount(uint32_t count) = 0;
};
using DirectionalLightRequestBus = EBus<DirectionalLightRequests>;
} // namespace Render
} // namespace AZ
@@ -0,0 +1,127 @@
/*
* 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/Component.h>
#include <AzCore/Math/Color.h>
#include <Atom/Feature/CoreLights/PhotometricValue.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/CoreLightsConstants.h>
namespace AZ
{
namespace Render
{
struct DirectionalLightComponentConfig final
: public ComponentConfig
{
AZ_RTTI(DirectionalLightConfiguration, "EB01B835-F9FE-4FF0-BDC4-455462BFE769", ComponentConfig);
static void Reflect(ReflectContext* context);
// The following functions provide information to an EditContext...
//! Returns characters for a suffix for the light type including a space. " lm" for lumens for example.
const char* GetIntensitySuffix() const;
//! Returns the minimum intensity value allowed depending on the m_intensityMode
float GetIntensityMin() const;
//! Returns the maximum intensity value allowed depending on the m_intensityMode
float GetIntensityMax() const;
//! Returns the minimum intensity value for UI depending on the m_intensityMode, but users may still type in a lesser value depending on GetIntensityMin().
float GetIntensitySoftMin() const;
//! Returns the maximum intensity value for UI depending on the m_intensityMode, but users may still type in a greater value depending on GetIntensityMin().
float GetIntensitySoftMax() const;
AZ::Color m_color = AZ::Color::CreateOne();
//! Lux or Ev100
PhotometricUnit m_intensityMode = PhotometricUnit::Ev100Illuminance;
//! Intensity in lux or Ev100 (depending on m_intensityMode)
float m_intensity = 4.0f;
//! Angular diameter of light in degrees, should be small. The sun is about 0.5.
float m_angularDiameter = 0.5f;
//! EntityId of the camera specifying view frustum to create shadowmaps.
EntityId m_cameraEntityId{ EntityId::InvalidEntityId };
//! Far depth clips for shadows.
float m_shadowFarClipDistance = 100.f;
//! Width/Height of shadowmap images.
ShadowmapSize m_shadowmapSize = MaxShadowmapImageSize;
//! Number of cascades.
uint32_t m_cascadeCount = 4;
//! Flag to switch splitting of shadowmap frustum to cascades automatically or not.
//! If true, m_shadowmapFrustumSplitSchemeRatio is used.
//! If false, m_cascadeFarDepths is used.
bool m_isShadowmapFrustumSplitAutomatic = true;
//! Ratio to lerp between the two types of frustum splitting scheme.
//! 0 = Uniform scheme which will split the Frustum evenly across all cascades.
//! 1 = Logarithmic scheme which is designed to split the frustum in a logarithmic fashion
//! in order to enable us to produce a more optimal perspective aliasing across the frustum.
//! This is valid only when m_shadowmapFrustumSplitIsAutomatic = true.
float m_shadowmapFrustumSplitSchemeRatio = 0.9f;
//! Far depth for each cascade.
//! Note that near depth of a cascade equals the far depth of the previous cascade.
//! This is valid only when m_shadowmapFrustumSplitIsAutomatic = false.
AZ::Vector4 m_cascadeFarDepths
{
m_shadowFarClipDistance * 1 / Shadow::MaxNumberOfCascades,
m_shadowFarClipDistance * 2 / Shadow::MaxNumberOfCascades,
m_shadowFarClipDistance * 3 / Shadow::MaxNumberOfCascades,
m_shadowFarClipDistance * 4 / Shadow::MaxNumberOfCascades
};
//! Height of camera from the ground.
//! The position of view frustum is corrected using cameraHeight
//! to get better quality of shadow around the area close to the camera.
//! To enable the correction, m_isCascadeCorrectionEnabled=true is required.
float m_groundHeight = 0.f;
//! Flag specifying whether view frustum positions are corrected.
//! The calculation of it is caused when the position of configuration of the camera is changed.
bool m_isCascadeCorrectionEnabled = false;
//! Flag specifying whether debug coloring is added.
bool m_isDebugColoringEnabled = false;
//! Method of shadow's filtering.
ShadowFilterMethod m_shadowFilterMethod = ShadowFilterMethod::None;
//! Width of the boundary between shadowed area and lit one.
//! If this is 0, edge softening is disabled. Units are in meters.
float m_boundaryWidth = 0.03f; // 3cm
//! Sample Count for prediction of whether the pixel is on the boundary (from 4 to 16)
//! The value should be less than or equal to m_filteringSampleCount.
uint16_t m_predictionSampleCount = 4;
//! Sample Count for filtering (from 4 to 64)
//! It is used only when the pixel is predicted as on the boundary.
uint16_t m_filteringSampleCount = 32;
bool IsSplitManual() const;
bool IsSplitAutomatic() const;
bool IsCascadeCorrectionDisabled() const;
bool IsShadowFilteringDisabled() const;
bool IsShadowPcfDisabled() const;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,130 @@
/*
* 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 <AzCore/Component/ComponentBus.h>
#include <AzCore/Math/Color.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/PointLightComponentConfig.h>
namespace AZ
{
namespace Render
{
class PointLightRequests
: public ComponentBus
{
public:
AZ_RTTI(PointLightRequests, "{359BE514-DBEB-4D6A-B283-F8C5E83CD477}");
/// Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~PointLightRequests() {}
/// Gets a point light's color. This value is indepedent from its intensity.
virtual const Color& GetColor() const = 0;
/// Sets a point light's color. This value is indepedent from its intensity.
virtual void SetColor(const Color& color) = 0;
/// Gets a point light's intensity. This value is indepedent from its color.
virtual float GetIntensity() const = 0;
//! Gets a point light's photometric type.
virtual PhotometricUnit GetIntensityMode() const = 0;
/// Sets a point light's intensity. This value is indepedent from its color.
virtual void SetIntensity(float intensity) = 0;
//! Sets a point light's intensity and intensity mode. This value is indepedent from its color.
virtual void SetIntensity(float intensity, PhotometricUnit intensityMode) = 0;
/// Gets the distance at which the point light will no longer affect lighting.
virtual float GetAttenuationRadius() const = 0;
/// Set the distance and which a point light will no longer affect lighitng. Setting this forces the RadiusCalculation to Explicit mode.
virtual void SetAttenuationRadius(float radius) = 0;
/// Gets the size in meters of the sphere representing the light bulb.
virtual float GetBulbRadius() const = 0;
/// Sets the size in meters of the sphere representing the light bulb in meters.
virtual void SetBulbRadius(float bulbSize) = 0;
/*
* If this is set to Automatic, the radius will immediately be recalculated based on the intensity.
* If this is set to Explicit, the radius value will be unchanged from its previous value.
*/
virtual void SetAttenuationRadiusMode(LightAttenuationRadiusMode attenuationRadiusMode) = 0;
/// Gets the flag whether attenuation radius calculation is automatic or not.
virtual bool GetAttenuationRadiusIsAutomatic() const = 0;
/// Sets the flag whether attenuation radius calculation is automatic or not.
virtual void SetAttenuationRadiusIsAutomatic(bool flag)
{
SetAttenuationRadiusMode(flag ? LightAttenuationRadiusMode::Automatic : LightAttenuationRadiusMode::Explicit);
}
//! Sets the photometric unit to the one provided and converts the intensity to the photometric unit so actual light intensity remains constant.
virtual void ConvertToIntensityMode(PhotometricUnit intensityMode) = 0;
};
/// The EBus for requests to for setting and getting light component properties.
typedef AZ::EBus<PointLightRequests> PointLightRequestBus;
class PointLightNotifications
: public ComponentBus
{
public:
AZ_RTTI(PointLightNotifications, "{7363728D-E3EE-4AC8-AAA7-C299782763F0}");
virtual ~PointLightNotifications() {}
/**
* Signals that the color of the light changed.
* @param color A reference to the new color of the light.
*/
virtual void OnColorChanged(const Color& /*color*/) { }
/**
* Signals that the intensity of the light changed.
* @param color A reference to the new intensity of the light.
*/
virtual void OnIntensityChanged(float /*intensity*/) { }
/**
* Signals that the color or intensity of the light changed. This is useful when both the color and intensity are need in the same call.
* @param color A reference to the new color of the light.
* @param color A reference to the new intensity of the light.
*/
virtual void OnColorOrIntensityChanged(const Color& /*color*/, float /*intensity*/) { }
/**
* Signals that the attenuation radius of the light changed.
* @param attenuationRadius The distance at which this light no longer affects lighting.
*/
virtual void OnAttenutationRadiusChanged(float /*attenuationRadius*/) { }
/**
* Signals that the bulb size of the light changed.
* @param bulbRadius The size in meters of the sphere representing the light bulb in meters.
*/
virtual void OnBulbRadiusChanged(float /*bulbRadius*/) { }
};
/// The EBus for light notification events.
typedef AZ::EBus<PointLightNotifications> PointLightNotificationBus;
} // namespace Render
} // namespace AZ
@@ -0,0 +1,113 @@
/*
* 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/Component.h>
#include <AzCore/Math/Color.h>
#include <AzCore/Math/MathUtils.h>
#include <Atom/Feature/CoreLights/PhotometricValue.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/CoreLightsConstants.h>
namespace AZ
{
namespace Render
{
struct PointLightComponentConfig final
: public ComponentConfig
{
AZ_RTTI(PointLightComponentConfig, "{B6FC35BA-D22F-4C20-BFFC-3FE7A48858FA}", ComponentConfig);
static void Reflect(AZ::ReflectContext* context);
static constexpr float DefaultIntensity = 800.0f; // 800 lumes is roughly equivalent to a 60 watt incandescent bulb
static constexpr float DefaultBulbRadius = 0.05f; // 5cm
AZ::Color m_color = AZ::Color::CreateOne();
PhotometricUnit m_intensityMode = PhotometricUnit::Lumen;
float m_intensity = DefaultIntensity;
float m_attenuationRadius = 0.0f;
float m_bulbRadius = DefaultBulbRadius;
LightAttenuationRadiusMode m_attenuationRadiusMode = LightAttenuationRadiusMode::Automatic;
// Not serialized, but used to keep scaled and unscaled properties in sync.
float m_scale = 1.0f;
// These values are used to deal adjusting the brightness and bulb radius based on the transform component's scale
// so that point lights scale concistently with meshes. Not serialized.
float m_unscaledIntensity = DefaultIntensity;
float m_unscaledBulbRadius = DefaultBulbRadius;
//! Updates scale and adjusts the values of intensity and bulb radius based on the new scale and the unscaled values.
void UpdateScale(float newScale)
{
m_scale = newScale;
m_intensity = m_unscaledIntensity;
// Lumens & Candela aren't based on surface area, so scale them.
if (!IsAreaBasedIntensityMode())
{
// Light surface area and brightness increases at scale^2 because of equation of sphere surface area.
m_intensity *= m_scale * m_scale;
}
m_bulbRadius = m_unscaledBulbRadius * m_scale;
}
//! Updates the unscaled intensity based on the current scaled value.
void UpdateUnscaledIntensity()
{
m_unscaledIntensity = m_intensity;
// Lumens & Candela aren't based on surface area, so scale them.
if (!IsAreaBasedIntensityMode())
{
// Light surface area and brightness increases at scale^2 because of equation of sphere surface area.
m_unscaledIntensity /= m_scale * m_scale;
}
}
//! Updates the unscaled bulb radius based on the current scaled value.
void UpdateUnscaledBulbRadius()
{
m_unscaledBulbRadius = m_bulbRadius / m_scale;
}
// Returns true if the intensity mode is an area based light unit (not lumens or candela)
bool IsAreaBasedIntensityMode()
{
return m_intensityMode != PhotometricUnit::Lumen && m_intensityMode != PhotometricUnit::Candela;
}
// Returns the surface area of the light bulb. 4.0 * pi * m_bulbRadius^2
float GetArea()
{
return 4.0f * Constants::Pi * m_bulbRadius * m_bulbRadius;
}
// The following functions provide information to an EditContext...
//! Returns true if m_attenuationRadiusMode is set to LightAttenuationRadiusMode::Automatic
bool IsAttenuationRadiusModeAutomatic() const
{
return m_attenuationRadiusMode == LightAttenuationRadiusMode::Automatic;
}
//! Returns characters for a suffix for the light type including a space. " lm" for lumens for example.
const char* GetIntensitySuffix() const
{
return PhotometricValue::GetTypeSuffix(m_intensityMode);
}
};
}
}
@@ -0,0 +1,165 @@
/*
* 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>
#include <AtomLyIntegration/CommonFeatures/CoreLights/SpotLightComponentConfig.h>
#include <Atom/Feature/CoreLights/ShadowConstants.h>
namespace AZ
{
namespace Render
{
class SpotLightRequests
: public ComponentBus
{
public:
//! Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~SpotLightRequests() = default;
//! Gets a spot light's color. This value is independent from its intensity.
virtual const Color& GetColor() const = 0;
//! Sets a spot light's color. This value is independent from its intensity.
virtual void SetColor(const Color& color) = 0;
//! Gets a spot light's intensity. This value is independent from its color.
virtual float GetIntensity() const = 0;
//! Sets a spot light's intensity. This value is independent from its color.
virtual void SetIntensity(float intensity) = 0;
//! Gets a spot light's bulb radius in meters.
virtual float GetBulbRadius() const = 0;
//! Sets a spot light's bulb radius in meters.
virtual void SetBulbRadius(float bulbRadius) = 0;
//! @return Returns inner cone angle of the spot light in degrees.
virtual float GetInnerConeAngleInDegrees() const = 0;
//! @brief Sets inner cone angle of the spot light in degrees.
virtual void SetInnerConeAngleInDegrees(float degrees) = 0;
//! @return Returns outer cone angle of the spot light in degrees.
virtual float GetOuterConeAngleInDegrees() const = 0;
//! @brief Sets outer cone angle of the spot light in degrees.
virtual void SetOuterConeAngleInDegrees(float degrees) = 0;
//! @return Returns penumbra bias for the falloff curve of the spot light.
virtual float GetPenumbraBias() const = 0;
//! @brief Sets penumbra bias for the falloff curve of the spot light.
virtual void SetPenumbraBias(float penumbraBias) = 0;
//! @return Returns radius attenuation of the spot light.
virtual float GetAttenuationRadius() const = 0;
//! @return Sets radius attenuation of the spot light.
virtual void SetAttenuationRadius(float radius) = 0;
//! @return Returns radius attenuation mode (Auto or Explicit).
virtual LightAttenuationRadiusMode GetAttenuationRadiusMode() const = 0;
//! If this is set to Automatic, the radius will immediately be recalculated based on the intensity.
//! If this is set to Explicit, the radius value will be unchanged from its previous value.
virtual void SetAttenuationRadiusMode(LightAttenuationRadiusMode attenuationRadiusMode) = 0;
//! @return the flag whether attenuation radius calculation is automatic or not.
virtual bool GetAttenuationRadiusIsAutomatic() const
{
return (GetAttenuationRadiusMode() == LightAttenuationRadiusMode::Automatic);
}
//! This sets flag whether attenuation radius calculation is automatic or not.
//! @param flag flag whether attenuation radius calculation is automatic or not.
virtual void SetAttenuationRadiusIsAutomatic(bool flag)
{
SetAttenuationRadiusMode(flag ? LightAttenuationRadiusMode::Automatic : LightAttenuationRadiusMode::Explicit);
}
//! @return the flag indicates this light have shadow or not.
virtual bool GetEnableShadow() const = 0;
//! This specify this spot light uses shadow or not.
//! @param enabled true if shadow is used, false otherwise.
virtual void SetEnableShadow(bool enabled) = 0;
//! @return the size of shadowmap (width and height).
virtual ShadowmapSize GetShadowmapSize() const = 0;
//! This specifies the size of shadowmap to size x size.
virtual void SetShadowmapSize(ShadowmapSize size) = 0;
//! This gets the filter method of shadows.
//! @return filter method
virtual ShadowFilterMethod GetShadowFilterMethod() const = 0;
//! This specifies filter method of shadows.
//! @param method Filter method.
virtual void SetShadowFilterMethod(ShadowFilterMethod method) = 0;
//! This gets the width of boundary between shadowed area and lit area.
//! The width is given by the angle, and the units are in degrees.
//! @return Boundary width. The degree of the shadowed region is gradually changed on the boundary.
virtual float GetSofteningBoundaryWidthAngle() const = 0;
//! This specifies the width of boundary between shadowed area and lit area.
//! @param width Boundary width. The degree of shadowed is gradually changed on the boundary.
//! If width == 0, softening edge is disabled. Units are in degrees.
virtual void SetSofteningBoundaryWidthAngle(float degrees) = 0;
//! This gets the sample count to predict boundary of shadow.
//! @return Sample Count for prediction of whether the pixel is on the boundary (up to 16)
virtual uint32_t GetPredictionSampleCount() const = 0;
//! This sets the sample count to predict boundary of shadow.
//! @param count Sample count for prediction of whether the pixel is on the boundary (up to 16)
//! This value should be less than or equal to m_filteringSampleCount.
virtual void SetPredictionSampleCount(uint32_t count) = 0;
//! This gets the sample count for filtering of the shadow boundary.
//! @return Sample Count for filtering (up to 64)
virtual uint32_t GetFilteringSampleCount() const = 0;
//! This sets the sample count for filtering of the shadow boundary.
//! @param count Sample Count for filtering (up to 64)
virtual void SetFilteringSampleCount(uint32_t count) = 0;
};
/// The EBus for requests to for setting and getting spot light component properties.
typedef AZ::EBus<SpotLightRequests> SpotLightRequestBus;
class SpotLightNotifications
: public ComponentBus
{
public:
virtual ~SpotLightNotifications() = default;
//! @brief Signals that the intensity of the light changed.
virtual void OnIntensityChanged(float intensity) { AZ_UNUSED(intensity); }
//! @brief Signals that the color of the light changed.
virtual void OnColorChanged(const Color& color) { AZ_UNUSED(color); }
//! @brief Signals that the cone angles of the spot light have changed.
virtual void OnConeAnglesChanged(float innerConeAngleDegrees, float outerConeAngleDegrees) { AZ_UNUSED(innerConeAngleDegrees); AZ_UNUSED(outerConeAngleDegrees); }
//! @brief Signals that the attenuation radius has changed.
virtual void OnAttenuationRadiusChanged(float attenuationRadius) { AZ_UNUSED(attenuationRadius); }
//! @brief Signals that the penumbra bias has changed.
virtual void OnPenumbraBiasChanged(float penumbraBias) { AZ_UNUSED(penumbraBias); }
};
//! The EBus for spot light notification events.
typedef AZ::EBus<SpotLightNotifications> SpotLightNotificationBus;
} // namespace Render
} // namespace AZ
@@ -0,0 +1,60 @@
/*
* 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/Component.h>
#include <AzCore/Math/Color.h>
#include <Atom/Feature/CoreLights/PhotometricValue.h>
#include <Atom/Feature/CoreLights/ShadowConstants.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/CoreLightsConstants.h>
namespace AZ
{
namespace Render
{
struct SpotLightComponentConfig final
: ComponentConfig
{
AZ_RTTI(SpotLightComponentConfig, "{20C882C8-615E-4272-93A8-BE9102E6EFED}", ComponentConfig);
static void Reflect(AZ::ReflectContext* context);
AZ::Color m_color = AZ::Color::CreateOne();
float m_intensity = 100.0f;
PhotometricUnit m_intensityMode = PhotometricUnit::Lumen;
float m_bulbRadius = 0.075;
float m_innerConeDegrees = 45.0f;
float m_outerConeDegrees = 55.0f;
float m_attenuationRadius = 20.0f;
float m_penumbraBias = 0.0f;
LightAttenuationRadiusMode m_attenuationRadiusMode = LightAttenuationRadiusMode::Automatic;
bool m_enabledShadow = false;
ShadowmapSize m_shadowmapSize = MaxShadowmapImageSize;
ShadowFilterMethod m_shadowFilterMethod = ShadowFilterMethod::None;
float m_boundaryWidthInDegrees = 0.25f;
uint16_t m_predictionSampleCount = 4;
uint16_t m_filteringSampleCount = 32;
// The following functions provide information to an EditContext...
//! Returns true if m_attenuationRadiusMode is set to LightAttenuationRadiusMode::Automatic
bool IsAttenuationRadiusModeAutomatic() const;
//! Returns characters for a suffix for the light type including a space. " lm" for lumens for example.
const char* GetIntensitySuffix() const;
float GetConeDegrees() const;
bool IsShadowFilteringDisabled() const;
bool IsShadowPcfDisabled() const;
};
}
}
@@ -0,0 +1,87 @@
/*
* 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 <AzCore/Component/ComponentBus.h>
#include <AtomLyIntegration/CommonFeatures/Decals/DecalComponentConfig.h>
namespace AZ
{
namespace Render
{
class DecalRequests
: public ComponentBus
{
public:
AZ_RTTI(DecalRequests, "{E9FC84EC-C63A-4241-B284-B8B72487F269}");
//! Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~DecalRequests() {}
//! Gets the attenuation angle. This controls how much the angle between geometry and the decal affects decal opacity.
virtual float GetAttenuationAngle() const = 0;
//! Sets the attenuation angle. This controls how much the angle between geometry and the decal affects decal opacity.
virtual void SetAttenuationAngle(float angle) = 0;
//! Gets the decal opacity
virtual float GetOpacity() const = 0;
//! Sets the decal opacity
virtual void SetOpacity(float opacity) = 0;
//! Gets the decal sort key. Decals with a larger sort key appear over top of smaller sort keys.
virtual uint8_t GetSortKey() const = 0;
//! Sets the decal sort key. Decals with a larger sort key appear over top of smaller sort keys.
virtual void SetSortKey(uint8_t sortKey) = 0;
//! Sets the material asset Id for this decal
virtual void SetMaterialAssetId(Data::AssetId) = 0;
//! Gets the material assert Id for this decal
virtual Data::AssetId GetMaterialAssetId() const = 0;
};
/// The EBus for requests to for setting and getting decal component properties.
typedef AZ::EBus<DecalRequests> DecalRequestBus;
class DecalNotifications
: public ComponentBus
{
public:
AZ_RTTI(DecalNotifications, "{BA81FBF5-FF66-4868-AD85-6B7954941B6B}");
virtual ~DecalNotifications() {}
//! Signals that the attenuation angle has changed.
//! @param attenuationAngle This controls how much the angle between geometry and the decal affects decal opacity.
virtual void OnAttenuationAngleChanged([[maybe_unused]] float attenuationAngle) { }
//! Signals that the opacity has changed.
//! @param opacity The opaqueness of the decal.
virtual void OnOpacityChanged([[maybe_unused]] float opacity){ }
//! Signals that the sortkey has changed.
//! @param sortKey Decals with a larger sort key appear over top of smaller sort keys.
virtual void OnSortKeyChanged([[maybe_unused]] uint8_t sortKey){ }
//! Signals that the material has changed
//! @param materialAsset The material asset of the decal
virtual void OnMaterialChanged(Data::Asset<RPI::MaterialAsset> materialAsset){ }
};
/// The EBus for decal notification events.
typedef AZ::EBus<DecalNotifications> DecalNotificationBus;
} // namespace Render
} // namespace AZ
@@ -0,0 +1,37 @@
/*
* 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/Component.h>
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
namespace AZ
{
namespace Render
{
struct DecalComponentConfig final
: public ComponentConfig
{
AZ_RTTI(DecalComponentConfig, "{5DFDC832-38B6-4F46-8C53-4CA0C82BC0AB}", ComponentConfig);
static void Reflect(AZ::ReflectContext* context);
static const uint8_t DefaultDecalSortKey = 16;
Data::Asset<RPI::MaterialAsset> m_materialAsset;
float m_attenuationAngle = 1.0f;
float m_opacity = 1.0f;
// Decals with a larger sort key appear over top of smaller sort keys
uint8_t m_sortKey = DefaultDecalSortKey;
};
}
}
@@ -0,0 +1,24 @@
/*
* 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/RTTI/BehaviorContext.h>
namespace AZ
{
namespace Render
{
static constexpr const char* const DecalComponentTypeId = "{45D0D830-85F0-47D9-B4D7-509D7D5E7A0C}";
static constexpr const char* const EditorDecalComponentTypeId = "{340F4C9C-89D1-45F9-9F7A-D4EE4F7FBE3E}";
} // namespace Render
} // namespace AZ
@@ -0,0 +1,54 @@
/*
* 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
{
//! GridComponentRequestBus provides an interface to request operations on a GridComponent
class GridComponentRequests
: public ComponentBus
{
public:
virtual void SetSize(float gridSize) = 0;
virtual float GetSize() const = 0;
virtual void SetPrimarySpacing(float gridPrimarySpacing) = 0;
virtual float GetPrimarySpacing() const = 0;
virtual void SetSecondarySpacing(float gridSecondarySpacing) = 0;
virtual float GetSecondarySpacing() const = 0;
virtual void SetAxisColor(const AZ::Color& gridAxisColor) = 0;
virtual AZ::Color GetAxisColor() const = 0;
virtual void SetPrimaryColor(const AZ::Color& gridPrimaryColor) = 0;
virtual AZ::Color GetPrimaryColor() const = 0;
virtual void SetSecondaryColor(const AZ::Color& gridSecondaryColor) = 0;
virtual AZ::Color GetSecondaryColor() const = 0;
};
using GridComponentRequestBus = EBus<GridComponentRequests>;
//! GridComponent provides an interface for receiving notifications about a GridComponent
class GridComponentNotifications
: public ComponentBus
{
public:
virtual void OnGridChanged() {}
};
using GridComponentNotificationBus = EBus<GridComponentNotifications>;
} // namespace Render
} // namespace AZ
@@ -0,0 +1,42 @@
/*
* 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/Component.h>
#include <AzCore/Math/Color.h>
namespace AZ
{
namespace Render
{
//! Common settings for GridComponents and EditorGridComponent.
class GridComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(GridComponentConfig, "{D1E357DF-6CCC-43C4-81F1-6B85C2E06A59}", ComponentConfig);
AZ_CLASS_ALLOCATOR(GridComponentConfig, SystemAllocator, 0);
static void Reflect(ReflectContext* context);
float m_gridSize = 32.0f;
AZ::Color m_axisColor = AZ::Color(0.0f, 0.0f, 1.0f, 1.0f);
float m_primarySpacing = 1.0f;
AZ::Color m_primaryColor = AZ::Color(0.25f, 0.25f, 0.25f, 1.0f);
float m_secondarySpacing = 0.25f;
AZ::Color m_secondaryColor = AZ::Color(0.5f, 0.5f, 0.5f, 1.0f);
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,22 @@
/*
* 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
namespace AZ
{
namespace Render
{
static constexpr const char* const GridComponentTypeId = "{27ACB2B3-C889-4DA5-BD27-E8C45CFBCFD6}";
static constexpr const char* const EditorGridComponentTypeId = "{DF2D071A-EC31-428A-9FD0-2B8A59945417}";
} // namespace Render
} // namespace AZ
@@ -0,0 +1,54 @@
/*
* 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 <Atom/RPI.Reflect/Image/StreamingImageAsset.h>
namespace AZ
{
namespace Render
{
//! ImageBasedLightComponentRequestBus provides an interface to request operations on a ImageBasedLightComponent
class ImageBasedLightComponentRequests
: public ComponentBus
{
public:
virtual void SetSpecularImageAsset(const Data::Asset<RPI::StreamingImageAsset>& imageAsset) = 0;
virtual void SetDiffuseImageAsset(const Data::Asset<RPI::StreamingImageAsset>& imageAsset) = 0;
virtual Data::Asset<RPI::StreamingImageAsset> GetSpecularImageAsset() const = 0;
virtual Data::Asset<RPI::StreamingImageAsset> GetDiffuseImageAsset() const = 0;
virtual void SetSpecularImageAssetId(const Data::AssetId imageAssetId) = 0;
virtual void SetDiffuseImageAssetId(const Data::AssetId imageAssetId) = 0;
virtual Data::AssetId GetSpecularImageAssetId() const = 0;
virtual Data::AssetId GetDiffuseImageAssetId() const = 0;
virtual void SetSpecularImageAssetPath(const AZStd::string path) = 0;
virtual void SetDiffuseImageAssetPath(const AZStd::string path) = 0;
virtual AZStd::string GetSpecularImageAssetPath() const = 0;
virtual AZStd::string GetDiffuseImageAssetPath() const = 0;
virtual void SetExposure(float exposure) = 0;
virtual float GetExposure() const = 0;
};
using ImageBasedLightComponentRequestBus = EBus<ImageBasedLightComponentRequests>;
//! ImageBasedLightComponent provides an interface for receiving notifications about a ImageBasedLightComponent
class ImageBasedLightComponentNotifications
: public ComponentBus
{
public:
virtual void OnSpecularImageUpdated() {};
virtual void OnDiffuseImageUpdated() {};
};
using ImageBasedLightComponentNotificationBus = EBus<ImageBasedLightComponentNotifications>;
} // namespace Render
} // namespace AZ
@@ -0,0 +1,37 @@
/*
* 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/Component.h>
#include <Atom/RPI.Reflect/Image/StreamingImageAsset.h>
namespace AZ
{
namespace Render
{
//! Common settings for ImageBasedLightComponents and EditorImageBasedLightComponent.
class ImageBasedLightComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(ImageBasedLightComponentConfig, "{2BD353A5-562B-4D84-9508-B2EFAFF1415E}", ComponentConfig);
AZ_CLASS_ALLOCATOR(ImageBasedLightComponentConfig, SystemAllocator, 0);
static void Reflect(ReflectContext* context);
Data::Asset<RPI::StreamingImageAsset> m_specularImageAsset;
Data::Asset<RPI::StreamingImageAsset> m_diffuseImageAsset;
float m_exposure = 0.0f;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,22 @@
/*
* 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
namespace AZ
{
namespace Render
{
static constexpr const char* const ImageBasedLightComponentTypeId = "{33A1302F-A769-4D06-820A-096A4836A7E9}";
static constexpr const char* const EditorImageBasedLightComponentTypeId = "{6202F16C-DDF9-4026-9479-F5BDC621D372}";
} // namespace Render
} // namespace AZ
@@ -0,0 +1,35 @@
/*
* 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/EBus/EBus.h>
#include <AzCore/std/string/string.h>
namespace AZ
{
namespace Render
{
//! EditorMaterialSystemComponentRequests provides an interface to communicate with MaterialEditor
class EditorMaterialSystemComponentRequests
: public AZ::EBusTraits
{
public:
// Only a single handler is allowed
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
//! Open document in material editor
virtual void OpenInMaterialEditor(const AZStd::string& sourcePath) = 0;
};
using EditorMaterialSystemComponentRequestBus = AZ::EBus<EditorMaterialSystemComponentRequests>;
} // namespace Render
} // namespace AZ
@@ -0,0 +1,91 @@
/*
* 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 <Atom/Feature/Material/MaterialAssignment.h>
namespace AZ
{
namespace Render
{
//! MaterialComponentRequestBus provides an interface to request operations on a MaterialComponent
class MaterialComponentRequests
: public ComponentBus
{
public:
//! Get all material assignments that can be overridden
virtual MaterialAssignmentMap GetOriginalMaterialAssignments() const = 0;
//! Set material overrides
virtual void SetMaterialOverrides(const MaterialAssignmentMap& materials) = 0;
//! Get material overrides
virtual const MaterialAssignmentMap& GetMaterialOverrides() const = 0;
//! Clear all material overrides
virtual void ClearAllMaterialOverrides() = 0;
//! Set default material override
virtual void SetDefaultMaterialOverride(const AZ::Data::AssetId& materialAssetId) = 0;
//! Get default material override
virtual const AZ::Data::AssetId GetDefaultMaterialOverride() const = 0;
//! Clear default material override
virtual void ClearDefaultMaterialOverride() = 0;
//! Set material override
virtual void SetMaterialOverride(const MaterialAssignmentId& materialAssignmentId, const AZ::Data::AssetId& materialAssetId) = 0;
//! Get material override
virtual const AZ::Data::AssetId GetMaterialOverride(const MaterialAssignmentId& materialAssignmentId) const = 0;
//! Clear material override
virtual void ClearMaterialOverride(const MaterialAssignmentId& materialAssignmentId) = 0;
//! Set a material property value override
virtual void SetPropertyOverride(const MaterialAssignmentId& materialAssignmentId, const Name& propertyName, const AZStd::any& propertyValue) = 0;
//! Get a material property value override
virtual AZStd::any GetPropertyOverride(const MaterialAssignmentId& materialAssignmentId, const Name& propertyName) const = 0;
//! Clear property override for a specific material assignment
virtual void ClearPropertyOverride(const MaterialAssignmentId& materialAssignmentId, const Name& propertyName) = 0;
//! Clear property overrides for a specific material assignment
virtual void ClearPropertyOverrides(const MaterialAssignmentId& materialAssignmentId) = 0;
//! Clear all property overrides
virtual void ClearAllPropertyOverrides() = 0;
//! Get Property overrides for a specific material assignment
virtual MaterialPropertyOverrideMap GetPropertyOverrides(const MaterialAssignmentId& materialAssignmentId) const = 0;
};
using MaterialComponentRequestBus = EBus<MaterialComponentRequests>;
//! MaterialComponent can send out notifications on the MaterialComponentNotificationBus
class MaterialComponentNotifications
: public ComponentBus
{
public:
virtual void OnMaterialsUpdated([[maybe_unused]] const MaterialAssignmentMap& materials) {}
virtual void OnMaterialsEdited([[maybe_unused]] const MaterialAssignmentMap& materials) {}
};
using MaterialComponentNotificationBus = EBus<MaterialComponentNotifications>;
//! Bus for retrieving information about materials embedded in or used by a source, like a model
class MaterialReceiverRequests
: public ComponentBus
{
public:
virtual MaterialAssignmentMap GetMaterialAssignments() const = 0;
virtual AZStd::unordered_set<AZ::Name> GetModelUvNames() const = 0;
};
using MaterialReceiverRequestBus = EBus<MaterialReceiverRequests>;
//! Bus for notifying when materials embedded in or used by a source, like a model, change
class MaterialReceiverNotifications
: public ComponentBus
{
public:
virtual void OnMaterialAssignmentsChanged() = 0;
};
using MaterialReceiverNotificationBus = EBus<MaterialReceiverNotifications>;
} // namespace Render
} // namespace AZ
@@ -0,0 +1,37 @@
/*
* 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/Component.h>
#include <Atom/RPI.Public/Material/Material.h>
#include <Atom/Feature/Material/MaterialAssignment.h>
namespace AZ
{
namespace Render
{
//! Common configuration for MaterialComponent that can be used to create
//! MaterialComponents dynamically and can be shared with EditorMaterialComponent.
class MaterialComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(MaterialComponentConfig, "{3366C279-32AE-48F6-839B-7700AE117A54}", ComponentConfig);
AZ_CLASS_ALLOCATOR(MaterialComponentConfig, SystemAllocator, 0);
static void Reflect(ReflectContext* context);
MaterialAssignmentMap m_materials;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,22 @@
/*
* 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
namespace AZ
{
namespace Render
{
static constexpr const char* const MaterialComponentTypeId = "{E5A56D7F-C63E-4080-BF62-01326AC60982}";
static constexpr const char* const EditorMaterialComponentTypeId = "{02B60E9D-470B-447D-A6EE-7D635B154183}";
} // namespace Render
} // namespace AZ
@@ -0,0 +1,67 @@
/*
* 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 <Atom/RPI.Public/Culling.h>
#include <Atom/RPI.Public/Model/Model.h>
#include <AzCore/Component/ComponentBus.h>
namespace AZ
{
namespace Render
{
/**
* MeshComponentRequestBus provides an interface to request operations on a MeshComponent
*/
class MeshComponentRequests
: public ComponentBus
{
public:
virtual void SetModelAsset(Data::Asset<RPI::ModelAsset> modelAsset) = 0;
virtual const Data::Asset<RPI::ModelAsset>& GetModelAsset() const = 0;
virtual void SetModelAssetId(Data::AssetId modelAssetId) = 0;
virtual Data::AssetId GetModelAssetId() const = 0;
virtual void SetModelAssetPath(const AZStd::string& path) = 0;
virtual AZStd::string GetModelAssetPath() const = 0;
virtual const Data::Instance<RPI::Model> GetModel() const = 0;
virtual void SetSortKey(RHI::DrawItemSortKey sortKey) = 0;
virtual RHI::DrawItemSortKey GetSortKey() const = 0;
virtual void SetLodOverride(RPI::Cullable::LodOverride lodOverride) = 0;
virtual RPI::Cullable::LodOverride GetLodOverride() const = 0;
virtual void SetVisibility(bool visible) = 0;
virtual bool GetVisibility() const = 0;
virtual AZ::Aabb GetWorldBounds() = 0;
virtual AZ::Aabb GetLocalBounds() = 0;
};
using MeshComponentRequestBus = EBus<MeshComponentRequests>;
/**
* MeshComponent can send out notifications on the MeshComponentNotificationBus
*/
class MeshComponentNotifications
: public ComponentBus
{
public:
virtual void OnModelReady(const Data::Asset<RPI::ModelAsset>& modelAsset, const Data::Instance<RPI::Model>& model) = 0;
};
using MeshComponentNotificationBus = EBus<MeshComponentNotifications>;
} // namespace Render
} // namespace AZ
@@ -0,0 +1,22 @@
/*
* 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
namespace AZ
{
namespace Render
{
static constexpr const char* const MeshComponentTypeId = "{C7801FA8-3E82-4D40-B039-4854F1892FDE}";
static constexpr const char* const EditorMeshComponentTypeId = "{DCE68F6E-2E16-4CB4-A834-B6C2F900A7E9}";
} // namespace Render
} // namespace AZ
@@ -0,0 +1,41 @@
/*
* 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/Component.h>
#include <Atom/Feature/PostProcess/Bloom/BloomConstants.h>
namespace AZ
{
namespace Render
{
class BloomRequests
: public ComponentBus
{
public:
AZ_RTTI(AZ::Render::BloomRequests, "{EE86AC6B-D496-4EFD-AFBF-BE06B0C886C0}");
/// Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~BloomRequests() {}
// Auto-gen virtual getters/setters...
#include <Atom/Feature/ParamMacros/StartParamFunctionsVirtual.inl>
#include <Atom/Feature/PostProcess/Bloom/BloomParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
};
typedef AZ::EBus<BloomRequests> BloomRequestBus;
}
}
@@ -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/Component.h>
#include <Atom/Feature/PostProcess/Bloom/BloomSettingsInterface.h>
namespace AZ
{
namespace Render
{
class BloomComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(AZ::Render::BloomComponentConfig, "{23545754-0FAE-4220-99AF-0AA0045F4D8D}", AZ::ComponentConfig);
static void Reflect(ReflectContext* context);
// Generate members...
#include <Atom/Feature/ParamMacros/StartParamMembers.inl>
#include <Atom/Feature/PostProcess/Bloom/BloomParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
// Generate Getters/Setters...
#include <Atom/Feature/ParamMacros/StartParamFunctions.inl>
#include <Atom/Feature/PostProcess/Bloom/BloomParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
void CopySettingsFrom(BloomSettingsInterface* settings);
void CopySettingsTo(BloomSettingsInterface* settings);
bool ArePropertiesReadOnly() const { return !m_enabled; }
};
}
}
@@ -0,0 +1,41 @@
/*
* 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/Component.h>
#include <Atom/Feature/PostProcess/DepthOfField/DepthOfFieldConstants.h>
namespace AZ
{
namespace Render
{
class DepthOfFieldRequests
: public ComponentBus
{
public:
AZ_RTTI(AZ::Render::DepthOfFieldRequests, "{E00A8956-5960-4059-A5E8-55C040A65514}");
/// Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~DepthOfFieldRequests() {}
// Auto-gen virtual getters/setters...
#include <Atom/Feature/ParamMacros/StartParamFunctionsVirtual.inl>
#include <Atom/Feature/PostProcess/DepthOfField/DepthOfFieldParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
};
typedef AZ::EBus<DepthOfFieldRequests> DepthOfFieldRequestBus;
}
}
@@ -0,0 +1,49 @@
/*
* 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/Component.h>
#include <Atom/Feature/PostProcess/DepthOfField/DepthOfFieldSettingsInterface.h>
namespace AZ
{
namespace Render
{
class DepthOfFieldComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(AZ::Render::DepthOfFieldComponentConfig, "{41E878A3-7DE6-4F27-AD14-FC115DE506F5}", AZ::ComponentConfig);
static void Reflect(ReflectContext* context);
// Generate members...
#include <Atom/Feature/ParamMacros/StartParamMembers.inl>
#include <Atom/Feature/PostProcess/DepthOfField/DepthOfFieldParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
// Generate Getters/Setters...
#include <Atom/Feature/ParamMacros/StartParamFunctions.inl>
#include <Atom/Feature/PostProcess/DepthOfField/DepthOfFieldParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
void CopySettingsFrom(DepthOfFieldSettingsInterface* settings);
void CopySettingsTo(DepthOfFieldSettingsInterface* settings);
bool IsCameraEntityInvalid() const { return !m_cameraEntityId.IsValid(); }
bool ArePropertiesReadOnly() const { return !m_enabled || IsCameraEntityInvalid(); }
bool IsAutoFocusReadOnly() const { return !m_enableAutoFocus || ArePropertiesReadOnly(); }
bool IsFocusDistanceReadOnly() const { return m_enableAutoFocus || ArePropertiesReadOnly(); }
};
}
}
@@ -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/Component/Component.h>
#include <Atom/Feature/DisplayMapper/DisplayMapperConfigurationDescriptor.h>
#include <Atom/RPI.Reflect/System/AnyAsset.h>
namespace AZ
{
namespace Render
{
class DisplayMapperComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(DisplayMapperComponentConfig, "{98560BEC-EA7F-4600-AA55-F76FDC07E950}", ComponentConfig);
AZ_CLASS_ALLOCATOR(DisplayMapperComponentConfig, SystemAllocator, 0);
static void Reflect(ReflectContext* context);
DisplayMapperOperationType m_displayMapperOperation = DisplayMapperOperationType::Aces;
bool m_ldrColorGradingLutEnabled = false;
Data::Asset<RPI::AnyAsset> m_ldrColorGradingLut = {};
};
}
}
@@ -0,0 +1,23 @@
/*
* 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
namespace AZ
{
namespace Render
{
static constexpr const char* const DisplayMapperComponentTypeId = "{FC666EDA-89B6-43C7-A6EC-0D33BE7CDFF1}";
static constexpr const char* const EditorDisplayMapperComponentTypeId = "{35963748-D7EC-4F8B-B779-B5BDB7984DA3}";
} // namespace Render
} // namespace AZ
@@ -0,0 +1,41 @@
/*
* 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/Component.h>
#include <Atom/Feature/PostProcess/ExposureControl/ExposureControlConstants.h>
namespace AZ
{
namespace Render
{
class ExposureControlRequests
: public ComponentBus
{
public:
AZ_RTTI(AZ::Render::ExposureControlRequests, "{2FAF1C0B-9306-4ECA-971B-1A17F9170F5B}");
/// Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~ExposureControlRequests() {}
// Auto-gen virtual getters/setters...
#include <Atom/Feature/ParamMacros/StartParamFunctionsVirtual.inl>
#include <Atom/Feature/PostProcess/ExposureControl/ExposureControlParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
};
typedef AZ::EBus<ExposureControlRequests> ExposureControlRequestBus;
}
}
@@ -0,0 +1,48 @@
/*
* 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/Component.h>
#include <Atom/Feature/PostProcess/ExposureControl/ExposureControlConstants.h>
#include <Atom/Feature/PostProcess/ExposureControl/ExposureControlSettingsInterface.h>
namespace AZ
{
namespace Render
{
class ExposureControlComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(AZ::Render::ExposureControlComponentConfig, "{3FBB712B-EA05-43DA-A2F5-9C8DA61AA787}", AZ::ComponentConfig);
static void Reflect(ReflectContext* context);
// Generate members...
#include <Atom/Feature/ParamMacros/StartParamMembers.inl>
#include <Atom/Feature/PostProcess/ExposureControl/ExposureControlParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
// Generate Getters/Setters...
#include <Atom/Feature/ParamMacros/StartParamFunctions.inl>
#include <Atom/Feature/PostProcess/ExposureControl/ExposureControlParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
void CopySettingsFrom(ExposureControlSettingsInterface* settings);
void CopySettingsTo(ExposureControlSettingsInterface* settings);
bool ArePropertiesReadOnly() const { return !m_enabled; }
bool IsEyeAdaptation() const { return m_exposureControlType == ExposureControl::ExposureControlType::EyeAdaptation; }
};
}
}
@@ -0,0 +1,23 @@
/*
* 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
namespace AZ
{
namespace Render
{
static constexpr const char* const ExposureControlComponentTypeId = "{0238ED5E-5ABF-463D-B87B-8E23CAA56C1A}";
static constexpr const char* const EditorExposureControlComponentTypeId = "{DB986527-F52D-4FAC-8BEC-B754A00CC595}";
} // namespace Render
} // namespace AZ
@@ -0,0 +1,33 @@
/*
* 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/Component.h>
#include <GradientSignal/GradientSampler.h>
namespace AZ
{
namespace Render
{
class GradientWeightModifierComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(AZ::Render::GradientWeightModifierComponentConfig, "{03CF0D7B-6763-4196-B329-7E247EBEDEF8}", AZ::ComponentConfig);
static void Reflect(ReflectContext* context);
GradientSignal::GradientSampler m_gradientSampler;
};
}
}
@@ -0,0 +1,23 @@
/*
* 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
namespace AZ
{
namespace Render
{
static constexpr const char* const GradientWeightModifierComponentTypeId = "{1D22E9BE-81A5-4784-BB9F-5DF59526026F}";
static constexpr const char* const EditorGradientWeightModifierComponentTypeId = "{ABD08A3E-1A35-4BE2-AA57-092FCCFC9CA7}";
} // namespace Render
} // namespace AZ
@@ -0,0 +1,41 @@
/*
* 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/Component.h>
#include <Atom/Feature/ACES/Aces.h>
#include <Atom/RPI.Reflect/Image/StreamingImageAsset.h>
namespace AZ
{
namespace Render
{
class LookModificationRequests
: public ComponentBus
{
public:
AZ_RTTI(AZ::Render::LookModificationRequests, "{F1E49309-8963-4F96-9EF8-BFC791E0DC36}");
/// Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~LookModificationRequests() {}
// Auto-gen virtual getters/setters...
#include <Atom/Feature/ParamMacros/StartParamFunctionsVirtual.inl>
#include <Atom/Feature/PostProcess/LookModification/LookModificationParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
};
typedef AZ::EBus<LookModificationRequests> LookModificationRequestBus;
}
}
@@ -0,0 +1,48 @@
/*
* 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/Component.h>
#include <Atom/Feature/ACES/Aces.h>
#include <Atom/Feature/PostProcess/LookModification/LookModificationSettingsInterface.h>
#include <Atom/RPI.Reflect/Image/StreamingImageAsset.h>
namespace AZ
{
namespace Render
{
class LookModificationComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(AZ::Render::LookModificationComponentConfig, "{604D14B8-6374-4FE0-8F31-03A37B238429}", AZ::ComponentConfig);
static void Reflect(ReflectContext* context);
// Generate members...
#include <Atom/Feature/ParamMacros/StartParamMembers.inl>
#include <Atom/Feature/PostProcess/LookModification/LookModificationParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
// Generate Getters/Setters...
#include <Atom/Feature/ParamMacros/StartParamFunctions.inl>
#include <Atom/Feature/PostProcess/LookModification/LookModificationParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
void CopySettingsFrom(LookModificationSettingsInterface* settings);
void CopySettingsTo(LookModificationSettingsInterface* settings);
bool ArePropertiesReadOnly() const { return !m_enabled; }
};
}
}
@@ -0,0 +1,23 @@
/*
* 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
namespace AZ
{
namespace Render
{
static constexpr const char* const LookModificationComponentTypeId = "{1D8CEFB6-3A08-4230-A6E6-32781BB3006D}";
static constexpr const char* const EditorLookModificationComponentTypeId = "{A38B4D55-7B7C-40F7-AB0A-31CAE9DC25E8}";
} // namespace Render
} // namespace AZ
@@ -0,0 +1,41 @@
/*
* 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/Component.h>
#include <Atom/Feature/PostProcess/PostProcessSettingsInterface.h>
namespace AZ
{
namespace Render
{
class PostFxLayerRequests
: public ComponentBus
{
public:
AZ_RTTI(AZ::Render::PostFxLayerRequests, "{30A215EB-8D51-43A9-B01E-8115E43636C6}");
/// Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~PostFxLayerRequests() {}
// Auto-gen virtual getters/setters...
#include <Atom/Feature/ParamMacros/StartParamFunctionsVirtual.inl>
#include <Atom/Feature/PostProcess/PostProcessParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
};
typedef AZ::EBus<PostFxLayerRequests> PostFxLayerRequestBus;
}
}
@@ -0,0 +1,41 @@
/*
* 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/EBus/EBus.h>
#include <Atom/Feature/PostProcess/PostFxLayerCategoriesConstants.h>
/**
* the EBus is used to request registered tags
*/
namespace AZ
{
namespace Render
{
class PostFxLayerCategoriesProviderRequests
: public AZ::EBusTraits
{
public:
// EBusTraits
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//! allows multiple threads to call
using MutexType = AZStd::recursive_mutex;
virtual void GetLayerCategories(PostFx::LayerCategoriesMap& layerCategories) const = 0;
};
typedef AZ::EBus<PostFxLayerCategoriesProviderRequests> PostFxLayerCategoriesProviderRequestBus;
}
}
@@ -0,0 +1,55 @@
/*
* 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/Component.h>
#include <Atom/Feature/PostProcess/PostProcessSettingsInterface.h>
#include <Atom/Feature/PostProcess/PostFxLayerCategoriesConstants.h>
namespace AZ
{
namespace Render
{
class PostFxLayerComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(AZ::Render::PostFxLayerComponentConfig, "{D9D31439-BD33-43AA-B341-4F47C669F843}", AZ::ComponentConfig);
static void Reflect(ReflectContext* context);
AZStd::string GetPriorityLabel();
// Generate members...
#include <Atom/Feature/ParamMacros/StartParamMembers.inl>
#include <Atom/Feature/PostProcess/PostProcessParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
// Generate Getters/Setters...
#include <Atom/Feature/ParamMacros/StartParamFunctions.inl>
#include <Atom/Feature/PostProcess/PostProcessParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
void CopySettingsTo(PostProcessSettingsInterface* settings) const;
// Returns a sorted list of priority-to-layer-categories
AZStd::vector<AZStd::pair<int, AZStd::string>> BuildLayerCategories() const;
int m_layerCategoryValue = PostFx::DefaultLayerCategoryValue;
// If entity containing the tags have cameras, PostFx will limit the effect to those specific entities
AZStd::vector<AZStd::string> m_cameraTags;
// If entity contains the following tags, PostFx will ignore those entities
AZStd::vector<AZStd::string> m_exclusionTags;
};
}
}
@@ -0,0 +1,23 @@
/*
* 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
namespace AZ
{
namespace Render
{
static constexpr const char* const PostFxLayerComponentTypeId = "{CB98EF9F-E99E-4262-9492-4964DCD01B8B}";
static constexpr const char* const EditorPostFxLayerComponentTypeId = "{4DE50024-068D-4656-862B-6B51D38C3273}";
} // namespace Render
} // namespace AZ
@@ -0,0 +1,36 @@
/*
* 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/Component.h>
namespace AZ
{
namespace Render
{
// PostFxWeightRequestBus provides an interface to call methods for modulating a PostFx's weight.
class PostFxWeightRequests
: public ComponentBus
{
public:
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~PostFxWeightRequests() = default;
// Given a position, return a weight value.
virtual float GetWeightAtPosition(const AZ::Vector3& influencerPosition) const = 0;
};
using PostFxWeightRequestBus = AZ::EBus<PostFxWeightRequests>;
}
}
@@ -0,0 +1,32 @@
/*
* 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/Component.h>
namespace AZ
{
namespace Render
{
class RadiusWeightModifierComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(AZ::Render::RadiusWeightModifierComponentConfig, "{80218725-E3B5-4A01-89FF-11314AB2EFF8}", AZ::ComponentConfig);
static void Reflect(ReflectContext* context);
float m_radius = 0;
};
}
}
@@ -0,0 +1,23 @@
/*
* 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
namespace AZ
{
namespace Render
{
static constexpr const char* const RadiusWeightModifierComponentTypeId = "{8F0FC718-50E1-425E-A1E7-9C0425879CEB}";
static constexpr const char* const EditorRadiusWeightModifierComponentTypeId = "{AFB4C267-2D2D-463A-94F7-A839353FF20E}";
} // namespace Render
} // namespace AZ
@@ -0,0 +1,32 @@
/*
* 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/Component.h>
namespace AZ
{
namespace Render
{
class ShapeWeightModifierComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(AZ::Render::ShapeWeightModifierComponentConfig, "{2CB13B7C-C532-4DFB-8FF4-79EF9F860868}", AZ::ComponentConfig);
static void Reflect(ReflectContext* context);
float m_falloffDistance = 1.0f;
};
}
}
@@ -0,0 +1,23 @@
/*
* 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
namespace AZ
{
namespace Render
{
static constexpr const char* const ShapeWeightModifierComponentTypeId = "{F5B04B16-9C1E-493F-AB5A-BC6E56D4952A}";
static constexpr const char* const EditorShapeWeightModifierComponentTypeId = "{7C528F7A-5EE7-4540-BA52-0507C17CE67D}";
} // namespace Render
} // namespace AZ
@@ -0,0 +1,41 @@
/*
* 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/Component.h>
#include <Atom/Feature/PostProcess/Ssao/SsaoConstants.h>
namespace AZ
{
namespace Render
{
class SsaoRequests
: public ComponentBus
{
public:
AZ_RTTI(AZ::Render::SsaoRequests, "{6F518EA6-D912-44C0-A79E-ABC16A30D2F7}");
/// Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~SsaoRequests() {}
// Auto-gen virtual getters/setters...
#include <Atom/Feature/ParamMacros/StartParamFunctionsVirtual.inl>
#include <Atom/Feature/PostProcess/Ssao/SsaoParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
};
typedef AZ::EBus<SsaoRequests> SsaoRequestBus;
}
}
@@ -0,0 +1,44 @@
/*
* 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/Component.h>
#include <Atom/Feature/PostProcess/Ssao/SsaoSettingsInterface.h>
namespace AZ
{
namespace Render
{
class SsaoComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(AZ::Render::SsaoComponentConfig, "{C1ACBBE7-C3BD-4245-B571-3B5FDCAC0B0B}", AZ::ComponentConfig);
static void Reflect(ReflectContext* context);
// Generate members...
#include <Atom/Feature/ParamMacros/StartParamMembers.inl>
#include <Atom/Feature/PostProcess/Ssao/SsaoParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
// Generate Getters/Setters...
#include <Atom/Feature/ParamMacros/StartParamFunctions.inl>
#include <Atom/Feature/PostProcess/Ssao/SsaoParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
void CopySettingsFrom(SsaoSettingsInterface* settings);
void CopySettingsTo(SsaoSettingsInterface* settings);
};
}
}
@@ -0,0 +1,36 @@
/*
* 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/Component.h>
namespace AZ
{
namespace Render
{
// Provides an interface to the Editor Reflection Probe component
class EditorReflectionProbeInterface
: public ComponentBus
{
public:
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~EditorReflectionProbeInterface() = default;
// Signals the component to bake the reflection probe
virtual AZ::u32 BakeReflectionProbe() = 0;
};
using EditorReflectionProbeBus = AZ::EBus<EditorReflectionProbeInterface>;
}
}
@@ -0,0 +1,43 @@
/*
* 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/Component.h>
namespace AZ
{
namespace Render
{
class DeferredFogRequests
: public ComponentBus
{
public:
AZ_RTTI(AZ::Render::DeferredFogRequests, "{B60F03EB-36D3-426B-91DE-4FB7B5EAE6CD}");
/// Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~DeferredFogRequests() {}
// Auto-gen virtual getter and setter functions - matching the interface methods
#define AZ_GFX_COMMON_PARAM(ValueType, Name, MemberName, DefaultValue) \
virtual ValueType Get##Name() const = 0; \
virtual void Set##Name(ValueType val) = 0; \
#include <Atom/Feature/ParamMacros/MapParamCommon.inl>
#include <Atom/Feature/ScreenSpace/DeferredFogParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
};
typedef AZ::EBus<DeferredFogRequests> DeferredFogRequestsBus;
}
}
@@ -0,0 +1,103 @@
/*
* 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/Vector2.h>
#include <AzCore/Math/Vector3.h>
#include <AzCore/Component/Component.h>
#include <Atom/Feature/ParamMacros/ParamMacrosHowTo.inl> // for education purposes
#include <Atom/Feature/ScreenSpace/DeferredFogSettingsInterface.h>
namespace AZ
{
namespace Render
{
class EditorDeferredFogComponent;
// The component config file containing the editor fog data for configuring 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 DeferredFogComponentConfig final :
public ComponentConfig
{
friend class EditorDeferredFogComponent;
public:
AZ_RTTI(AZ::Render::DeferredFogComponentConfig, "{3C2671FE-6027-4A1E-907B-F7E2B1B64F7B}", AZ::ComponentConfig );
static void Reflect(ReflectContext* context);
void CopySettingsFrom(DeferredFogSettingsInterface* settings);
void CopySettingsTo(DeferredFogSettingsInterface* settings);
// DeferredFogComponentConfigInterface overrides...
void SetEnabled(bool value)
{
m_enabled = value;
}
bool GetIsEnabled()
{
return m_enabled;
}
void SetUseNoiseTextureShaderOption(bool value)
{
m_useNoiseTextureShaderOption = value;
}
bool GetUseNoiseTextureShaderOption()
{
return m_useNoiseTextureShaderOption;
}
void SetEnableFogLayerShaderOption(bool value)
{
m_enableFogLayerShaderOption = value;
}
bool GetEnableFogLayerShaderOption()
{
return m_enableFogLayerShaderOption;
}
// Generate Get / Set methods
#define AZ_GFX_COMMON_PARAM(ValueType, Name, MemberName, DefaultValue) \
virtual ValueType Get##Name() const { return MemberName; } \
virtual void Set##Name(ValueType val) { MemberName = val; } \
#include <Atom/Feature/ParamMacros/MapParamCommon.inl>
#include <Atom/Feature/ScreenSpace/DeferredFogParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
private:
// SRG constants
#define AZ_GFX_COMMON_PARAM(ValueType, Name, MemberName, DefaultValue) \
ValueType MemberName = DefaultValue; \
#include <Atom/Feature/ParamMacros/MapParamCommon.inl>
#include <Atom/Feature/ScreenSpace/DeferredFogParams.inl>
#include <Atom/Feature/ParamMacros/EndParams.inl>
bool m_enabled = false;
bool m_useNoiseTextureShaderOption = false;
bool m_enableFogLayerShaderOption = false;
};
}
}
@@ -0,0 +1,33 @@
/*
* 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/Component.h>
#include <AzCore/std/containers/vector.h>
namespace AZ
{
namespace Render
{
class EntityReferenceComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(AZ::Render::EntityReferenceComponentConfig, "{12D214C7-878A-48D2-AFDD-4FCFF0BBC876}", AZ::ComponentConfig);
static void Reflect(ReflectContext* context);
AZStd::vector<AZ::EntityId> m_entityIdReferences;
};
}
}
@@ -0,0 +1,22 @@
/*
* 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
namespace AZ
{
namespace Render
{
static constexpr const char* const EntityReferenceComponentTypeId = "{0B6422F7-DD6E-447A-9A99-DEB5A325A274}";
static constexpr const char* const EditorEntityReferenceComponentTypeId = "{71C5AD29-2B0C-4264-BCBF-61E0A4E98D32}";
}
}
@@ -0,0 +1,34 @@
/*
* 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/Component.h>
namespace AZ
{
namespace Render
{
class EntityReferenceRequests
: public ComponentBus
{
public:
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~EntityReferenceRequests() = default;
virtual AZStd::vector<EntityId> GetEntityReferences() const = 0;
};
using EntityReferenceRequestBus = AZ::EBus<EntityReferenceRequests>;
}
}
@@ -0,0 +1,40 @@
/*
* 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 <Atom/RPI.Public/Image/StreamingImage.h>
namespace AZ
{
namespace Render
{
class HDRiSkyboxRequests
: public ComponentBus
{
public:
AZ_RTTI(AZ::Render::HDRiSkyboxRequests, "{86278300-438D-40B3-B87C-B87EE045373E}");
/// Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~HDRiSkyboxRequests() {}
virtual Data::Asset<RPI::StreamingImageAsset> GetCubemapAsset() const = 0;
virtual void SetCubemapAsset(const Data::Asset<RPI::StreamingImageAsset>& cubemapAsset) = 0;
virtual void SetExposure(float exposure) = 0;
virtual float GetExposure() const = 0;
};
typedef AZ::EBus<HDRiSkyboxRequests> HDRiSkyboxRequestBus;
}
}
@@ -0,0 +1,35 @@
/*
* 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/Component.h>
#include <Atom/RPI.Reflect/Image/StreamingImageAsset.h>
#include <AzCore/Math/Matrix4x4.h>
namespace AZ
{
namespace Render
{
class HDRiSkyboxComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(AZ::Render::HDRiSkyboxComponentConfig, "{AEAD8F5A-8D2F-47CD-B98C-C99541F7B229}", AZ::ComponentConfig);
static void Reflect(ReflectContext* context);
Data::Asset<RPI::StreamingImageAsset> m_cubemapAsset;
float m_exposure = 0.0f;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,54 @@
/*
* 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 <Atom/Feature/CoreLights/PhotometricValue.h>
namespace AZ
{
namespace Render
{
class PhysicalSkyRequests
: public ComponentBus
{
public:
AZ_RTTI(AZ::Render::PhysicalSkyRequests, "{2A3744DD-C0B3-4680-9BF3-41886DEC30A1}");
/// Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~PhysicalSkyRequests() {}
// reasonable range is 1 ~ 10
virtual void SetTurbidity(int turbidity) = 0;
virtual int GetTurbidity() = 0;
// reasonable range is 0.1 ~ 2.0
virtual void SetSunRadiusFactor(float factor) = 0;
virtual float GetSunRadiusFactor() = 0;
// reasonable range is -4.0 ~ 11.0 for EV100
virtual void SetSkyIntensity(float intensity, PhotometricUnit unit) = 0;
virtual void SetSkyIntensity(float intensity) = 0;
virtual float GetSkyIntensity(PhotometricUnit unit) = 0;
virtual float GetSkyIntensity() = 0;
// reasonable range is -4.0 ~ 16.0 for EV100
virtual void SetSunIntensity(float intensity, PhotometricUnit unit) = 0;
virtual void SetSunIntensity(float intensity) = 0;
virtual float GetSunIntensity(PhotometricUnit unit) = 0;
virtual float GetSunIntensity() = 0;
};
typedef AZ::EBus<PhysicalSkyRequests> PhysicalSkyRequestBus;
}
}
@@ -0,0 +1,50 @@
/*
* 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/Component.h>
#include <Atom/Feature/CoreLights/PhotometricValue.h>
#include <Atom/Feature/SkyBox/SkyboxConstants.h>
namespace AZ
{
namespace Render
{
class PhysicalSkyComponentConfig final
: public ComponentConfig
{
public:
AZ_RTTI(AZ::Render::PhysicalSkyComponentConfig, "{D0A40D6B-F838-46AB-A79C-CC2218C0146C}", AZ::ComponentConfig);
static void Reflect(ReflectContext* context);
PhotometricUnit m_intensityMode = PhotometricUnit::Ev100Luminance;
float m_skyIntensity = PhysicalSkyDefaultIntensity;
float m_sunIntensity = PhysicalSunDefaultIntensity;
int m_turbidity = 1;
float m_sunRadiusFactor = 1.0f;
//! Returns characters for a suffix for the light type including a space. " lm" for lumens for example.
const char* GetIntensitySuffix() const;
//! Returns the minimum intensity value allowed depending on the m_intensityMode
float GetSkyIntensityMin() const;
float GetSunIntensityMin() const;
//! Returns the maximum intensity value allowed depending on the m_intensityMode
float GetSkyIntensityMax() const;
float GetSunIntensityMax() const;
};
}
}
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>Icons/materialtype.svg</file>
</qresource>
</RCC>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Icons / Editor / Base Material</title>
<g id="Icons-/-Editor-/-Base-Material" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<rect id="Icon-Background" x="0" y="0" width="24" height="24"></rect>
<rect id="Icon-Background" x="0" y="0" width="24" height="24"></rect>
<g id="community" transform="translate(2.000000, 2.000000)" fill="#FFFFFF" fill-rule="nonzero">
<path d="M10,-5.86197757e-14 C4.45454545,-5.86197757e-14 -8.52651283e-14,4.45454545 -8.52651283e-14,10 C-8.52651283e-14,15.5454545 4.45454545,20 10,20 C15.5454545,20 20,15.5454545 20,10 C20,4.45454545 15.5454545,-5.86197757e-14 10,-5.86197757e-14 Z M17.3636364,6.36363636 L14.2727273,6.36363636 C14,4.90909091 13.6363636,3.45454545 13.0909091,2.36363636 C14.9090909,3.18181818 16.4545455,4.54545455 17.3636364,6.36363636 Z M12.7272727,10 C12.7272727,10.6363636 12.7272727,11.2727273 12.6363636,11.8181818 L7.36363636,11.8181818 C7.27272727,11.2727273 7.27272727,10.6363636 7.27272727,10 C7.27272727,9.36363636 7.27272727,8.72727273 7.36363636,8.18181818 L12.6363636,8.18181818 C12.7272727,8.72727273 12.7272727,9.36363636 12.7272727,10 Z M10,18.1818182 C9.18181818,18.1818182 8.09090909,16.4545455 7.54545455,13.6363636 L12.3636364,13.6363636 C11.9090909,16.4545455 10.8181818,18.1818182 10,18.1818182 Z M7.54545455,6.36363636 C8.09090909,3.54545455 9.18181818,1.81818182 10,1.81818182 C10.8181818,1.81818182 11.9090909,3.54545455 12.4545455,6.36363636 L7.54545455,6.36363636 Z M7,2.36363636 C6.45454545,3.45454545 6,4.90909091 5.72727273,6.36363636 L2.63636364,6.36363636 C3.54545455,4.54545455 5.09090909,3.18181818 7,2.36363636 Z M2,8.18181818 L5.45454545,8.18181818 C5.45454545,8.81818182 5.45454545,9.36363636 5.45454545,10 C5.45454545,10.6363636 5.45454545,11.1818182 5.54545455,11.8181818 L2,11.8181818 C1.90909091,11.2727273 1.81818182,10.6363636 1.81818182,10 C1.81818182,9.36363636 1.90909091,8.72727273 2,8.18181818 Z M2.63636364,13.6363636 L5.72727273,13.6363636 C6,15.0909091 6.36363636,16.5454545 6.90909091,17.6363636 C5.09090909,16.8181818 3.54545455,15.4545455 2.63636364,13.6363636 Z M13,17.6363636 C13.5454545,16.5454545 14,15.1818182 14.1818182,13.6363636 L17.2727273,13.6363636 C16.4545455,15.4545455 14.9090909,16.8181818 13,17.6363636 Z M18,11.8181818 L14.5454545,11.8181818 C14.6363636,11.1818182 14.6363636,10.6363636 14.6363636,10 C14.6363636,9.36363636 14.6363636,8.81818182 14.5454545,8.18181818 L18,8.18181818 C18.0909091,8.72727273 18.1818182,9.36363636 18.1818182,10 C18.1818182,10.6363636 18.0909091,11.2727273 18,11.8181818 Z" id="Shape"></path>
</g>
<path d="M22,20.8342395 C22,18.1069667 22,17.2661779 22,11.7433304 C22,6.22048287 22,5.379694 22,2.65242127 C22,-0.0748514543 12,6.28878491 12,11.7433304 C12,17.1978758 22,23.5615122 22,20.8342395 Z" id="Path" fill="#FFFFFF" fill-rule="nonzero" transform="translate(17.000000, 11.743330) scale(-1, 1) translate(-17.000000, -11.743330) "></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

@@ -0,0 +1,82 @@
/*
* 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 <CommonFeaturesSystemComponent.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/EditContextConstants.inl>
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/CoreLightsConstants.h>
#include <AtomLyIntegration/CommonFeatures/Mesh/MeshComponentConstants.h>
namespace AZ
{
namespace Render
{
void AtomLyIntegrationCommonFeaturesSystemComponent::Reflect(ReflectContext* context)
{
if (SerializeContext* serialize = azrtti_cast<SerializeContext*>(context))
{
serialize->Class<AtomLyIntegrationCommonFeaturesSystemComponent, Component>()
->Version(0);
if (AZ::EditContext* ec = serialize->GetEditContext())
{
ec->Class<AtomLyIntegrationCommonFeaturesSystemComponent>("Common", "[Description of functionality provided by this System Component]")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System", 0xc94d118b))
->Attribute(Edit::Attributes::AutoExpand, true)
;
}
}
CoreLightConstantsReflect(context);
}
void AtomLyIntegrationCommonFeaturesSystemComponent::GetProvidedServices(ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("LyIntegrationCommonFeaturesService", 0x9083ee7d));
}
void AtomLyIntegrationCommonFeaturesSystemComponent::GetIncompatibleServices(ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("LyIntegrationCommonFeaturesService", 0x9083ee7d));
}
void AtomLyIntegrationCommonFeaturesSystemComponent::GetRequiredServices(ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC("CommonService", 0x6398eec4));
}
void AtomLyIntegrationCommonFeaturesSystemComponent::GetDependentServices(ComponentDescriptor::DependencyArrayType& dependent)
{
AZ_UNUSED(dependent);
}
void AtomLyIntegrationCommonFeaturesSystemComponent::Init()
{
}
void AtomLyIntegrationCommonFeaturesSystemComponent::Activate()
{
auto modelAssetHandler = azrtti_cast<RPI::ModelAssetHandler*>(Data::AssetManager::Instance().GetHandler(azrtti_typeid<RPI::ModelAsset>()));
modelAssetHandler->m_componentTypeId = EditorMeshComponentTypeId;
}
void AtomLyIntegrationCommonFeaturesSystemComponent::Deactivate()
{
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,43 @@
/*
* 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/Component.h>
namespace AZ
{
namespace Render
{
class AtomLyIntegrationCommonFeaturesSystemComponent
: public AZ::Component
{
public:
AZ_COMPONENT(AtomLyIntegrationCommonFeaturesSystemComponent, "{E29DAE7C-BF0F-42A9-9570-037FBB689A0A}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
protected:
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,44 @@
/*
* 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 <CoreLights/AreaLightComponent.h>
namespace AZ
{
namespace Render
{
AreaLightComponent::AreaLightComponent(const AreaLightComponentConfig& config)
: BaseClass(config)
{
}
void AreaLightComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<AreaLightComponent, BaseClass>();
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<AreaLightComponent>()->RequestBus("AreaLightRequestBus");
behaviorContext->ConstantProperty("AreaLightComponentTypeId", BehaviorConstant(Uuid(AreaLightComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common);
}
}
} // namespace Render
} // namespace AZ
@@ -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 <AzFramework/Components/ComponentAdapter.h>
#include <CoreLights/AreaLightComponentController.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/CoreLightsConstants.h>
namespace AZ
{
namespace Render
{
class AreaLightComponent final
: public AzFramework::Components::ComponentAdapter<AreaLightComponentController, AreaLightComponentConfig>
{
public:
using BaseClass = AzFramework::Components::ComponentAdapter<AreaLightComponentController, AreaLightComponentConfig>;
AZ_COMPONENT(AZ::Render::AreaLightComponent, AreaLightComponentTypeId, BaseClass);
AreaLightComponent() = default;
AreaLightComponent(const AreaLightComponentConfig& config);
static void Reflect(AZ::ReflectContext* context);
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,114 @@
/*
* 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 <AtomLyIntegration/CommonFeatures/CoreLights/AreaLightComponentConfig.h>
namespace AZ
{
namespace Render
{
void AreaLightComponentConfig::Reflect(ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<AreaLightComponentConfig, ComponentConfig>()
->Version(3)
->Field("Color", &AreaLightComponentConfig::m_color)
->Field("IntensityMode", &AreaLightComponentConfig::m_intensityMode)
->Field("Intensity", &AreaLightComponentConfig::m_intensity)
->Field("AttenuationRadiusMode", &AreaLightComponentConfig::m_attenuationRadiusMode)
->Field("AttenuationRadius", &AreaLightComponentConfig::m_attenuationRadius)
->Field("LightEmitsBothDirections", &AreaLightComponentConfig::m_lightEmitsBothDirections)
->Field("UseFastApproximation", &AreaLightComponentConfig::m_useFastApproximation)
;
}
}
bool AreaLightComponentConfig::IsAttenuationRadiusModeAutomatic() const
{
return m_attenuationRadiusMode == LightAttenuationRadiusMode::Automatic;
}
bool AreaLightComponentConfig::Is2DSurface() const
{
return m_shapeType == AZ_CRC_CE("DiskShape")
|| m_shapeType == AZ_CRC_CE("QuadShape")
|| m_shapeType == AZ_CRC_CE("PolygonPrism");
}
bool AreaLightComponentConfig::SupportsFastApproximation() const
{
return m_shapeType == AZ_CRC_CE("QuadShape");
}
const char* AreaLightComponentConfig::GetIntensitySuffix() const
{
return PhotometricValue::GetTypeSuffix(m_intensityMode);
}
float AreaLightComponentConfig::GetIntensityMin() const
{
switch (m_intensityMode)
{
case PhotometricUnit::Candela:
case PhotometricUnit::Lumen:
case PhotometricUnit::Nit:
return 0.0f;
case PhotometricUnit::Ev100Luminance:
return -10.0f;
}
return 0.0f;
}
float AreaLightComponentConfig::GetIntensityMax() const
{
switch (m_intensityMode)
{
case PhotometricUnit::Candela:
case PhotometricUnit::Lumen:
case PhotometricUnit::Nit:
return 1'000'000.0f;
case PhotometricUnit::Ev100Luminance:
return 20.0f;
}
return 0.0f;
}
float AreaLightComponentConfig::GetIntensitySoftMin() const
{
switch (m_intensityMode)
{
case PhotometricUnit::Candela:
case PhotometricUnit::Lumen:
case PhotometricUnit::Nit:
case PhotometricUnit::Ev100Luminance:
return 0.0f;
}
return 0.0f;
}
float AreaLightComponentConfig::GetIntensitySoftMax() const
{
switch (m_intensityMode)
{
case PhotometricUnit::Candela:
case PhotometricUnit::Lumen:
case PhotometricUnit::Nit:
return 1'000.0f;
case PhotometricUnit::Ev100Luminance:
return 16.0f;
}
return 0.0f;
}
}
}
@@ -0,0 +1,327 @@
/*
* 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 <CoreLights/AreaLightComponentController.h>
#include <CoreLights/CapsuleLightDelegate.h>
#include <CoreLights/DiskLightDelegate.h>
#include <CoreLights/PolygonLightDelegate.h>
#include <CoreLights/QuadLightDelegate.h>
#include <CoreLights/SphereLightDelegate.h>
#include <Atom/Feature/CoreLights/PhotometricValue.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/CoreLightsConstants.h>
#include <LmbrCentral/Shape/ShapeComponentBus.h>
#include <LmbrCentral/Shape/SphereShapeComponentBus.h>
#include <LmbrCentral/Shape/DiskShapeComponentBus.h>
#include <LmbrCentral/Shape/CapsuleShapeComponentBus.h>
#include <LmbrCentral/Shape/PolygonPrismShapeComponentBus.h>
#include <LmbrCentral/Shape/QuadShapeComponentBus.h>
namespace AZ
{
namespace Render
{
void AreaLightComponentController::Reflect(ReflectContext* context)
{
AreaLightComponentConfig::Reflect(context);
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<AreaLightComponentController>()
->Version(0)
->Field("Configuration", &AreaLightComponentController::m_configuration);
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<AreaLightRequestBus>("AreaLightRequestBus")
->Event("GetAttenuationRadius", &AreaLightRequestBus::Events::GetAttenuationRadius)
->Event("SetAttenuationRadius", &AreaLightRequestBus::Events::SetAttenuationRadius)
->Event("SetAttenuationRadiusMode", &AreaLightRequestBus::Events::SetAttenuationRadiusMode)
->Event("GetColor", &AreaLightRequestBus::Events::GetColor)
->Event("SetColor", &AreaLightRequestBus::Events::SetColor)
->Event("GetEmitsLightBothDirections", &AreaLightRequestBus::Events::GetLightEmitsBothDirections)
->Event("SetEmitsLightBothDirections", &AreaLightRequestBus::Events::SetLightEmitsBothDirections)
->Event("GetUseFastApproximation", &AreaLightRequestBus::Events::GetUseFastApproximation)
->Event("SetUseFastApproximation", &AreaLightRequestBus::Events::SetUseFastApproximation)
->Event("GetIntensity", &AreaLightRequestBus::Events::GetIntensity)
->Event("SetIntensity", static_cast<void(AreaLightRequestBus::Events::*)(float)>(&AreaLightRequestBus::Events::SetIntensity))
->Event("GetIntensityMode", &AreaLightRequestBus::Events::GetIntensityMode)
->Event("ConvertToIntensityMode", &AreaLightRequestBus::Events::ConvertToIntensityMode)
->VirtualProperty("AttenuationRadius", "GetAttenuationRadius", "SetAttenuationRadius")
->VirtualProperty("Color", "GetColor", "SetColor")
->VirtualProperty("EmitsLightBothDirections", "GetEmitsLightBothDirections", "SetEmitsLightBothDirections")
->VirtualProperty("UseFastApproximation", "GetUseFastApproximation", "SetUseFastApproximation")
->VirtualProperty("Intensity", "GetIntensity", "SetIntensity")
;
}
}
void AreaLightComponentController::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC_CE("AreaLightService"));
}
void AreaLightComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC_CE("AreaLightService"));
}
void AreaLightComponentController::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC_CE("AreaLightShapeService"));
}
AreaLightComponentController::AreaLightComponentController(const AreaLightComponentConfig& config)
: m_configuration(config)
{
}
void AreaLightComponentController::Activate(EntityId entityId)
{
m_entityId = entityId;
CreateLightShapeDelegate();
AZ_Warning("AreaLightComponentController", m_lightShapeDelegate, "AreaLightComponentController activated without having required component.");
// Used to determine if the shape can be double-sided.
LmbrCentral::ShapeComponentRequestsBus::EventResult(m_configuration.m_shapeType, m_entityId, &LmbrCentral::ShapeComponentRequestsBus::Events::GetShapeType);
AreaLightRequestBus::Handler::BusConnect(m_entityId);
ConfigurationChanged();
}
void AreaLightComponentController::Deactivate()
{
AreaLightRequestBus::Handler::BusDisconnect(m_entityId);
m_lightShapeDelegate.reset();
}
void AreaLightComponentController::SetConfiguration(const AreaLightComponentConfig& config)
{
m_configuration = config;
ConfigurationChanged();
}
const AreaLightComponentConfig& AreaLightComponentController::GetConfiguration() const
{
return m_configuration;
}
void AreaLightComponentController::SetVisibiliy(bool isVisible)
{
m_isVisible = isVisible;
if (m_lightShapeDelegate)
{
m_lightShapeDelegate->SetVisibility(m_isVisible);
}
}
void AreaLightComponentController::ConfigurationChanged()
{
ChromaChanged();
IntensityChanged();
AttenuationRadiusChanged();
if (m_lightShapeDelegate)
{
m_lightShapeDelegate->SetLightEmitsBothDirections(m_configuration.m_lightEmitsBothDirections);
m_lightShapeDelegate->SetUseFastApproximation(m_configuration.m_useFastApproximation);
}
}
void AreaLightComponentController::IntensityChanged()
{
AreaLightNotificationBus::Event(m_entityId, &AreaLightNotifications::OnColorOrIntensityChanged, m_configuration.m_color, m_configuration.m_intensity);
if (m_lightShapeDelegate)
{
m_lightShapeDelegate->SetPhotometricUnit(m_configuration.m_intensityMode);
m_lightShapeDelegate->SetIntensity(m_configuration.m_intensity);
}
}
void AreaLightComponentController::ChromaChanged()
{
if (m_lightShapeDelegate)
{
m_lightShapeDelegate->SetChroma(m_configuration.m_color);
}
}
void AreaLightComponentController::AttenuationRadiusChanged()
{
if (m_configuration.m_attenuationRadiusMode == LightAttenuationRadiusMode::Automatic)
{
AutoCalculateAttenuationRadius();
}
AreaLightNotificationBus::Event(m_entityId, &AreaLightNotifications::OnAttenutationRadiusChanged, m_configuration.m_attenuationRadius);
if (m_lightShapeDelegate)
{
m_lightShapeDelegate->SetAttenuationRadius(m_configuration.m_attenuationRadius);
}
}
void AreaLightComponentController::AutoCalculateAttenuationRadius()
{
if (m_lightShapeDelegate)
{
m_configuration.m_attenuationRadius = m_lightShapeDelegate->CalculateAttenuationRadius(AreaLightComponentConfig::CutoffIntensity);
}
}
const Color& AreaLightComponentController::GetColor() const
{
return m_configuration.m_color;
}
void AreaLightComponentController::SetColor(const Color& color)
{
m_configuration.m_color = color;
AreaLightNotificationBus::Event(m_entityId, &AreaLightNotifications::OnColorChanged, color);
ChromaChanged();
}
bool AreaLightComponentController::GetLightEmitsBothDirections() const
{
return m_configuration.m_lightEmitsBothDirections;
}
void AreaLightComponentController::SetLightEmitsBothDirections(bool value)
{
m_configuration.m_lightEmitsBothDirections = value;
}
bool AreaLightComponentController::GetUseFastApproximation() const
{
return m_configuration.m_useFastApproximation;
}
void AreaLightComponentController::SetUseFastApproximation(bool value)
{
m_configuration.m_useFastApproximation = value;
}
PhotometricUnit AreaLightComponentController::GetIntensityMode() const
{
return m_configuration.m_intensityMode;
}
float AreaLightComponentController::GetIntensity() const
{
return m_configuration.m_intensity;
}
void AreaLightComponentController::SetIntensity(float intensity, PhotometricUnit intensityMode)
{
m_configuration.m_intensityMode = intensityMode;
m_configuration.m_intensity = intensity;
AreaLightNotificationBus::Event(m_entityId, &AreaLightNotifications::OnIntensityChanged, intensity, intensityMode);
IntensityChanged();
}
void AreaLightComponentController::SetIntensity(float intensity)
{
m_configuration.m_intensity = intensity;
AreaLightNotificationBus::Event(m_entityId, &AreaLightNotifications::OnIntensityChanged, intensity, m_configuration.m_intensityMode);
IntensityChanged();
}
float AreaLightComponentController::GetAttenuationRadius() const
{
return m_configuration.m_attenuationRadius;
}
void AreaLightComponentController::SetAttenuationRadius(float radius)
{
m_configuration.m_attenuationRadius = radius;
m_configuration.m_attenuationRadiusMode = LightAttenuationRadiusMode::Explicit;
AttenuationRadiusChanged();
}
void AreaLightComponentController::SetAttenuationRadiusMode(LightAttenuationRadiusMode attenuationRadiusMode)
{
m_configuration.m_attenuationRadiusMode = attenuationRadiusMode;
AttenuationRadiusChanged();
}
void AreaLightComponentController::ConvertToIntensityMode(PhotometricUnit intensityMode)
{
if (m_lightShapeDelegate && m_lightShapeDelegate->GetPhotometricValue().GetType() != intensityMode)
{
m_configuration.m_intensityMode = intensityMode;
m_configuration.m_intensity = m_lightShapeDelegate->SetPhotometricUnit(intensityMode);
}
}
void AreaLightComponentController::HandleDisplayEntityViewport(
[[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo,
AzFramework::DebugDisplayRequests& debugDisplay,
bool isSelected)
{
Transform transform = Transform::CreateIdentity();
TransformBus::EventResult(transform, m_entityId, &TransformBus::Events::GetWorldTM);
if (m_lightShapeDelegate)
{
m_lightShapeDelegate->DrawDebugDisplay(transform, m_configuration.m_color, debugDisplay, isSelected);
}
}
void AreaLightComponentController::CreateLightShapeDelegate()
{
LmbrCentral::SphereShapeComponentRequests* sphereShapeInterface = LmbrCentral::SphereShapeComponentRequestsBus::FindFirstHandler(m_entityId);
if (sphereShapeInterface)
{
m_lightShapeDelegate = AZStd::make_unique<SphereLightDelegate>(sphereShapeInterface, m_entityId, m_isVisible);
return;
}
LmbrCentral::DiskShapeComponentRequests* diskShapeInterface = LmbrCentral::DiskShapeComponentRequestBus::FindFirstHandler(m_entityId);
if (diskShapeInterface)
{
m_lightShapeDelegate = AZStd::make_unique<DiskLightDelegate>(diskShapeInterface, m_entityId, m_isVisible);
return;
}
LmbrCentral::CapsuleShapeComponentRequests* capsuleShapeInterface = LmbrCentral::CapsuleShapeComponentRequestsBus::FindFirstHandler(m_entityId);
if (capsuleShapeInterface)
{
m_lightShapeDelegate = AZStd::make_unique<CapsuleLightDelegate>(capsuleShapeInterface, m_entityId, m_isVisible);
return;
}
LmbrCentral::QuadShapeComponentRequests* quadShapeInterface = LmbrCentral::QuadShapeComponentRequestBus::FindFirstHandler(m_entityId);
if (quadShapeInterface)
{
m_lightShapeDelegate = AZStd::make_unique<QuadLightDelegate>(quadShapeInterface, m_entityId, m_isVisible);
return;
}
LmbrCentral::PolygonPrismShapeComponentRequests* polyPrismShapeInterface = LmbrCentral::PolygonPrismShapeComponentRequestBus::FindFirstHandler(m_entityId);
if (polyPrismShapeInterface)
{
m_lightShapeDelegate = AZStd::make_unique<PolygonLightDelegate>(polyPrismShapeInterface, m_entityId, m_isVisible);
return;
}
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,96 @@
/*
* 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/EntityBus.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Component/TransformBus.h>
#include <AzCore/Math/Color.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/AreaLightBus.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/AreaLightComponentConfig.h>
#include <CoreLights/LightDelegateInterface.h>
namespace AZ
{
namespace Render
{
class AreaLightComponentController final
: private AreaLightRequestBus::Handler
{
public:
friend class EditorAreaLightComponent;
AZ_TYPE_INFO(AZ::Render::AreaLightComponentController, "{C185C0F7-0923-4EF7-94F7-B41D60FE535B}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
AreaLightComponentController() = default;
AreaLightComponentController(const AreaLightComponentConfig& config);
void Activate(EntityId entityId);
void Deactivate();
void SetConfiguration(const AreaLightComponentConfig& config);
const AreaLightComponentConfig& GetConfiguration() const;
//! Used by the editor to control visibility - the controller must remain active while invisible to handle light unit conversions.
void SetVisibiliy(bool isVisible);
private:
AZ_DISABLE_COPY(AreaLightComponentController);
// AreaLightRequestBus::Handler overrides ...
const Color& GetColor() const override;
void SetColor(const Color& color) override;
bool GetLightEmitsBothDirections() const override;
void SetLightEmitsBothDirections(bool value) override;
bool GetUseFastApproximation() const override;
void SetUseFastApproximation(bool useFastApproximation) override;
PhotometricUnit GetIntensityMode() const override;
float GetIntensity() const override;
void SetIntensity(float intensity, PhotometricUnit intensityMode) override;
void SetIntensity(float intensity) override;
float GetAttenuationRadius() const override;
void SetAttenuationRadius(float radius) override;
void SetAttenuationRadiusMode(LightAttenuationRadiusMode attenuationRadiusMode) override;
void ConvertToIntensityMode(PhotometricUnit intensityMode) override;
void HandleDisplayEntityViewport(
const AzFramework::ViewportInfo& viewportInfo,
AzFramework::DebugDisplayRequests& debugDisplay,
bool isSelected);
void ConfigurationChanged();
void IntensityChanged();
void ChromaChanged();
void AttenuationRadiusChanged();
//! Handles calculating the attenuation radius when LightAttenuationRadiusMode is auto
void AutoCalculateAttenuationRadius();
//! Handles creating the light shape delegate. Separate function to allow for early returns once the correct shape inteface is found.
void CreateLightShapeDelegate();
AZStd::unique_ptr<LightDelegateInterface> m_lightShapeDelegate;
AreaLightComponentConfig m_configuration;
EntityId m_entityId;
bool m_isVisible = true;
};
} // namespace Render
} // AZ namespace
@@ -0,0 +1,93 @@
/*
* 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 <CoreLights/CapsuleLightDelegate.h>
#include <Atom/RPI.Public/Scene.h>
#include <Atom/Feature/CoreLights/CapsuleLightFeatureProcessorInterface.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/AreaLightComponentConfig.h>
namespace AZ
{
namespace Render
{
CapsuleLightDelegate::CapsuleLightDelegate(LmbrCentral::CapsuleShapeComponentRequests* shapeBus, EntityId entityId, bool isVisible)
: LightDelegateBase<CapsuleLightFeatureProcessorInterface>(entityId, isVisible)
, m_shapeBus(shapeBus)
{
InitBase(entityId);
}
float CapsuleLightDelegate::CalculateAttenuationRadius(float lightThreshold) const
{
// Calculate the radius at which the irradiance will be equal to lightThreshold.
lightThreshold = AZStd::max<float>(lightThreshold, 0.001f); // prevent divide by zero.
// This equation is based off of the integration of a line segment against a perpendicular normal pointing at the center of the
// line segment from some distance away.
float scale = GetTransform().GetScale().GetMaxElement();
float h = GetInteriorHeight() * scale;
float t2 = lightThreshold * lightThreshold;
float h2 = h * h;
float h4 = h2 * h2;
float radius = sqrt(((-h2 / 4.0f) + sqrt((h4 / 16.0f) + (4.0f / t2))) / 2.0f);
float intensity = GetPhotometricValue().GetCombinedIntensity(PhotometricUnit::Candela);
return radius * intensity;
}
void CapsuleLightDelegate::HandleShapeChanged()
{
if (GetLightHandle().IsValid())
{
const auto endpoints = m_shapeBus->GetCapsulePoints();
GetFeatureProcessor()->SetCapsuleLineSegment(GetLightHandle(), endpoints.m_begin, endpoints.m_end);
float scale = GetTransform().GetScale().GetMaxElement();
float radius = m_shapeBus->GetRadius();
GetFeatureProcessor()->SetCapsuleRadius(GetLightHandle(), scale * radius);
}
}
float CapsuleLightDelegate::GetSurfaceArea() const
{
float scale = GetTransform().GetScale().GetMaxElement();
float radius = m_shapeBus->GetRadius();
float capsArea = 4.0f * Constants::Pi * radius * radius; // both caps make a sphere
float sideArea = 2.0f * Constants::Pi * radius * GetInteriorHeight(); // cylindrical area of capsule
return (capsArea + sideArea) * scale * scale;
}
void CapsuleLightDelegate::DrawDebugDisplay(const Transform& transform, const Color& color, AzFramework::DebugDisplayRequests& debugDisplay, bool isSelected) const
{
if (isSelected)
{
// Attenuation radius shape is just a capsule with the same internal height, but a radius of the attenuation radius.
float radius = CalculateAttenuationRadius(AreaLightComponentConfig::CutoffIntensity);
// Add on the caps for the attenuation radius
float scale = GetTransform().GetScale().GetMaxElement();
float height = m_shapeBus->GetHeight() * scale;
debugDisplay.SetColor(color);
debugDisplay.DrawWireCapsule(transform.GetTranslation(), transform.GetBasisZ(), radius, height);
}
}
float CapsuleLightDelegate::GetInteriorHeight() const
{
return m_shapeBus->GetHeight() - m_shapeBus->GetRadius() * 2.0f;
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,55 @@
/*
* 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 <CoreLights/LightDelegateBase.h>
#include <AzCore/Component/TransformBus.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <LmbrCentral/Shape/ShapeComponentBus.h>
#include <LmbrCentral/Shape/CapsuleShapeComponentBus.h>
#include <Atom/Feature/CoreLights/CapsuleLightFeatureProcessorInterface.h>
namespace AZ
{
namespace Render
{
//! Manages rendering a capsule light through the capsule light feature processor and communication with a capsule shape bus for the area light component.
class CapsuleLightDelegate final
: public LightDelegateBase<CapsuleLightFeatureProcessorInterface>
{
public:
CapsuleLightDelegate(LmbrCentral::CapsuleShapeComponentRequests* shapeBus, EntityId entityId, bool isVisible);
// LightDelegateBase overrides...
float GetSurfaceArea() const override;
float GetEffectiveSolidAngle() const override { return PhotometricValue::OmnidirectionalSteradians; }
float CalculateAttenuationRadius(float lightThreshold) const override;
void DrawDebugDisplay(const Transform& transform, const Color& color, AzFramework::DebugDisplayRequests& debugDisplay, bool isSelected) const override;
private:
// LightDelegateBase overrides...
void HandleShapeChanged() override;
// Gets the height of the capsule shape without caps
float GetInteriorHeight() const;
LmbrCentral::CapsuleShapeComponentRequests* m_shapeBus = nullptr;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,45 @@
/*
* 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 <CoreLights/DirectionalLightComponent.h>
#include <AzCore/Serialization/SerializeContext.h>
namespace AZ
{
namespace Render
{
DirectionalLightComponent::DirectionalLightComponent(const DirectionalLightComponentConfig& config)
: BaseClass(config)
{
}
void DirectionalLightComponent::Reflect(ReflectContext* context)
{
BaseClass::Reflect(context);
if (auto serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<DirectionalLightComponent, BaseClass>();
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<DirectionalLightComponent>()->RequestBus("DirectionalLightRequestBus");
behaviorContext->ConstantProperty("DirectionalLightComponentTypeId", BehaviorConstant(Uuid(DirectionalLightComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common);
}
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,40 @@
/*
* 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 <CoreLights/DirectionalLightComponentController.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/CoreLightsConstants.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/DirectionalLightComponentConfig.h>
#include <AzFramework/Components/ComponentAdapter.h>
namespace AZ
{
namespace Render
{
class DirectionalLightComponent final
: public AzFramework::Components::ComponentAdapter<DirectionalLightComponentController, DirectionalLightComponentConfig>
{
public:
using BaseClass = AzFramework::Components::ComponentAdapter<DirectionalLightComponentController, DirectionalLightComponentConfig>;
AZ_COMPONENT(AZ::Render::DirectionalLightComponent, DirectionalLightComponentTypeId);
DirectionalLightComponent() = default;
DirectionalLightComponent(const DirectionalLightComponentConfig& config);
virtual ~DirectionalLightComponent() override = default;
static void Reflect(ReflectContext* context);
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,130 @@
/*
* 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 <Atom/Feature/CoreLights/PhotometricValue.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/DirectionalLightComponentConfig.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
namespace AZ
{
namespace Render
{
void DirectionalLightComponentConfig::Reflect(ReflectContext* context)
{
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<DirectionalLightComponentConfig, ComponentConfig>()
->Version(6)
->Field("Color", &DirectionalLightComponentConfig::m_color)
->Field("IntensityMode", &DirectionalLightComponentConfig::m_intensityMode)
->Field("Intensity", &DirectionalLightComponentConfig::m_intensity)
->Field("AngularDiameter", &DirectionalLightComponentConfig::m_angularDiameter)
->Field("CameraEntityId", &DirectionalLightComponentConfig::m_cameraEntityId)
->Field("ShadowFarClipDistance", &DirectionalLightComponentConfig::m_shadowFarClipDistance)
->Field("ShadowmapSize", &DirectionalLightComponentConfig::m_shadowmapSize)
->Field("CascadeCount", &DirectionalLightComponentConfig::m_cascadeCount)
->Field("SplitAutomatic", &DirectionalLightComponentConfig::m_isShadowmapFrustumSplitAutomatic)
->Field("SplitRatio", &DirectionalLightComponentConfig::m_shadowmapFrustumSplitSchemeRatio)
->Field("CascadeFarDepths", &DirectionalLightComponentConfig::m_cascadeFarDepths)
->Field("GroundHeight", &DirectionalLightComponentConfig::m_groundHeight)
->Field("IsCascadeCorrectionEnabled", &DirectionalLightComponentConfig::m_isCascadeCorrectionEnabled)
->Field("IsDebugColoringEnabled", &DirectionalLightComponentConfig::m_isDebugColoringEnabled)
->Field("ShadowFilterMethod", &DirectionalLightComponentConfig::m_shadowFilterMethod)
->Field("SofteningBoundaryWidth", &DirectionalLightComponentConfig::m_boundaryWidth)
->Field("PcfPredictionSampleCount", &DirectionalLightComponentConfig::m_predictionSampleCount)
->Field("PcfFilteringSampleCount", &DirectionalLightComponentConfig::m_filteringSampleCount)
;
}
}
const char* DirectionalLightComponentConfig::GetIntensitySuffix() const
{
return PhotometricValue::GetTypeSuffix(m_intensityMode);
}
float DirectionalLightComponentConfig::GetIntensityMin() const
{
switch (m_intensityMode)
{
case PhotometricUnit::Lux:
return 0.0f;
case PhotometricUnit::Ev100Illuminance:
return -10.0f;
}
return 0.0f;
}
float DirectionalLightComponentConfig::GetIntensityMax() const
{
switch (m_intensityMode)
{
case PhotometricUnit::Lux:
return 1'000'000.0f;
case PhotometricUnit::Ev100Illuminance:
return 20.0f;
}
return 0.0f;
}
float DirectionalLightComponentConfig::GetIntensitySoftMin() const
{
switch (m_intensityMode)
{
case PhotometricUnit::Lux:
return 0.0f;
case PhotometricUnit::Ev100Illuminance:
return -4.0f;
}
return 0.0f;
}
float DirectionalLightComponentConfig::GetIntensitySoftMax() const
{
switch (m_intensityMode)
{
case PhotometricUnit::Lux:
return 200'000.0f;
case PhotometricUnit::Ev100Illuminance:
return 16.0f;
}
return 0.0f;
}
bool DirectionalLightComponentConfig::IsSplitManual() const
{
return !m_isShadowmapFrustumSplitAutomatic;
}
bool DirectionalLightComponentConfig::IsSplitAutomatic() const
{
return m_isShadowmapFrustumSplitAutomatic;
}
bool DirectionalLightComponentConfig::IsCascadeCorrectionDisabled() const
{
return (m_cascadeCount == 1 || !m_isCascadeCorrectionEnabled);
}
bool DirectionalLightComponentConfig::IsShadowFilteringDisabled() const
{
return (m_shadowFilterMethod == ShadowFilterMethod::None);
}
bool DirectionalLightComponentConfig::IsShadowPcfDisabled() const
{
return !(m_shadowFilterMethod == ShadowFilterMethod::Pcf ||
m_shadowFilterMethod == ShadowFilterMethod::EsmPcf);
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,625 @@
/*
* 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 <CoreLights/DirectionalLightComponentController.h>
#include <Atom/RPI.Public/Scene.h>
#include <Atom/Feature/CoreLights/ShadowConstants.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/Component/TransformBus.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/containers/vector.h>
namespace AZ
{
namespace Render
{
void DirectionalLightComponentController::Reflect(ReflectContext* context)
{
DirectionalLightComponentConfig::Reflect(context);
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<DirectionalLightComponentController>()
->Version(1)
->Field("Configuration", &DirectionalLightComponentController::m_configuration);
;
}
if (BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext
->Enum<static_cast<uint32_t>(ShadowFilterMethod::None)>("ShadowFilterMethod_None")
->Enum<static_cast<uint32_t>(ShadowFilterMethod::Pcf)>("ShadowFilterMethod_PCF")
->Enum<static_cast<uint32_t>(ShadowFilterMethod::Esm)>("ShadowFilterMethod_ESM")
->Enum<static_cast<uint32_t>(ShadowFilterMethod::EsmPcf)>("ShadowFilterMethod_ESM_PCF")
->Enum<static_cast<uint32_t>(ShadowmapSize::None)>("ShadowmapSize_None")
->Enum<static_cast<uint32_t>(ShadowmapSize::Size256)>("ShadowmapSize_256")
->Enum<static_cast<uint32_t>(ShadowmapSize::Size512)>("ShadowmapSize_512")
->Enum<static_cast<uint32_t>(ShadowmapSize::Size1024)>("ShadowmapSize_1024")
->Enum<static_cast<uint32_t>(ShadowmapSize::Size2048)>("ShadowmapSize_2045")
;
behaviorContext->EBus<DirectionalLightRequestBus>("DirectionalLightRequestBus")
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Event("GetColor", &DirectionalLightRequestBus::Events::GetColor)
->Event("SetColor", &DirectionalLightRequestBus::Events::SetColor)
->Event("GetIntensity", &DirectionalLightRequestBus::Events::GetIntensity)
->Event("SetIntensity", static_cast<void(DirectionalLightRequestBus::Events::*)(float)>(&DirectionalLightRequestBus::Events::SetIntensity))
->Event("GetAngularDiameter", &DirectionalLightRequestBus::Events::GetAngularDiameter)
->Event("SetAngularDiameter", &DirectionalLightRequestBus::Events::SetAngularDiameter)
->Event("GetShadowmapSize", &DirectionalLightRequestBus::Events::GetShadowmapSize)
->Event("SetShadowmapSize", &DirectionalLightRequestBus::Events::SetShadowmapSize)
->Event("GetCascadeCount", &DirectionalLightRequestBus::Events::GetCascadeCount)
->Event("SetCascadeCount", &DirectionalLightRequestBus::Events::SetCascadeCount)
->Event("GetSplitRatio", &DirectionalLightRequestBus::Events::GetShadowmapFrustumSplitSchemeRatio)
->Event("SetSplitRatio", &DirectionalLightRequestBus::Events::SetShadowmapFrustumSplitSchemeRatio)
->Event("GetCascadeFarDepth", &DirectionalLightRequestBus::Events::GetCascadeFarDepth)
->Event("SetCascadeFarDepth", &DirectionalLightRequestBus::Events::SetCascadeFarDepth)
->Event("GetSplitAutomatic", &DirectionalLightRequestBus::Events::GetShadowmapFrustumSplitAutomatic)
->Event("SetSplitAutomatic", &DirectionalLightRequestBus::Events::SetShadowmapFrustumSplitAutomatic)
->Event("GetCameraEntityId", &DirectionalLightRequestBus::Events::GetCameraEntityId)
->Event("SetCameraEntityId", &DirectionalLightRequestBus::Events::SetCameraEntityId)
->Event("GetShadowFarClipDistance", &DirectionalLightRequestBus::Events::GetShadowFarClipDistance)
->Event("SetShadowFarClipDistance", &DirectionalLightRequestBus::Events::SetShadowFarClipDistance)
->Event("GetGroundHeight", &DirectionalLightRequestBus::Events::GetGroundHeight)
->Event("SetGroundHeight", &DirectionalLightRequestBus::Events::SetGroundHeight)
->Event("GetViewFrustumCorrectionEnabled", &DirectionalLightRequestBus::Events::GetViewFrustumCorrectionEnabled)
->Event("SetViewFrustumCorrectionEnabled", &DirectionalLightRequestBus::Events::SetViewFrustumCorrectionEnabled)
->Event("GetDebugColoringEnabled", &DirectionalLightRequestBus::Events::GetDebugColoringEnabled)
->Event("SetDebugColoringEnabled", &DirectionalLightRequestBus::Events::SetDebugColoringEnabled)
->Event("GetShadowFilterMethod", &DirectionalLightRequestBus::Events::GetShadowFilterMethod)
->Event("SetShadowFilterMethod", &DirectionalLightRequestBus::Events::SetShadowFilterMethod)
->Event("GetSofteningBoundaryWidth", &DirectionalLightRequestBus::Events::GetSofteningBoundaryWidth)
->Event("SetSofteningBoundaryWidth", &DirectionalLightRequestBus::Events::SetSofteningBoundaryWidth)
->Event("GetPredictionSampleCount", &DirectionalLightRequestBus::Events::GetPredictionSampleCount)
->Event("SetPredictionSampleCount", &DirectionalLightRequestBus::Events::SetPredictionSampleCount)
->Event("GetFilteringSampleCount", &DirectionalLightRequestBus::Events::GetFilteringSampleCount)
->Event("SetFilteringSampleCount", &DirectionalLightRequestBus::Events::SetFilteringSampleCount)
->VirtualProperty("Color", "GetColor", "SetColor")
->VirtualProperty("Intensity", "GetIntensity", "SetIntensity")
->VirtualProperty("AngularDiameter", "GetAngularDiameter", "SetAngularDiameter")
->VirtualProperty("ShadowmapSize", "GetShadowmapSize", "SetShadowmapSize")
->VirtualProperty("CascadeCount", "GetCascadeCount", "SetCascadeCount")
->VirtualProperty("SplitRatio", "GetSplitRatio", "SetSplitRatio")
->VirtualProperty("CascadeDepth", "GetCascadeFarDepth", "SetCascadeFarDepth")
->VirtualProperty("SplitAutomatic", "GetSplitAutomatic", "SetSplitAutomatic")
->VirtualProperty("ShadowFarClipDistance", "GetShadowFarClipDistance", "SetShadowFarClipDistance")
->VirtualProperty("GroundHeight", "GetGroundHeight", "SetGroundHeight")
->VirtualProperty("ViewFrustumCorrectionEnabled", "GetViewFrustumCorrectionEnabled", "SetViewFrustumCorrectionEnabled")
->VirtualProperty("DebugColoringEnabled", "GetDebugColoringEnabled", "SetDebugColoringEnabled")
->VirtualProperty("ShadowFilterMethod", "GetShadowFilterMethod", "SetShadowFilterMethod")
->VirtualProperty("SofteningBoundaryWidth", "GetSofteningBoundaryWidth", "SetSofteningBoundaryWidth")
->VirtualProperty("PredictionSampleCount", "GetPredictionSampleCount", "SetPredictionSampleCount")
->VirtualProperty("FilteringSampleCount", "GetFilteringSampleCount", "SetFilteringSampleCount")
;
}
}
void DirectionalLightComponentController::GetDependentServices(ComponentDescriptor::DependencyArrayType& dependent)
{
dependent.push_back(AZ_CRC("TransformService", 0x8ee22c50));
}
void DirectionalLightComponentController::GetIncompatibleServices(ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("DirectionalLightService", 0x5270619f));
}
void DirectionalLightComponentController::GetProvidedServices(ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("DirectionalLightService", 0x5270619f));
}
DirectionalLightComponentController::DirectionalLightComponentController(const DirectionalLightComponentConfig& config)
: m_configuration(config)
{
}
void DirectionalLightComponentController::Activate(EntityId entityId)
{
m_entityId = entityId;
m_featureProcessor = RPI::Scene::GetFeatureProcessorForEntity<DirectionalLightFeatureProcessorInterface>(entityId);
AZ_Error("DirectionalLightComponentController", m_featureProcessor, "Could not find a DirectionalLightFeatureProcessorInterface on the scene.");
if (m_featureProcessor)
{
m_lightHandle = m_featureProcessor->AcquireLight();
ApplyConfiguration();
DirectionalLightRequestBus::Handler::BusConnect(entityId);
TickBus::Handler::BusConnect();
TransformNotificationBus::MultiHandler::BusConnect(entityId);
Camera::CameraNotificationBus::Handler::BusConnect();
}
}
void DirectionalLightComponentController::Deactivate()
{
Camera::CameraNotificationBus::Handler::BusDisconnect();
TransformNotificationBus::MultiHandler::BusDisconnect();
TickBus::Handler::BusDisconnect();
DirectionalLightRequestBus::Handler::BusDisconnect();
if (m_featureProcessor)
{
m_featureProcessor->ReleaseLight(m_lightHandle);
}
m_entityId.SetInvalid();
}
void DirectionalLightComponentController::SetConfiguration(const DirectionalLightComponentConfig& config)
{
m_configuration = config;
if (m_featureProcessor)
{
ApplyConfiguration();
}
}
const Color& DirectionalLightComponentController::GetColor() const
{
return m_configuration.m_color;
}
void DirectionalLightComponentController::SetColor(const Color& color)
{
m_configuration.m_color = color;
ColorIntensityChanged();
}
float DirectionalLightComponentController::GetIntensity() const
{
return m_configuration.m_intensity;
}
void DirectionalLightComponentController::SetIntensity(float intensity, PhotometricUnit unit)
{
m_photometricValue.ConvertToPhotometricUnit(unit);
m_photometricValue.SetIntensity(intensity);
m_configuration.m_intensityMode = unit;
m_configuration.m_intensity = intensity;
ColorIntensityChanged();
}
void DirectionalLightComponentController::SetIntensity(float intensity)
{
m_photometricValue.SetIntensity(intensity);
m_configuration.m_intensity = intensity;
ColorIntensityChanged();
}
float DirectionalLightComponentController::GetAngularDiameter() const
{
return m_configuration.m_angularDiameter;
}
void DirectionalLightComponentController::SetAngularDiameter(float angularDiameter)
{
m_configuration.m_angularDiameter = angularDiameter;
if (m_featureProcessor)
{
m_featureProcessor->SetAngularDiameter(m_lightHandle, m_configuration.m_angularDiameter);
}
}
ShadowmapSize DirectionalLightComponentController::GetShadowmapSize() const
{
return m_configuration.m_shadowmapSize;
}
void DirectionalLightComponentController::SetShadowmapSize(ShadowmapSize size)
{
// The minimum valid ShadowmapSize is 256 and maximum one is 2048.
const uint32_t sizeInt = aznumeric_cast<uint32_t>(size);
if (sizeInt < aznumeric_cast<uint32_t>(ShadowmapSize::Size512))
{
size = ShadowmapSize::Size256;
}
else if (sizeInt < aznumeric_cast<uint32_t>(ShadowmapSize::Size1024))
{
size = ShadowmapSize::Size512;
}
else if (sizeInt < aznumeric_cast<uint32_t>(ShadowmapSize::Size2048))
{
size = ShadowmapSize::Size1024;
}
else
{
size = ShadowmapSize::Size2048;
}
m_configuration.m_shadowmapSize = size;
if (m_featureProcessor)
{
m_featureProcessor->SetShadowmapSize(m_lightHandle, size);
}
}
uint32_t DirectionalLightComponentController::GetCascadeCount() const
{
return aznumeric_cast<uint32_t>(m_configuration.m_cascadeCount);
}
void DirectionalLightComponentController::SetCascadeCount(uint32_t cascadeCount)
{
const uint16_t cascadeCount16 = cascadeCount = GetMin(Shadow::MaxNumberOfCascades, GetMax<uint16_t>(1, aznumeric_cast<uint16_t>(cascadeCount)));
m_configuration.m_cascadeCount = cascadeCount16;
if (m_featureProcessor)
{
m_featureProcessor->SetCascadeCount(m_lightHandle, cascadeCount16);
}
}
float DirectionalLightComponentController::GetShadowmapFrustumSplitSchemeRatio() const
{
return m_configuration.m_shadowmapFrustumSplitSchemeRatio;
}
void DirectionalLightComponentController::SetShadowmapFrustumSplitSchemeRatio(float ratio)
{
ratio = GetMin(1.f, GetMax(0.f, ratio));
m_configuration.m_shadowmapFrustumSplitSchemeRatio = ratio;
m_configuration.m_isShadowmapFrustumSplitAutomatic = true;
if (m_featureProcessor)
{
m_featureProcessor->SetShadowmapFrustumSplitSchemeRatio(m_lightHandle, ratio);
}
}
const Vector4& DirectionalLightComponentController::GetCascadeFarDepth()
{
return m_configuration.m_cascadeFarDepths;
}
void DirectionalLightComponentController::SetCascadeFarDepth(const Vector4& farDepth)
{
m_configuration.m_cascadeFarDepths = farDepth;
if (m_featureProcessor)
{
for (uint16_t index = 0; index < Shadow::MaxNumberOfCascades; ++index)
{
m_featureProcessor->SetCascadeFarDepth(m_lightHandle, index, farDepth.GetElement(index));
}
}
}
bool DirectionalLightComponentController::GetShadowmapFrustumSplitAutomatic() const
{
return m_configuration.m_isShadowmapFrustumSplitAutomatic;
}
void DirectionalLightComponentController::SetShadowmapFrustumSplitAutomatic(bool isAutomatic)
{
m_configuration.m_isShadowmapFrustumSplitAutomatic = isAutomatic;
}
EntityId DirectionalLightComponentController::GetCameraEntityId() const
{
return m_configuration.m_cameraEntityId;
}
void DirectionalLightComponentController::SetCameraEntityId(EntityId cameraEntityId)
{
if (m_configuration.m_cameraEntityId.IsValid())
{
TransformNotificationBus::MultiHandler::BusDisconnect(m_configuration.m_cameraEntityId);
}
if (cameraEntityId.IsValid())
{
TransformNotificationBus::MultiHandler::BusConnect(cameraEntityId);
}
m_configuration.m_cameraEntityId = cameraEntityId;
}
float DirectionalLightComponentController::GetShadowFarClipDistance() const
{
return m_configuration.m_shadowFarClipDistance;
}
void DirectionalLightComponentController::SetShadowFarClipDistance(float farDist)
{
m_configuration.m_shadowFarClipDistance = farDist;
if (m_featureProcessor)
{
m_featureProcessor->SetShadowFarClipDistance(m_lightHandle, farDist);
}
}
float DirectionalLightComponentController::GetGroundHeight() const
{
return m_configuration.m_groundHeight;
}
void DirectionalLightComponentController::SetGroundHeight(float groundHeight)
{
m_configuration.m_groundHeight = groundHeight;
if (m_featureProcessor)
{
m_featureProcessor->SetGroundHeight(m_lightHandle, groundHeight);
}
}
bool DirectionalLightComponentController::GetViewFrustumCorrectionEnabled() const
{
return m_configuration.m_isCascadeCorrectionEnabled;
}
void DirectionalLightComponentController::SetViewFrustumCorrectionEnabled(bool enabled)
{
m_configuration.m_isCascadeCorrectionEnabled = enabled;
if (m_featureProcessor)
{
m_featureProcessor->SetViewFrustumCorrectionEnabled(m_lightHandle, enabled);
}
}
bool DirectionalLightComponentController::GetDebugColoringEnabled() const
{
return m_configuration.m_isDebugColoringEnabled;
}
void DirectionalLightComponentController::SetDebugColoringEnabled(bool enabled)
{
m_configuration.m_isDebugColoringEnabled = enabled;
if (m_featureProcessor)
{
m_featureProcessor->SetDebugFlags(m_lightHandle, enabled ?
DirectionalLightFeatureProcessorInterface::DebugDrawFlags::DebugDrawAll :
DirectionalLightFeatureProcessorInterface::DebugDrawFlags::DebugDrawNone
);
}
}
ShadowFilterMethod DirectionalLightComponentController::GetShadowFilterMethod() const
{
return m_configuration.m_shadowFilterMethod;
}
void DirectionalLightComponentController::SetShadowFilterMethod(ShadowFilterMethod method)
{
if (aznumeric_cast<uint32_t>(method) >= aznumeric_cast<uint32_t>(ShadowFilterMethod::Count))
{
method = ShadowFilterMethod::None;
}
m_configuration.m_shadowFilterMethod = method;
if (m_featureProcessor)
{
m_featureProcessor->SetShadowFilterMethod(m_lightHandle, method);
}
}
float DirectionalLightComponentController::GetSofteningBoundaryWidth() const
{
return m_configuration.m_boundaryWidth;
}
void DirectionalLightComponentController::SetSofteningBoundaryWidth(float width)
{
width = GetMin(Shadow::MaxSofteningBoundaryWidth, GetMax(0.f, width));
m_configuration.m_boundaryWidth = width;
if (m_featureProcessor)
{
m_featureProcessor->SetShadowBoundaryWidth(m_lightHandle, width);
}
}
uint32_t DirectionalLightComponentController::GetPredictionSampleCount() const
{
return aznumeric_cast<uint32_t>(m_configuration.m_predictionSampleCount);
}
void DirectionalLightComponentController::SetPredictionSampleCount(uint32_t count)
{
const uint16_t count16 = GetMin(Shadow::MaxPcfSamplingCount, aznumeric_cast<uint16_t>(count));
m_configuration.m_predictionSampleCount = count16;
if (m_featureProcessor)
{
m_featureProcessor->SetPredictionSampleCount(m_lightHandle, count16);
}
}
uint32_t DirectionalLightComponentController::GetFilteringSampleCount() const
{
return aznumeric_cast<uint32_t>(m_configuration.m_filteringSampleCount);
}
void DirectionalLightComponentController::SetFilteringSampleCount(uint32_t count)
{
const uint16_t count16 = GetMin(Shadow::MaxPcfSamplingCount, aznumeric_cast<uint16_t>(count));
m_configuration.m_filteringSampleCount = count16;
if (m_featureProcessor)
{
m_featureProcessor->SetFilteringSampleCount(m_lightHandle, count16);
}
}
const DirectionalLightComponentConfig& DirectionalLightComponentController::GetConfiguration() const
{
return m_configuration;
}
void DirectionalLightComponentController::OnTick(float, ScriptTimePoint)
{
if (!m_configuration.m_cameraEntityId.IsValid())
{
UpdateCameraTransform();
}
if (m_featureProcessor)
{
m_featureProcessor->SetCameraConfiguration(m_lightHandle, GetCameraConfiguration());
}
}
void DirectionalLightComponentController::OnTransformChanged(const Transform&, const Transform&)
{
const EntityId* currentBusId = TransformNotificationBus::GetCurrentBusId();
if (!currentBusId)
{
AZ_Assert(false, "Cannot get current Bus ID.");
return;
}
if (*currentBusId == m_entityId)
{
UpdateLightTransform();
}
else if (*currentBusId == m_configuration.m_cameraEntityId)
{
UpdateCameraTransform();
}
}
void DirectionalLightComponentController::OnCameraAdded(const AZ::EntityId& cameraId)
{
if (cameraId == m_configuration.m_cameraEntityId)
{
TransformNotificationBus::MultiHandler::BusConnect(cameraId);
}
}
void DirectionalLightComponentController::OnCameraRemoved(const AZ::EntityId& cameraId)
{
if (cameraId == m_configuration.m_cameraEntityId)
{
TransformNotificationBus::MultiHandler::BusDisconnect(cameraId);
m_configuration.m_cameraEntityId.SetInvalid();
}
}
void DirectionalLightComponentController::ApplyConfiguration()
{
m_photometricValue = PhotometricValue(m_configuration.m_intensity, m_configuration.m_color, m_configuration.m_intensityMode);
ColorIntensityChanged();
SetAngularDiameter(m_configuration.m_angularDiameter);
SetCameraEntityId(m_configuration.m_cameraEntityId);
SetCascadeCount(m_configuration.m_cascadeCount);
if (m_configuration.m_isShadowmapFrustumSplitAutomatic)
{
SetShadowmapFrustumSplitSchemeRatio(m_configuration.m_shadowmapFrustumSplitSchemeRatio);
}
else
{
SetCascadeFarDepth(m_configuration.m_cascadeFarDepths);
}
SetShadowmapSize(m_configuration.m_shadowmapSize);
UpdateLightTransform();
m_lastCameraTransform = Transform::CreateTranslation(AZ::Vector3(std::numeric_limits<float>::max())); // invalid value
UpdateCameraTransform();
if (m_featureProcessor)
{
m_featureProcessor->SetCameraConfiguration(m_lightHandle, GetCameraConfiguration());
}
SetShadowFarClipDistance(m_configuration.m_shadowFarClipDistance);
SetGroundHeight(m_configuration.m_groundHeight);
SetViewFrustumCorrectionEnabled(m_configuration.m_isCascadeCorrectionEnabled);
SetDebugColoringEnabled(m_configuration.m_isDebugColoringEnabled);
SetShadowFilterMethod(m_configuration.m_shadowFilterMethod);
SetSofteningBoundaryWidth(m_configuration.m_boundaryWidth);
SetPredictionSampleCount(m_configuration.m_predictionSampleCount);
SetFilteringSampleCount(m_configuration.m_filteringSampleCount);
// [GFX TODO][ATOM-1726] share config for multiple light (e.g., light ID).
// [GFX TODO][ATOM-2416] adapt to multiple viewports.
}
Camera::Configuration DirectionalLightComponentController::GetCameraConfiguration() const
{
Camera::Configuration config;
if (m_configuration.m_cameraEntityId.IsValid())
{
Camera::CameraRequestBus::EventResult(
config,
m_configuration.m_cameraEntityId,
&Camera::CameraRequestBus::Events::GetCameraConfiguration);
}
else
{
Camera::ActiveCameraRequestBus::BroadcastResult(
config,
&Camera::ActiveCameraRequestBus::Events::GetActiveCameraConfiguration);
}
if (config.m_fovRadians == 0.f)
{
// When the entity does not have a camera component,
// the config. get invalid. Then we use the default config.
config.m_fovRadians = Constants::HalfPi;
config.m_nearClipDistance = 0.1f;
config.m_farClipDistance = 100.f;
config.m_frustumWidth = 100.f;
config.m_frustumHeight = 100.f;
}
return config;
}
void DirectionalLightComponentController::UpdateCameraTransform()
{
auto cameraTransform = Transform::CreateIdentity();
if (m_configuration.m_cameraEntityId.IsValid())
{
TransformBus::EventResult(
cameraTransform,
m_configuration.m_cameraEntityId,
&TransformBus::Events::GetWorldTM);
}
else
{
Camera::ActiveCameraRequestBus::BroadcastResult(
cameraTransform,
&Camera::ActiveCameraRequestBus::Events::GetActiveCameraTransform);
}
if (cameraTransform == m_lastCameraTransform)
{
return;
}
m_lastCameraTransform = cameraTransform;
if (m_featureProcessor)
{
m_featureProcessor->SetCameraTransform(m_lightHandle, cameraTransform);
}
}
void DirectionalLightComponentController::UpdateLightTransform()
{
auto lightTransform = Transform::CreateIdentity();
TransformBus::EventResult(
lightTransform,
m_entityId,
&TransformBus::Events::GetWorldTM);
if (m_featureProcessor)
{
m_featureProcessor->SetDirection(m_lightHandle, lightTransform.GetBasisY());
}
}
void DirectionalLightComponentController::ColorIntensityChanged()
{
m_photometricValue.SetChroma(m_configuration.m_color);
m_photometricValue.SetIntensity(m_configuration.m_intensity);
if (m_featureProcessor)
{
m_featureProcessor->SetRgbIntensity(m_lightHandle, m_photometricValue.GetCombinedRgb<PhotometricUnit::Lux>());
}
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,130 @@
/*
* 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 <Atom/Feature/CoreLights/DirectionalLightFeatureProcessorInterface.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/DirectionalLightBus.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/DirectionalLightComponentConfig.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Component/TickBus.h>
#include <AzCore/Component/TransformBus.h>
#include <AzFramework/Components/CameraBus.h>
namespace AZ
{
namespace Render
{
class EditorDirectionalLightComponent;
class DirectionalLightComponentController final
: public DirectionalLightRequestBus::Handler
, public TickBus::Handler
, TransformNotificationBus::MultiHandler
, Camera::CameraNotificationBus::Handler
{
public:
friend class EditorDirectionaLightComponent;
AZ_TYPE_INFO(AZ::Render::DirectionalLightComponentController, "60A9DFF4-6A05-4D83-81BD-13ADEB95B29C");
static void Reflect(ReflectContext* context);
static void GetDependentServices(ComponentDescriptor::DependencyArrayType& dependent);
static void GetProvidedServices(ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(ComponentDescriptor::DependencyArrayType& incompatible);
DirectionalLightComponentController() = default;
DirectionalLightComponentController(const DirectionalLightComponentConfig& config);
virtual ~DirectionalLightComponentController() = default;
void Activate(EntityId entityId);
void Deactivate();
void SetConfiguration(const DirectionalLightComponentConfig& config);
const DirectionalLightComponentConfig& GetConfiguration() const;
// DirectionalLightRequestBus::Handler overrides...
const Color& GetColor() const override;
void SetColor(const Color& color) override;
float GetIntensity() const override;
void SetIntensity(float intensity, PhotometricUnit unit) override;
void SetIntensity(float intensity) override;
float GetAngularDiameter() const override;
void SetAngularDiameter(float angularDiameter) override;
ShadowmapSize GetShadowmapSize() const override;
void SetShadowmapSize(ShadowmapSize size) override;
uint32_t GetCascadeCount() const override;
void SetCascadeCount(uint32_t cascadeCount) override;
float GetShadowmapFrustumSplitSchemeRatio() const override;
void SetShadowmapFrustumSplitSchemeRatio(float ratio) override;
const Vector4& GetCascadeFarDepth() override;
void SetCascadeFarDepth(const Vector4& farDepth) override;
bool GetShadowmapFrustumSplitAutomatic() const override;
void SetShadowmapFrustumSplitAutomatic(bool isAutomatic) override;
EntityId GetCameraEntityId() const override;
void SetCameraEntityId(EntityId entityId) override;
float GetShadowFarClipDistance() const override;
void SetShadowFarClipDistance(float farDist) override;
float GetGroundHeight() const override;
void SetGroundHeight(float groundHeight) override;
bool GetViewFrustumCorrectionEnabled() const override;
void SetViewFrustumCorrectionEnabled(bool enabled) override;
bool GetDebugColoringEnabled() const override;
void SetDebugColoringEnabled(bool enabled) override;
ShadowFilterMethod GetShadowFilterMethod() const override;
void SetShadowFilterMethod(ShadowFilterMethod method) override;
float GetSofteningBoundaryWidth() const override;
void SetSofteningBoundaryWidth(float width) override;
uint32_t GetPredictionSampleCount() const override;
void SetPredictionSampleCount(uint32_t count) override;
uint32_t GetFilteringSampleCount() const override;
void SetFilteringSampleCount(uint32_t count) override;
private:
friend class EditorDirectionalLightComponent;
// TickBus::Handler overrides...
void OnTick(float deltaTime, ScriptTimePoint time) override;
// TransformNotificationBus::MultiHandler overrides...
void OnTransformChanged(const Transform& /*local*/, const Transform& /*world*/) override;
// Camera::CameraNotificationBus::Handler overrides...
void OnCameraAdded(const AZ::EntityId& cameraId) override;
void OnCameraRemoved(const AZ::EntityId& cameraId) override;
//! This apply the contents of m_configuration to the light.
void ApplyConfiguration();
//! This returns the configuration of camera.
Camera::Configuration GetCameraConfiguration() const;
//! This updates the current camera transform.
//! The camera transform defines the camera view frustum.
void UpdateCameraTransform();
//! This updates the current directional light transform.
void UpdateLightTransform();
//! Updates current directional light color and intensity.
void ColorIntensityChanged();
DirectionalLightComponentConfig m_configuration;
EntityId m_entityId{ EntityId::InvalidEntityId };
Transform m_lastCameraTransform = Transform::CreateTranslation(AZ::Vector3(std::numeric_limits<float>::max()));
PhotometricValue m_photometricValue;
DirectionalLightFeatureProcessorInterface* m_featureProcessor = nullptr;
DirectionalLightFeatureProcessorInterface::LightHandle m_lightHandle;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,75 @@
/*
* 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 <CoreLights/DiskLightDelegate.h>
#include <Atom/RPI.Public/Scene.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/AreaLightComponentConfig.h>
namespace AZ
{
namespace Render
{
DiskLightDelegate::DiskLightDelegate(LmbrCentral::DiskShapeComponentRequests* shapeBus, EntityId entityId, bool isVisible)
: LightDelegateBase<DiskLightFeatureProcessorInterface>(entityId, isVisible)
, m_shapeBus(shapeBus)
{
InitBase(entityId);
}
void DiskLightDelegate::SetLightEmitsBothDirections(bool lightEmitsBothDirections)
{
if (GetLightHandle().IsValid())
{
GetFeatureProcessor()->SetLightEmitsBothDirections(GetLightHandle(), lightEmitsBothDirections);
}
}
float DiskLightDelegate::CalculateAttenuationRadius(float lightThreshold) const
{
// Calculate the radius at which the irradiance will be equal to cutoffIntensity.
float intensity = GetPhotometricValue().GetCombinedIntensity(PhotometricUnit::Lumen);
return sqrt(intensity / lightThreshold);
}
void DiskLightDelegate::HandleShapeChanged()
{
if (GetLightHandle().IsValid())
{
GetFeatureProcessor()->SetPosition(GetLightHandle(), GetTransform().GetTranslation());
GetFeatureProcessor()->SetDirection(GetLightHandle(), m_shapeBus->GetNormal());
GetFeatureProcessor()->SetDiskRadius(GetLightHandle(), GetRadius());
}
}
float DiskLightDelegate::GetSurfaceArea() const
{
float radius = GetRadius();
return Constants::Pi * radius * radius;
}
float DiskLightDelegate::GetRadius() const
{
return m_shapeBus->GetRadius() * GetTransform().GetScale().GetMaxElement();
}
void DiskLightDelegate::DrawDebugDisplay(const Transform& transform, const Color& color, AzFramework::DebugDisplayRequests& debugDisplay, bool isSelected) const
{
if (isSelected)
{
debugDisplay.SetColor(color);
// Draw a disk for the attenuation radius
debugDisplay.DrawWireSphere(transform.GetTranslation(), CalculateAttenuationRadius(AreaLightComponentConfig::CutoffIntensity));
}
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,55 @@
/*
* 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 <CoreLights/LightDelegateBase.h>
#include <AzCore/Component/TransformBus.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <LmbrCentral/Shape/ShapeComponentBus.h>
#include <LmbrCentral/Shape/DiskShapeComponentBus.h>
#include <Atom/Feature/CoreLights/DiskLightFeatureProcessorInterface.h>
namespace AZ
{
namespace Render
{
//! Manages rendering a disk light through the disk light feature processor and communication with a disk shape bus for the area light component.
class DiskLightDelegate final
: public LightDelegateBase<DiskLightFeatureProcessorInterface>
{
public:
DiskLightDelegate(LmbrCentral::DiskShapeComponentRequests* shapeBus, EntityId entityId, bool isVisible);
// LightDelegateBase overrides...
void SetLightEmitsBothDirections(bool lightEmitsBothDirections) override;
float GetSurfaceArea() const override;
float GetEffectiveSolidAngle() const override { return PhotometricValue::DirectionalEffectiveSteradians; }
float CalculateAttenuationRadius(float lightThreshold) const override;
void DrawDebugDisplay(const Transform& transform, const Color& color, AzFramework::DebugDisplayRequests& debugDisplay, bool isSelected) const override;
private:
// LightDelegateBase overrides...
void HandleShapeChanged() override;
float GetRadius() const;
LmbrCentral::DiskShapeComponentRequests* m_shapeBus = nullptr;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,155 @@
/*
* 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 <CoreLights/EditorAreaLightComponent.h>
#include <Atom/RPI.Edit/Common/ColorUtils.h>
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
#include <LmbrCentral/Shape/ShapeComponentBus.h>
#include <LmbrCentral/Shape/EditorShapeComponentBus.h>
namespace AZ
{
namespace Render
{
EditorAreaLightComponent::EditorAreaLightComponent(const AreaLightComponentConfig& config)
: BaseClass(config)
{
}
void EditorAreaLightComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EditorAreaLightComponent, BaseClass>()
->Version(1, ConvertToEditorRenderComponentAdapter<1>);
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<EditorAreaLightComponent>(
"Area Light", "An Area light emits light emits light from a goemetric shape.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Atom")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/Component_Placeholder.svg")
->Attribute(AZ::Edit::Attributes::ViewportIcon, "editor/icons/components/viewport/component_placeholder.png")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://docs.aws.amazon.com/lumberyard/latest/userguide/component-area-light.html")
;
editContext->Class<AreaLightComponentController>(
"AreaLightComponentController", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &AreaLightComponentController::m_configuration, "Configuration", "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
;
editContext->Class<AreaLightComponentConfig>(
"AreaLightComponentConfig", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->DataElement(AZ::Edit::UIHandlers::Color, &AreaLightComponentConfig::m_color, "Color", "Color of the light")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute("ColorEditorConfiguration", AZ::RPI::ColorUtils::GetLinearRgbEditorConfig())
->DataElement(AZ::Edit::UIHandlers::ComboBox, &AreaLightComponentConfig::m_intensityMode, "Intensity Mode", "Allows specifying which photometric unit to work in.")
->EnumAttribute(PhotometricUnit::Candela, "Candela")
->EnumAttribute(PhotometricUnit::Lumen, "Lumen")
->EnumAttribute(PhotometricUnit::Nit, "Nit")
->EnumAttribute(PhotometricUnit::Ev100Luminance, "Ev100")
->DataElement(Edit::UIHandlers::Slider, &AreaLightComponentConfig::m_intensity, "Intensity", "Intensity of the light in the set photometric unit.")
->Attribute(Edit::Attributes::Min, &AreaLightComponentConfig::GetIntensityMin)
->Attribute(Edit::Attributes::Max, &AreaLightComponentConfig::GetIntensityMax)
->Attribute(Edit::Attributes::SoftMin, &AreaLightComponentConfig::GetIntensitySoftMin)
->Attribute(Edit::Attributes::SoftMax, &AreaLightComponentConfig::GetIntensitySoftMax)
->Attribute(Edit::Attributes::Suffix, &AreaLightComponentConfig::GetIntensitySuffix)
->DataElement(AZ::Edit::UIHandlers::CheckBox, &AreaLightComponentConfig::m_lightEmitsBothDirections, "Both Directions", "Whether light should emit from both sides of the surface or just the front")
->Attribute(AZ::Edit::Attributes::Visibility, &AreaLightComponentConfig::Is2DSurface)
->DataElement(AZ::Edit::UIHandlers::CheckBox, &AreaLightComponentConfig::m_useFastApproximation, "Fast Approximation", "Whether the light should use the default high quality linear transformed cosine technique or a faster approximation.")
->Attribute(AZ::Edit::Attributes::Visibility, &AreaLightComponentConfig::SupportsFastApproximation)
->ClassElement(AZ::Edit::ClassElements::Group, "Attenuation Radius")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::ComboBox, &AreaLightComponentConfig::m_attenuationRadiusMode, "Mode", "Controls whether the attenation radius is calculated automatically or set explicitly.")
->EnumAttribute(LightAttenuationRadiusMode::Automatic, "Automatic")
->EnumAttribute(LightAttenuationRadiusMode::Explicit, "Explicit")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::AttributesAndValues)
->DataElement(AZ::Edit::UIHandlers::Default, &AreaLightComponentConfig::m_attenuationRadius, "Radius", "The distance at which this light no longer has an affect.")
->Attribute(AZ::Edit::Attributes::ReadOnly, &AreaLightComponentConfig::IsAttenuationRadiusModeAutomatic)
;
}
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<EditorAreaLightComponent>()->RequestBus("AreaLightRequestBus");
behaviorContext->ConstantProperty("EditorAreaLightComponentTypeId", BehaviorConstant(Uuid(EditorAreaLightComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
}
}
void EditorAreaLightComponent::Activate()
{
m_controller.SetVisibiliy(IsVisible());
BaseClass::Activate();
AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(GetEntityId());
// Override the shape component so that this component controls the color.
LmbrCentral::EditorShapeComponentRequestsBus::Event(GetEntityId(), &LmbrCentral::EditorShapeComponentRequests::SetShapeColorIsEditable, false);
LmbrCentral::EditorShapeComponentRequestsBus::Event(GetEntityId(), &LmbrCentral::EditorShapeComponentRequests::SetShapeColor, m_controller.m_configuration.m_color);
}
void EditorAreaLightComponent::Deactivate()
{
LmbrCentral::EditorShapeComponentRequestsBus::Event(GetEntityId(), &LmbrCentral::EditorShapeComponentRequests::SetShapeColorIsEditable, true);
AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect();
BaseClass::Deactivate();
}
AZ::u32 EditorAreaLightComponent::OnConfigurationChanged()
{
LmbrCentral::EditorShapeComponentRequestsBus::Event(GetEntityId(), &LmbrCentral::EditorShapeComponentRequests::SetShapeColor, m_controller.m_configuration.m_color);
// If photometric unit changes, convert the intensities so the actual intensity doesn't change.
m_controller.ConvertToIntensityMode(m_controller.m_configuration.m_intensityMode);
BaseClass::OnConfigurationChanged();
return Edit::PropertyRefreshLevels::AttributesAndValues;
}
void EditorAreaLightComponent::OnEntityVisibilityChanged(bool visibility)
{
m_controller.SetVisibiliy(visibility);
}
void EditorAreaLightComponent::DisplayEntityViewport(
const AzFramework::ViewportInfo& viewportInfo,
AzFramework::DebugDisplayRequests& debugDisplay)
{
if (IsVisible())
{
m_controller.HandleDisplayEntityViewport(viewportInfo, debugDisplay, IsSelected());
}
}
bool EditorAreaLightComponent::ShouldActivateController() const
{
// Always true since this component needs to activate even when invisible.
return true;
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,59 @@
/*
* 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/PlatformDef.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <Atom/Feature/Utils/EditorRenderComponentAdapter.h>
#include <CoreLights/AreaLightComponent.h>
namespace AZ
{
namespace Render
{
class EditorAreaLightComponent final
: public EditorRenderComponentAdapter<AreaLightComponentController, AreaLightComponent, AreaLightComponentConfig>
, private AzFramework::EntityDebugDisplayEventBus::Handler
{
public:
using BaseClass = EditorRenderComponentAdapter<AreaLightComponentController, AreaLightComponent, AreaLightComponentConfig>;
AZ_EDITOR_COMPONENT(AZ::Render::EditorAreaLightComponent, EditorAreaLightComponentTypeId, BaseClass);
static void Reflect(AZ::ReflectContext* context);
EditorAreaLightComponent() = default;
EditorAreaLightComponent(const AreaLightComponentConfig& config);
void Activate() override;
void Deactivate() override;
private:
// AzFramework::EntityDebugDisplayEventBus::Handler overrides...
void DisplayEntityViewport(
const AzFramework::ViewportInfo& viewportInfo,
AzFramework::DebugDisplayRequests& debugDisplay) override;
// AzToolsFramework::EditorEntityVisibilityNotificationBus::Handler overrides (inherited from EditorRenderComponentAdapter)
void OnEntityVisibilityChanged(bool visibility) override;
// EditorRenderComponentAdapter overrides...
bool ShouldActivateController() const override;
AZ::u32 OnConfigurationChanged() override;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,250 @@
/*
* 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 <CoreLights/EditorDirectionalLightComponent.h>
#include <Atom/RPI.Edit/Common/ColorUtils.h>
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
#include <AzCore/Component/TransformBus.h>
#include <AzCore/Math/Transform.h>
#include <AzCore/Math/Vector3.h>
#include <Atom/Feature/CoreLights/PhotometricValue.h>
namespace AZ
{
namespace Render
{
EditorDirectionalLightComponent::EditorDirectionalLightComponent(const DirectionalLightComponentConfig& config)
: BaseClass(config)
{
}
void EditorDirectionalLightComponent::Reflect(ReflectContext* context)
{
BaseClass::Reflect(context);
if (SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<EditorDirectionalLightComponent, BaseClass>()
->Version(3, ConvertToEditorRenderComponentAdapter<2>);
if (EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<EditorDirectionalLightComponent>(
"Directional Light", "A directional light to cast a shadow of meshes onto meshes.")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute(Edit::Attributes::Category, "Atom")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/Component_Placeholder.svg") // [GFX TODO][ATOM-1998] create icons.
->Attribute(AZ::Edit::Attributes::ViewportIcon, "editor/icons/components/viewport/component_placeholder.png") // [GFX TODO][ATOM-1998] create icons.
->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->Attribute(Edit::Attributes::AutoExpand, true)
->Attribute(Edit::Attributes::HelpPageURL, "https://") // [GFX TODO][ATOM-1998] create page
;
editContext->Class<DirectionalLightComponentController>(
"DirectionalLightComponentController", "")
->ClassElement(Edit::ClassElements::EditorData, "")
->Attribute(Edit::Attributes::AutoExpand, true)
->DataElement(Edit::UIHandlers::Default, &DirectionalLightComponentController::m_configuration, "Configuration", "")
->Attribute(Edit::Attributes::Visibility, Edit::PropertyVisibility::ShowChildrenOnly)
;
editContext->Class<DirectionalLightComponentConfig>("DirectionalLightComponentConfig", "")
->ClassElement(Edit::ClassElements::EditorData, "")
->DataElement(Edit::UIHandlers::Color, &DirectionalLightComponentConfig::m_color, "Color", "Color of the light")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute("ColorEditorConfiguration", AZ::RPI::ColorUtils::GetLinearRgbEditorConfig())
->DataElement(Edit::UIHandlers::ComboBox, &DirectionalLightComponentConfig::m_intensityMode, "Intensity Mode", "Allows specifying light values in lux or Ev100")
->EnumAttribute(PhotometricUnit::Lux, "Lux")
->EnumAttribute(PhotometricUnit::Ev100Illuminance, "Ev100")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::AttributesAndValues)
->DataElement(Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_intensity, "Intensity", "Intensity of the light in the set photometric unit.")
->Attribute(Edit::Attributes::Min, &DirectionalLightComponentConfig::GetIntensityMin)
->Attribute(Edit::Attributes::Max, &DirectionalLightComponentConfig::GetIntensityMax)
->Attribute(Edit::Attributes::SoftMin, &DirectionalLightComponentConfig::GetIntensitySoftMin)
->Attribute(Edit::Attributes::SoftMax, &DirectionalLightComponentConfig::GetIntensitySoftMax)
->Attribute(Edit::Attributes::Suffix, &DirectionalLightComponentConfig::GetIntensitySuffix)
->DataElement(Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_angularDiameter, "Angular Diameter", "Angular Diameter of the directional light in degrees. The sun is about 0.5.")
->Attribute(Edit::Attributes::Min, 0.0f)
->Attribute(Edit::Attributes::Max, 5.0f)
->Attribute(Edit::Attributes::SoftMax, 1.0f)
->Attribute(Edit::Attributes::Suffix, " deg")
->ClassElement(AZ::Edit::ClassElements::Group, "Shadow")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(Edit::UIHandlers::EntityId, &DirectionalLightComponentConfig::m_cameraEntityId, "Camera", "Entity of the camera for cascaded shadowmap view frustum.")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(Edit::UIHandlers::Default, &DirectionalLightComponentConfig::m_shadowFarClipDistance, "Shadow Far Clip", "Shadow sepcific far clip distance.")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(Edit::UIHandlers::ComboBox, &DirectionalLightComponentConfig::m_shadowmapSize, "Shadowmap Size", "Width/Height of shadowmap")
->EnumAttribute(ShadowmapSize::Size256, " 256")
->EnumAttribute(ShadowmapSize::Size512, " 512")
->EnumAttribute(ShadowmapSize::Size1024, "1024")
->EnumAttribute(ShadowmapSize::Size2048, "2048")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_cascadeCount, "Cascade Count", "Number of cascades")
->Attribute(Edit::Attributes::Min, 1)
->Attribute(Edit::Attributes::Max, Shadow::MaxNumberOfCascades)
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(Edit::UIHandlers::Default, &DirectionalLightComponentConfig::m_isShadowmapFrustumSplitAutomatic, "Split Automatic",
"Switch splitting of shadowmap frustum to cascades automatically or not.")
->DataElement(Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_shadowmapFrustumSplitSchemeRatio, "Split Ratio",
"Ratio to lerp between the two types of frustum splitting scheme.\n"
"0 = Uniform scheme which will split the Frustum evenly across all cascades.\n"
"1 = Logarithmic scheme which is designed to split the frustum in a logarithmic fashion "
"in order to enable us to produce a more optimal perspective aliasing across the frustum.")
->Attribute(Edit::Attributes::Min, 0.f)
->Attribute(Edit::Attributes::Max, 1.f)
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &DirectionalLightComponentConfig::IsSplitManual)
->DataElement(Edit::UIHandlers::Vector4, &DirectionalLightComponentConfig::m_cascadeFarDepths, "Far Depth Cascade",
"Far Depth of each cascade. The value of the index greater than or equal to cascade count is ignored.")
->Attribute(Edit::Attributes::Min, 0.01f)
->Attribute(Edit::Attributes::Max, &DirectionalLightComponentConfig::m_shadowFarClipDistance)
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &DirectionalLightComponentConfig::IsSplitAutomatic)
->DataElement(Edit::UIHandlers::Default, &DirectionalLightComponentConfig::m_groundHeight, "Ground Height",
"Height of the ground. Used to correct position of cascades.")
->Attribute(Edit::Attributes::Suffix, " m")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &DirectionalLightComponentConfig::IsCascadeCorrectionDisabled)
->DataElement(Edit::UIHandlers::CheckBox,
&DirectionalLightComponentConfig::m_isCascadeCorrectionEnabled, "Enable Cascade Correction?",
"Enable position correction of cascades to optimize the appearance for certain camera positions.")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(Edit::UIHandlers::CheckBox,
&DirectionalLightComponentConfig::m_isDebugColoringEnabled, "Enable Debug Coloring?",
"Enable coloring to see how cascades places 0:red, 1:green, 2:blue, 3:yellow.")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(Edit::UIHandlers::ComboBox, &DirectionalLightComponentConfig::m_shadowFilterMethod, "Shadow Filter Method",
"Filtering method of edge-softening of shadows.\n"
" None: no filtering\n"
" PCF: Percentage-Closer Filtering\n"
" ESM: Exponential Shadow Maps\n"
" ESM+PCF: ESM with a PCF fallback\n"
"For BehaviorContext (or TrackView), None=0, PCF=1, ESM=2, ESM+PCF=3")
->EnumAttribute(ShadowFilterMethod::None, "None")
->EnumAttribute(ShadowFilterMethod::Pcf, "PCF")
->EnumAttribute(ShadowFilterMethod::Esm, "ESM")
->EnumAttribute(ShadowFilterMethod::EsmPcf, "ESM+PCF")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_boundaryWidth, "Softening Boundary Width",
"Width of the boundary between shadowed area and lit one. "
"Units are in meters. "
"If this is 0, softening edge is disabled.")
->Attribute(Edit::Attributes::Min, 0.f)
->Attribute(Edit::Attributes::Max, 0.1f)
->Attribute(Edit::Attributes::Suffix, " m")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &DirectionalLightComponentConfig::IsShadowFilteringDisabled)
->DataElement(Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_predictionSampleCount, "Prediction Sample Count",
"Sample Count for prediction of whether the pixel is on the boundary. "
"Specific to PCF and ESM+PCF.")
->Attribute(Edit::Attributes::Min, 4)
->Attribute(Edit::Attributes::Max, 16)
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &DirectionalLightComponentConfig::IsShadowPcfDisabled)
->DataElement(Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_filteringSampleCount, "Filtering Sample Count",
"It is used only when the pixel is predicted as on the boundary. "
"Specific to PCF and ESM+PCF.")
->Attribute(Edit::Attributes::Min, 4)
->Attribute(Edit::Attributes::Max, 64)
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &DirectionalLightComponentConfig::IsShadowPcfDisabled)
;
}
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<EditorDirectionalLightComponent>()->RequestBus("DirectionalLightRequestBus");
behaviorContext->ConstantProperty("EditorDirectionalLightComponentTypeId", BehaviorConstant(Uuid(EditorDirectionalLightComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
}
}
void EditorDirectionalLightComponent::Activate()
{
BaseClass::Activate();
AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(GetEntityId());
}
void EditorDirectionalLightComponent::Deactivate()
{
AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect();
BaseClass::Deactivate();
}
void EditorDirectionalLightComponent::DisplayEntityViewport(
[[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo,
AzFramework::DebugDisplayRequests& debugDisplay)
{
static const auto forward = Vector3::CreateAxisY();
static const auto up = Vector3::CreateAxisZ();
static const auto right = Vector3::CreateAxisX();
static const float arrowScale = 0.5f;
static const float arrowLength = 1.5f;
static const float arrowOffset = 0.75f;
static const float originScale = 0.2f;
static const float originScale0 = 0.1f;
static const float originScale1 = 0.05f;
auto transform = Transform::CreateIdentity();
TransformBus::EventResult(
transform,
GetEntityId(),
&TransformBus::Events::GetWorldTM);
transform.ExtractScale();
const Vector3 origin = transform.GetTranslation();
const Vector3 originOffset = origin - (transform.TransformVector(forward) * arrowOffset);
const Vector3 target = origin - (transform.TransformVector(forward) * (arrowLength + arrowOffset));
const Vector3 originPozZ = originOffset + (transform.TransformVector(up) * (originScale + originScale1));
const Vector3 targetPosZ = target + (transform.TransformVector(up) * (originScale + originScale1));
const Vector3 originPosX = originOffset + (transform.TransformVector(right) * (originScale + originScale1));
const Vector3 targetPosX = target + (transform.TransformVector(right) * (originScale + originScale1));
const Vector3 originNegX = originOffset - (transform.TransformVector(right) * (originScale + originScale1));
const Vector3 targetNegX = target - (transform.TransformVector(right) * (originScale + originScale1));
const Vector3 originNegZ = originOffset - (transform.TransformVector(up) * (originScale + originScale1));
const Vector3 targetNegZ = target - (transform.TransformVector(up) * (originScale + originScale1));
debugDisplay.SetColor(m_controller.GetColor());
debugDisplay.DrawWireDisk(origin, transform.TransformVector(-forward), originScale + originScale0);
debugDisplay.DrawArrow(targetPosZ, originPozZ, arrowScale);
debugDisplay.DrawArrow(targetNegZ, originNegZ, arrowScale);
debugDisplay.DrawArrow(targetPosX, originPosX, arrowScale);
debugDisplay.DrawArrow(targetNegX, originNegX, arrowScale);
debugDisplay.DrawDisk(origin, transform.TransformVector(forward), originScale);
}
u32 EditorDirectionalLightComponent::OnConfigurationChanged()
{
// Set the intenstiy of the photometric unit in case the controller is disabled. This is needed to correctly convert between photometric units.
m_controller.m_photometricValue.SetIntensity(m_controller.m_configuration.m_intensity);
// If the intensity mode changes in the editor, convert the photometric value and update the intensity
if (m_controller.m_configuration.m_intensityMode != m_controller.m_photometricValue.GetType())
{
m_controller.m_photometricValue.ConvertToPhotometricUnit(m_controller.m_configuration.m_intensityMode);
m_controller.m_configuration.m_intensity = m_controller.m_photometricValue.GetIntensity();
}
BaseClass::OnConfigurationChanged();
return Edit::PropertyRefreshLevels::AttributesAndValues;
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,51 @@
/*
* 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 <CoreLights/DirectionalLightComponent.h>
#include <Atom/Feature/Utils/EditorRenderComponentAdapter.h>
#include <AtomLyIntegration/CommonFeatures/CoreLights/DirectionalLightComponentConfig.h>
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
namespace AZ
{
namespace Render
{
class EditorDirectionalLightComponent final
: public EditorRenderComponentAdapter<DirectionalLightComponentController, DirectionalLightComponent, DirectionalLightComponentConfig>
, private AzFramework::EntityDebugDisplayEventBus::Handler
{
public:
using BaseClass = EditorRenderComponentAdapter<DirectionalLightComponentController, DirectionalLightComponent, DirectionalLightComponentConfig>;
AZ_EDITOR_COMPONENT(AZ::Render::EditorDirectionalLightComponent, EditorDirectionalLightComponentTypeId, BaseClass);
static void Reflect(ReflectContext* context);
EditorDirectionalLightComponent() = default;
EditorDirectionalLightComponent(const DirectionalLightComponentConfig& config);
void Activate() override;
void Deactivate() override;
//! EditorRenderComponentAdapter overrides...
AZ::u32 OnConfigurationChanged() override;
//! AzFramework::EntityDebugDisplayEventBus::Handler overrides...
void DisplayEntityViewport(
const AzFramework::ViewportInfo& viewportInfo,
AzFramework::DebugDisplayRequests& debugDisplay) override;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,206 @@
/*
* 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 <CoreLights/EditorPointLightComponent.h>
#include <Atom/RPI.Edit/Common/ColorUtils.h>
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
#include <AzCore/Math/IntersectSegment.h>
namespace AZ
{
namespace Render
{
EditorPointLightComponent::EditorPointLightComponent(const PointLightComponentConfig& config)
: BaseClass(config)
{
}
void EditorPointLightComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EditorPointLightComponent, BaseClass>()
->Version(1, ConvertToEditorRenderComponentAdapter<1>);
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<EditorPointLightComponent>(
"Point Light", "A point light emits light in all directions from a single point in space.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Atom")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/Component_Placeholder.svg")
->Attribute(AZ::Edit::Attributes::ViewportIcon, "editor/icons/components/viewport/component_placeholder.png")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://docs.aws.amazon.com/lumberyard/latest/userguide/component-point-light.html")
;
editContext->Class<PointLightComponentController>(
"PointLightComponentController", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &PointLightComponentController::m_configuration, "Configuration", "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
;
editContext->Class<PointLightComponentConfig>(
"PointLightComponentConfig", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->DataElement(AZ::Edit::UIHandlers::Color, &PointLightComponentConfig::m_color, "Color", "Color of the light")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute("ColorEditorConfiguration", AZ::RPI::ColorUtils::GetLinearRgbEditorConfig())
->DataElement(Edit::UIHandlers::ComboBox, &PointLightComponentConfig::m_intensityMode, "Intensity Mode", "Allows specifying light values in candelas or lumens")
->EnumAttribute(PhotometricUnit::Candela, "Candela")
->EnumAttribute(PhotometricUnit::Lumen, "Lumen")
->EnumAttribute(PhotometricUnit::Nit, "Nit")
->EnumAttribute(PhotometricUnit::Ev100Luminance, "Ev100")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::AttributesAndValues)
->DataElement(AZ::Edit::UIHandlers::Default, &PointLightComponentConfig::m_intensity, "Intensity", "Intensity of the light")
->Attribute(AZ::Edit::Attributes::Min, 0.f)
->Attribute(AZ::Edit::Attributes::Suffix, &PointLightComponentConfig::GetIntensitySuffix)
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(AZ::Edit::UIHandlers::Slider, &PointLightComponentConfig::m_bulbRadius, "Bulb Radius", "The size of the bulb in meters")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Max, 100000.0f)
->Attribute(AZ::Edit::Attributes::SoftMin, 0.01f)
->Attribute(AZ::Edit::Attributes::SoftMax, 1.0f)
->Attribute(AZ::Edit::Attributes::Suffix, " m")
->ClassElement(AZ::Edit::ClassElements::Group, "Attenuation Radius")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::ComboBox, &PointLightComponentConfig::m_attenuationRadiusMode, "Mode", "Controls whether the attenation radius is calculated automatically or set explicitly.")
->EnumAttribute(LightAttenuationRadiusMode::Automatic, "Automatic")
->EnumAttribute(LightAttenuationRadiusMode::Explicit, "Explicit")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::AttributesAndValues)
->DataElement(AZ::Edit::UIHandlers::Default, &PointLightComponentConfig::m_attenuationRadius, "Radius", "The distance at which this light no longer has an affect.")
->Attribute(AZ::Edit::Attributes::ReadOnly, &PointLightComponentConfig::IsAttenuationRadiusModeAutomatic)
;
}
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<EditorPointLightComponent>()->RequestBus("PointLightRequestBus");
behaviorContext->ConstantProperty("EditorPointLightComponentTypeId", BehaviorConstant(Uuid(EditorPointLightComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
}
}
void EditorPointLightComponent::Activate()
{
BaseClass::Activate();
AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(GetEntityId());
AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusConnect(GetEntityId());
TransformNotificationBus::Handler::BusConnect(GetEntityId());
AzFramework::BoundsRequestBus::Handler::BusConnect(GetEntityId());
}
void EditorPointLightComponent::Deactivate()
{
AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusDisconnect();
AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect();
BaseClass::Deactivate();
}
AZStd::tuple<float, Vector3> EditorPointLightComponent::GetRadiusAndPosition() const
{
Vector3 position = Vector3::CreateZero();
AZ::TransformBus::EventResult(position, GetEntityId(), &AZ::TransformBus::Events::GetWorldTranslation);
return AZStd::tuple<float, Vector3>(m_controller.GetBulbRadius(), position);
}
AZStd::tuple<float, Vector3> EditorPointLightComponent::GetViewportRadiusAndPosition(const AzFramework::ViewportInfo& viewportInfo) const
{
const auto [radius, position] = GetRadiusAndPosition();
constexpr float PixelRadius = 10.0f;
const AzFramework::CameraState cameraState = AzToolsFramework::GetCameraState(viewportInfo.m_viewportId);
const float distance = cameraState.m_position.GetDistance(position);
const float screenScale = (distance * cameraState.m_fovOrZoom) / cameraState.m_viewportSize.GetX();
return AZStd::tuple<float, Vector3>(AZ::GetMax(radius, screenScale * PixelRadius), position);
}
void EditorPointLightComponent::DisplayEntityViewport(
const AzFramework::ViewportInfo& viewportInfo,
AzFramework::DebugDisplayRequests& debugDisplay)
{
debugDisplay.SetColor(m_controller.GetColor());
// Draw a sphere for the light itself.
auto [sphereSize, position] = GetViewportRadiusAndPosition(viewportInfo);
debugDisplay.DrawWireSphere(position, sphereSize);
// Don't draw extra visualization unless selected.
if (!IsSelected())
{
return;
}
// Draw a sphere for the attenuation radius
debugDisplay.DrawWireSphere(position, m_controller.GetAttenuationRadius());
}
AZ::Aabb EditorPointLightComponent::GetEditorSelectionBoundsViewport(const AzFramework::ViewportInfo& viewportInfo)
{
auto [radius, position] = GetViewportRadiusAndPosition(viewportInfo);
return Aabb::CreateCenterRadius(position, radius);
}
bool EditorPointLightComponent::EditorSelectionIntersectRayViewport(
const AzFramework::ViewportInfo& viewportInfo, const AZ::Vector3& src, const AZ::Vector3& dir, float& distance)
{
auto [radius, position] = GetViewportRadiusAndPosition(viewportInfo);
return AZ::Intersect::IntersectRaySphere(src, dir, position, radius, distance) > 0;
}
void EditorPointLightComponent::OnTransformChanged([[maybe_unused]] const AZ::Transform& local, [[maybe_unused]] const AZ::Transform& world)
{
// Transform scale impacts the bulb radius and intensity of the light, so refresh the values.
AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(
&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay,
AzToolsFramework::Refresh_Values);
}
AZ::Aabb EditorPointLightComponent::GetWorldBounds()
{
auto [radius, position] = GetRadiusAndPosition();
return Aabb::CreateCenterRadius(position, radius);
}
AZ::Aabb EditorPointLightComponent::GetLocalBounds()
{
return Aabb::CreateCenterRadius(AZ::Vector3::CreateZero(), m_controller.GetBulbRadius());
}
u32 EditorPointLightComponent::OnConfigurationChanged()
{
// Set the intenstiy of the photometric unit in case the controller is disabled. This is needed to correctly convert between photometric units.
m_controller.m_photometricValue.SetIntensity(m_controller.m_configuration.m_intensity);
// If the intensity mode changes in the editor, convert the photometric value and update the intensity
if (m_controller.m_configuration.m_intensityMode != m_controller.m_photometricValue.GetType())
{
m_controller.m_photometricValue.SetArea(m_controller.m_configuration.GetArea());
m_controller.m_photometricValue.ConvertToPhotometricUnit(m_controller.m_configuration.m_intensityMode);
m_controller.m_configuration.m_intensity = m_controller.m_photometricValue.GetIntensity();
}
BaseClass::OnConfigurationChanged();
return Edit::PropertyRefreshLevels::AttributesAndValues;
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,74 @@
/*
* 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 <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <AzFramework/Visibility/BoundsBus.h>
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
#include <Atom/Feature/Utils/EditorRenderComponentAdapter.h>
#include <CoreLights/PointLightComponent.h>
namespace AZ
{
namespace Render
{
class EditorPointLightComponent final
: public EditorRenderComponentAdapter<PointLightComponentController, PointLightComponent, PointLightComponentConfig>
, private AzToolsFramework::EditorComponentSelectionRequestsBus::Handler
, private AzFramework::EntityDebugDisplayEventBus::Handler
, private TransformNotificationBus::Handler
, public AzFramework::BoundsRequestBus::Handler
{
public:
using BaseClass = EditorRenderComponentAdapter<PointLightComponentController, PointLightComponent, PointLightComponentConfig>;
AZ_EDITOR_COMPONENT(AZ::Render::EditorPointLightComponent, EditorPointLightComponentTypeId, BaseClass);
static void Reflect(AZ::ReflectContext* context);
EditorPointLightComponent() = default;
EditorPointLightComponent(const PointLightComponentConfig& config);
void Activate() override;
void Deactivate() override;
// EntityDebugDisplayEventBus overrides ...
void DisplayEntityViewport(
const AzFramework::ViewportInfo& viewportInfo,
AzFramework::DebugDisplayRequests& debugDisplay) override;
// EditorComponentSelectionRequestsBus overrides ...
bool SupportsEditorRayIntersect() override { return true; }
bool EditorSelectionIntersectRayViewport(
const AzFramework::ViewportInfo& viewportInfo, const AZ::Vector3& src, const AZ::Vector3& dir, float& distance) override;
AZ::Aabb GetEditorSelectionBoundsViewport(const AzFramework::ViewportInfo& viewportInfo) override;
// BoundsRequestBus overrides ...
AZ::Aabb GetWorldBounds() override;
AZ::Aabb GetLocalBounds() override;
private:
AZStd::tuple<float, Vector3> GetRadiusAndPosition() const;
// TransformNotificationBus::Handler overrides ...
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
//! Returns a radius for the light relative to the viewport, ensuring the the light will always take up at least a certain amount of
//! screen space for selection and debug drawing
AZStd::tuple<float, Vector3> GetViewportRadiusAndPosition(const AzFramework::ViewportInfo& viewportInfo) const;
//! EditorRenderComponentAdapter overrides ...
u32 OnConfigurationChanged() override;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,253 @@
/*
* 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 <CoreLights/EditorSpotLightComponent.h>
#include <Atom/RPI.Edit/Common/ColorUtils.h>
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
#include <CoreLights/SpotLightComponent.h>
namespace AZ
{
namespace Render
{
EditorSpotLightComponent::EditorSpotLightComponent(const SpotLightComponentConfig& config)
: BaseClass(config)
{
}
void EditorSpotLightComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<EditorSpotLightComponent, BaseClass>()
->Version(3, ConvertToEditorRenderComponentAdapter<2>);
if (AZ::EditContext * editContext = serializeContext->GetEditContext())
{
editContext->Class<EditorSpotLightComponent>(
"Spot Light", "A spot light emits light in a cone from a single point in space.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Atom")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/Component_Placeholder.svg")
->Attribute(AZ::Edit::Attributes::ViewportIcon, "editor/icons/components/viewport/component_placeholder.png")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://docs.aws.amazon.com/lumberyard/latest/userguide/component-spot-light.html")
;
editContext->Class<SpotLightComponentController>(
"SpotLightComponentController", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Default, &SpotLightComponentController::m_configuration, "Configuration", "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
;
editContext->Class<SpotLightComponentConfig>(
"SpotLightComponentConfig", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->DataElement(AZ::Edit::UIHandlers::Color, &SpotLightComponentConfig::m_color, "Color", "Color of the light")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute("ColorEditorConfiguration", AZ::RPI::ColorUtils::GetLinearRgbEditorConfig())
->DataElement(Edit::UIHandlers::ComboBox, &SpotLightComponentConfig::m_intensityMode, "Intensity Mode",
"Allows specifying light values in candelas or lumens")
->EnumAttribute(PhotometricUnit::Candela, "Candela")
->EnumAttribute(PhotometricUnit::Lumen, "Lumen")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::AttributesAndValues)
->DataElement(AZ::Edit::UIHandlers::Default, &SpotLightComponentConfig::m_intensity, "Intensity", "Intensity of the light")
->Attribute(AZ::Edit::Attributes::Min, 0.f)
->Attribute(AZ::Edit::Attributes::Suffix, &SpotLightComponentConfig::GetIntensitySuffix)
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(AZ::Edit::UIHandlers::Slider, &SpotLightComponentConfig::m_bulbRadius, "Bulb Radius",
"Radius of the disk that represents the spot light bulb.")
->Attribute(AZ::Edit::Attributes::Min, 0.f)
->Attribute(AZ::Edit::Attributes::SoftMax, 0.25f)
->Attribute(AZ::Edit::Attributes::Suffix, " m")
->ClassElement(AZ::Edit::ClassElements::Group, "Cone Configuration")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::Slider, &SpotLightComponentConfig::m_innerConeDegrees, "Inner Cone Angle",
"Angle from the direction axis at which this light starts to fall off.")
->Attribute(AZ::Edit::Attributes::Min, 0.f)
->Attribute(AZ::Edit::Attributes::Max, &SpotLightComponentConfig::GetConeDegrees)
->Attribute(AZ::Edit::Attributes::Suffix, " degrees")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(AZ::Edit::UIHandlers::Slider, &SpotLightComponentConfig::m_outerConeDegrees, "Outer Cone Angle",
"Angle from the direction axis at which this light no longer has an effect.")
->Attribute(AZ::Edit::Attributes::Min, 0.f)
->Attribute(AZ::Edit::Attributes::Max, &SpotLightComponentConfig::GetConeDegrees)
->Attribute(AZ::Edit::Attributes::Suffix, " degrees")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(AZ::Edit::UIHandlers::Slider, &SpotLightComponentConfig::m_penumbraBias, "Penumbra Bias",
"Controls biasing the fall off curve of the penumbra towards the inner or outer cone angles.")
->Attribute(AZ::Edit::Attributes::Min, -1.0f)
->Attribute(AZ::Edit::Attributes::Max, 1.0f)
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->ClassElement(AZ::Edit::ClassElements::Group, "Attenuation Radius")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(AZ::Edit::UIHandlers::ComboBox, &SpotLightComponentConfig::m_attenuationRadiusMode, "Mode",
"Controls whether the attenuation radius is calculated automatically or set explicitly.")
->EnumAttribute(LightAttenuationRadiusMode::Automatic, "Automatic")
->EnumAttribute(LightAttenuationRadiusMode::Explicit, "Explicit")
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::AttributesAndValues)
->DataElement(AZ::Edit::UIHandlers::Default, &SpotLightComponentConfig::m_attenuationRadius, "Radius",
"The distance at which this light no longer has an affect.")
->Attribute(AZ::Edit::Attributes::ReadOnly, &SpotLightComponentConfig::IsAttenuationRadiusModeAutomatic)
->ClassElement(AZ::Edit::ClassElements::Group, "Shadow")
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
->DataElement(Edit::UIHandlers::Default, &SpotLightComponentConfig::m_enabledShadow, "Enable Shadow", "Enable shadow for the light")
->DataElement(Edit::UIHandlers::ComboBox, &SpotLightComponentConfig::m_shadowmapSize, "Shadowmap Size", "Width/Height of shadowmap")
->EnumAttribute(ShadowmapSize::Size256, " 256")
->EnumAttribute(ShadowmapSize::Size512, " 512")
->EnumAttribute(ShadowmapSize::Size1024, "1024")
->EnumAttribute(ShadowmapSize::Size2048, "2048")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(Edit::UIHandlers::ComboBox, &SpotLightComponentConfig::m_shadowFilterMethod, "Shadow Filter Method",
"Filtering method of edge-softening of shadows.\n"
" None: no filtering\n"
" PCF: Percentage-Closer Filtering\n"
" ESM: Exponential Shadow Maps\n"
" ESM+PCF: ESM with a PCF fallback\n"
"For BehaviorContext (or TrackView), None=0, PCF=1, ESM=2, ESM+PCF=3")
->EnumAttribute(ShadowFilterMethod::None, "None")
->EnumAttribute(ShadowFilterMethod::Pcf, "PCF")
->EnumAttribute(ShadowFilterMethod::Esm, "ESM")
->EnumAttribute(ShadowFilterMethod::EsmPcf, "ESM+PCF")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(Edit::UIHandlers::Slider, &SpotLightComponentConfig::m_boundaryWidthInDegrees, "Softening Boundary Width",
"Width of the boundary between shadowed area and lit one. "
"Units are in degrees. "
"If this is 0, softening edge is disabled.")
->Attribute(Edit::Attributes::Min, 0.f)
->Attribute(Edit::Attributes::Max, 1.f)
->Attribute(Edit::Attributes::Suffix, " deg")
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &SpotLightComponentConfig::IsShadowFilteringDisabled)
->DataElement(Edit::UIHandlers::Slider, &SpotLightComponentConfig::m_predictionSampleCount, "Prediction Sample Count",
"Sample Count for prediction of whether the pixel is on the boundary. Specific to PCF and ESM+PCF.")
->Attribute(Edit::Attributes::Min, 4)
->Attribute(Edit::Attributes::Max, 16)
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &SpotLightComponentConfig::IsShadowPcfDisabled)
->DataElement(Edit::UIHandlers::Slider, &SpotLightComponentConfig::m_filteringSampleCount, "Filtering Sample Count",
"It is used only when the pixel is predicted to be on the boundary. Specific to PCF and ESM+PCF.")
->Attribute(Edit::Attributes::Min, 4)
->Attribute(Edit::Attributes::Max, 64)
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
->Attribute(Edit::Attributes::ReadOnly, &SpotLightComponentConfig::IsShadowPcfDisabled)
;
}
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<EditorSpotLightComponent>()->RequestBus("SpotLightRequestBus");
behaviorContext->ConstantProperty("EditorSpotLightComponentTypeId", BehaviorConstant(Uuid(EditorSpotLightComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
}
}
void EditorSpotLightComponent::Activate()
{
BaseClass::Activate();
AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(GetEntityId());
}
void EditorSpotLightComponent::Deactivate()
{
AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect();
BaseClass::Deactivate();
}
void EditorSpotLightComponent::DisplayEntityViewport(
const AzFramework::ViewportInfo& viewportInfo,
AzFramework::DebugDisplayRequests& debugDisplay)
{
AZ::Transform worldTM;
AZ::TransformBus::EventResult(worldTM, GetEntityId(), &AZ::TransformBus::Events::GetWorldTM);
const AZ::Vector3 position = worldTM.GetTranslation();
debugDisplay.SetColor(m_controller.GetColor());
// Draw a sphere for the light itself.
const float pixelRadius = 10.0f;
const AzFramework::CameraState cameraState = AzToolsFramework::GetCameraState(viewportInfo.m_viewportId);
const float distance = cameraState.m_position.GetDistance(position);
const float screenScale = (distance * cameraState.m_fovOrZoom) / cameraState.m_viewportSize.GetX();
debugDisplay.DrawWireSphere(position, screenScale * pixelRadius);
// Don't draw extra visualization unless selected.
if (!IsSelected())
{
return;
}
/*
* Draw rays to show the affected volume of the spot light.
* As well as two circle showing inner and outer cone angles.
* Note: the circles will not be drawn if cone are angles go beyond 90 degrees.
*/
worldTM.ExtractScale();
debugDisplay.PushMatrix(worldTM);
debugDisplay.SetColor(m_controller.GetColor());
float outerConeHalfAngle = m_controller.GetOuterConeAngleInDegrees() * 0.5f;
float innerConeHalfAngle = m_controller.GetInnerConeAngleInDegrees() * 0.5f;
const float debugConeHeight = m_controller.GetAttenuationRadius();
const float debugOuterConeRadius = tanf(AZ::DegToRad(outerConeHalfAngle)) * debugConeHeight;
debugDisplay.DrawArrow(Vector3::CreateZero(), Vector3::CreateAxisY() * debugConeHeight * 0.5f, debugConeHeight * 0.2f);
constexpr float rightAngleInDegrees = 90.0f;
if (outerConeHalfAngle < rightAngleInDegrees)
{
// outer cone
debugDisplay.DrawCircle(Vector3::CreateAxisY() * debugConeHeight, debugOuterConeRadius, 1);
}
if (innerConeHalfAngle < rightAngleInDegrees)
{
// inner cone
const float debugInnerConeRadius = tanf(AZ::DegToRad(innerConeHalfAngle)) * debugConeHeight;
debugDisplay.DrawCircle(Vector3::CreateAxisY() * debugConeHeight, debugInnerConeRadius, 1);
}
constexpr int debugRays = 6;
for (int rayIndex = 0; rayIndex < debugRays; ++rayIndex)
{
const float angle = (AZ::Constants::TwoPi / debugRays) * rayIndex;
const Vector3 spotRay = Vector3::CreateAxisY() * debugConeHeight + debugOuterConeRadius * Vector3(sinf(angle), 0.f, cosf(angle));
debugDisplay.DrawLine(Vector3::CreateZero(), spotRay * (outerConeHalfAngle > rightAngleInDegrees ? -1.f : 1.f));
}
debugDisplay.PopMatrix();
}
u32 EditorSpotLightComponent::OnConfigurationChanged()
{
// Set the intenstiy of the photometric unit in case the controller is disabled. This is needed to correctly convert between photometric units.
m_controller.m_photometricValue.SetIntensity(m_controller.m_configuration.m_intensity);
// If the intensity mode changes in the editor, convert the photometric value and update the intensity
if (m_controller.m_configuration.m_intensityMode != m_controller.m_photometricValue.GetType())
{
m_controller.m_photometricValue.ConvertToPhotometricUnit(m_controller.m_configuration.m_intensityMode);
m_controller.m_configuration.m_intensity = m_controller.m_photometricValue.GetIntensity();
}
BaseClass::OnConfigurationChanged();
return Edit::PropertyRefreshLevels::AttributesAndValues;
}
} // namespace Render
} // namespace AZ
@@ -0,0 +1,49 @@
/*
* 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 <AzFramework/Entity/EntityDebugDisplayBus.h>
#include <Atom/Feature/Utils/EditorRenderComponentAdapter.h>
#include <CoreLights/SpotLightComponent.h>
namespace AZ
{
namespace Render
{
class EditorSpotLightComponent final
: public EditorRenderComponentAdapter<SpotLightComponentController, SpotLightComponent, SpotLightComponentConfig>
, private AzFramework::EntityDebugDisplayEventBus::Handler
{
public:
using BaseClass = EditorRenderComponentAdapter<SpotLightComponentController, SpotLightComponent, SpotLightComponentConfig>;
AZ_EDITOR_COMPONENT(AZ::Render::EditorSpotLightComponent, EditorSpotLightComponentTypeId, BaseClass);
static void Reflect(AZ::ReflectContext* context);
EditorSpotLightComponent() = default;
EditorSpotLightComponent(const SpotLightComponentConfig& config);
void Activate() override;
void Deactivate() override;
// AzFramework::EntityDebugDisplayEventBus::Handler overrides...
void DisplayEntityViewport(
const AzFramework::ViewportInfo& viewportInfo,
AzFramework::DebugDisplayRequests& debugDisplay) override;
// EditorComponentAdapter overrides...
AZ::u32 OnConfigurationChanged() override;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,76 @@
/*
* 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/TransformBus.h>
#include <Atom/Feature/CoreLights/PhotometricValue.h>
#include <LmbrCentral/Shape/SphereShapeComponentBus.h>
#include <CoreLights/LightDelegateInterface.h>
namespace AzFramework
{
class DebugDisplayRequests;
}
namespace AZ
{
class Color;
class Transform;
namespace Render
{
//! Delegate for managing light shape specific functionality in the AreaLightComponentController.
template<typename FeatureProcessorType>
class LightDelegateBase
: public LightDelegateInterface
, private LmbrCentral::ShapeComponentNotificationsBus::Handler
{
public:
LightDelegateBase(EntityId entityId, bool isVisible);
virtual ~LightDelegateBase();
// LightDelegateInterface overrides...
virtual void SetChroma(const AZ::Color& chroma) override;
virtual void SetIntensity(float intensity) override;
virtual float SetPhotometricUnit(PhotometricUnit unit) override;
virtual void SetAttenuationRadius(float radius) override;
virtual const PhotometricValue& GetPhotometricValue() const override { return m_photometricValue; };
virtual void SetLightEmitsBothDirections([[maybe_unused]] bool lightEmitsBothDirections) override {};
virtual void SetUseFastApproximation([[maybe_unused]] bool useFastApproximation) override {};
virtual void SetVisibility(bool visibility) override;
protected:
void InitBase(EntityId entityId);
// Trivial getters
FeatureProcessorType* GetFeatureProcessor() const { return m_featureProcessor; };
typename FeatureProcessorType::LightHandle GetLightHandle() const { return m_lightHandle; };
const AZ::Transform& GetTransform() const { return m_transform; };
virtual void HandleShapeChanged() = 0;
// ShapeComponentNotificationsBus::Handler overrides...
void OnShapeChanged(ShapeChangeReasons changeReason) override;
private:
FeatureProcessorType* m_featureProcessor = nullptr;
typename FeatureProcessorType::LightHandle m_lightHandle;
LmbrCentral::ShapeComponentRequests* m_shapeBus;
AZ::Transform m_transform;
PhotometricValue m_photometricValue;
};
} // namespace Render
} // namespace AZ
#include <CoreLights/LightDelegateBase.inl>
@@ -0,0 +1,125 @@
/*
* 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 <Atom/RPI.Public/Scene.h>
namespace AZ
{
namespace Render
{
template <typename FeatureProcessorType>
LightDelegateBase<FeatureProcessorType>::LightDelegateBase(EntityId entityId, bool isVisible)
{
m_featureProcessor = RPI::Scene::GetFeatureProcessorForEntity<FeatureProcessorType>(entityId);
AZ_Error("LightDelegateBase", m_featureProcessor, "Unable to find a %s on the scene.", FeatureProcessorType::RTTI_TypeName());
if (m_featureProcessor && isVisible)
{
m_lightHandle = m_featureProcessor->AcquireLight();
}
}
template <typename FeatureProcessorType>
LightDelegateBase<FeatureProcessorType>::~LightDelegateBase()
{
LmbrCentral::ShapeComponentNotificationsBus::Handler::BusDisconnect();
if (m_lightHandle.IsValid())
{
m_featureProcessor->ReleaseLight(m_lightHandle);
}
}
template <typename FeatureProcessorType>
void LightDelegateBase<FeatureProcessorType>::InitBase(EntityId entityId)
{
m_photometricValue.SetEffectiveSolidAngle(GetEffectiveSolidAngle());
LmbrCentral::ShapeComponentNotificationsBus::Handler::BusConnect(entityId);
m_shapeBus = LmbrCentral::ShapeComponentRequestsBus::FindFirstHandler(entityId);
TransformBus::EventResult(m_transform, entityId, &TransformBus::Events::GetWorldTM);
OnShapeChanged(ShapeChangeReasons::TransformChanged);
}
template <typename FeatureProcessorType>
void LightDelegateBase<FeatureProcessorType>::SetChroma(const AZ::Color& color)
{
m_photometricValue.SetChroma(color);
if (m_lightHandle.IsValid())
{
m_featureProcessor->SetRgbIntensity(m_lightHandle, m_photometricValue.GetCombinedRgb<FeatureProcessorType::PhotometricUnitType>());
}
}
template <typename FeatureProcessorType>
void LightDelegateBase<FeatureProcessorType>::SetIntensity(float intensity)
{
m_photometricValue.SetIntensity(intensity);
if (m_lightHandle.IsValid())
{
m_featureProcessor->SetRgbIntensity(m_lightHandle, m_photometricValue.GetCombinedRgb<FeatureProcessorType::PhotometricUnitType>());
}
}
template <typename FeatureProcessorType>
float LightDelegateBase<FeatureProcessorType>::SetPhotometricUnit(PhotometricUnit unit)
{
m_photometricValue.SetArea(GetSurfaceArea());
m_photometricValue.ConvertToPhotometricUnit(unit);
if (m_lightHandle.IsValid())
{
m_featureProcessor->SetRgbIntensity(m_lightHandle, m_photometricValue.GetCombinedRgb<FeatureProcessorType::PhotometricUnitType>());
}
return m_photometricValue.GetIntensity();
}
template <typename FeatureProcessorType>
void LightDelegateBase<FeatureProcessorType>::OnShapeChanged(ShapeChangeReasons changeReason)
{
if (changeReason == ShapeChangeReasons::TransformChanged)
{
AZ::Aabb aabb; // unused, but required for GetTransformAndLocalBounds()
m_shapeBus->GetTransformAndLocalBounds(m_transform, aabb);
}
m_photometricValue.SetArea(GetSurfaceArea());
if (m_lightHandle.IsValid())
{
m_featureProcessor->SetRgbIntensity(m_lightHandle, m_photometricValue.GetCombinedRgb<FeatureProcessorType::PhotometricUnitType>());
}
HandleShapeChanged();
}
template <typename FeatureProcessorType>
void LightDelegateBase<FeatureProcessorType>::SetVisibility(bool isVisible)
{
if (m_lightHandle.IsValid() && !isVisible)
{
// no longer visible, release light handle
m_featureProcessor->ReleaseLight(m_lightHandle);
}
else if (!m_lightHandle.IsValid() && isVisible && m_featureProcessor)
{
// now visible, acquire light handle and update values.
m_lightHandle = m_featureProcessor->AcquireLight();
OnShapeChanged(ShapeChangeReasons::TransformChanged);
}
}
template <typename FeatureProcessorType>
void LightDelegateBase<FeatureProcessorType>::SetAttenuationRadius(float radius)
{
if (m_lightHandle.IsValid())
{
m_featureProcessor->SetAttenuationRadius(m_lightHandle, radius);
}
}
}
}
@@ -0,0 +1,61 @@
/*
* 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/TransformBus.h>
#include <Atom/Feature/CoreLights/PhotometricValue.h>
namespace AzFramework
{
class DebugDisplayRequests;
}
namespace AZ
{
class Color;
class Transform;
namespace Render
{
//! Delegate for managing light shape specific functionality in the AreaLightComponentController.
class LightDelegateInterface
{
public:
virtual ~LightDelegateInterface() {};
//! Sets the color of the light independent of light intensity. The color is a mask on the total light intensity.
virtual void SetChroma(const AZ::Color& chroma) = 0;
//! Sets the light intensity
virtual void SetIntensity(float intensity) = 0;
//! Sets the light unit, and returns the converted light intensity.
virtual float SetPhotometricUnit(PhotometricUnit unit) = 0;
//! Sets the maximum distance from any part of the surface of the area light at which this light will have an effect.
virtual void SetAttenuationRadius(float radius) = 0;
//! Gets the light intensity
virtual const PhotometricValue& GetPhotometricValue() const = 0;
//! Gets the surface area of the shape
virtual float GetSurfaceArea() const = 0;
//! Returns the number of steradians covered by this light type.
virtual float GetEffectiveSolidAngle() const = 0;
//! Sets if this shape is double-sided (only applicable for 2d shapes)
virtual void SetLightEmitsBothDirections([[maybe_unused]] bool lightEmitsBothDirections) = 0;
//! Sets if this light uses linearly transformed cosines (false) or a faster approximation (true). Only applicable for shapes that support LTC.
virtual void SetUseFastApproximation([[maybe_unused]] bool useFastApproximation) = 0;
//! Calculates the atteunation radius for this light type based on a threshold value.
virtual float CalculateAttenuationRadius(float lightThreshold) const = 0;
//! Handle any additional debug display drawing for beyond what the shape already provides.
virtual void DrawDebugDisplay(const Transform& transform, const Color& color, AzFramework::DebugDisplayRequests& debugDisplay, bool isSelected) const = 0;
//! Turns the visibility of this light on/off.
virtual void SetVisibility(bool visibility) = 0;
};
} // namespace Render
} // namespace AZ
@@ -0,0 +1,44 @@
/*
* 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 <CoreLights/PointLightComponent.h>
namespace AZ
{
namespace Render
{
PointLightComponent::PointLightComponent(const PointLightComponentConfig& config)
: BaseClass(config)
{
}
void PointLightComponent::Reflect(AZ::ReflectContext* context)
{
BaseClass::Reflect(context);
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<PointLightComponent, BaseClass>();
}
if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
{
behaviorContext->Class<PointLightComponent>()->RequestBus("PointLightRequestBus");
behaviorContext->ConstantProperty("PointLightComponentTypeId", BehaviorConstant(Uuid(PointLightComponentTypeId)))
->Attribute(AZ::Script::Attributes::Module, "render")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common);
}
}
} // namespace Render
} // namespace AZ

Some files were not shown because too many files have changed in this diff Show More