SkyAtmosphereComponentController.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Atom/Feature/SkyBox/SkyboxConstants.h>
  9. #include <SkyAtmosphere/SkyAtmosphereComponentController.h>
  10. #include <AtomLyIntegration/CommonFeatures/CoreLights/DirectionalLightBus.h>
  11. #include <AzCore/RTTI/BehaviorContext.h>
  12. #include <AzCore/Serialization/SerializeContext.h>
  13. #include <Atom/RPI.Public/Scene.h>
  14. namespace AZ::Render
  15. {
  16. // The {{{#_Property}}} magic is giving a friendly name to the Set Event parameter
  17. #define SKY_VIRTUAL_PROPERTY(_Property, _Param) \
  18. ->Event("Get" #_Property, &SkyAtmosphereRequestBus::Events::Get##_Property) \
  19. ->Event("Set" #_Property, &SkyAtmosphereRequestBus::Events::Set##_Property, {{{#_Param}}}) \
  20. ->VirtualProperty(#_Property, "Get" #_Property, "Set" #_Property)
  21. void SkyAtmosphereComponentController::Reflect(ReflectContext* context)
  22. {
  23. SkyAtmosphereComponentConfig::Reflect(context);
  24. if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
  25. {
  26. serializeContext->Class<SkyAtmosphereComponentController>()
  27. ->Version(1)
  28. ->Field("Configuration", &SkyAtmosphereComponentController::m_configuration);
  29. }
  30. if (auto* behaviorContext = azrtti_cast<BehaviorContext*>(context))
  31. {
  32. behaviorContext->EBus<SkyAtmosphereRequestBus>("SkyAtmosphereRequestBus")
  33. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
  34. ->Attribute(AZ::Script::Attributes::Category, "Render")
  35. ->Attribute(AZ::Script::Attributes::Module, "Render")
  36. SKY_VIRTUAL_PROPERTY(Enabled, Enabled)
  37. SKY_VIRTUAL_PROPERTY(PlanetOriginMode, Mode)
  38. SKY_VIRTUAL_PROPERTY(AtmosphereHeight, Height)
  39. SKY_VIRTUAL_PROPERTY(PlanetRadius, RadiusKm)
  40. SKY_VIRTUAL_PROPERTY(GroundAlbedo, Albedo)
  41. SKY_VIRTUAL_PROPERTY(LuminanceFactor, Factor)
  42. SKY_VIRTUAL_PROPERTY(MieAbsorption, Absorption)
  43. SKY_VIRTUAL_PROPERTY(MieExpDistribution, Distribution)
  44. SKY_VIRTUAL_PROPERTY(MieScattering, Scattering)
  45. SKY_VIRTUAL_PROPERTY(RayleighExpDistribution, Distribution)
  46. SKY_VIRTUAL_PROPERTY(RayleighScattering, Scattering)
  47. SKY_VIRTUAL_PROPERTY(MaxSamples, Samples)
  48. SKY_VIRTUAL_PROPERTY(MinSamples, Samples)
  49. SKY_VIRTUAL_PROPERTY(SunEnabled, Enabled)
  50. SKY_VIRTUAL_PROPERTY(SunEntityId, EntityId)
  51. SKY_VIRTUAL_PROPERTY(SunColor, Color)
  52. SKY_VIRTUAL_PROPERTY(SunLuminanceFactor, Factor)
  53. SKY_VIRTUAL_PROPERTY(SunLimbColor, Color)
  54. SKY_VIRTUAL_PROPERTY(SunFalloffFactor, Factor)
  55. SKY_VIRTUAL_PROPERTY(SunRadiusFactor, Factor)
  56. SKY_VIRTUAL_PROPERTY(SunDirection, Direction)
  57. SKY_VIRTUAL_PROPERTY(FastSkyEnabled, Enabled)
  58. SKY_VIRTUAL_PROPERTY(FastAerialPerspectiveEnabled, Enabled)
  59. SKY_VIRTUAL_PROPERTY(AerialPerspectiveEnabled, Enabled)
  60. SKY_VIRTUAL_PROPERTY(NearClip, NearClip)
  61. SKY_VIRTUAL_PROPERTY(NearFadeDistance, Distance)
  62. SKY_VIRTUAL_PROPERTY(AerialDepthFactor, Factor)
  63. SKY_VIRTUAL_PROPERTY(ShadowsEnabled, Enabled)
  64. ;
  65. }
  66. }
  67. void SkyAtmosphereComponentController::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  68. {
  69. provided.push_back(AZ_CRC_CE("SkyAtmosphereService"));
  70. }
  71. void SkyAtmosphereComponentController::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  72. {
  73. incompatible.push_back(AZ_CRC_CE("NonUniformScaleService"));
  74. }
  75. void SkyAtmosphereComponentController::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  76. {
  77. required.push_back(AZ_CRC_CE("TransformService"));
  78. }
  79. SkyAtmosphereComponentController::SkyAtmosphereComponentController(const SkyAtmosphereComponentConfig& config)
  80. : m_configuration(config)
  81. {
  82. }
  83. const SkyAtmosphereParams& SkyAtmosphereComponentController::GetUpdatedSkyAtmosphereParams()
  84. {
  85. UpdateSkyAtmosphereParams(m_atmosphereParams);
  86. return m_atmosphereParams;
  87. }
  88. void SkyAtmosphereComponentController::UpdateSkyAtmosphereParams(SkyAtmosphereParams& params)
  89. {
  90. // general params
  91. params.m_absorption = m_configuration.m_absorption * m_configuration.m_absorptionScale;
  92. params.m_atmosphereRadius = m_configuration.m_groundRadius + m_configuration.m_atmosphereHeight;
  93. params.m_fastSkyEnabled = m_configuration.m_fastSkyEnabled;
  94. params.m_fastAerialPerspectiveEnabled = m_configuration.m_fastAerialPerspectiveEnabled;
  95. params.m_aerialPerspectiveEnabled = m_configuration.m_aerialPerspectiveEnabled;
  96. params.m_aerialDepthFactor = m_configuration.m_aerialDepthFactor;
  97. params.m_groundAlbedo = m_configuration.m_groundAlbedo;
  98. params.m_luminanceFactor = m_configuration.m_luminanceFactor;
  99. params.m_mieAbsorption = m_configuration.m_mieAbsorption * m_configuration.m_mieAbsorptionScale;
  100. params.m_mieExpDistribution = m_configuration.m_mieExponentialDistribution;
  101. params.m_mieScattering = m_configuration.m_mieScattering * m_configuration.m_mieScatteringScale;
  102. params.m_minSamples = m_configuration.m_minSamples;
  103. params.m_maxSamples = m_configuration.m_maxSamples;
  104. params.m_planetRadius = m_configuration.m_groundRadius;
  105. params.m_rayleighScattering = m_configuration.m_rayleighScattering * m_configuration.m_rayleighScatteringScale;
  106. params.m_rayleighExpDistribution = m_configuration.m_rayleighExponentialDistribution;
  107. params.m_shadowsEnabled = m_configuration.m_shadowsEnabled;
  108. params.m_nearClip = m_configuration.m_nearClip;
  109. params.m_nearFadeDistance = m_configuration.m_nearFadeDistance;
  110. // sun params
  111. params.m_sunEnabled = m_configuration.m_drawSun;
  112. params.m_sunColor = m_configuration.m_sunColor * m_configuration.m_sunLuminanceFactor;
  113. params.m_sunLimbColor = m_configuration.m_sunLimbColor * m_configuration.m_sunLuminanceFactor;
  114. params.m_sunFalloffFactor = m_configuration.m_sunFalloffFactor;
  115. params.m_sunRadiusFactor = m_configuration.m_sunRadiusFactor;
  116. if (m_configuration.m_sun != m_sunEntityId)
  117. {
  118. if(m_sunEntityId.IsValid())
  119. {
  120. AZ::TransformNotificationBus::MultiHandler::BusDisconnect(m_sunEntityId);
  121. m_sunEntityId.SetInvalid();
  122. }
  123. if (m_configuration.m_sun.IsValid() && m_configuration.m_sun != m_entityId)
  124. {
  125. m_sunEntityId = m_configuration.m_sun;
  126. AZ::TransformNotificationBus::MultiHandler::BusConnect(m_configuration.m_sun);
  127. if (auto handler = TransformBus::FindFirstHandler(m_configuration.m_sun); handler == nullptr)
  128. {
  129. // connect to the entity bus so we can be notified when this entity activates so we can get
  130. // notified when the transform changes
  131. AZ::EntityBus::Handler::BusConnect(m_configuration.m_sun);
  132. }
  133. }
  134. }
  135. // sun direction using own transform or sun entity
  136. const AZ::Transform& transform = m_transformInterface ? m_transformInterface->GetWorldTM() : Transform::Identity();
  137. auto sunTransformInterface = TransformBus::FindFirstHandler(m_configuration.m_sun);
  138. AZ::Transform sunTransform = sunTransformInterface ? sunTransformInterface->GetWorldTM() : transform;
  139. params.m_sunDirection = -sunTransform.GetBasisY();
  140. if (auto directionalLightInterface = DirectionalLightRequestBus::FindFirstHandler(m_configuration.m_sun);
  141. directionalLightInterface != nullptr)
  142. {
  143. params.m_sunShadowsFarClip = directionalLightInterface->GetShadowFarClipDistance();
  144. }
  145. else
  146. {
  147. // use the first directional light in the scene
  148. DirectionalLightRequestBus::BroadcastResult(params.m_sunShadowsFarClip, &DirectionalLightRequests::GetShadowFarClipDistance);
  149. }
  150. if (m_transformInterface)
  151. {
  152. switch (m_configuration.m_originMode)
  153. {
  154. case SkyAtmosphereComponentConfig::AtmosphereOrigin::PlanetCenterAtLocalOrigin:
  155. params.m_planetOrigin = m_transformInterface->GetWorldTranslation() * 0.001f;
  156. break;
  157. case SkyAtmosphereComponentConfig::AtmosphereOrigin::GroundAtLocalOrigin:
  158. params.m_planetOrigin = m_transformInterface->GetWorldTranslation() * 0.001f - AZ::Vector3(0.0, 0.0, m_configuration.m_groundRadius);
  159. break;
  160. default:
  161. case SkyAtmosphereComponentConfig::AtmosphereOrigin::GroundAtWorldOrigin:
  162. params.m_planetOrigin = -AZ::Vector3(0.0, 0.0, m_configuration.m_groundRadius);
  163. break;
  164. }
  165. }
  166. else
  167. {
  168. params.m_planetOrigin = Vector3::CreateZero();
  169. }
  170. }
  171. void SkyAtmosphereComponentController::Activate(EntityId entityId)
  172. {
  173. SkyAtmosphereRequestBus::Handler::BusConnect(entityId);
  174. m_featureProcessorInterface = RPI::Scene::GetFeatureProcessorForEntity<SkyAtmosphereFeatureProcessorInterface>(entityId);
  175. if (m_featureProcessorInterface)
  176. {
  177. m_entityId = entityId;
  178. m_transformInterface = TransformBus::FindFirstHandler(m_entityId);
  179. m_atmosphereId = m_featureProcessorInterface->CreateAtmosphere();
  180. m_featureProcessorInterface->SetAtmosphereParams(m_atmosphereId, GetUpdatedSkyAtmosphereParams());
  181. AZ::TransformNotificationBus::MultiHandler::BusConnect(m_entityId);
  182. }
  183. }
  184. void SkyAtmosphereComponentController::Deactivate()
  185. {
  186. SkyAtmosphereRequestBus::Handler::BusDisconnect();
  187. TransformNotificationBus::MultiHandler::BusDisconnect(m_entityId);
  188. TransformNotificationBus::MultiHandler::BusDisconnect(m_configuration.m_sun);
  189. AZ::EntityBus::Handler::BusDisconnect(m_configuration.m_sun);
  190. if (m_featureProcessorInterface)
  191. {
  192. m_featureProcessorInterface->ReleaseAtmosphere(m_atmosphereId);
  193. m_featureProcessorInterface = nullptr;
  194. m_atmosphereId.Reset();
  195. }
  196. m_transformInterface = nullptr;
  197. // set the sun entity as invalid so we re-connect to the transform interface if we get re-activated
  198. m_sunEntityId.SetInvalid();
  199. }
  200. void SkyAtmosphereComponentController::SetConfiguration(const SkyAtmosphereComponentConfig& config)
  201. {
  202. m_configuration = config;
  203. }
  204. const SkyAtmosphereComponentConfig& SkyAtmosphereComponentController::GetConfiguration() const
  205. {
  206. return m_configuration;
  207. }
  208. void SkyAtmosphereComponentController::OnParamUpdated()
  209. {
  210. if (m_featureProcessorInterface && m_atmosphereId.IsValid())
  211. {
  212. m_featureProcessorInterface->SetAtmosphereParams(m_atmosphereId, GetUpdatedSkyAtmosphereParams());
  213. }
  214. }
  215. void SkyAtmosphereComponentController::SetEnabled(bool enabled)
  216. {
  217. if (m_featureProcessorInterface && m_atmosphereId.IsValid())
  218. {
  219. m_featureProcessorInterface->SetAtmosphereEnabled(m_atmosphereId, enabled);
  220. }
  221. }
  222. bool SkyAtmosphereComponentController::GetEnabled()
  223. {
  224. if (m_featureProcessorInterface && m_atmosphereId.IsValid())
  225. {
  226. return m_featureProcessorInterface->GetAtmosphereEnabled(m_atmosphereId);
  227. }
  228. return false;
  229. }
  230. void SkyAtmosphereComponentController::SetPlanetOriginMode(SkyAtmosphereComponentConfig::AtmosphereOrigin mode)
  231. {
  232. m_configuration.m_originMode = mode;
  233. OnParamUpdated();
  234. }
  235. SkyAtmosphereComponentConfig::AtmosphereOrigin SkyAtmosphereComponentController::GetPlanetOriginMode()
  236. {
  237. return m_configuration.m_originMode;
  238. }
  239. void SkyAtmosphereComponentController::SetAtmosphereHeight(float atmosphereHeightKm)
  240. {
  241. m_configuration.m_atmosphereHeight = atmosphereHeightKm;
  242. OnParamUpdated();
  243. }
  244. float SkyAtmosphereComponentController::GetAtmosphereHeight()
  245. {
  246. return m_configuration.m_atmosphereHeight;
  247. }
  248. void SkyAtmosphereComponentController::SetPlanetRadius(float planetRadiusKm)
  249. {
  250. m_configuration.m_groundRadius = planetRadiusKm;
  251. OnParamUpdated();
  252. }
  253. float SkyAtmosphereComponentController::GetPlanetRadius()
  254. {
  255. return m_configuration.m_groundRadius;
  256. }
  257. void SkyAtmosphereComponentController::SetGroundAlbedo(const AZ::Vector3& groundAlbedo)
  258. {
  259. m_configuration.m_groundAlbedo = groundAlbedo;
  260. OnParamUpdated();
  261. }
  262. AZ::Vector3 SkyAtmosphereComponentController::GetGroundAlbedo()
  263. {
  264. return m_configuration.m_groundAlbedo;
  265. }
  266. void SkyAtmosphereComponentController::SetLuminanceFactor(const AZ::Vector3& luminanceFactor)
  267. {
  268. m_configuration.m_luminanceFactor = luminanceFactor;
  269. OnParamUpdated();
  270. }
  271. AZ::Vector3 SkyAtmosphereComponentController::GetLuminanceFactor()
  272. {
  273. return m_configuration.m_luminanceFactor;
  274. }
  275. void SkyAtmosphereComponentController::SetMieAbsorption(const AZ::Vector3& mieAbsorption)
  276. {
  277. if (m_configuration.m_mieAbsorptionScale > 0.f)
  278. {
  279. m_configuration.m_mieAbsorption = mieAbsorption / m_configuration.m_mieAbsorptionScale;
  280. OnParamUpdated();
  281. }
  282. }
  283. AZ::Vector3 SkyAtmosphereComponentController::GetMieAbsorption()
  284. {
  285. return m_configuration.m_mieAbsorption * m_configuration.m_mieAbsorptionScale;
  286. }
  287. void SkyAtmosphereComponentController::SetMieExpDistribution(float mieExpDistribution)
  288. {
  289. m_configuration.m_mieExponentialDistribution = mieExpDistribution;
  290. OnParamUpdated();
  291. }
  292. float SkyAtmosphereComponentController::GetMieExpDistribution()
  293. {
  294. return m_configuration.m_mieExponentialDistribution;
  295. }
  296. void SkyAtmosphereComponentController::SetMieScattering(const AZ::Vector3& mieScattering)
  297. {
  298. if (m_configuration.m_mieScatteringScale > 0.f)
  299. {
  300. m_configuration.m_mieScattering = mieScattering / m_configuration.m_mieScatteringScale;
  301. OnParamUpdated();
  302. }
  303. }
  304. AZ::Vector3 SkyAtmosphereComponentController::GetMieScattering()
  305. {
  306. return m_configuration.m_mieScattering * m_configuration.m_mieScatteringScale;
  307. }
  308. void SkyAtmosphereComponentController::SetRayleighExpDistribution(float rayleighExpDistribution)
  309. {
  310. m_configuration.m_rayleighExponentialDistribution = rayleighExpDistribution;
  311. OnParamUpdated();
  312. }
  313. float SkyAtmosphereComponentController::GetRayleighExpDistribution()
  314. {
  315. return m_configuration.m_rayleighExponentialDistribution;
  316. }
  317. void SkyAtmosphereComponentController::SetRayleighScattering(const AZ::Vector3& rayleighScattering)
  318. {
  319. if (m_configuration.m_rayleighScatteringScale > 0.f)
  320. {
  321. m_configuration.m_rayleighScattering = rayleighScattering / m_configuration.m_rayleighScatteringScale;
  322. OnParamUpdated();
  323. }
  324. }
  325. AZ::Vector3 SkyAtmosphereComponentController::GetRayleighScattering()
  326. {
  327. return m_configuration.m_rayleighScattering * m_configuration.m_rayleighScatteringScale;
  328. }
  329. void SkyAtmosphereComponentController::SetMaxSamples(uint8_t maxSamples)
  330. {
  331. m_configuration.m_maxSamples = maxSamples;
  332. OnParamUpdated();
  333. }
  334. uint8_t SkyAtmosphereComponentController::GetMaxSamples()
  335. {
  336. return m_configuration.m_maxSamples;
  337. }
  338. void SkyAtmosphereComponentController::SetMinSamples(uint8_t minSamples)
  339. {
  340. m_configuration.m_minSamples = minSamples;
  341. OnParamUpdated();
  342. }
  343. uint8_t SkyAtmosphereComponentController::GetMinSamples()
  344. {
  345. return m_configuration.m_minSamples;
  346. }
  347. void SkyAtmosphereComponentController::SetSunEnabled(bool enabled)
  348. {
  349. m_configuration.m_drawSun = enabled;
  350. OnParamUpdated();
  351. }
  352. bool SkyAtmosphereComponentController::GetSunEnabled()
  353. {
  354. return m_configuration.m_drawSun;
  355. }
  356. void SkyAtmosphereComponentController::SetSunEntityId(AZ::EntityId entityId)
  357. {
  358. m_configuration.m_sun = entityId;
  359. OnParamUpdated();
  360. }
  361. AZ::EntityId SkyAtmosphereComponentController::GetSunEntityId()
  362. {
  363. return m_configuration.m_sun;
  364. }
  365. void SkyAtmosphereComponentController::SetSunColor(const AZ::Color sunColor)
  366. {
  367. m_configuration.m_sunColor = sunColor;
  368. OnParamUpdated();
  369. }
  370. AZ::Color SkyAtmosphereComponentController::GetSunColor()
  371. {
  372. return m_configuration.m_sunColor;
  373. }
  374. void SkyAtmosphereComponentController::SetSunLuminanceFactor(float factor)
  375. {
  376. m_configuration.m_sunLuminanceFactor = factor;
  377. OnParamUpdated();
  378. }
  379. float SkyAtmosphereComponentController::GetSunLuminanceFactor()
  380. {
  381. return m_configuration.m_sunLuminanceFactor;
  382. }
  383. void SkyAtmosphereComponentController::SetSunLimbColor(const AZ::Color sunLimbColor)
  384. {
  385. m_configuration.m_sunLimbColor = sunLimbColor;
  386. OnParamUpdated();
  387. }
  388. AZ::Color SkyAtmosphereComponentController::GetSunLimbColor()
  389. {
  390. return m_configuration.m_sunLimbColor;
  391. }
  392. void SkyAtmosphereComponentController::SetSunFalloffFactor(float factor)
  393. {
  394. m_configuration.m_sunFalloffFactor = factor;
  395. OnParamUpdated();
  396. }
  397. float SkyAtmosphereComponentController::GetSunFalloffFactor()
  398. {
  399. return m_configuration.m_sunFalloffFactor;
  400. }
  401. void SkyAtmosphereComponentController::SetSunRadiusFactor(float factor)
  402. {
  403. m_configuration.m_sunRadiusFactor = factor;
  404. OnParamUpdated();
  405. }
  406. float SkyAtmosphereComponentController::GetSunRadiusFactor()
  407. {
  408. return m_configuration.m_sunRadiusFactor;
  409. }
  410. void SkyAtmosphereComponentController::SetSunDirection(const AZ::Vector3& sunDirection)
  411. {
  412. if (m_configuration.m_sun.IsValid())
  413. {
  414. AZ_WarningOnce("SkyAtmosphereComponentController", false, "Cannot set the sun direction when a sun entity exists, rotate the sun entity instead.");
  415. }
  416. else if (m_transformInterface)
  417. {
  418. const Vector3 up = Vector3::CreateAxisZ();
  419. const Vector3 right = sunDirection.Cross(up);
  420. const AZ::Quaternion lookAt = AZ::Quaternion::CreateFromBasis(right, sunDirection, up);
  421. m_transformInterface->SetWorldRotationQuaternion(lookAt);
  422. OnParamUpdated();
  423. }
  424. }
  425. AZ::Vector3 SkyAtmosphereComponentController::GetSunDirection()
  426. {
  427. if (m_configuration.m_sun.IsValid())
  428. {
  429. AZ::Transform worldTm;
  430. AZ::TransformBus::EventResult(worldTm, m_configuration.m_sun, &AZ::TransformBus::Events::GetWorldTM);
  431. return worldTm.GetBasisY();
  432. }
  433. else if (m_transformInterface)
  434. {
  435. return m_transformInterface->GetWorldTM().GetBasisY();
  436. }
  437. return AZ::Vector3::CreateAxisY();
  438. }
  439. void SkyAtmosphereComponentController::SetFastSkyEnabled(bool enabled)
  440. {
  441. m_configuration.m_fastSkyEnabled = enabled;
  442. OnParamUpdated();
  443. }
  444. bool SkyAtmosphereComponentController::GetFastSkyEnabled()
  445. {
  446. return m_configuration.m_fastSkyEnabled;
  447. }
  448. void SkyAtmosphereComponentController::SetFastAerialPerspectiveEnabled(bool enabled)
  449. {
  450. m_configuration.m_fastAerialPerspectiveEnabled = enabled;
  451. OnParamUpdated();
  452. }
  453. bool SkyAtmosphereComponentController::GetFastAerialPerspectiveEnabled()
  454. {
  455. return m_configuration.m_fastAerialPerspectiveEnabled;
  456. }
  457. void SkyAtmosphereComponentController::SetAerialPerspectiveEnabled(bool enabled)
  458. {
  459. m_configuration.m_aerialPerspectiveEnabled = enabled;
  460. OnParamUpdated();
  461. }
  462. bool SkyAtmosphereComponentController::GetAerialPerspectiveEnabled()
  463. {
  464. return m_configuration.m_aerialPerspectiveEnabled;
  465. }
  466. void SkyAtmosphereComponentController::SetNearClip(float nearClip)
  467. {
  468. m_configuration.m_nearClip = nearClip;
  469. OnParamUpdated();
  470. }
  471. float SkyAtmosphereComponentController::GetNearClip()
  472. {
  473. return m_configuration.m_nearClip;
  474. }
  475. void SkyAtmosphereComponentController::SetNearFadeDistance(float nearFadeDistance)
  476. {
  477. m_configuration.m_nearFadeDistance = nearFadeDistance;
  478. OnParamUpdated();
  479. }
  480. float SkyAtmosphereComponentController::GetNearFadeDistance()
  481. {
  482. return m_configuration.m_nearFadeDistance;
  483. }
  484. void SkyAtmosphereComponentController::SetAerialDepthFactor(float aerialDepthFactor)
  485. {
  486. m_configuration.m_aerialDepthFactor = aerialDepthFactor;
  487. OnParamUpdated();
  488. }
  489. float SkyAtmosphereComponentController::GetAerialDepthFactor()
  490. {
  491. return m_configuration.m_aerialDepthFactor;
  492. }
  493. void SkyAtmosphereComponentController::SetShadowsEnabled(bool enabled)
  494. {
  495. m_configuration.m_shadowsEnabled = enabled;
  496. OnParamUpdated();
  497. }
  498. bool SkyAtmosphereComponentController::GetShadowsEnabled()
  499. {
  500. return m_configuration.m_shadowsEnabled;
  501. }
  502. void SkyAtmosphereComponentController::OnTransformChanged([[maybe_unused]] const AZ::Transform& local,[[maybe_unused]] const AZ::Transform& world)
  503. {
  504. m_featureProcessorInterface->SetAtmosphereParams(m_atmosphereId, GetUpdatedSkyAtmosphereParams());
  505. }
  506. void SkyAtmosphereComponentController::OnEntityActivated(const AZ::EntityId& entityId)
  507. {
  508. m_featureProcessorInterface->SetAtmosphereParams(m_atmosphereId, GetUpdatedSkyAtmosphereParams());
  509. AZ::EntityBus::Handler::BusDisconnect(entityId);
  510. }
  511. } // namespace AZ::Render