UseTextureFunctor.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #include <Atom/RHI.Reflect/Limits.h>
  12. namespace AZ
  13. {
  14. namespace Render
  15. {
  16. //! Materials can use this functor to control whether a specific texture property will be sampled.
  17. //! Sampling will be disabled if no texture is bound or if the useTexture flag is disabled.
  18. class UseTextureFunctor final
  19. : public RPI::MaterialFunctor
  20. {
  21. friend class UseTextureFunctorSourceData;
  22. public:
  23. AZ_CLASS_ALLOCATOR(UseTextureFunctor , SystemAllocator)
  24. AZ_RTTI(UseTextureFunctor, "{CFAC6159-840A-4696-8699-D3850D8A3930}", RPI::MaterialFunctor);
  25. static void Reflect(ReflectContext* context);
  26. using RPI::MaterialFunctor::Process;
  27. void Process(RPI::MaterialFunctorAPI::RuntimeContext& context) override;
  28. void Process(RPI::MaterialFunctorAPI::EditorContext& context) override;
  29. private:
  30. // Material property inputs...
  31. RPI::MaterialPropertyIndex m_texturePropertyIndex; //!< material property for a texture
  32. RPI::MaterialPropertyIndex m_useTexturePropertyIndex; //!< material property for a bool that indicates whether to use the texture
  33. //! material properties that relate to the texture, which will be enabled only when the texture map is enabled.
  34. AZStd::vector<RPI::MaterialPropertyIndex> m_dependentPropertyIndexes;
  35. // Shader option output...
  36. Name m_useTextureOptionName;
  37. };
  38. } // namespace Render
  39. } // namespace AZ