Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,78 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <Atom/Features/SrgSemantics.azsli>
struct VertexInput
{
float2 Position : POSITION;
float2 UV : UV;
float4 Color : COLOR;
};
struct VertexOutput
{
float4 Position : SV_Position;
float4 Color : COLOR;
float2 UV : UV;
};
ShaderResourceGroup ObjectSrg : SRG_PerObject
{
Texture2D<float4> FontImage;
Sampler LinearSampler
{
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
AddressW = Clamp;
};
column_major float4x4 m_projectionMatrix;
}
float3 SRGBToLinear( float3 x )
{
return x < 0.04045f ? x / 12.92f : pow( (abs(x) + 0.055f) / 1.055f, 2.4f );
// NOTE: abs on x quiets FXC warning "X3571: pow(f, e) will not work for negative f,
// use abs(f) or conditionally handle negative values if you expect them".
// Ternary operator ?: in shaders can handle vectors in the condition, but it doesn't
// count as 'conditionally handle' since branching is not involved. When we start using
// DXC instead of FXC we can remove abs since DXC handles it correctly with no warnings.
}
VertexOutput MainVS(in VertexInput input)
{
VertexOutput output;
output.Position = mul(float4(input.Position, 0.0f, 1.0f), ObjectSrg::m_projectionMatrix);
output.Color = float4(SRGBToLinear(input.Color.rgb), input.Color.a);
output.UV = input.UV;
return output;
}
struct PixelOutput
{
float4 m_color : SV_Target0;
};
PixelOutput MainPS(in VertexOutput input)
{
PixelOutput output;
float4 color = ObjectSrg::FontImage.Sample(ObjectSrg::LinearSampler, input.UV) * input.Color;
output.m_color = float4(color.rgb * color.a, color.a);
return output;
}
@@ -0,0 +1,37 @@
{
"Source" : "ImGuiAtom",
"RasterState" : { "CullMode" : "None" },
"DepthStencilState" : {
"Depth" : { "Enable" : false, "CompareFunc" : "GreaterEqual" }
},
"BlendState" : {
"Enable" : true,
"BlendSource" : "One",
"BlendAlphaSource" : "One",
"BlendDest" : "AlphaSourceInverse",
"BlendAlphaDest" : "AlphaSourceInverse",
"BlendAlphaOp" : "Add"
},
"DrawList" : "imgui",
"ProgramSettings":
{
"EntryPoints":
[
{
"name": "MainVS",
"type": "Vertex"
},
{
"name": "MainPS",
"type": "Fragment"
}
]
}
}
@@ -0,0 +1,12 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
add_subdirectory(Code)
@@ -0,0 +1,45 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
ly_add_target(
NAME ImguiAtom.Static STATIC
NAMESPACE Gem
FILES_CMAKE
imguiatom_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
Include
BUILD_DEPENDENCIES
PUBLIC
AZ::AtomCore
AZ::AzCore
Gem::ImGui.Static
Gem::Atom_Feature_Common.Static
)
ly_add_target(
NAME ImguiAtom ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
NAMESPACE Gem
OUTPUT_NAME Gem.ImguiAtom.9986e22e14184f2fb6bb1e7dd185b2f9.v0.1.0
FILES_CMAKE
imguiatom_shared_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
Include
BUILD_DEPENDENCIES
PRIVATE
AZ::AzFramework
Gem::ImguiAtom.Static
)
@@ -0,0 +1,51 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Module/Module.h>
#include <ImguiAtomSystemComponent.h>
namespace ImguiAtom
{
class ImguiAtomModule
: public AZ::Module
{
public:
AZ_RTTI(ImguiAtomModule, "{E3CE5991-30B5-4B04-BF79-516DDBD4D233}", AZ::Module);
AZ_CLASS_ALLOCATOR(ImguiAtomModule, AZ::SystemAllocator, 0);
ImguiAtomModule()
: AZ::Module()
{
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
m_descriptors.insert(m_descriptors.end(), {
AZ::LYIntegration::ImguiAtomSystemComponent::CreateDescriptor(),
});
}
/**
* Add required SystemComponents to the SystemEntity.
*/
AZ::ComponentTypeList GetRequiredSystemComponents() const override
{
return AZ::ComponentTypeList{
azrtti_typeid<AZ::LYIntegration::ImguiAtomSystemComponent>(),
};
}
};
}
// DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM
// The first parameter should be GemName_GemIdLower
// The second should be the fully qualified name of the class above
AZ_DECLARE_MODULE_CLASS(Gem_ImguiAtom, ImguiAtom::ImguiAtomModule)
@@ -0,0 +1,64 @@
/*
* All or portions of this file Copyright(c) Amazon.com, Inc.or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution(the "License").All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file.Do not
* remove or modify any license notices.This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "ImguiAtomSystemComponent.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzFramework/Windowing/WindowBus.h>
#include <Atom/Feature/ImGui/ImGuiUtils.h>
#include <Atom/Feature/ImGui/SystemBus.h>
namespace AZ
{
namespace LYIntegration
{
void ImguiAtomSystemComponent::Reflect(AZ::ReflectContext* context)
{
if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<ImguiAtomSystemComponent, AZ::Component>()
->Version(0)
;
}
}
void ImguiAtomSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC_CE("ImguiAtomSystemComponent"));
}
void ImguiAtomSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC_CE("CommonService"));
}
void ImguiAtomSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatbile)
{
incompatbile.push_back(AZ_CRC_CE("ImguiAtomSystemComponent"));
}
void ImguiAtomSystemComponent::Activate()
{
ImGui::OtherActiveImGuiRequestBus::Handler::BusConnect();
}
void ImguiAtomSystemComponent::Deactivate()
{
ImGui::OtherActiveImGuiRequestBus::Handler::BusDisconnect();
}
void ImguiAtomSystemComponent::RenderImGuiBuffers(const ImDrawData& drawData)
{
Render::ImGuiSystemRequestBus::Broadcast(&Render::ImGuiSystemRequests::RenderImGuiBuffersToDefaultPass, drawData);
}
}
}
@@ -0,0 +1,50 @@
/*
* All or portions of this file Copyright(c) Amazon.com, Inc.or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution(the "License").All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file.Do not
* remove or modify any license notices.This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzCore/Component/TickBus.h>
#include <OtherActiveImGuiBus.h>
namespace AZ
{
namespace LYIntegration
{
class ImGuiFeatureProcessor;
//! When Atom is enabled, ImGuiManager from LY's ImGui gem will hand over drawing of ImGui via @OtherActiveImGuiRequestBus to this system component.
//! Note: The LY ImGui gem only supports a single ImGui context, so Atom must have a single ImGui pass marked as the default.
class ImguiAtomSystemComponent final
: public AZ::Component
, public ImGui::OtherActiveImGuiRequestBus::Handler
{
public:
AZ_COMPONENT(ImguiAtomSystemComponent, "{D423E075-D971-435A-A9C1-57C3B0623A9B}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatbile);
~ImguiAtomSystemComponent() override = default;
// AZ::Component
void Activate() override;
void Deactivate() override;
// OtherActiveImGuiRequestBus overrides ...
void RenderImGuiBuffers(const ImDrawData& drawData) override;
};
} // namespace LYIntegration
} // namespace AZ
@@ -0,0 +1,15 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
Source/ImguiAtomSystemComponent.cpp
Source/ImguiAtomSystemComponent.h
)
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
Source/ImguiAtomModule.cpp
)
+31
View File
@@ -0,0 +1,31 @@
{
"GemFormatVersion": 4,
"Uuid": "9986e22e14184f2fb6bb1e7dd185b2f9",
"Name": "ImguiAtom",
"DisplayName": "ImGui.Atom",
"Version": "0.1.0",
"Summary": "Provides ImGui implementation for Atom renderer",
"Tags": ["Atom", "ImGui"],
"IconPath": "preview.png",
"Modules": [
{
"Type": "GameModule"
}
],
"Dependencies": [
{
"Uuid": "bab8807a1bc646b3909f3cc200ffeedf",
"VersionConstraints": [
"~>0.1"
],
"_comment": "ImGui"
},
{
"Uuid": "a218db9eb2114477b46600fea4441a6c",
"VersionConstraints": [
"~>0.1"
],
"_comment": "Atom RPI"
}
]
}
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6d6204c6730e5675791765ca194e9b1cbec282208e280507de830afc2805e5fa
size 41127