Files
o3de/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshShaderOptionsCache.h
T
Steve Pham 38261d0800 Shorten copyright headers by splitting into 2 lines (#2213)
* Updated all copyright headers to split the longer original copyright line into 2 shorter lines

Signed-off-by: Steve Pham <spham@amazon.com>
2021-07-16 15:25:48 -07:00

65 lines
2.5 KiB
C++

/*
* 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
*
*/
#pragma once
#include <Atom/Feature/SkinnedMesh/SkinnedMeshShaderOptions.h>
#include <Atom/RPI.Reflect/Shader/ShaderOptionGroup.h>
#include <AtomCore/Instance/Instance.h>
#include <AzCore/EBus/Event.h>
namespace AZ
{
namespace RPI
{
class Shader;
}
namespace Render
{
class CachedSkinnedMeshShaderOptions;
//! Notifies listeners that the skinned mesh shader has reloaded and the shader options need to be updated
class SkinnedMeshShaderOptionNotifications
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
using BusIdType = CachedSkinnedMeshShaderOptions*;
using MutexType = AZStd::mutex;
virtual void OnShaderReinitialized(const CachedSkinnedMeshShaderOptions* cachedShaderOptions) = 0;
};
using SkinnedMeshShaderOptionNotificationBus = AZ::EBus<SkinnedMeshShaderOptionNotifications>;
//! This class caches the indices of the skinned mesh shader options and uses them to more optimally create a ShaderOptionGroup
class CachedSkinnedMeshShaderOptions
{
public:
void SetShader(Data::Instance<RPI::Shader> shader);
void ConnectToShaderReinitializedEvent(SkinnedMeshShaderOptionNotificationBus::Handler& shaderReinitializedEventHandler);
RPI::ShaderOptionGroup CreateShaderOptionGroup(const SkinnedMeshShaderOptions& shaderOptions) const;
private:
Data::Instance<RPI::Shader> m_shader;
RPI::ShaderOptionIndex m_skinningMethodOptionIndex;
RPI::ShaderOptionValue m_skinningMethodLinearSkinningValue;
RPI::ShaderOptionValue m_skinningMethodDualQuaternionValue;
RPI::ShaderOptionIndex m_applyMorphTargetOptionIndex;
RPI::ShaderOptionValue m_applyMorphTargetFalseValue;
RPI::ShaderOptionValue m_applyMorphTargetTrueValue;
RPI::ShaderOptionIndex m_applyColorMorphTargetOptionIndex;
RPI::ShaderOptionValue m_applyColorMorphTargetFalseValue;
RPI::ShaderOptionValue m_applyColorMorphTargetTrueValue;
};
} // namespace Render
} // namespace AZ