2
0

StacksShaderInputFunctorSourceData.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  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 <MaterialFunctors/StacksShaderInputFunctorSourceData.h>
  9. #include <Atom/RHI.Reflect/ShaderResourceGroupLayout.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. namespace AtomSampleViewer
  12. {
  13. void StacksShaderInputFunctorSourceData::Reflect(AZ::ReflectContext* context)
  14. {
  15. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  16. {
  17. serializeContext->Class<StacksShaderInputFunctorSourceData>()
  18. ->Version(2)
  19. ;
  20. }
  21. }
  22. AZ::RPI::MaterialFunctorSourceData::FunctorResult StacksShaderInputFunctorSourceData::CreateFunctor(const RuntimeContext& context) const
  23. {
  24. AZ::RPI::Ptr<StacksShaderInputFunctor> functor = aznew StacksShaderInputFunctor;
  25. functor->m_azimuthDegreesIndex = context.FindMaterialPropertyIndex(AZ::Name{ "light.azimuthDegrees" });
  26. functor->m_elevationDegreesIndex = context.FindMaterialPropertyIndex(AZ::Name{ "light.elevationDegrees" });
  27. AddMaterialPropertyDependency(functor, functor->m_azimuthDegreesIndex);
  28. AddMaterialPropertyDependency(functor, functor->m_elevationDegreesIndex);
  29. functor->m_lightDirectionIndex = context.GetShaderResourceGroupLayout()->FindShaderInputConstantIndex(AZ::Name{ "m_lightDir" });
  30. return AZ::Success(AZ::RPI::Ptr<AZ::RPI::MaterialFunctor>(functor));
  31. }
  32. }