diff --git a/Engine/Auto/Scripts/editor.lua b/Engine/Auto/Scripts/editor.lua index 4d019bb7..af289796 100644 --- a/Engine/Auto/Scripts/editor.lua +++ b/Engine/Auto/Scripts/editor.lua @@ -103,16 +103,10 @@ project("Editor") if not USE_CLANG_TOOLSET then links { "GenericProducer", - "TerrainProducer", } defines { "ENABLE_GENERIC_PRODUCER", - "ENABLE_TERRAIN_PRODUCER", - } - else - excludes { - path.join(EditorSourcePath, "UILayers/TerrainEditor.*") } end diff --git a/Engine/Auto/Scripts/engine.lua b/Engine/Auto/Scripts/engine.lua index 4b2da6e4..825a7ca4 100644 --- a/Engine/Auto/Scripts/engine.lua +++ b/Engine/Auto/Scripts/engine.lua @@ -36,7 +36,6 @@ project("Engine") } end - local bgfxBuildBinPath = nil local platformDefines = {} local platformIncludeDirs = {} @@ -161,22 +160,26 @@ project("Engine") } filter {} - filter { "configurations:Release" } - if DDGI_SDK_PATH ~= "" then - includedirs { - path.join(DDGI_SDK_PATH, "include"), - } - libdirs { - path.join(DDGI_SDK_PATH, "lib"), - } - links { - "ddgi_sdk", "mright_sdk", "DDGIProbeDecoderBin" - } - defines { - "DDGI_SDK_PATH=\""..DDGI_SDK_PATH.."\"", - } - end - filter {} + if ENABLE_DDGI then + includedirs { + path.join(DDGI_SDK_PATH, "include"), + } + libdirs { + path.join(DDGI_SDK_PATH, "lib"), + } + links { + "ddgi_sdk", "mright_sdk", "DDGIProbeDecoderBin" + } + defines { + "ENABLE_DDGI", + "DDGI_SDK_PATH=\""..DDGI_SDK_PATH.."\"", + } + else + excludes { + path.join(RuntimeSourcePath, "ECWorld/DDGIComponent.*"), + path.join(RuntimeSourcePath, "Rendering/DDGIRenderer.*"), + } + end if "SharedLib" == EngineBuildLibKind then table.insert(platformDefines, "ENGINE_BUILD_SHARED") @@ -217,7 +220,7 @@ project("Engine") "MultiProcessorCompile", -- compiler uses multiple thread } - if DDGI_SDK_PATH == "" and not USE_CLANG_TOOLSET then + if ShouldTreatWaringAsError then flags { "FatalWarnings", -- treat warnings as errors } diff --git a/Engine/Auto/Scripts/game.lua b/Engine/Auto/Scripts/game.lua index 0d7f676c..2c975bc4 100644 --- a/Engine/Auto/Scripts/game.lua +++ b/Engine/Auto/Scripts/game.lua @@ -64,10 +64,6 @@ project("Game") "CDConsumer", } - excludes { - path.join(EditorSourcePath, "UILayers/TerrainEditor.*") - } - -- Disable these options can reduce the size of compiled binaries. justmycode("Off") editAndContinue("Off") diff --git a/Engine/Auto/Scripts/premake5.lua b/Engine/Auto/Scripts/premake5.lua index 5f6473a4..203093c2 100644 --- a/Engine/Auto/Scripts/premake5.lua +++ b/Engine/Auto/Scripts/premake5.lua @@ -39,6 +39,9 @@ ENABLE_FREETYPE = not USE_CLANG_TOOLSET and not IsLinuxPlatform() and not IsAndr ENABLE_SPDLOG = not USE_CLANG_TOOLSET and not IsLinuxPlatform() and not IsAndroidPlatform() ENABLE_SUBPROCESS = not USE_CLANG_TOOLSET and not IsLinuxPlatform() and not IsAndroidPlatform() ENABLE_TRACY = not USE_CLANG_TOOLSET and not IsLinuxPlatform() and not IsAndroidPlatform() +ENABLE_DDGI = DDGI_SDK_PATH ~= "" + +ShouldTreatWaringAsError = not (ENABLE_DDGI or USE_CLANG_TOOLSET) PlatformSettings = {} PlatformSettings["Windows"] = { @@ -175,7 +178,6 @@ function CopyDllAutomatically() if not USE_CLANG_TOOLSET then postbuildcommands { "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Debug/GenericProducer.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Debug/TerrainProducer.*").."\" \""..BinariesPath.."\"", "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Debug/assimp-*-mtd.*").."\" \""..BinariesPath.."\"", } end @@ -199,21 +201,18 @@ function CopyDllAutomatically() if not USE_CLANG_TOOLSET then postbuildcommands { "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Release/GenericProducer.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Release/TerrainProducer.*").."\" \""..BinariesPath.."\"", "{COPYFILE} \""..path.join(ThirdPartySourcePath, "AssetPipeline/build/bin/Release/assimp-*-mt.*").."\" \""..BinariesPath.."\"", } end filter {} - filter { "configurations:Release" } - if DDGI_SDK_PATH ~= "" then - postbuildcommands { - "{COPYFILE} \""..path.join(DDGI_SDK_PATH, "bin/*.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(DDGI_SDK_PATH, "bin/ThirdParty/ffmpeg/*.*").."\" \""..BinariesPath.."\"", - "{COPYFILE} \""..path.join(DDGI_SDK_PATH, "bin/ThirdParty/zlib/*.*").."\" \""..BinariesPath.."\"", - } - end - filter {} + if ENABLE_DDGI then + postbuildcommands { + "{COPYFILE} \""..path.join(DDGI_SDK_PATH, "bin/*.*").."\" \""..BinariesPath.."\"", + "{COPYFILE} \""..path.join(DDGI_SDK_PATH, "bin/ThirdParty/ffmpeg/*.*").."\" \""..BinariesPath.."\"", + "{COPYFILE} \""..path.join(DDGI_SDK_PATH, "bin/ThirdParty/zlib/*.*").."\" \""..BinariesPath.."\"", + } + end end -- thirdparty projects diff --git a/Engine/Source/Editor/ECWorld/ECTerrainConsumer.cpp b/Engine/Source/Editor/ECWorld/ECTerrainConsumer.cpp deleted file mode 100644 index af8a2560..00000000 --- a/Engine/Source/Editor/ECWorld/ECTerrainConsumer.cpp +++ /dev/null @@ -1,161 +0,0 @@ -#include "ECTerrainConsumer.h" - -#include "ECWorld/ComponentsStorage.hpp" -#include "ECWorld/MaterialComponent.h" -#include "ECWorld/NameComponent.h" -#include "ECWorld/SceneWorld.h" -#include "ECWorld/StaticMeshComponent.h" -#include "ECWorld/World.h" -#include "Log/Log.h" -#include "Material/MaterialType.h" -#include "Path/Path.h" -#include "Rendering/RenderContext.h" -#include "Resources/ResourceBuilder.h" -#include "Resources/ResourceLoader.h" -#include "Scene/Material.h" -#include "Scene/MaterialTextureType.h" -#include "Scene/Node.h" -#include "Scene/SceneDatabase.h" -#include "Scene/VertexFormat.h" -#include "Utilities/StringUtils.h" - -#include -#include - -namespace editor -{ - -ECTerrainConsumer::ECTerrainConsumer(engine::SceneWorld* pSceneWorld, engine::RenderContext* pRenderContext) - : m_pSceneWorld(pSceneWorld) -{ -} - -void ECTerrainConsumer::Execute(const cd::SceneDatabase* pSceneDatabase) -{ - assert(pSceneDatabase->GetMeshCount() > 0); - - for (const cd::Mesh& mesh : pSceneDatabase->GetMeshes()) - { - const cd::MeshID::ValueType meshID = mesh.GetID().Data(); - if (m_meshToEntity.find(meshID) == m_meshToEntity.cend()) - { - engine::Entity terrainEntity = m_pSceneWorld->GetWorld()->CreateEntity(); - engine::MaterialType* pMaterialType = m_pSceneWorld->GetTerrainMaterialType(); - AddStaticMesh(terrainEntity, &mesh, pMaterialType->GetRequiredVertexFormat()); - const cd::MaterialID meshMaterialID = mesh.GetMaterialID(); - if (meshMaterialID.IsValid()) - { - AddMaterial(terrainEntity, &pSceneDatabase->GetMaterial(meshMaterialID.Data()), pMaterialType, pSceneDatabase); - } - m_meshToEntity[meshID] = terrainEntity; - } - } -} - -void ECTerrainConsumer::Clear() -{ - for (const auto& [meshID, entity] : m_meshToEntity) - { - m_pSceneWorld->DeleteEntity(entity); - } -} - -void ECTerrainConsumer::AddStaticMesh(engine::Entity entity, const cd::Mesh* mesh, const cd::VertexFormat& vertexFormat) -{ - assert(mesh->GetVertexCount() > 0 && mesh->GetPolygonCount() > 0); - - engine::World* pWorld = m_pSceneWorld->GetWorld(); - engine::NameComponent& nameComponent = pWorld->CreateComponent(entity); - nameComponent.SetName(mesh->GetName()); - - engine::StaticMeshComponent& staticMeshComponent = pWorld->CreateComponent(entity); - staticMeshComponent.SetMeshData(mesh); - staticMeshComponent.SetRequiredVertexFormat(&vertexFormat); - staticMeshComponent.Build(); -} - -void ECTerrainConsumer::AddMaterial(engine::Entity entity, const cd::Material* pMaterial, engine::MaterialType* pMaterialType, const cd::SceneDatabase* pSceneDatabase) -{ - cd::TextureID baseColorTextureID = pMaterial->GetTextureID(cd::MaterialTextureType::BaseColor); - assert(baseColorTextureID.IsValid()); - const cd::Texture& baseColorTexture = pSceneDatabase->GetTexture(baseColorTextureID.Data()); - const std::string baseColorTexturePath = GetTextureOutputFilePath(baseColorTexture.GetPath()); - std::string textureDir = cd::string_format("%sTextures/textures/%s.png", CDPROJECT_RESOURCES_ROOT_PATH, baseColorTexture.GetPath()); - ResourceBuilder::Get().AddTextureBuildTask(baseColorTexture.GetType(), textureDir.c_str(), baseColorTexturePath.c_str()); - - // Shaders - engine::ShaderSchema& shaderSchema = pMaterialType->GetShaderSchema(); - const std::string outputVSFilePath = GetShaderOutputFilePath(shaderSchema.GetVertexShaderPath()); - ResourceBuilder::Get().AddShaderBuildTask(ShaderType::Vertex, shaderSchema.GetVertexShaderPath(), outputVSFilePath.c_str()); - - const std::string outputFSFilePath = GetShaderOutputFilePath(shaderSchema.GetFragmentShaderPath()); - ResourceBuilder::Get().AddShaderBuildTask(ShaderType::Fragment, shaderSchema.GetFragmentShaderPath(), outputFSFilePath.c_str()); - - // TODO : ResourceBuilder will move to EditorApp::Update in the future. - // Now let's wait all resource build tasks done here. - ResourceBuilder::Get().Update(); - - // TODO : create material component before ResourceBuilder done. - engine::MaterialComponent& materialComponent = m_pSceneWorld->GetWorld()->CreateComponent(entity); - materialComponent.Init(); - materialComponent.SetMaterialType(pMaterialType); - materialComponent.SetMaterialData(pMaterial); - - // Textures - cd::TextureID elevationTextureID = pMaterial->GetTextureID(cd::MaterialTextureType::Elevation); - assert(elevationTextureID.IsValid()); - // Don't need to load as this is generated - const cd::Texture& elevationTexture = pSceneDatabase->GetTexture(elevationTextureID.Data()); - materialComponent.AddTextureBlob(elevationTexture.GetType(), elevationTexture.GetFormat(), cd::TextureMapMode::Clamp, cd::TextureMapMode::Clamp, - engine::MaterialComponent::TextureBlob(elevationTexture.GetRawData()), elevationTexture.GetWidth(), elevationTexture.GetHeight()); - - cd::TextureID alphaMapTextureID = pMaterial->GetTextureID(cd::MaterialTextureType::AlphaMap); - if (alphaMapTextureID.IsValid()) - { - const cd::Texture& alphaMapTexture = pSceneDatabase->GetTexture(alphaMapTextureID.Data()); - materialComponent.AddTextureBlob(alphaMapTexture.GetType(), alphaMapTexture.GetFormat(), cd::TextureMapMode::Clamp, cd::TextureMapMode::Clamp, - engine::MaterialComponent::TextureBlob(alphaMapTexture.GetRawData()), alphaMapTexture.GetWidth(), alphaMapTexture.GetHeight()); - } - - // Shaders - shaderSchema.AddUberOptionVSBlob(engine::ResourceLoader::LoadFile(outputVSFilePath.c_str())); - const engine::ShaderSchema::ShaderBlob& VSBlob = shaderSchema.GetVSBlob(); - bgfx::ShaderHandle vsHandle = bgfx::createShader(bgfx::makeRef(VSBlob.data(), static_cast(VSBlob.size()))); - - shaderSchema.AddUberOptionFSBlob(engine::ShaderSchema::DefaultUberShaderCrc, engine::ResourceLoader::LoadFile(outputFSFilePath.c_str())); - const engine::ShaderSchema::ShaderBlob& FSBlob = shaderSchema.GetFSBlob(engine::ShaderSchema::DefaultUberShaderCrc); - bgfx::ShaderHandle fsHandle = bgfx::createShader(bgfx::makeRef(FSBlob.data(), static_cast(FSBlob.size()))); - bgfx::ProgramHandle uberProgramHandle = bgfx::createProgram(vsHandle, fsHandle); - shaderSchema.SetCompiledProgram(engine::ShaderSchema::DefaultUberShaderCrc, uberProgramHandle.idx); - - materialComponent.Build(); -} - -std::string ECTerrainConsumer::GetShaderOutputFilePath(const char* pInputFilePath, const char* pAppendFileName /* = nullptr */) -{ - std::filesystem::path inputShaderPath(pInputFilePath); - std::string inputShaderFileName = inputShaderPath.stem().generic_string(); - std::filesystem::path outputShaderPath = engine::Path::GetShaderOutputDirectory() / inputShaderFileName; - if (pAppendFileName) - { - if (engine::ShaderSchema::DefaultUberShaderCrc != engine::StringCrc(pAppendFileName)) - { - outputShaderPath += "_"; - outputShaderPath += pAppendFileName; - } - } - outputShaderPath += ".bin"; - return outputShaderPath.string(); -} - - -std::string ECTerrainConsumer::GetTextureOutputFilePath(const char* pInputFilePath) -{ - std::filesystem::path inputTexturePath(pInputFilePath); - std::string inputTextureFileName = inputTexturePath.stem().generic_string(); - std::string outputTexturePath = CDPROJECT_RESOURCES_ROOT_PATH; - outputTexturePath += "Textures/" + inputTextureFileName + ".dds"; - return outputTexturePath; -} - -} \ No newline at end of file diff --git a/Engine/Source/Editor/ECWorld/ECTerrainConsumer.h b/Engine/Source/Editor/ECWorld/ECTerrainConsumer.h deleted file mode 100644 index c6405750..00000000 --- a/Engine/Source/Editor/ECWorld/ECTerrainConsumer.h +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -#include "Base/Template.h" -#include "ECWorld/Entity.h" -#include "Framework/IConsumer.h" -#include "Scene/ObjectID.h" - -#include -#include - -namespace cd -{ -class Material; -class Mesh; -class SceneDatabase; -class Texture; -class VertexFormat; -} - -namespace engine -{ -class MaterialType; -class RenderContext; -class SceneWorld; -class World; -} - -namespace editor -{ - -class ECTerrainConsumer final : public cdtools::IConsumer -{ -public: - ECTerrainConsumer() = delete; - explicit ECTerrainConsumer(engine::SceneWorld* pSceneWorld, engine::RenderContext* pRenderContext); - ECTerrainConsumer(const ECTerrainConsumer&) = delete; - ECTerrainConsumer& operator=(const ECTerrainConsumer&) = delete; - ECTerrainConsumer(ECTerrainConsumer&&) = delete; - ECTerrainConsumer& operator=(ECTerrainConsumer&&) = delete; - virtual ~ECTerrainConsumer() = default; - - virtual void Execute(const cd::SceneDatabase* pSceneDatabase) override; - - void Clear(); - -private: - void AddStaticMesh(engine::Entity entity, const cd::Mesh* mesh, const cd::VertexFormat& vertexFormat); - void AddMaterial(engine::Entity entity, const cd::Material* pMaterial, engine::MaterialType* pMaterialType, const cd::SceneDatabase* pSceneDatabase); - - std::string GetShaderOutputFilePath(const char* pInputFilePath, const char* pAppendFileName = nullptr); - std::string GetTextureOutputFilePath(const char* pInputFilePath); - - engine::SceneWorld* m_pSceneWorld; - std::map m_meshToEntity; -}; - -} diff --git a/Engine/Source/Editor/ECWorld/ECWorldConsumer.cpp b/Engine/Source/Editor/ECWorld/ECWorldConsumer.cpp index ead2e193..0e5b5b0e 100644 --- a/Engine/Source/Editor/ECWorld/ECWorldConsumer.cpp +++ b/Engine/Source/Editor/ECWorld/ECWorldConsumer.cpp @@ -1,14 +1,7 @@ #include "ECWorldConsumer.h" -#include "ECWorld/ComponentsStorage.hpp" -#include "ECWorld/DDGIComponent.h" -#include "ECWorld/HierarchyComponent.h" -#include "ECWorld/MaterialComponent.h" -#include "ECWorld/NameComponent.h" +#include "ECWorld/AllComponentsHeader.h" #include "ECWorld/SceneWorld.h" -#include "ECWorld/SkyComponent.h" -#include "ECWorld/StaticMeshComponent.h" -#include "ECWorld/TransformComponent.h" #include "Log/Log.h" #include "Material/MaterialType.h" #include "Math/Transform.hpp" @@ -71,43 +64,24 @@ void ECWorldConsumer::Execute(const cd::SceneDatabase* pSceneDatabase) const auto& mesh = pSceneDatabase->GetMesh(meshID.Data()); - if(m_meshAssetType == MeshAssetType::Standard) + // TODO : Or the user doesn't want to import animation data. + const bool isStaticMesh = 0U == mesh.GetVertexInfluenceCount(); + if(isStaticMesh) { - // TODO : Or the user doesn't want to import animation data. - const bool isStaticMesh = 0U == mesh.GetVertexInfluenceCount(); - if(isStaticMesh) - { - engine::MaterialType* pMaterialType = m_pSceneWorld->GetPBRMaterialType(); - AddStaticMesh(meshEntity, mesh, pMaterialType->GetRequiredVertexFormat()); - - cd::MaterialID meshMaterialID = mesh.GetMaterialID(); - AddMaterial(meshEntity, meshMaterialID.IsValid() ? &pSceneDatabase->GetMaterial(meshMaterialID.Data()) : nullptr, pMaterialType, pSceneDatabase); - } - else - { - engine::MaterialType* pMaterialType = m_pSceneWorld->GetAnimationMaterialType(); - AddSkinMesh(meshEntity, mesh, pMaterialType->GetRequiredVertexFormat()); - - // TODO : Use a standalone .cdanim file to play animation. - // Currently, we assume that imported SkinMesh will play animation automatically for testing. - AddAnimation(meshEntity, pSceneDatabase->GetAnimation(0), pSceneDatabase); - AddMaterial(meshEntity, nullptr, pMaterialType, pSceneDatabase); - } - } - else if(m_meshAssetType == MeshAssetType::DDGI) - { - engine::MaterialType *pMaterialType = m_pSceneWorld->GetDDGIMaterialType(); - AddStaticMesh(meshEntity, mesh, pMaterialType->GetRequiredVertexFormat()); + AddStaticMesh(meshEntity, mesh, m_pDefaultMaterialType->GetRequiredVertexFormat()); cd::MaterialID meshMaterialID = mesh.GetMaterialID(); - if(meshMaterialID.IsValid()) - { - AddMaterial(meshEntity, &pSceneDatabase->GetMaterial(meshMaterialID.Data()), pMaterialType, pSceneDatabase); - } + AddMaterial(meshEntity, meshMaterialID.IsValid() ? &pSceneDatabase->GetMaterial(meshMaterialID.Data()) : nullptr, m_pDefaultMaterialType, pSceneDatabase); } else { - CD_ERROR("Unknown MeshAssetType!"); + engine::MaterialType* pMaterialType = m_pSceneWorld->GetAnimationMaterialType(); + AddSkinMesh(meshEntity, mesh, pMaterialType->GetRequiredVertexFormat()); + + // TODO : Use a standalone .cdanim file to play animation. + // Currently, we assume that imported SkinMesh will play animation automatically for testing. + AddAnimation(meshEntity, pSceneDatabase->GetAnimation(0), pSceneDatabase); + AddMaterial(meshEntity, nullptr, pMaterialType, pSceneDatabase); } }; diff --git a/Engine/Source/Editor/ECWorld/ECWorldConsumer.h b/Engine/Source/Editor/ECWorld/ECWorldConsumer.h index d3fbcd13..605a0373 100644 --- a/Engine/Source/Editor/ECWorld/ECWorldConsumer.h +++ b/Engine/Source/Editor/ECWorld/ECWorldConsumer.h @@ -42,12 +42,6 @@ class SceneWorld; namespace editor { -enum class MeshAssetType : uint8_t -{ - Standard, - DDGI, -}; - class ECWorldConsumer final : public cdtools::IConsumer { public: @@ -59,11 +53,10 @@ class ECWorldConsumer final : public cdtools::IConsumer ECWorldConsumer& operator=(ECWorldConsumer&&) = delete; virtual ~ECWorldConsumer() = default; + void SetDefaultMaterialType(engine::MaterialType* pMaterialType) { m_pDefaultMaterialType = pMaterialType; } void SetSceneDatabaseIDs(uint32_t nodeID, uint32_t meshID); virtual void Execute(const cd::SceneDatabase* pSceneDatabase) override; - void ActivateDDGIService() { m_meshAssetType = MeshAssetType::DDGI; } - private: void AddCamera(engine::Entity entity, const cd::Camera& camera); void AddLight(engine::Entity entity, const cd::Light& light); @@ -74,11 +67,11 @@ class ECWorldConsumer final : public cdtools::IConsumer void AddMaterial(engine::Entity entity, const cd::Material* pMaterial, engine::MaterialType* pMaterialType, const cd::SceneDatabase* pSceneDatabase); private: - engine::SceneWorld* m_pSceneWorld; + engine::MaterialType* m_pDefaultMaterialType = nullptr; + engine::SceneWorld* m_pSceneWorld = nullptr; uint32_t m_nodeMinID; uint32_t m_meshMinID; - MeshAssetType m_meshAssetType = MeshAssetType::Standard; }; } \ No newline at end of file diff --git a/Engine/Source/Editor/EditorApp.cpp b/Engine/Source/Editor/EditorApp.cpp index d391e834..e0878a3f 100644 --- a/Engine/Source/Editor/EditorApp.cpp +++ b/Engine/Source/Editor/EditorApp.cpp @@ -12,7 +12,9 @@ #include "Path/Path.h" #include "Rendering/AnimationRenderer.h" #include "Rendering/BlitRenderTargetPass.h" +#ifdef ENABLE_DDGI #include "Rendering/DDGIRenderer.h" +#endif #include "Rendering/DebugRenderer.h" #include "Rendering/ImGuiRenderer.h" #include "Rendering/PBRSkyRenderer.h" @@ -36,11 +38,6 @@ #include "Window/Input.h" #include "Window/Window.h" -#ifdef ENABLE_TERRAIN_PRODUCER -#include "UILayers/TerrainEditor.h" -#include "Rendering/TerrainRenderer.h" -#endif - #include #define IMGUI_DEFINE_MATH_OPERATORS #include @@ -163,11 +160,6 @@ void EditorApp::InitEditorUILayers() m_pSceneView = pSceneView.get(); m_pEditorImGuiContext->AddDynamicLayer(cd::MoveTemp(pSceneView)); -#ifdef ENABLE_TERRAIN_PRODUCER - auto pTerrainEditor = std::make_unique("Terrain Editor"); - m_pEditorImGuiContext->AddDynamicLayer(cd::MoveTemp(pTerrainEditor)); -#endif - m_pEditorImGuiContext->AddDynamicLayer(std::make_unique("Inspector")); auto pAssetBrowser = std::make_unique("AssetBrowser"); @@ -232,8 +224,10 @@ void EditorApp::InitECWorld() InitEditorCameraEntity(); +#ifdef ENABLE_DDGI m_pSceneWorld->InitDDGISDK(); InitDDGIEntity(); +#endif InitSkyEntity(); } @@ -267,6 +261,7 @@ void EditorApp::InitEditorCameraEntity() cameraComponent.BuildViewMatrix(cameraTransform); } +#ifdef ENABLE_DDGI void EditorApp::InitDDGIEntity() { engine::World* pWorld = m_pSceneWorld->GetWorld(); @@ -279,6 +274,7 @@ void EditorApp::InitDDGIEntity() pWorld->CreateComponent(ddgiEntity); } +#endif void EditorApp::InitSkyEntity() { @@ -351,12 +347,6 @@ void EditorApp::InitEngineRenderers() AddEngineRenderer(cd::MoveTemp(pPBRSkyRenderer)); } -#ifdef ENABLE_TERRAIN_PRODUCER - auto pTerrainRenderer = std::make_unique(m_pRenderContext->CreateView(), pSceneRenderTarget); - pTerrainRenderer->SetSceneWorld(m_pSceneWorld.get()); - AddEngineRenderer(cd::MoveTemp(pTerrainRenderer)); -#endif - auto pSceneRenderer = std::make_unique(m_pRenderContext->CreateView(), pSceneRenderTarget); m_pSceneRenderer = pSceneRenderer.get(); pSceneRenderer->SetSceneWorld(m_pSceneWorld.get()); @@ -372,9 +362,11 @@ void EditorApp::InitEngineRenderers() pDebugRenderer->SetEnable(false); AddEngineRenderer(cd::MoveTemp(pDebugRenderer)); +#ifdef ENABLE_DDGI auto pDDGIRenderer = std::make_unique(m_pRenderContext->CreateView(), pSceneRenderTarget); pDDGIRenderer->SetSceneWorld(m_pSceneWorld.get()); AddEngineRenderer(cd::MoveTemp(pDDGIRenderer)); +#endif auto pBlitRTRenderPass = std::make_unique(m_pRenderContext->CreateView(), pSceneRenderTarget); AddEngineRenderer(cd::MoveTemp(pBlitRTRenderPass)); @@ -408,8 +400,9 @@ void EditorApp::InitShaderPrograms() const ShaderBuilder::BuildUberShader(m_pSceneWorld->GetPBRMaterialType()); ShaderBuilder::BuildUberShader(m_pSceneWorld->GetAnimationMaterialType()); - ShaderBuilder::BuildUberShader(m_pSceneWorld->GetTerrainMaterialType()); +#ifdef ENABLE_DDGI ShaderBuilder::BuildUberShader(m_pSceneWorld->GetDDGIMaterialType()); +#endif } void EditorApp::InitEditorController() @@ -444,8 +437,9 @@ bool EditorApp::Update(float deltaTime) m_bInitEditor = true; engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetPBRMaterialType()); engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetAnimationMaterialType()); - engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetTerrainMaterialType()); +#ifdef ENABLE_DDGI engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetDDGIMaterialType()); +#endif // Phase 2 - Project Manager // * TODO : Show project selector diff --git a/Engine/Source/Editor/UILayers/AssetBrowser.cpp b/Engine/Source/Editor/UILayers/AssetBrowser.cpp index 7901d345..87e1da4f 100644 --- a/Engine/Source/Editor/UILayers/AssetBrowser.cpp +++ b/Engine/Source/Editor/UILayers/AssetBrowser.cpp @@ -938,10 +938,12 @@ void AssetBrowser::ImportModelFile(const char* pFilePath) { ECWorldConsumer ecConsumer(pSceneWorld, pCurrentRenderContext); ecConsumer.SetSceneDatabaseIDs(oldNodeCount, oldMeshCount); +#ifdef ENABLE_DDGI if (m_importOptions.AssetType == IOAssetType::DDGIModel) { - ecConsumer.ActivateDDGIService(); + ecConsumer.SetDefaultMaterialType(pSceneWorld->GetDDGIMaterialType()); } +#endif cdtools::Processor processor(nullptr, &ecConsumer, pSceneDatabase); processor.SetDumpSceneDatabaseEnable(true); processor.Run(); @@ -955,31 +957,6 @@ void AssetBrowser::ImportModelFile(const char* pFilePath) processor.SetDumpSceneDatabaseEnable(false); processor.Run(); } - -#if 0 - // Temporary : Edit texture file path. - { - - cdtools::CDConsumer cdConsumer("C:/Users/22470/Desktop/subo/new/subo.cdbin2"); - cdConsumer.SetExportMode(cdtools::ExportMode::PureBinary); - - auto &textures = pSceneDatabase->GetTextures(); - for (auto &tx : textures) - { - std::filesystem::path texturePath = tx.GetPath(); - texturePath.replace_extension("dds"); - std::string newName = texturePath.filename().string(); - tx.SetPath(newName.c_str()); - - CD_FATAL("newName : {}", newName); - } - - cdtools::Processor processor(nullptr, &cdConsumer, pSceneDatabase); - processor.SetDumpSceneDatabaseEnable(false); - processor.Run(); - } -#endif - } void AssetBrowser::ImportJson(const char* pFilePath) diff --git a/Engine/Source/Editor/UILayers/Inspector.cpp b/Engine/Source/Editor/UILayers/Inspector.cpp index c93ac287..6489a522 100644 --- a/Engine/Source/Editor/UILayers/Inspector.cpp +++ b/Engine/Source/Editor/UILayers/Inspector.cpp @@ -261,6 +261,7 @@ void UpdateComponentWidget(engine::SceneWorld* pSceneWor ImGui::PopStyleVar(); } +#ifdef ENABLE_DDGI template<> void UpdateComponentWidget(engine::SceneWorld *pSceneWorld, engine::Entity entity) { @@ -289,6 +290,7 @@ void UpdateComponentWidget(engine::SceneWorld *pSceneWorl ImGui::Separator(); ImGui::PopStyleVar(); } +#endif template<> void UpdateComponentWidget(engine::SceneWorld* pSceneWorld, engine::Entity entity) @@ -373,7 +375,9 @@ void Inspector::Update() details::UpdateComponentWidget(pSceneWorld, selectedEntity); details::UpdateComponentWidget(pSceneWorld, selectedEntity); details::UpdateComponentWidget(pSceneWorld, selectedEntity); +#ifdef ENABLE_DDGI details::UpdateComponentWidget(pSceneWorld, selectedEntity); +#endif details::UpdateComponentWidget(pSceneWorld, selectedEntity); ImGui::End(); diff --git a/Engine/Source/Editor/UILayers/TerrainEditor.cpp b/Engine/Source/Editor/UILayers/TerrainEditor.cpp deleted file mode 100644 index 51c842ac..00000000 --- a/Engine/Source/Editor/UILayers/TerrainEditor.cpp +++ /dev/null @@ -1,245 +0,0 @@ -#include "TerrainEditor.h" - -#include "ECWorld/ECTerrainConsumer.h" -#include "ECWorld/SceneWorld.h" -#include "Framework/Processor.h" -#include "ImGui/IconFont/IconsMaterialDesignIcons.h" -#include "ImGui/ImGuiContextInstance.h" -#include "Rendering/RenderContext.h" -#include "Utilities/StringUtils.h" - -#include - -using namespace cd; -using namespace cdtools; -using namespace engine; - -namespace editor -{ - -TerrainEditor::TerrainEditor(const char* pName) - : ImGuiBaseLayer(pName) - , m_terrainMetadata(1, 1, 0, 2000, 5.0f) - , m_sectorMetadata(1, 1, 10, 10) - , m_generateAlphaMap(false) - , m_terrainProducer(m_terrainMetadata, m_sectorMetadata) - , m_terrainEntities() -{} - -TerrainEditor::~TerrainEditor() -{} - -void TerrainEditor::Init() -{ - // Initialize some reasonable values - m_terrainMetadata.numSectorsInX = 5; - m_terrainMetadata.numSectorsInZ = 5; - m_terrainMetadata.minElevation = 0; - m_terrainMetadata.maxElevation = 100; - m_terrainMetadata.redistPow = 4.5f; - m_terrainMetadata.octaves.push_back(ElevationOctave(4564781151579, 1.0f, 1.0f)); - m_terrainMetadata.octaves.push_back(ElevationOctave(1341177459887, 2.0f, 0.8f)); - m_terrainMetadata.octaves.push_back(ElevationOctave(1551312147123, 4.0f, 0.6f)); - m_terrainMetadata.octaves.push_back(ElevationOctave(8707137379821, 8.0f, 0.4f)); - m_terrainMetadata.octaves.push_back(ElevationOctave(1362045344796, 16.0f, 0.2f)); - m_terrainMetadata.octaves.push_back(ElevationOctave(8714321343102, 32.0f, 0.1f)); - - m_sectorMetadata.numQuadsInX = 5; - m_sectorMetadata.numQuadsInZ = 5; - m_sectorMetadata.quadLenInX = 5; - m_sectorMetadata.quadLenInZ = 5; - - m_redGreenBlendRegion.blendStart = 0; - m_redGreenBlendRegion.blendEnd = 0; - m_greenBlueBlendRegion.blendStart = 0; - m_greenBlueBlendRegion.blendEnd = 0; - m_blueAlphaBlendRegion.blendStart = 0; - m_blueAlphaBlendRegion.blendEnd = 0; - - strcpy_s(m_redChannelTextureName, "dirty_baseColor.dds"); - strcpy_s(m_greenChannelTextureName, "rockyGrass_baseColor.dds"); - strcpy_s(m_blueChannelTextureName, "roughRock_baseColor.dds"); - strcpy_s(m_alphaChannelTextureName, "snowyRock_baseColor.dds"); - - m_pSceneDatabase = std::make_unique(); -} - -void TerrainEditor::Update() -{ - static constexpr float kInputItemWidth = 120; - - auto flags = ImGuiWindowFlags_None; // ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse; - ImGui::Begin(GetName(), &m_isEnable, flags); - - if (ImGui::Button("Update Terrain")) - { - ImGuiIO& io = ImGui::GetIO(); - RenderContext* pCurrentRenderContext = reinterpret_cast(io.BackendRendererUserData); - ImGuiContextInstance* pImGuiContextInstance = reinterpret_cast(io.UserData); - SceneWorld* pSceneWorld = pImGuiContextInstance->GetSceneWorld(); - - if (!m_pEcTerrainConsumer) { - m_pEcTerrainConsumer = std::make_unique(pSceneWorld, pCurrentRenderContext); - } else { - // Clean up previously generated entities - m_pSceneDatabase = std::make_unique(); - m_pEcTerrainConsumer->Clear(); - } - m_terrainProducer.SetSceneDatabaseIDs(m_pSceneDatabase.get()); - m_terrainProducer.SetTerrainMetadata(m_terrainMetadata); - m_terrainProducer.SetSectorMetadata(m_sectorMetadata); - if (m_generateAlphaMap) - { - // m_terrainProducer.SetAlphaMapTextureName(AlphaMapChannel::Red, m_redChannelTextureName); - // m_terrainProducer.SetAlphaMapTextureName(AlphaMapChannel::Green, m_greenChannelTextureName); - // m_terrainProducer.SetAlphaMapTextureName(AlphaMapChannel::Blue, m_blueChannelTextureName); - // m_terrainProducer.SetAlphaMapTextureName(AlphaMapChannel::Alpha, m_alphaChannelTextureName); - m_terrainProducer.GenerateAlphaMapWithElevation(m_redGreenBlendRegion, m_greenBlueBlendRegion, m_blueAlphaBlendRegion, AlphaMapBlendFunction::SmoothStep); - } - m_terrainProducer.Initialize(); - - Processor processor(&m_terrainProducer, m_pEcTerrainConsumer.get(), m_pSceneDatabase.get()); - processor.Run(); - } - // Terrain Metadata Group - ImGui::BeginGroup(); - { - const uint16_t sectorStep = 1; - ImGui::Text("Terrain Parameters:"); - ImGui::SetNextItemWidth(kInputItemWidth); - if (ImGui::InputScalar("Sector Count X", ImGuiDataType_U16, &m_terrainMetadata.numSectorsInX, §orStep, §orStep, NULL, ImGuiInputTextFlags_CharsDecimal)) - { - if (m_terrainMetadata.numSectorsInX == 0) - { - m_terrainMetadata.numSectorsInX = 1; - } - } - ImGui::SetNextItemWidth(kInputItemWidth); - if (ImGui::InputScalar("Sector Count Z", ImGuiDataType_U16, &m_terrainMetadata.numSectorsInZ, §orStep, §orStep, NULL, ImGuiInputTextFlags_CharsDecimal)) - { - if (m_terrainMetadata.numSectorsInZ == 0) - { - m_terrainMetadata.numSectorsInZ = 1; - } - } - ImGui::SetNextItemWidth(kInputItemWidth); - if (ImGui::InputScalar("Quads Count X", ImGuiDataType_U16, &m_sectorMetadata.numQuadsInX, §orStep, §orStep, NULL, ImGuiInputTextFlags_CharsDecimal)) - { - if (m_sectorMetadata.numQuadsInX == 0) - { - m_sectorMetadata.numQuadsInX = 1; - } - } - ImGui::SetNextItemWidth(kInputItemWidth); - if (ImGui::InputScalar("Quads Count Z", ImGuiDataType_U16, &m_sectorMetadata.numQuadsInZ, §orStep, §orStep, NULL, ImGuiInputTextFlags_CharsDecimal)) - { - if (m_sectorMetadata.numQuadsInZ == 0) - { - m_sectorMetadata.numQuadsInZ = 1; - } - } - ImGui::SetNextItemWidth(kInputItemWidth); - if (ImGui::InputScalar("Quads Length X", ImGuiDataType_U16, &m_sectorMetadata.quadLenInX, §orStep, §orStep, NULL, ImGuiInputTextFlags_CharsDecimal)) - { - if (m_sectorMetadata.quadLenInX == 0) - { - m_sectorMetadata.quadLenInX = 1; - } - } - ImGui::SetNextItemWidth(kInputItemWidth); - if (ImGui::InputScalar("Quads Length Z", ImGuiDataType_U16, &m_sectorMetadata.quadLenInZ, §orStep, §orStep, NULL, ImGuiInputTextFlags_CharsDecimal)) - { - if (m_sectorMetadata.quadLenInZ == 0) - { - m_sectorMetadata.quadLenInZ = 1; - } - } - - const int32_t elevationStep = 1; - const int32_t elevationBigStep = 10; - ImGui::SetNextItemWidth(kInputItemWidth); - if (ImGui::InputScalar("Min Elevation", ImGuiDataType_S32, &m_terrainMetadata.minElevation, &elevationStep, &elevationBigStep, NULL, ImGuiInputTextFlags_CharsDecimal)) - { - if (m_terrainMetadata.minElevation >= m_terrainMetadata.maxElevation) - { - m_terrainMetadata.minElevation = m_terrainMetadata.maxElevation - 1; - } - } - ImGui::SetNextItemWidth(kInputItemWidth); - if (ImGui::InputScalar("Max Elevation", ImGuiDataType_S32, &m_terrainMetadata.maxElevation, &elevationStep, &elevationBigStep, NULL, ImGuiInputTextFlags_CharsDecimal)) - { - if (m_terrainMetadata.maxElevation <= m_terrainMetadata.minElevation) - { - m_terrainMetadata.maxElevation = m_terrainMetadata.minElevation + 1; - } - } - - const float redistPowStep = 0.1f; - const float redistPowBigStep = 1.0f; - ImGui::SetNextItemWidth(kInputItemWidth); - ImGui::InputScalar("Power", ImGuiDataType_Float, &m_terrainMetadata.redistPow, &redistPowStep, &redistPowBigStep, "%.2f", ImGuiInputTextFlags_CharsDecimal); - } - ImGui::EndGroup(); - - // Alpha mapping - ImGui::BeginGroup(); - { - ImGui::Checkbox("Elevation Alpha Map", &m_generateAlphaMap); - if (m_generateAlphaMap) - { - ImGui::InputInt("RGBlend Start", &m_redGreenBlendRegion.blendStart); - ImGui::InputInt("RGBlend End", &m_redGreenBlendRegion.blendEnd); - - ImGui::InputInt("GBBlend Start", &m_greenBlueBlendRegion.blendStart); - ImGui::InputInt("GBBlend End", &m_greenBlueBlendRegion.blendEnd); - - ImGui::InputInt("BABlend Start", &m_blueAlphaBlendRegion.blendStart); - ImGui::InputInt("BABlend End", &m_blueAlphaBlendRegion.blendEnd); - - ImGui::InputText("Red Texture", m_redChannelTextureName, 128); - ImGui::InputText("Green Texture", m_greenChannelTextureName, 128); - ImGui::InputText("Blue Texture", m_blueChannelTextureName, 128); - ImGui::InputText("Alpha Texture", m_alphaChannelTextureName, 128); - } - } - ImGui::EndGroup(); - - // Octaves Group - const int64_t seedStep = 1; - const float freqAndWeightStep = 0.1f; - ImGui::BeginGroup(); - { - ImGui::Separator(); - if (ImGui::Button("Add Octave")) - { - m_terrainMetadata.octaves.emplace_back(); - } - if (ImGui::Button("Remove Octave")) - { - m_terrainMetadata.octaves.pop_back(); - } - ImGui::Separator(); - ImGui::BeginChild("Elevation Octaves", ImVec2(0, 0), true); - for (uint32_t i = 0; i < m_terrainMetadata.octaves.size(); ++i) - { - ImGui::PushID(i); - ImGui::InputScalar(string_format("Seed %d", i).c_str(), ImGuiDataType_S64, &m_terrainMetadata.octaves[i].seed, &seedStep, &seedStep, NULL, ImGuiInputTextFlags_CharsDecimal); - if (ImGui::InputScalar(string_format("Frequency %d", i).c_str(), ImGuiDataType_Float, &m_terrainMetadata.octaves[i].frequency, &freqAndWeightStep, &freqAndWeightStep, NULL, ImGuiInputTextFlags_CharsDecimal)) - { - if (m_terrainMetadata.octaves[i].frequency <= 0.0f) - { - m_terrainMetadata.octaves[i].frequency = freqAndWeightStep; - } - } - ImGui::InputScalar(string_format("Weight %d", i).c_str(), ImGuiDataType_Float, &m_terrainMetadata.octaves[i].weight, &freqAndWeightStep, &freqAndWeightStep, NULL, ImGuiInputTextFlags_CharsDecimal); - ImGui::PopID(); - ImGui::Separator(); - } - ImGui::EndChild(); - } - ImGui::EndGroup(); - - ImGui::End(); -} - -} \ No newline at end of file diff --git a/Engine/Source/Editor/UILayers/TerrainEditor.h b/Engine/Source/Editor/UILayers/TerrainEditor.h deleted file mode 100644 index bfc3da90..00000000 --- a/Engine/Source/Editor/UILayers/TerrainEditor.h +++ /dev/null @@ -1,48 +0,0 @@ -#include "ImGui/ImGuiBaseLayer.h" - -#include "ECWorld/Entity.h" -#include "Producers/TerrainProducer/AlphaMapTypes.h" -#include "Producers/TerrainProducer/TerrainProducer.h" -#include "Producers/TerrainProducer/TerrainTypes.h" - -#include - -namespace cd -{ -class SceneDatabase; -} - -namespace editor -{ - - class ECTerrainConsumer; - -class TerrainEditor : public engine::ImGuiBaseLayer -{ -public: - using ImGuiBaseLayer::ImGuiBaseLayer; - - explicit TerrainEditor(const char* pName); - virtual ~TerrainEditor(); - - virtual void Init() override; - virtual void Update() override; - -private: - cdtools::TerrainMetadata m_terrainMetadata; - cdtools::TerrainSectorMetadata m_sectorMetadata; - bool m_generateAlphaMap; - cdtools::AlphaMapBlendRegion m_redGreenBlendRegion; - cdtools::AlphaMapBlendRegion m_greenBlueBlendRegion; - cdtools::AlphaMapBlendRegion m_blueAlphaBlendRegion; - char m_redChannelTextureName[128]; - char m_greenChannelTextureName[128]; - char m_blueChannelTextureName[128]; - char m_alphaChannelTextureName[128]; - cdtools::TerrainProducer m_terrainProducer; - std::unique_ptr m_pEcTerrainConsumer; - std::vector m_terrainEntities; - std::unique_ptr m_pSceneDatabase; -}; - -} \ No newline at end of file diff --git a/Engine/Source/Game/GameApp.cpp b/Engine/Source/Game/GameApp.cpp index 06f8390e..0ff8b744 100644 --- a/Engine/Source/Game/GameApp.cpp +++ b/Engine/Source/Game/GameApp.cpp @@ -10,7 +10,9 @@ #include "Math/MeshGenerator.h" #include "Path/Path.h" #include "Rendering/AnimationRenderer.h" +#ifdef ENABLE_DDGI #include "Rendering/DDGIRenderer.h" +#endif #include "Rendering/DebugRenderer.h" #include "Rendering/ImGuiRenderer.h" #include "Rendering/PBRSkyRenderer.h" @@ -23,11 +25,6 @@ #include "Window/Input.h" #include "Window/Window.h" -#ifdef ENABLE_TERRAIN_PRODUCER -#include "UILayers/TerrainEditor.h" -#include "Rendering/TerrainRenderer.h" -#endif - #include #define IMGUI_DEFINE_MATH_OPERATORS #include @@ -127,8 +124,9 @@ void GameApp::InitECWorld() InitEditorCameraEntity(); - m_pSceneWorld->InitDDGISDK(); +#ifdef ENABLE_DDGI InitDDGIEntity(); +#endif InitSkyEntity(); } @@ -163,6 +161,7 @@ void GameApp::InitEditorCameraEntity() cameraComponent.BuildViewMatrix(cameraTransform); } +#ifdef ENABLE_DDGI void GameApp::InitDDGIEntity() { engine::World* pWorld = m_pSceneWorld->GetWorld(); @@ -175,6 +174,7 @@ void GameApp::InitDDGIEntity() pWorld->CreateComponent(ddgiEntity); } +#endif void GameApp::InitSkyEntity() { @@ -243,12 +243,6 @@ void GameApp::InitEngineRenderers() AddEngineRenderer(cd::MoveTemp(pPBRSkyRenderer)); } -#ifdef ENABLE_TERRAIN_PRODUCER - auto pTerrainRenderer = std::make_unique(m_pRenderContext->CreateView(), pSceneRenderTarget); - pTerrainRenderer->SetSceneWorld(m_pSceneWorld.get()); - AddEngineRenderer(cd::MoveTemp(pTerrainRenderer)); -#endif - auto pSceneRenderer = std::make_unique(m_pRenderContext->CreateView(), pSceneRenderTarget); m_pSceneRenderer = pSceneRenderer.get(); pSceneRenderer->SetSceneWorld(m_pSceneWorld.get()); @@ -264,9 +258,11 @@ void GameApp::InitEngineRenderers() pDebugRenderer->SetEnable(false); AddEngineRenderer(cd::MoveTemp(pDebugRenderer)); +#ifdef ENABLE_DDGI auto pDDGIRenderer = std::make_unique(m_pRenderContext->CreateView(), pSceneRenderTarget); pDDGIRenderer->SetSceneWorld(m_pSceneWorld.get()); AddEngineRenderer(cd::MoveTemp(pDDGIRenderer)); +#endif // We can debug vertex/material/texture information by just output that to screen as fragmentColor. // But postprocess will bring unnecessary confusion. @@ -312,9 +308,9 @@ bool GameApp::Update(float deltaTime) m_bInitEditor = true; engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetPBRMaterialType()); engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetAnimationMaterialType()); - engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetTerrainMaterialType()); +#ifdef ENABLE_DDGI engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetDDGIMaterialType()); - +#endif // Phase 2 - Project Manager // * TODO : Show project selector //GetMainWindow()->SetTitle("Project Manager"); diff --git a/Engine/Source/Game/GameApp.h b/Engine/Source/Game/GameApp.h index 06c26399..9137570b 100644 --- a/Engine/Source/Game/GameApp.h +++ b/Engine/Source/Game/GameApp.h @@ -62,7 +62,9 @@ class GameApp final : public engine::IApplication private: void InitEditorCameraEntity(); +#ifdef ENABLE_DDGI void InitDDGIEntity(); +#endif void InitSkyEntity(); bool m_bInitEditor = false; diff --git a/Engine/Source/Runtime/ECWorld/AllComponentsHeader.h b/Engine/Source/Runtime/ECWorld/AllComponentsHeader.h index 312be6d1..579299ba 100644 --- a/Engine/Source/Runtime/ECWorld/AllComponentsHeader.h +++ b/Engine/Source/Runtime/ECWorld/AllComponentsHeader.h @@ -3,7 +3,9 @@ #include "ECWorld/AnimationComponent.h" #include "ECWorld/CameraComponent.h" #include "ECWorld/CollisionMeshComponent.h" +#ifdef ENABLE_DDGI #include "ECWorld/DDGIComponent.h" +#endif #include "ECWorld/HierarchyComponent.h" #include "ECWorld/LightComponent.h" #include "ECWorld/MaterialComponent.h" diff --git a/Engine/Source/Runtime/ECWorld/SceneWorld.cpp b/Engine/Source/Runtime/ECWorld/SceneWorld.cpp index 2263ad8d..f410dd82 100644 --- a/Engine/Source/Runtime/ECWorld/SceneWorld.cpp +++ b/Engine/Source/Runtime/ECWorld/SceneWorld.cpp @@ -4,11 +4,7 @@ #include "Path/Path.h" #include "U_BaseSlot.sh" -#if (defined DDGI_SDK_PATH && defined NDEBUG) - #define ENABLE_DDGI_SDK -#endif - -#ifdef ENABLE_DDGI_SDK +#ifdef ENABLE_DDGI #include "ddgi_sdk.h" #endif @@ -28,7 +24,9 @@ SceneWorld::SceneWorld() m_pAnimationComponentStorage = m_pWorld->Register(); m_pCameraComponentStorage = m_pWorld->Register(); m_pCollisionMeshComponentStorage = m_pWorld->Register(); +#ifdef ENABLE_DDGI m_pDDGIComponentStorage = m_pWorld->Register(); +#endif m_pHierarchyComponentStorage = m_pWorld->Register(); m_pLightComponentStorage = m_pWorld->Register(); m_pMaterialComponentStorage = m_pWorld->Register(); @@ -39,8 +37,9 @@ SceneWorld::SceneWorld() CreatePBRMaterialType(); CreateAnimationMaterialType(); - CreateTerrainMaterialType(); +#ifdef ENABLE_DDGI CreateDDGIMaterialType(); +#endif } void SceneWorld::CreatePBRMaterialType() @@ -90,24 +89,7 @@ void SceneWorld::CreateAnimationMaterialType() m_pAnimationMaterialType->SetRequiredVertexFormat(cd::MoveTemp(animationVertexFormat)); } -void SceneWorld::CreateTerrainMaterialType() -{ - m_pTerrainMaterialType = std::make_unique(); - m_pTerrainMaterialType->SetMaterialName("CD_Terrain"); - - ShaderSchema shaderSchema(Path::GetBuiltinShaderInputPath("shaders/vs_terrain"), Path::GetBuiltinShaderInputPath("shaders/fs_terrain")); - shaderSchema.RegisterUberOption(Uber::DEFAULT); - m_pTerrainMaterialType->SetShaderSchema(cd::MoveTemp(shaderSchema)); - - cd::VertexFormat terrainVertexFormat; - terrainVertexFormat.AddAttributeLayout(cd::VertexAttributeType::Position, cd::GetAttributeValueType(), cd::Point::Size); - terrainVertexFormat.AddAttributeLayout(cd::VertexAttributeType::UV, cd::GetAttributeValueType(), cd::UV::Size); - m_pTerrainMaterialType->SetRequiredVertexFormat(cd::MoveTemp(terrainVertexFormat)); - - m_pTerrainMaterialType->AddRequiredTextureType(cd::MaterialTextureType::Elevation, 1); - m_pTerrainMaterialType->AddOptionalTextureType(cd::MaterialTextureType::AlphaMap, 2); -} - +#ifdef ENABLE_DDGI void SceneWorld::CreateDDGIMaterialType() { m_pDDGIMaterialType = std::make_unique(); @@ -135,6 +117,7 @@ void SceneWorld::CreateDDGIMaterialType() m_pDDGIMaterialType->AddOptionalTextureType(cd::MaterialTextureType::Metallic, ORM_MAP_SLOT); m_pDDGIMaterialType->AddOptionalTextureType(cd::MaterialTextureType::Emissive, EMISSIVE_MAP_SLOT); } +#endif void SceneWorld::SetSelectedEntity(engine::Entity entity) { @@ -148,11 +131,13 @@ void SceneWorld::SetMainCameraEntity(engine::Entity entity) m_mainCameraEntity = entity; } +#ifdef ENABLE_DDGI void SceneWorld::SetDDGIEntity(engine::Entity entity) { CD_TRACE("Setup DDGI entity : {0}", entity); m_ddgiEntity = entity; } +#endif void SceneWorld::SetSkyEntity(engine::Entity entity) { @@ -234,19 +219,6 @@ void SceneWorld::AddMaterialToSceneDatabase(engine::Entity entity) pMaterialData->SetFloatProperty(cd::MaterialPropertyGroup::Roughness, cd::MaterialProperty::Factor, pMaterialComponent->GetRoughnessFactor()); pMaterialData->SetBoolProperty(cd::MaterialPropertyGroup::General, cd::MaterialProperty::TwoSided, pMaterialComponent->GetTwoSided()); -#if 0 - std::vector removeMaterialNames = { "Floor_Tiles_03", "WoodFloor" }; - for (auto& name : removeMaterialNames) - { - if (strcmp(pMaterialData->GetName(), name) == 0) - { - pMaterialData->RemoveTexture(cd::MaterialPropertyGroup::Metallic); - pMaterialData->RemoveTexture(cd::MaterialPropertyGroup::Occlusion); - pMaterialData->RemoveTexture(cd::MaterialPropertyGroup::Roughness); - } - } -#endif - for (int textureTypeValue = 0; textureTypeValue (cd::MaterialTextureType::Count); ++textureTypeValue) { if (MaterialComponent::TextureInfo* textureInfo = pMaterialComponent->GetTextureInfo(static_cast(textureTypeValue))) @@ -257,9 +229,9 @@ void SceneWorld::AddMaterialToSceneDatabase(engine::Entity entity) } } +#ifdef ENABLE_DDGI void SceneWorld::InitDDGISDK() { -#ifdef ENABLE_DDGI_SDK if (InitDDGI(DDGI_SDK_PATH)) { CD_ENGINE_FATAL("Init DDGI client success at : {0}", DDGI_SDK_PATH); @@ -268,12 +240,12 @@ void SceneWorld::InitDDGISDK() { CD_ENGINE_FATAL("Init DDGI client failed at : {0}", DDGI_SDK_PATH); } -#endif } +#endif void SceneWorld::Update() { -#ifdef ENABLE_DDGI_SDK +#ifdef ENABLE_DDGI // Send request 30 times per second. static auto startTime = std::chrono::steady_clock::now(); if (std::chrono::duration_cast(std::chrono::steady_clock::now() - startTime).count() <= 33 * 1000 * 1000) diff --git a/Engine/Source/Runtime/ECWorld/SceneWorld.h b/Engine/Source/Runtime/ECWorld/SceneWorld.h index df005ccf..6303a367 100644 --- a/Engine/Source/Runtime/ECWorld/SceneWorld.h +++ b/Engine/Source/Runtime/ECWorld/SceneWorld.h @@ -30,7 +30,9 @@ class SceneWorld DEFINE_COMPONENT_STORAGE_WITH_APIS(Animation); DEFINE_COMPONENT_STORAGE_WITH_APIS(Camera); DEFINE_COMPONENT_STORAGE_WITH_APIS(CollisionMesh); +#ifdef ENABLE_DDGI DEFINE_COMPONENT_STORAGE_WITH_APIS(DDGI); +#endif DEFINE_COMPONENT_STORAGE_WITH_APIS(Hierarchy); DEFINE_COMPONENT_STORAGE_WITH_APIS(Light); DEFINE_COMPONENT_STORAGE_WITH_APIS(Material); @@ -57,8 +59,10 @@ class SceneWorld void SetMainCameraEntity(engine::Entity entity); CD_FORCEINLINE engine::Entity GetMainCameraEntity() const { return m_mainCameraEntity; } +#ifdef ENABLE_DDGI void SetDDGIEntity(engine::Entity entity); CD_FORCEINLINE engine::Entity GetDDGIEntity() const { return m_ddgiEntity; } +#endif void SetSkyEntity(engine::Entity entity); CD_FORCEINLINE engine::Entity GetSkyEntity() const { return m_skyEntity; } @@ -80,7 +84,9 @@ class SceneWorld DeleteAnimationComponent(entity); DeleteCameraComponent(entity); DeleteCollisionMeshComponent(entity); +#ifdef ENABLE_DDGI DeleteDDGIComponent(entity); +#endif DeleteHierarchyComponent(entity); DeleteLightComponent(entity); DeleteMaterialComponent(entity); @@ -99,14 +105,19 @@ class SceneWorld void CreateTerrainMaterialType(); CD_FORCEINLINE engine::MaterialType* GetTerrainMaterialType() const { return m_pTerrainMaterialType.get(); } +#ifdef ENABLE_DDGI void CreateDDGIMaterialType(); CD_FORCEINLINE engine::MaterialType* GetDDGIMaterialType() const { return m_pDDGIMaterialType.get(); } +#endif void AddCameraToSceneDatabase(engine::Entity entity); void AddLightToSceneDatabase(engine::Entity entity); void AddMaterialToSceneDatabase(engine::Entity entity); +#ifdef ENABLE_DDGI void InitDDGISDK(); +#endif + void Update(); private: @@ -121,7 +132,9 @@ class SceneWorld // TODO : wrap them into another class? engine::Entity m_selectedEntity = engine::INVALID_ENTITY; engine::Entity m_mainCameraEntity = engine::INVALID_ENTITY; +#ifdef ENABLE_DDGI engine::Entity m_ddgiEntity = engine::INVALID_ENTITY; +#endif engine::Entity m_skyEntity = engine::INVALID_ENTITY; }; diff --git a/Engine/Source/Runtime/Process/Process.h b/Engine/Source/Runtime/Process/Process.h index 2ff7b040..da94703e 100644 --- a/Engine/Source/Runtime/Process/Process.h +++ b/Engine/Source/Runtime/Process/Process.h @@ -62,6 +62,7 @@ class Process final Process& operator=(Process&&) = default; ~Process() = default; + void SetPrintChildProcessLog(bool doPrint) {} void SetWaitUntilFinished(bool doWait) {} void SetCommandArguments(std::vector arguments) {} void SetEnvironments(std::vector environments) {} diff --git a/Engine/Source/Runtime/Rendering/TerrainRenderer.cpp b/Engine/Source/Runtime/Rendering/TerrainRenderer.cpp deleted file mode 100644 index c7ad1c12..00000000 --- a/Engine/Source/Runtime/Rendering/TerrainRenderer.cpp +++ /dev/null @@ -1,270 +0,0 @@ -#include "TerrainRenderer.h" - -#include "Core/StringCrc.h" -#include "Framework/Processor.h" -#include "Log/Log.h" -#include "Math/Transform.hpp" -#include "Path/Path.h" -#include "Producers/CDProducer/CDProducer.h" -#include "RenderContext.h" -#include "Scene/Texture.h" - -#include -#include -#include - -#include -#include - -using namespace cd; - -namespace -{ -constexpr const char* kUniformSectorOrigin = "u_SectorOrigin"; -//constexpr engine::StringCrc kUniformSectorOriginCrc(kUniformSectorOrigin); -constexpr const char* kUniformSectorDimension = "u_SectorDimension"; -//constexpr engine::StringCrc kUniformSectorDimensionCrc(kUniformSectorDimension); - -bx::AllocatorI* GetResourceAllocator() -{ - static bx::DefaultAllocator s_allocator; - return &s_allocator; -} - -std::vector LoadFile(const char* pFilePath) -{ - std::vector fileData; - - std::ifstream fin(pFilePath, std::ios::in | std::ios::binary); - if (!fin.is_open()) - { - return fileData; - } - - fin.seekg(0L, std::ios::end); - size_t fileSize = fin.tellg(); - fin.seekg(0L, std::ios::beg); - fileData.resize(fileSize); - fin.read(reinterpret_cast(fileData.data()), fileSize); - fin.close(); - - return fileData; -} - -} - -namespace engine -{ - -void TerrainRenderer::Init() -{ - bgfx::setViewName(GetViewID(), "TerrainRenderer"); - m_updateUniforms = true; - - m_dirtTexture = CreateTerrainTexture("terrain/dirty_baseColor", 0); - // TEMP CODE TODO move this to terrain editor - m_redChannelTexture = CreateTerrainTexture("terrain/dirty_baseColor", 3); - m_greenChannelTexture = CreateTerrainTexture("terrain/rockyGrass_baseColor", 4); - m_blueChannelTexture = CreateTerrainTexture("terrain/gravel_baseColor", 5); - m_alphaChannelTexture = CreateTerrainTexture("terrain/snowyRock_baseColor", 6); - - u_terrainOrigin = GetRenderContext()->CreateUniform(kUniformSectorOrigin, bgfx::UniformType::Enum::Vec4, 1); - u_terrainDimension = GetRenderContext()->CreateUniform(kUniformSectorDimension, bgfx::UniformType::Vec4, 1); -} - -void TerrainRenderer::UpdateView(const float* pViewMatrix, const float* pProjectionMatrix) -{ - UpdateViewRenderTarget(); - bgfx::setViewTransform(GetViewID(), pViewMatrix, pProjectionMatrix); - - UpdateUniforms(); -} - -void TerrainRenderer::Render(float deltaTime) -{ - for (const Entity& entity : m_pCurrentSceneWorld->GetMaterialEntities()) - { - if (!IsTerrainMesh(entity)) - { - continue; - } - - if (m_entityToRenderInfo.find(entity) == m_entityToRenderInfo.cend()) - { - m_updateUniforms = true; - UpdateUniforms(); - } - - // Check cull dist - const Entity& cameraEntity = m_pCurrentSceneWorld->GetMainCameraEntity(); - const cd::Transform cameraTransform = m_pCurrentSceneWorld->GetTransformComponent(cameraEntity)->GetTransform(); - const float dx = cameraTransform.GetTranslation().x() - m_entityToRenderInfo[entity].m_origin[0]; - const float dy = cameraTransform.GetTranslation().y() - m_entityToRenderInfo[entity].m_origin[1]; - const float dz = cameraTransform.GetTranslation().z() - m_entityToRenderInfo[entity].m_origin[2]; - if (m_cullDistanceSquared <= (dx * dx + dy * dy + dz * dz)) { - // skip - continue; - } - - const MaterialComponent* pMaterialComponent = m_pCurrentSceneWorld->GetMaterialComponent(entity); - const StaticMeshComponent* pMeshComponent = m_pCurrentSceneWorld->GetStaticMeshComponent(entity); - - bgfx::setVertexBuffer(0, bgfx::VertexBufferHandle{pMeshComponent->GetVertexBuffer()}); - bgfx::setIndexBuffer(bgfx::IndexBufferHandle{pMeshComponent->GetIndexBuffer()}); - - bgfx::setTexture(m_dirtTexture.slot, bgfx::UniformHandle{m_dirtTexture.samplerHandle}, bgfx::TextureHandle{m_dirtTexture.textureHandle}); - if (m_redChannelTexture.textureHandle != bgfx::kInvalidHandle && m_redChannelTexture.samplerHandle != bgfx::kInvalidHandle) - { - bgfx::setTexture(m_redChannelTexture.slot, bgfx::UniformHandle{m_redChannelTexture.samplerHandle}, bgfx::TextureHandle{m_redChannelTexture.textureHandle}); - } - if (m_greenChannelTexture.textureHandle != bgfx::kInvalidHandle && m_greenChannelTexture.samplerHandle != bgfx::kInvalidHandle) - { - bgfx::setTexture(m_greenChannelTexture.slot, bgfx::UniformHandle{m_greenChannelTexture.samplerHandle}, bgfx::TextureHandle{m_greenChannelTexture.textureHandle}); - } - if (m_blueChannelTexture.textureHandle != bgfx::kInvalidHandle && m_blueChannelTexture.samplerHandle != bgfx::kInvalidHandle) - { - bgfx::setTexture(m_blueChannelTexture.slot, bgfx::UniformHandle{m_blueChannelTexture.samplerHandle}, bgfx::TextureHandle{m_blueChannelTexture.textureHandle}); - } - if (m_alphaChannelTexture.textureHandle != bgfx::kInvalidHandle && m_alphaChannelTexture.samplerHandle != bgfx::kInvalidHandle) - { - bgfx::setTexture(m_alphaChannelTexture.slot, bgfx::UniformHandle{m_alphaChannelTexture.samplerHandle}, bgfx::TextureHandle{m_alphaChannelTexture.textureHandle}); - } - - for (const auto& [textureType, textureInfo] : pMaterialComponent->GetTextureResources()) - { - // TODO optimize by using textureInfo instead of GetTextureInfo - if (const MaterialComponent::TextureInfo* pTextureInfo = pMaterialComponent->GetTextureInfo(textureType)) - { - bgfx::setTexture(pTextureInfo->slot, bgfx::UniformHandle{pTextureInfo->samplerHandle}, bgfx::TextureHandle{pTextureInfo->textureHandle}); - } - } - - const TerrainRenderInfo& meshRenderInfo = m_entityToRenderInfo[entity]; - bgfx::setUniform(u_terrainOrigin, static_cast(meshRenderInfo.m_origin)); - bgfx::setUniform(u_terrainDimension, static_cast(meshRenderInfo.m_dimension)); - - constexpr uint64_t state = BGFX_STATE_WRITE_MASK | BGFX_STATE_CULL_CCW | BGFX_STATE_MSAA | BGFX_STATE_DEPTH_TEST_LESS; - bgfx::setState(state); - - bgfx::submit(GetViewID(), bgfx::ProgramHandle{pMaterialComponent->GetShadreProgram()}); - } -} - -void TerrainRenderer::SetAndLoadAlphaMapTexture(const cdtools::AlphaMapChannel channel, const std::string& textureName) -{ - switch (channel) - { - case cdtools::AlphaMapChannel::Red: - m_redChannelTexture = CreateTerrainTexture(textureName.c_str(), 3); - break; - case cdtools::AlphaMapChannel::Green: - m_greenChannelTexture = CreateTerrainTexture(textureName.c_str(), 4); - break; - case cdtools::AlphaMapChannel::Blue: - m_blueChannelTexture = CreateTerrainTexture(textureName.c_str(), 5); - break; - case cdtools::AlphaMapChannel::Alpha: - m_alphaChannelTexture = CreateTerrainTexture(textureName.c_str(), 6); - break; - default: - assert(false); - } -} - -TerrainRenderer::TerrainTexture TerrainRenderer::CreateTerrainTexture(const char* textureFileName, uint8_t slot) -{ - TerrainTexture outTexture; - outTexture.slot = slot; - outTexture.samplerHandle = bgfx::kInvalidHandle; - outTexture.textureHandle = bgfx::kInvalidHandle; - outTexture.format = cd::TextureFormat::Count; - - const std::string textureFilePath = engine::Path::GetTerrainTextureOutputFilePath(textureFileName, ".dds"); - // Load the texture file - std::vector textureFileBlob = LoadFile(textureFilePath.c_str()); - assert(!textureFileBlob.empty()); - // Decode the texture - bimg::ImageContainer* pImageContainer = bimg::imageParse(GetResourceAllocator(), textureFileBlob.data(), static_cast(textureFileBlob.size())); - const bgfx::Memory* pMemory = bgfx::makeRef(pImageContainer->m_data, pImageContainer->m_size); - outTexture.format = static_cast(pImageContainer->m_format); - const uint64_t textureFlag = (BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP | BGFX_TEXTURE_SRGB); - outTexture.textureHandle = bgfx::createTexture2D( - pImageContainer->m_width, - pImageContainer->m_height, - pImageContainer->m_numMips, - pImageContainer->m_numLayers, - static_cast(pImageContainer->m_format), - textureFlag, - pMemory - ).idx; - - std::string samplerUniformName = "s_terrainTextureSampler"; - samplerUniformName += std::to_string(slot); - outTexture.samplerHandle = bgfx::createUniform(samplerUniformName.c_str(), bgfx::UniformType::Sampler).idx; - assert(outTexture.textureHandle != bgfx::kInvalidHandle); - assert(outTexture.samplerHandle != bgfx::kInvalidHandle); - - return outTexture; -} - -bool TerrainRenderer::IsTerrainMesh(Entity entity) const -{ - const MaterialComponent* pMaterialComponent = m_pCurrentSceneWorld->GetMaterialComponent(entity); - if (!pMaterialComponent || - pMaterialComponent->GetMaterialType() != m_pCurrentSceneWorld->GetTerrainMaterialType()) - { - return false; - } - const StaticMeshComponent* pMeshComponent = m_pCurrentSceneWorld->GetStaticMeshComponent(entity); - if (!pMeshComponent) - { - CD_ENGINE_WARN("Entity: %u has terrain material but is missing mesh component!", entity); - return false; - } - return true; -} - -void TerrainRenderer::UpdateUniforms() -{ - if (m_updateUniforms) - { - for (const Entity& entity : m_pCurrentSceneWorld->GetMaterialEntities()) - { - if (!IsTerrainMesh(entity)) - { - continue; - } - if (m_entityToRenderInfo.find(entity) == m_entityToRenderInfo.cend()) - { - m_entityToRenderInfo[entity] = TerrainRenderInfo(); - } - TerrainRenderInfo& renderInfo = m_entityToRenderInfo[entity]; - const StaticMeshComponent* pMeshComponent = m_pCurrentSceneWorld->GetStaticMeshComponent(entity); - const Mesh* terrainMesh = pMeshComponent->GetMeshData(); - if (!terrainMesh) - { - CD_ENGINE_WARN("Entity: %u has null mesh data!", entity); - continue; - } - // Convention is determined by TerrainProducer that the origin is always the first vertex - const std::vector& vertices = terrainMesh->GetVertexPositions(); - const Point& origin = vertices[0]; - renderInfo.m_origin[0] = origin.x(); - renderInfo.m_origin[1] = origin.y(); - renderInfo.m_origin[2] = origin.z(); - renderInfo.m_origin[3] = 0.0f; - - const MaterialComponent* pMaterialComponent = m_pCurrentSceneWorld->GetMaterialComponent(entity); - const MaterialComponent::TextureInfo* pElevationTexture = pMaterialComponent->GetTextureInfo(MaterialTextureType::Elevation); - assert(pElevationTexture); - renderInfo.m_dimension[0] = static_cast(pElevationTexture->width); - renderInfo.m_dimension[1] = static_cast(pElevationTexture->height); - renderInfo.m_dimension[2] = 0.0f; - renderInfo.m_dimension[3] = 0.0f; - } - - m_updateUniforms = false; - } -} - -} \ No newline at end of file diff --git a/Engine/Source/Runtime/Rendering/TerrainRenderer.h b/Engine/Source/Runtime/Rendering/TerrainRenderer.h deleted file mode 100644 index 816f01ba..00000000 --- a/Engine/Source/Runtime/Rendering/TerrainRenderer.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include "ECWorld/SceneWorld.h" -#include "Producers/TerrainProducer/AlphaMapTypes.h" -#include "Renderer.h" - -#include - -#include - -namespace engine -{ - -class SceneWorld; - -class TerrainRenderer final : public Renderer -{ -public: - using Renderer::Renderer; - - virtual void Init() override; - virtual void UpdateView(const float* pViewMatrix, const float* pProjectionMatrix) override; - virtual void Render(float deltaTime) override; - - void SetSceneWorld(SceneWorld* pSceneWorld) { m_pCurrentSceneWorld = pSceneWorld; } - void SetCullDistance(uint32_t dist) { m_cullDistanceSquared = dist * dist; } - void SetAndLoadAlphaMapTexture(const cdtools::AlphaMapChannel channel, const std::string& textureName); - -private: - struct TerrainRenderInfo - { - TerrainRenderInfo() - { - memset(m_origin, 0, sizeof(float) * 4); - memset(m_dimension, 0, sizeof(float) * 4); - } - float m_origin[4]; - float m_dimension[4]; - }; - - struct TerrainTexture - { - uint8_t slot; - uint16_t samplerHandle = bgfx::kInvalidHandle; - uint16_t textureHandle = bgfx::kInvalidHandle; - cd::TextureFormat format; - }; - - TerrainTexture CreateTerrainTexture(const char* textureFileName, uint8_t slot); - - bool IsTerrainMesh(Entity) const; - - void UpdateUniforms(); - - - bool m_updateUniforms = true; - SceneWorld* m_pCurrentSceneWorld = nullptr; - std::unordered_map m_entityToRenderInfo; - uint32_t m_cullDistanceSquared = 40000; - - // Textures - TerrainTexture m_dirtTexture; - TerrainTexture m_redChannelTexture; - TerrainTexture m_greenChannelTexture; - TerrainTexture m_blueChannelTexture; - TerrainTexture m_alphaChannelTexture; - // Uniforms - bgfx::UniformHandle u_terrainOrigin; // bottom left corner in world coord; vec2 - bgfx::UniformHandle u_terrainDimension; // width and depth of the terrain; vec2 -}; - -} \ No newline at end of file diff --git a/Engine/Source/ThirdParty/AssetPipeline b/Engine/Source/ThirdParty/AssetPipeline index 263c11cd..ac915ca6 160000 --- a/Engine/Source/ThirdParty/AssetPipeline +++ b/Engine/Source/ThirdParty/AssetPipeline @@ -1 +1 @@ -Subproject commit 263c11cdbb78b418368885c2d4e745c6c2a5afc4 +Subproject commit ac915ca690d20cb59147a509ca7b5e675a52056b