Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkTreasure1 committed Mar 24, 2024
1 parent 634168f commit c475652
Show file tree
Hide file tree
Showing 12 changed files with 236 additions and 63 deletions.
8 changes: 4 additions & 4 deletions Engine/Engine/Shaders/Source/HLSL/2D/Billboard_gs.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ void main(point DefaultBillboardVertex input[1], inout TriangleStream<Output> ou
{
const float2 offsets[4] =
{
{ -100.f, 100.f },
{ 100.f, 100.f },
{ -100.f, -100.f },
{ 100.f, -100.f }
{ -1.f, 1.f },
{ 1.f, 1.f },
{ -1.f, -1.f },
{ 1.f, -1.f }
};

const float2 uvs[4] =
Expand Down
2 changes: 1 addition & 1 deletion Engine/Engine/Shaders/Source/HLSL/Deferred/Decal_ps.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Output main(DecalOutput input)
const float3 pixelNormal = normalize(cross(ddy(pixelWorldPosition), ddx(pixelWorldPosition)));

float decalCull = saturate(dot(rotVec.xyz, pixelNormal));
const float2 sampleCoords = -(objectSpacePosition.xy / 100.f) + 0.5f;
const float2 sampleCoords = -objectSpacePosition.xy + 0.5f;

const Material material = GetMaterial(u_materialData.materialIndex);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ float3 CalculateInscatteredLight(in float3 accumulatedLight, float2 position)
float4 main(Input input) : SV_Target0
{
float4 result = 0.f;
result = u_environmentMap.SampleLevel(u_linearSampler, input.samplePosition / 100.f, u_pushConstants.lod) * u_pushConstants.intensity;
result = u_environmentMap.SampleLevel(u_linearSampler, input.samplePosition, u_pushConstants.lod) * u_pushConstants.intensity;
result.a = 1.f;

result.rgb += CalculateInscatteredLight(result.rgb, input.position.xy);
Expand Down
46 changes: 46 additions & 0 deletions Volt/Sandbox/src/Sandbox/Sandbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,52 @@ bool Sandbox::OnImGuiUpdateEvent(Volt::AppImGuiUpdateEvent& e)
RenderProgressBar(buildProgess);
}

if (ImGui::Begin("Conversion Window"))
{
if (ImGui::Button("Convert Scene to M"))
{
Volt::Entity mainMenuEntity = myRuntimeScene->GetEntityWithName("PF_MainMenu");

myRuntimeScene->ForEachWithComponents<Volt::TransformComponent, Volt::MeshComponent>([&](const entt::entity id, Volt::TransformComponent& transComp, const Volt::MeshComponent& meshComp)
{
Volt::Entity entity{ id, myRuntimeScene };
entity.SetScale(entity.GetScale() * 0.01f);
});

myRuntimeScene->ForEachWithComponents<Volt::TransformComponent>([&](const entt::entity id, Volt::TransformComponent& transComp)
{
Volt::Entity entity{ id, myRuntimeScene };

if (mainMenuEntity)
{
if (myRuntimeScene->IsRelatedTo(mainMenuEntity, entity))
{
return;
}
}

if (entity == mainMenuEntity)
{
return;
}

entity.SetLocalPosition(entity.GetLocalPosition() * 0.01f);
});

myRuntimeScene->ForEachWithComponents<Volt::PointLightComponent>([&](const entt::entity id, Volt::PointLightComponent& comp)
{
comp.radius *= 0.01f;
});

myRuntimeScene->ForEachWithComponents<Volt::SpotLightComponent>([&](const entt::entity id, Volt::SpotLightComponent& comp)
{
comp.range *= 0.01f;
});
}

ImGui::End();
}

return false;
}

Expand Down
64 changes: 32 additions & 32 deletions Volt/Volt/src/Volt/Asset/Asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,40 @@ namespace Volt
Queued = BIT(2)
};

enum class AssetType : uint64_t
enum class AssetType : uint32_t
{
None = 0,
Mesh = BIT(0),
MeshSource = BIT(1),
Animation = BIT(2),
Skeleton = BIT(3),
Texture = BIT(4),
Material = BIT(5),
Shader = BIT(6),
ShaderSource = BIT(7),
Scene = BIT(8),
AnimatedCharacter = BIT(9),
ParticlePreset = BIT(10),
Prefab = BIT(11),
Font = BIT(12),
PhysicsMaterial = BIT(13),
Video = BIT(14),
BlendSpace = BIT(15),
NavMesh = BIT(16),
AnimationGraph = BIT(17),
GraphKey = BIT(18),
MonoScript = BIT(19),
BehaviorGraph = BIT(20),
MaterialGraph = BIT(21),
RenderPipeline = BIT(22),
Timeline = BIT(23),
NetContract = BIT(24),
PostProcessingMaterial = BIT(25),
PostProcessingStack = BIT(26),
MotionWeave = BIT(27),
TextureSource = BIT(28)
Mesh,
MeshSource,
Animation,
Skeleton,
Texture,
Material,
Shader,
ShaderSource,
Scene,
AnimatedCharacter,
ParticlePreset,
Prefab,
Font,
PhysicsMaterial,
Video,
BlendSpace,
NavMesh,
AnimationGraph,
GraphKey,
MonoScript,
BehaviorGraph,
RenderPipeline,
Timeline,
NetContract,
PostProcessingMaterial,
PostProcessingStack,
MotionWeave,
TextureSource,

// Add new assets above this line
Count
};

inline AssetType operator|(AssetType aLhs, AssetType aRhs)
Expand Down Expand Up @@ -97,7 +99,6 @@ namespace Volt
{ ".hlslh", AssetType::ShaderSource },
{ ".hlsli", AssetType::ShaderSource },

{ ".vtmgraph", AssetType::MaterialGraph },
{ ".vtmat", AssetType::Material },
{ ".vtpostmat", AssetType::PostProcessingMaterial },
{ ".vtpoststack", AssetType::PostProcessingStack },
Expand Down Expand Up @@ -135,7 +136,6 @@ namespace Volt
{ "Shader", AssetType::Shader },
{ "Shader Source", AssetType::ShaderSource },

{ "Material Graph", AssetType::MaterialGraph },
{ "Material", AssetType::Material },
{ "Post Processing Material", AssetType::PostProcessingMaterial },
{ "Post Processing Stack", AssetType::PostProcessingStack },
Expand Down
78 changes: 78 additions & 0 deletions Volt/Volt/src/Volt/Asset/AssetFactory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#include "vtpch.h"
#include "AssetFactory.h"

#include "Volt/Asset/Mesh/Mesh.h"
#include "Volt/Asset/Mesh/Material.h"
#include "Volt/Asset/Animation/Animation.h"
#include "Volt/Asset/Animation/Skeleton.h"
#include "Volt/Asset/Animation/AnimatedCharacter.h"
#include "Volt/Asset/Animation/AnimationGraphAsset.h"
#include "Volt/Asset/ParticlePreset.h"
#include "Volt/Asset/Text/Font.h"
#include "Volt/Asset/Prefab.h"
#include "Volt/Asset/Video/Video.h"
#include "Volt/Asset/TimelinePreset.h"
#include "Volt/Asset/Rendering/PostProcessingMaterial.h"
#include "Volt/Asset/Rendering/PostProcessingStack.h"

#include "Volt/Scene/Scene.h"
#include "Volt/Animation/BlendSpace.h"

#include "Volt/Physics/PhysicsMaterial.h"

#include "Volt/Rendering/Shader/Shader.h"
#include "Volt/Rendering/Texture/Texture2D.h"

#include "Volt/BehaviorTree/BehaviorTree.hpp"
#include "Volt/Rendering/RenderPipeline/RenderPipeline.h"
#include "Volt/Net/SceneInteraction/NetContract.h"

#include <Navigation/NavMesh/VTNavMesh.h>

namespace Volt
{
template<typename T>
void RegisterCreateFunction(AssetType type, std::unordered_map<AssetType, AssetFactory::AssetCreateFunction>& out)
{
out[type] = []() { return CreateRef<T>(); }
}

void AssetFactory::Initialize()
{
RegisterCreateFunction<Mesh>(AssetType::Mesh, m_assetFactoryFunctions);
RegisterCreateFunction<Mesh>(AssetType::MeshSource, m_assetFactoryFunctions);
RegisterCreateFunction<Animation>(AssetType::Animation, m_assetFactoryFunctions);
RegisterCreateFunction<Skeleton>(AssetType::Skeleton, m_assetFactoryFunctions);
RegisterCreateFunction<Texture2D>(AssetType::Texture, m_assetFactoryFunctions);
RegisterCreateFunction<Material>(AssetType::Material, m_assetFactoryFunctions);
RegisterCreateFunction<Shader>(AssetType::Shader, m_assetFactoryFunctions);
RegisterCreateFunction<Shader>(AssetType::ShaderSource, m_assetFactoryFunctions);
RegisterCreateFunction<Scene>(AssetType::Scene, m_assetFactoryFunctions);
RegisterCreateFunction<AnimatedCharacter>(AssetType::AnimatedCharacter, m_assetFactoryFunctions);
RegisterCreateFunction<ParticlePreset>(AssetType::ParticlePreset, m_assetFactoryFunctions);
RegisterCreateFunction<Prefab>(AssetType::Prefab, m_assetFactoryFunctions);
RegisterCreateFunction<Font>(AssetType::Font, m_assetFactoryFunctions);
RegisterCreateFunction<PhysicsMaterial>(AssetType::PhysicsMaterial, m_assetFactoryFunctions);
RegisterCreateFunction<Video>(AssetType::Video, m_assetFactoryFunctions);
RegisterCreateFunction<BlendSpace>(AssetType::BlendSpace, m_assetFactoryFunctions);
RegisterCreateFunction<AI::NavMesh>(AssetType::NavMesh, m_assetFactoryFunctions);
RegisterCreateFunction<AnimationGraphAsset>(AssetType::AnimationGraph, m_assetFactoryFunctions);
RegisterCreateFunction<GraphKey::Graph>(AssetType::GraphKey, m_assetFactoryFunctions);
RegisterCreateFunction<BehaviorTree::Tree>(AssetType::BehaviorGraph, m_assetFactoryFunctions);
RegisterCreateFunction<BehaviorTree::Tree>(AssetType::GraphKey, m_assetFactoryFunctions);
RegisterCreateFunction<RenderPipeline>(AssetType::RenderPipeline, m_assetFactoryFunctions);
RegisterCreateFunction<TimelinePreset>(AssetType::Timeline, m_assetFactoryFunctions);
RegisterCreateFunction<NetContract>(AssetType::NetContract, m_assetFactoryFunctions);
RegisterCreateFunction<PostProcessingMaterial>(AssetType::PostProcessingMaterial, m_assetFactoryFunctions);
RegisterCreateFunction<PostProcessingStack>(AssetType::PostProcessingStack, m_assetFactoryFunctions);
}

void AssetFactory::Shutdown()
{
}

Ref<Asset> AssetFactory::CreateAssetOfType(AssetType type)
{
return Ref<Asset>();
}
}
25 changes: 25 additions & 0 deletions Volt/Volt/src/Volt/Asset/AssetFactory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include "Volt/Core/Base.h"
#include "Volt/Asset/Asset.h"

#include <functional>

namespace Volt
{
class Asset;

class AssetFactory
{
public:
using AssetCreateFunction = std::function<Ref<Asset>()>;

void Initialize();
void Shutdown();

Ref<Asset> CreateAssetOfType(AssetType type);

private:
std::unordered_map<AssetType, AssetCreateFunction> m_assetFactoryFunctions;
};
}
58 changes: 37 additions & 21 deletions Volt/Volt/src/Volt/Asset/AssetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,8 @@ namespace Volt
MeshTypeImporter::Initialize();
TextureImporter::Initialize();

m_assetImporters.emplace(AssetType::MeshSource, CreateScope<MeshSourceImporter>()); // Done
m_assetImporters.emplace(AssetType::Texture, CreateScope<TextureSourceImporter>()); // Done
m_assetImporters.emplace(AssetType::Shader, CreateScope<ShaderImporter>()); // Done
m_assetImporters.emplace(AssetType::Material, CreateScope<MaterialImporter>()); // Done
m_assetImporters.emplace(AssetType::Mesh, CreateScope<MeshSourceImporter>()); // Done
m_assetImporters.emplace(AssetType::NavMesh, CreateScope<VTNavMeshImporter>()); // Done
m_assetImporters.emplace(AssetType::Scene, CreateScope<SceneImporter>()); // Done
m_assetImporters.emplace(AssetType::Skeleton, CreateScope<SkeletonImporter>()); // Done
m_assetImporters.emplace(AssetType::AnimationGraph, CreateScope<AnimationGraphImporter>()); // Done
m_assetImporters.emplace(AssetType::Animation, CreateScope<AnimationImporter>()); // Done
m_assetImporters.emplace(AssetType::AnimatedCharacter, CreateScope<AnimatedCharacterImporter>()); // Done
m_assetImporters.emplace(AssetType::ParticlePreset, CreateScope<ParticlePresetImporter>()); // Done
m_assetImporters.emplace(AssetType::Prefab, CreateScope<PrefabImporter>()); // Done
m_assetImporters.emplace(AssetType::Font, CreateScope<FontImporter>()); // Done
m_assetImporters.emplace(AssetType::PhysicsMaterial, CreateScope<PhysicsMaterialImporter>()); // Done
m_assetImporters.emplace(AssetType::Video, CreateScope<VideoImporter>()); // Done
m_assetImporters.emplace(AssetType::BehaviorGraph, CreateScope<BehaviorTreeImporter>()); // Done
m_assetImporters.emplace(AssetType::BlendSpace, CreateScope<BlendSpaceImporter>()); // Done
m_assetImporters.emplace(AssetType::PostProcessingStack, CreateScope<PostProcessingStackImporter>()); // Done
m_assetImporters.emplace(AssetType::PostProcessingMaterial, CreateScope<PostProcessingMaterialImporter>()); // Done
m_assetImporters.emplace(AssetType::NetContract, CreateScope<NetContractImporter>()); // Done
RegisterAssetSerializers();
RegisterAssetCreateFunctions();

LoadAssetMetafiles();
}
Expand Down Expand Up @@ -162,6 +143,41 @@ namespace Volt
return result;
}

void AssetManager::RegisterAssetSerializers()
{
m_assetImporters.emplace(AssetType::MeshSource, CreateScope<MeshSourceImporter>()); // Done
m_assetImporters.emplace(AssetType::Texture, CreateScope<TextureSourceImporter>()); // Done
m_assetImporters.emplace(AssetType::Shader, CreateScope<ShaderImporter>()); // Done
m_assetImporters.emplace(AssetType::Material, CreateScope<MaterialImporter>()); // Done
m_assetImporters.emplace(AssetType::Mesh, CreateScope<MeshSourceImporter>()); // Done
m_assetImporters.emplace(AssetType::NavMesh, CreateScope<VTNavMeshImporter>()); // Done
m_assetImporters.emplace(AssetType::Scene, CreateScope<SceneImporter>()); // Done
m_assetImporters.emplace(AssetType::Skeleton, CreateScope<SkeletonImporter>()); // Done
m_assetImporters.emplace(AssetType::AnimationGraph, CreateScope<AnimationGraphImporter>()); // Done
m_assetImporters.emplace(AssetType::Animation, CreateScope<AnimationImporter>()); // Done
m_assetImporters.emplace(AssetType::AnimatedCharacter, CreateScope<AnimatedCharacterImporter>()); // Done
m_assetImporters.emplace(AssetType::ParticlePreset, CreateScope<ParticlePresetImporter>()); // Done
m_assetImporters.emplace(AssetType::Prefab, CreateScope<PrefabImporter>()); // Done
m_assetImporters.emplace(AssetType::Font, CreateScope<FontImporter>()); // Done
m_assetImporters.emplace(AssetType::PhysicsMaterial, CreateScope<PhysicsMaterialImporter>()); // Done
m_assetImporters.emplace(AssetType::Video, CreateScope<VideoImporter>()); // Done
m_assetImporters.emplace(AssetType::BehaviorGraph, CreateScope<BehaviorTreeImporter>()); // Done
m_assetImporters.emplace(AssetType::BlendSpace, CreateScope<BlendSpaceImporter>()); // Done
m_assetImporters.emplace(AssetType::PostProcessingStack, CreateScope<PostProcessingStackImporter>()); // Done
m_assetImporters.emplace(AssetType::PostProcessingMaterial, CreateScope<PostProcessingMaterialImporter>()); // Done
m_assetImporters.emplace(AssetType::NetContract, CreateScope<NetContractImporter>()); // Done
}

template<typename T>
void RegisterCreateFunction(AssetType assetType, std::unordered_map<AssetType, AssetManager::AssetCreateFunction>& functionMap)
{
functionMap[assetType] = []() { return CreateRef<T>(); }
}

void AssetManager::RegisterAssetCreateFunctions()
{
}

void AssetManager::LoadAsset(AssetHandle assetHandle, Ref<Asset>& asset)
{
{
Expand Down
5 changes: 5 additions & 0 deletions Volt/Volt/src/Volt/Asset/AssetManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Volt
public:
using WriteLock = std::unique_lock<std::shared_mutex>;
using ReadLock = std::shared_lock<std::shared_mutex>;
using AssetCreateFunction = std::function<Ref<Asset>()>;

AssetManager();
~AssetManager();
Expand Down Expand Up @@ -135,6 +136,8 @@ namespace Volt
inline static AssetManager* s_instance = nullptr;
inline static AssetMetadata s_nullMetadata = {};

void RegisterAssetSerializers();

void LoadAsset(AssetHandle assetHandle, Ref<Asset>& asset);
void DeserializeAssetMetafile(std::filesystem::path metaPath);
void LoadAssetMetafiles();
Expand All @@ -154,6 +157,8 @@ namespace Volt
std::vector<std::filesystem::path> GetProjectMetaFiles();

std::unordered_map<AssetType, Scope<AssetImporter>> m_assetImporters;
std::unordered_map<AssetType, AssetCreateFunction> m_assetCreateFunctions;

std::unordered_map<AssetHandle, Ref<Asset>> m_assetCache;
std::unordered_map<AssetHandle, Ref<Asset>> m_memoryAssets;
std::unordered_map<AssetHandle, AssetMetadata> m_assetRegistry;
Expand Down
2 changes: 1 addition & 1 deletion Volt/Volt/src/Volt/Rendering/SceneRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2467,7 +2467,7 @@ namespace Volt

if (GetGPUData().postProcessingStack && mySettings.enablePostProcessing)
{
AddPostProcessingStackPasses(frameGraph);
//AddPostProcessingStackPasses(frameGraph);§
}

if (mySettings.enableOutline)
Expand Down
Loading

0 comments on commit c475652

Please sign in to comment.