/* * 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. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include #include #include namespace AtomSampleViewer { void StacksShaderCollectionFunctor::Reflect(AZ::ReflectContext* context) { if (auto* serializeContext = azrtti_cast(context)) { serializeContext->Class() ->Version(1) ->Field("m_stackCountProperty", &StacksShaderCollectionFunctor::m_stackCountProperty) ->Field("m_highlightLastStackProperty", &StacksShaderCollectionFunctor::m_highlightLastStackProperty) ->Field("m_highlightLastStackOption", &StacksShaderCollectionFunctor::m_highlightLastStackOption) ; } } void StacksShaderCollectionFunctor::Process(RuntimeContext& context) { using namespace AZ::RPI; const uint32_t stackCount = context.GetMaterialPropertyValue(m_stackCountProperty); const bool highlightLastStack = context.GetMaterialPropertyValue(m_highlightLastStackProperty); static const int AvailableStackCount = 4; for (uint32_t i = 0; i < AvailableStackCount; ++i) { const bool isLastStack = (i == stackCount - 1); const bool shouldHighlight = highlightLastStack && isLastStack; context.SetShaderOptionValue(i, m_highlightLastStackOption, ShaderOptionValue{ shouldHighlight }); context.SetShaderEnabled(i, i < stackCount); } } } // namespace AtomSampleViewer