StacksShaderCollectionFunctor.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0 OR MIT
  5. *
  6. */
  7. #pragma once
  8. #include <Atom/RPI.Reflect/Material/MaterialFunctor.h>
  9. #include <Atom/RPI.Reflect/Material/MaterialPropertyDescriptor.h>
  10. namespace AtomSampleViewer
  11. {
  12. //! This is an example of a custom hard-coded MaterialFunctor used to dynamically select shaders/variants/passes.
  13. //! It is used by comprehensive.materialtype to enable/disable variants of the "stacks" shader.
  14. class StacksShaderCollectionFunctor final
  15. : public AZ::RPI::MaterialFunctor
  16. {
  17. friend class StacksShaderCollectionFunctorSourceData;
  18. public:
  19. AZ_RTTI(StacksShaderCollectionFunctor, "{4E51A7D5-7DF1-4402-8975-F6C9DFDEDC1E}", AZ::RPI::MaterialFunctor);
  20. static void Reflect(AZ::ReflectContext* context);
  21. void Process(RuntimeContext& context) override;
  22. private:
  23. // Indexes used to look up material property values at runtime
  24. AZ::RPI::MaterialPropertyIndex m_stackCountProperty;
  25. AZ::RPI::MaterialPropertyIndex m_highlightLastStackProperty;
  26. // Indexes used to access ShaderOption values at runtime
  27. AZ::RPI::ShaderOptionIndex m_highlightLastStackOption;
  28. };
  29. } // namespace AtomSampleViewer