StacksShaderInputFunctor.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #pragma once
  9. #include <Atom/RPI.Reflect/Material/MaterialFunctor.h>
  10. #include <Atom/RPI.Reflect/Material/MaterialPropertyDescriptor.h>
  11. namespace AtomSampleViewer
  12. {
  13. //! This is an example of a custom hard-coded MaterialFunctor used to perform calculations on material
  14. //! property values to produce shader input values.
  15. //! It is used by comprehensive.materialtype to transform angle values into a light direction vector.
  16. class StacksShaderInputFunctor final
  17. : public AZ::RPI::MaterialFunctor
  18. {
  19. friend class StacksShaderInputFunctorSourceData;
  20. public:
  21. AZ_RTTI(StacksShaderInputFunctor, "{7F607170-1BC2-4510-A252-8A665FC02052}", AZ::RPI::MaterialFunctor);
  22. static void Reflect(AZ::ReflectContext* context);
  23. using AZ::RPI::MaterialFunctor::Process;
  24. void Process(RuntimeContext& context) override;
  25. private:
  26. // Indices used to look up material property values at runtime
  27. AZ::RPI::MaterialPropertyIndex m_azimuthDegreesIndex;
  28. AZ::RPI::MaterialPropertyIndex m_elevationDegreesIndex;
  29. // Indices used to look up ShaderResourceGroup inputs at runtime
  30. AZ::RHI::ShaderInputConstantIndex m_lightDirectionIndex;
  31. };
  32. } // namespace AtomSampleViewer