StacksShaderCollectionFunctor.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 dynamically select shaders/variants/passes.
  14. //! It is used by comprehensive.materialtype to enable/disable variants of the "stacks" shader.
  15. class StacksShaderCollectionFunctor final
  16. : public AZ::RPI::MaterialFunctor
  17. {
  18. friend class StacksShaderCollectionFunctorSourceData;
  19. public:
  20. AZ_RTTI(StacksShaderCollectionFunctor, "{4E51A7D5-7DF1-4402-8975-F6C9DFDEDC1E}", AZ::RPI::MaterialFunctor);
  21. static void Reflect(AZ::ReflectContext* context);
  22. using AZ::RPI::MaterialFunctor::Process;
  23. void Process(RuntimeContext& context) override;
  24. private:
  25. // Indexes used to look up material property values at runtime
  26. AZ::RPI::MaterialPropertyIndex m_stackCountProperty;
  27. AZ::RPI::MaterialPropertyIndex m_highlightLastStackProperty;
  28. // Indexes used to access ShaderOption values at runtime
  29. AZ::RPI::ShaderOptionIndex m_highlightLastStackOption;
  30. };
  31. } // namespace AtomSampleViewer