Merge pull request #176 from SHADE-DP/SP3-1-BuiltInMesh
Pregenerates default meshes and provides a function to retrieve them
This commit is contained in:
commit
29c25c2d6d
|
@ -41,6 +41,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Resource/SHResourceManager.h"
|
#include "Resource/SHResourceManager.h"
|
||||||
#include "Graphics/SHVkUtil.h"
|
#include "Graphics/SHVkUtil.h"
|
||||||
#include "Graphics/RenderGraph/SHRenderGraphNodeCompute.h"
|
#include "Graphics/RenderGraph/SHRenderGraphNodeCompute.h"
|
||||||
|
#include "../Meshes/SHPrimitiveGenerator.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -259,7 +260,6 @@ namespace SHADE
|
||||||
// Generate world render graph
|
// Generate world render graph
|
||||||
worldRenderGraph->Generate();
|
worldRenderGraph->Generate();
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* BIND RENDER GRAPH TO RENDERER */
|
/* BIND RENDER GRAPH TO RENDERER */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
@ -269,17 +269,6 @@ namespace SHADE
|
||||||
|
|
||||||
worldRenderer->SetCameraDirector(cameraSystem->CreateDirector());
|
worldRenderer->SetCameraDirector(cameraSystem->CreateDirector());
|
||||||
|
|
||||||
// Create default materials
|
|
||||||
std::array<SHTexture::PixelChannel, 4> defaultTexture = { 255, 255, 255, 255 };
|
|
||||||
std::vector<uint32_t> mipOffsets{};
|
|
||||||
mipOffsets.push_back(0);
|
|
||||||
auto tex = AddTexture(4, defaultTexture.data(), 1, 1, SHTexture::TextureFormat::eR8G8B8A8Unorm, mipOffsets);
|
|
||||||
BuildTextures();
|
|
||||||
|
|
||||||
defaultMaterial = AddMaterial(defaultVertShader, defaultFragShader, gBufferSubpass);
|
|
||||||
defaultMaterial->SetProperty("data.textureIndex", tex->TextureArrayIndex);
|
|
||||||
|
|
||||||
|
|
||||||
// Create debug draw pipeline
|
// Create debug draw pipeline
|
||||||
debugDrawPipeline = createDebugDrawPipeline(debugDrawNode->GetRenderpass(), debugDrawSubpass);
|
debugDrawPipeline = createDebugDrawPipeline(debugDrawNode->GetRenderpass(), debugDrawSubpass);
|
||||||
debugDrawDepthPipeline = createDebugDrawPipeline(debugDrawNodeDepth->GetRenderpass(), debugDrawDepthSubpass);
|
debugDrawDepthPipeline = createDebugDrawPipeline(debugDrawNodeDepth->GetRenderpass(), debugDrawDepthSubpass);
|
||||||
|
@ -321,7 +310,29 @@ namespace SHADE
|
||||||
|
|
||||||
lightingSubSystem = resourceManager.Create<SHLightingSubSystem>();
|
lightingSubSystem = resourceManager.Create<SHLightingSubSystem>();
|
||||||
lightingSubSystem->Init(device, descPool);
|
lightingSubSystem->Init(device, descPool);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsSystem::InitBuiltInResources(void)
|
||||||
|
{
|
||||||
|
// Create default texture
|
||||||
|
std::array<SHTexture::PixelChannel, 4> defaultTextureData = { 255, 255, 255, 255 };
|
||||||
|
std::vector<uint32_t> mipOffsets{};
|
||||||
|
mipOffsets.push_back(0);
|
||||||
|
defaultTexture = AddTexture(4, defaultTextureData.data(), 1, 1, SHTexture::TextureFormat::eR8G8B8A8Unorm, mipOffsets);
|
||||||
|
BuildTextures();
|
||||||
|
|
||||||
|
// Create default meshes
|
||||||
|
primitiveMeshes[static_cast<int>(PrimitiveType::Cube)] = SHPrimitiveGenerator::Cube(meshLibrary);
|
||||||
|
primitiveMeshes[static_cast<int>(PrimitiveType::Sphere)] = SHPrimitiveGenerator::Sphere(meshLibrary);
|
||||||
|
BuildMeshBuffers();
|
||||||
|
|
||||||
|
// Create default materials
|
||||||
|
defaultMaterial = AddMaterial
|
||||||
|
(
|
||||||
|
defaultVertShader, defaultFragShader,
|
||||||
|
worldRenderGraph->GetNode("G-Buffer")->GetSubpass("G-Buffer Write")
|
||||||
|
);
|
||||||
|
defaultMaterial->SetProperty("data.textureIndex", defaultTexture->TextureArrayIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
|
@ -364,8 +375,7 @@ namespace SHADE
|
||||||
InitBoilerplate();
|
InitBoilerplate();
|
||||||
InitMiddleEnd();
|
InitMiddleEnd();
|
||||||
InitSubsystems();
|
InitSubsystems();
|
||||||
|
InitBuiltInResources();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHGraphicsSystem::Exit(void)
|
void SHGraphicsSystem::Exit(void)
|
||||||
|
@ -723,6 +733,18 @@ namespace SHADE
|
||||||
transferCmdBuffer.Free(); transferCmdBuffer = {};
|
transferCmdBuffer.Free(); transferCmdBuffer = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Handle<SHMesh> SHGraphicsSystem::GetMeshPrimitive(PrimitiveType type) const noexcept
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case PrimitiveType::Cube:
|
||||||
|
case PrimitiveType::Sphere:
|
||||||
|
return primitiveMeshes[static_cast<int>(type)];
|
||||||
|
default:
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Texture Registration Functions */
|
/* Texture Registration Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -58,6 +58,19 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Type Definitions */
|
/* Type Definitions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/***********************************************************************************/
|
||||||
|
/*!
|
||||||
|
\brief
|
||||||
|
Type of built-in primitive meshes that are available.
|
||||||
|
*/
|
||||||
|
/***********************************************************************************/
|
||||||
|
enum class PrimitiveType
|
||||||
|
{
|
||||||
|
Cube,
|
||||||
|
Sphere
|
||||||
|
};
|
||||||
|
static constexpr int MAX_PRIMITIVE_TYPES = 2;
|
||||||
|
|
||||||
/***********************************************************************************/
|
/***********************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
\brief
|
\brief
|
||||||
|
@ -72,6 +85,7 @@ namespace SHADE
|
||||||
void InitSceneRenderGraph (void) noexcept;
|
void InitSceneRenderGraph (void) noexcept;
|
||||||
void InitMiddleEnd (void) noexcept;
|
void InitMiddleEnd (void) noexcept;
|
||||||
void InitSubsystems (void) noexcept;
|
void InitSubsystems (void) noexcept;
|
||||||
|
void InitBuiltInResources (void);
|
||||||
|
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
void InitEditorRenderGraph (void) noexcept;
|
void InitEditorRenderGraph (void) noexcept;
|
||||||
|
@ -207,6 +221,21 @@ namespace SHADE
|
||||||
*/
|
*/
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
void BuildMeshBuffers();
|
void BuildMeshBuffers();
|
||||||
|
/*******************************************************************************/
|
||||||
|
/*!
|
||||||
|
|
||||||
|
\brief
|
||||||
|
Retrieves the built-in mesh specified.
|
||||||
|
|
||||||
|
\param type
|
||||||
|
Type of built-in mesh to retrieve.
|
||||||
|
|
||||||
|
\returns
|
||||||
|
Handle to the mesh that was specfied. However, if an invalid type is specified,
|
||||||
|
a null Handle will be returned.
|
||||||
|
*/
|
||||||
|
/*******************************************************************************/
|
||||||
|
Handle<SHMesh> GetMeshPrimitive(PrimitiveType type) const noexcept;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Texture Registration Functions */
|
/* Texture Registration Functions */
|
||||||
|
@ -278,6 +307,18 @@ namespace SHADE
|
||||||
*/
|
*/
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
Handle<SHTexture> GetTextureHandle(SHTexture::Index textureId) const;
|
Handle<SHTexture> GetTextureHandle(SHTexture::Index textureId) const;
|
||||||
|
/***************************************************************************/
|
||||||
|
/*!
|
||||||
|
*
|
||||||
|
\brief
|
||||||
|
Retrieves the handle to the default texture. A white 1x1 texture.
|
||||||
|
|
||||||
|
\returns
|
||||||
|
Handle to the default texture.
|
||||||
|
|
||||||
|
*/
|
||||||
|
/***************************************************************************/
|
||||||
|
Handle<SHTexture> GetDefaultTexture() const noexcept { return defaultTexture; }
|
||||||
|
|
||||||
void PrepareResize(uint32_t newWidth, uint32_t newHeight) noexcept;
|
void PrepareResize(uint32_t newWidth, uint32_t newHeight) noexcept;
|
||||||
void HandleResize(void) noexcept;
|
void HandleResize(void) noexcept;
|
||||||
|
@ -378,6 +419,13 @@ namespace SHADE
|
||||||
Handle<SHVkPipeline> debugDrawPipeline;
|
Handle<SHVkPipeline> debugDrawPipeline;
|
||||||
Handle<SHVkPipeline> debugDrawDepthPipeline;
|
Handle<SHVkPipeline> debugDrawDepthPipeline;
|
||||||
|
|
||||||
|
// Built-In Textures
|
||||||
|
Handle<SHTexture> defaultTexture;
|
||||||
|
|
||||||
|
// Built-In Meshes
|
||||||
|
std::array<Handle<SHMesh>, MAX_PRIMITIVE_TYPES> primitiveMeshes;
|
||||||
|
|
||||||
|
// Render Graphs
|
||||||
Handle<SHRenderGraph> worldRenderGraph;
|
Handle<SHRenderGraph> worldRenderGraph;
|
||||||
|
|
||||||
// Sub systems
|
// Sub systems
|
||||||
|
|
Loading…
Reference in New Issue