Trajectory Rendering WIP
- Trajectory rendering system is all in place. Just requires testing through the component. - Component needs to be reflected in editor - Shaders for trajectory rendering is also in place
This commit is contained in:
parent
cee45863fa
commit
f1217cc20b
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
Name: Trajectory_FS
|
||||||
|
ID: 45635685
|
||||||
|
Type: 2
|
|
@ -2,9 +2,9 @@
|
||||||
#extension GL_KHR_vulkan_glsl : enable
|
#extension GL_KHR_vulkan_glsl : enable
|
||||||
|
|
||||||
// vertex inputs
|
// vertex inputs
|
||||||
layout(location = 0) in vec4 aPos;
|
layout(location = 0) in vec3 aPos;
|
||||||
layout(location = 1) in vec2 aUV;
|
layout(location = 1) in vec2 aUV;
|
||||||
layout(location = 2) in vec2 aColor;
|
layout(location = 2) in vec4 aColor;
|
||||||
layout(location = 3) in mat4 aTransform;
|
layout(location = 3) in mat4 aTransform;
|
||||||
|
|
||||||
// between shader stages
|
// between shader stages
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
Name: Trajectory_VS
|
||||||
|
ID: 41042628
|
||||||
|
Type: 2
|
|
@ -64,6 +64,17 @@ namespace SHADE
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
static constexpr std::string_view DEFERRED_COMPOSITE_PASS = "Deferred Comp Pass";
|
static constexpr std::string_view DEFERRED_COMPOSITE_PASS = "Deferred Comp Pass";
|
||||||
|
|
||||||
|
/***************************************************************************/
|
||||||
|
/*!
|
||||||
|
|
||||||
|
\brief
|
||||||
|
Name of vfx render graph node.
|
||||||
|
|
||||||
|
*/
|
||||||
|
/***************************************************************************/
|
||||||
|
static constexpr std::string_view VFX_PASS = "Vfx Pass";
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
|
|
||||||
|
@ -117,6 +128,7 @@ namespace SHADE
|
||||||
|
|
||||||
static constexpr std::string_view GBUFFER_WRITE_SUBPASS = "G-Buffer Write";
|
static constexpr std::string_view GBUFFER_WRITE_SUBPASS = "G-Buffer Write";
|
||||||
static constexpr std::string_view UI_SUBPASS = "UI";
|
static constexpr std::string_view UI_SUBPASS = "UI";
|
||||||
|
static constexpr std::string_view VFX_SUBPASS = "VFX";
|
||||||
|
|
||||||
static constexpr std::array USABLE_SUBPASSES =
|
static constexpr std::array USABLE_SUBPASSES =
|
||||||
{
|
{
|
||||||
|
|
|
@ -138,7 +138,8 @@ namespace SHADE
|
||||||
//SHAssetManager::CompileAsset("../../Assets/Shaders/UI_VS.glsl", false);
|
//SHAssetManager::CompileAsset("../../Assets/Shaders/UI_VS.glsl", false);
|
||||||
//SHAssetManager::CompileAsset("../../Assets/Shaders/UI_FS.glsl", false);
|
//SHAssetManager::CompileAsset("../../Assets/Shaders/UI_FS.glsl", false);
|
||||||
//SHAssetManager::CompileAsset("../../Assets/Shaders/Text_VS.glsl", false);
|
//SHAssetManager::CompileAsset("../../Assets/Shaders/Text_VS.glsl", false);
|
||||||
|
SHAssetManager::CompileAsset("../../Assets/Shaders/Trajectory_VS.glsl", false);
|
||||||
|
SHAssetManager::CompileAsset("../../Assets/Shaders/Trajectory_FS.glsl", false);
|
||||||
|
|
||||||
// Load Built In Shaders
|
// Load Built In Shaders
|
||||||
static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT);
|
static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT);
|
||||||
|
@ -156,6 +157,8 @@ namespace SHADE
|
||||||
static constexpr AssetID RENDER_SC_FS = 36869006; renderToSwapchainFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(RENDER_SC_FS);
|
static constexpr AssetID RENDER_SC_FS = 36869006; renderToSwapchainFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(RENDER_SC_FS);
|
||||||
static constexpr AssetID SHADOW_MAP_VS = 44646107; shadowMapVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(SHADOW_MAP_VS);
|
static constexpr AssetID SHADOW_MAP_VS = 44646107; shadowMapVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(SHADOW_MAP_VS);
|
||||||
static constexpr AssetID SHADOW_MAP_FS = 45925790; shadowMapFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(SHADOW_MAP_FS);
|
static constexpr AssetID SHADOW_MAP_FS = 45925790; shadowMapFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(SHADOW_MAP_FS);
|
||||||
|
static constexpr AssetID TRAJECTORY_VS = 41042628; trajectoryVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TRAJECTORY_VS);
|
||||||
|
static constexpr AssetID TRAJECTORY_FS = 45635685; trajectoryFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TRAJECTORY_FS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,13 +311,24 @@ namespace SHADE
|
||||||
lightingSubSystem->PrepareShadowMapsForRead(cmdBuffer);
|
lightingSubSystem->PrepareShadowMapsForRead(cmdBuffer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* VFX PASS */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
auto vfxPass = renderGraph->AddNode(SHGraphicsConstants::RenderGraphEntityNames::VFX_PASS.data(), { "Scene", "Depth Buffer" }, { SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data(), SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data() });
|
||||||
|
auto vfxSubpass = vfxPass->AddSubpass("Vfx Subpass", worldViewport, worldRenderer);
|
||||||
|
vfxSubpass->AddColorOutput("Scene");
|
||||||
|
vfxSubpass->AddDepthOutput("Depth Buffer");
|
||||||
|
vfxSubpass->AddExteriorDrawCalls([=](Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHRenderer> renderer, uint32_t frameIndex)
|
||||||
|
{
|
||||||
|
trajectoryRenderingSubSystem->Render(cmdBuffer, renderer, frameIndex);
|
||||||
|
});
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* DEBUG DRAW PASS INIT */
|
/* DEBUG DRAW PASS INIT */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
// Set up Debug Draw Passes
|
// Set up Debug Draw Passes
|
||||||
// - Depth Tested
|
// - Depth Tested
|
||||||
auto debugDrawNodeDepth = renderGraph->AddNode(SHGraphicsConstants::RenderGraphEntityNames::DEBUG_DRAW_DEPTH_PASS.data(), {"Scene", "Depth Buffer"}, {SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data(), SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data()});
|
auto debugDrawNodeDepth = renderGraph->AddNode(SHGraphicsConstants::RenderGraphEntityNames::DEBUG_DRAW_DEPTH_PASS.data(), {"Scene", "Depth Buffer"}, { SHGraphicsConstants::RenderGraphEntityNames::VFX_PASS.data()/*, SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data()*/});
|
||||||
auto debugDrawDepthSubpass = debugDrawNodeDepth->AddSubpass("Debug Draw with Depth", worldViewport, worldRenderer);
|
auto debugDrawDepthSubpass = debugDrawNodeDepth->AddSubpass("Debug Draw with Depth", worldViewport, worldRenderer);
|
||||||
debugDrawDepthSubpass->AddColorOutput("Scene");
|
debugDrawDepthSubpass->AddColorOutput("Scene");
|
||||||
debugDrawDepthSubpass->AddDepthOutput("Depth Buffer");
|
debugDrawDepthSubpass->AddDepthOutput("Depth Buffer");
|
||||||
|
@ -435,8 +449,8 @@ namespace SHADE
|
||||||
|
|
||||||
trajectoryRenderingSubSystem = resourceManager.Create<SHTrajectoryRenderingSubSystem>();
|
trajectoryRenderingSubSystem = resourceManager.Create<SHTrajectoryRenderingSubSystem>();
|
||||||
|
|
||||||
//auto gBufferNode = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::SCREEN_SPACE_PASS.data());
|
auto vfxNode = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::SCREEN_SPACE_PASS.data());
|
||||||
//trajectoryRenderingSubSystem->Init(device, )
|
trajectoryRenderingSubSystem->Init(device, vfxNode->GetRenderpass(), vfxNode->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::UI_SUBPASS), trajectoryVS, trajectoryFS);
|
||||||
|
|
||||||
SHGlobalDescriptorSets::SetLightingSubSystem(lightingSubSystem);
|
SHGlobalDescriptorSets::SetLightingSubSystem(lightingSubSystem);
|
||||||
|
|
||||||
|
@ -572,6 +586,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
textRenderingSubSystem->Run(frameIndex);
|
textRenderingSubSystem->Run(frameIndex);
|
||||||
|
trajectoryRenderingSubSystem->Run(frameIndex);
|
||||||
|
|
||||||
|
|
||||||
for (auto renderer : renderers)
|
for (auto renderer : renderers)
|
||||||
|
|
|
@ -471,6 +471,8 @@ namespace SHADE
|
||||||
Handle<SHVkShaderModule> renderToSwapchainFS;
|
Handle<SHVkShaderModule> renderToSwapchainFS;
|
||||||
Handle<SHVkShaderModule> shadowMapVS;
|
Handle<SHVkShaderModule> shadowMapVS;
|
||||||
Handle<SHVkShaderModule> shadowMapFS;
|
Handle<SHVkShaderModule> shadowMapFS;
|
||||||
|
Handle<SHVkShaderModule> trajectoryVS;
|
||||||
|
Handle<SHVkShaderModule> trajectoryFS;
|
||||||
|
|
||||||
// Fonts
|
// Fonts
|
||||||
Handle<SHFont> testFont;
|
Handle<SHFont> testFont;
|
||||||
|
|
|
@ -62,6 +62,11 @@ namespace SHADE
|
||||||
mesh = newMesh;
|
mesh = newMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHTrajectoryRenderableComponent::SetPositions(std::vector<SHVec3> const& inPositions) noexcept
|
||||||
|
{
|
||||||
|
positions = inPositions;
|
||||||
|
}
|
||||||
|
|
||||||
void SHTrajectoryRenderableComponent::SetStartColor(SHVec4 color) noexcept
|
void SHTrajectoryRenderableComponent::SetStartColor(SHVec4 color) noexcept
|
||||||
{
|
{
|
||||||
startColor = color;
|
startColor = color;
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace SHADE
|
||||||
//! Color the trajectory should evolve to the longer it is
|
//! Color the trajectory should evolve to the longer it is
|
||||||
SHVec4 endColor;
|
SHVec4 endColor;
|
||||||
|
|
||||||
//! evolving rate of the color (with respect to dt)
|
//! evolving rate of the color
|
||||||
float colorEvolveRate;
|
float colorEvolveRate;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -34,6 +34,7 @@ namespace SHADE
|
||||||
/* PRIVATE MEMBER FUNCTIONS */
|
/* PRIVATE MEMBER FUNCTIONS */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
void SetMesh(Handle<SHMesh> newMesh) noexcept;
|
void SetMesh(Handle<SHMesh> newMesh) noexcept;
|
||||||
|
void SetPositions (std::vector<SHVec3> const& inPositions) noexcept;
|
||||||
void SetStartColor(SHVec4 startColor) noexcept;
|
void SetStartColor(SHVec4 startColor) noexcept;
|
||||||
void SetEndColor (SHVec4 endColor) noexcept;
|
void SetEndColor (SHVec4 endColor) noexcept;
|
||||||
void SetColorEvolveRate (float rate) noexcept;
|
void SetColorEvolveRate (float rate) noexcept;
|
||||||
|
|
|
@ -70,11 +70,17 @@ namespace SHADE
|
||||||
pipeline->GetPipelineState().SetColorBlenState(colorBlendState);
|
pipeline->GetPipelineState().SetColorBlenState(colorBlendState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHTrajectoryRenderingSubSystem::Run(uint32_t frameIndex, float dt) noexcept
|
void SHTrajectoryRenderingSubSystem::Run(uint32_t frameIndex) noexcept
|
||||||
{
|
{
|
||||||
auto& comps = SHComponentManager::GetDense<SHTrajectoryRenderableComponent>();
|
auto& comps = SHComponentManager::GetDense<SHTrajectoryRenderableComponent>();
|
||||||
for (auto& comp : comps)
|
for (auto& comp : comps)
|
||||||
{
|
{
|
||||||
|
comp.SetPositions(std::vector
|
||||||
|
{
|
||||||
|
SHVec3 {},
|
||||||
|
SHVec3 {}
|
||||||
|
});
|
||||||
|
|
||||||
// If has positions, feed data to buffer.
|
// If has positions, feed data to buffer.
|
||||||
if (comp.HasPositions())
|
if (comp.HasPositions())
|
||||||
{
|
{
|
||||||
|
@ -115,7 +121,7 @@ namespace SHADE
|
||||||
currentColor = SHVec4::Lerp(startColor, endColor, lerpValue);
|
currentColor = SHVec4::Lerp(startColor, endColor, lerpValue);
|
||||||
|
|
||||||
// evolve lerp value and clamp to 1
|
// evolve lerp value and clamp to 1
|
||||||
lerpValue = std::max (1.0f, lerpValue + (colorEvolveRate * dt));
|
lerpValue = std::max (1.0f, lerpValue + colorEvolveRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add draw data for this trajectory
|
// add draw data for this trajectory
|
||||||
|
@ -134,6 +140,8 @@ namespace SHADE
|
||||||
comp.ClearPositions();
|
comp.ClearPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!transformData.empty())
|
||||||
|
{
|
||||||
// read transform data to buffer
|
// read transform data to buffer
|
||||||
// read draw data to buffer
|
// read draw data to buffer
|
||||||
SHVkUtil::EnsureBufferAndCopyHostVisibleData(logicalDevice, transformBuffer, transformData.data(), sizeof (SHMatrix) * transformData.size(), vk::BufferUsageFlagBits::eVertexBuffer, "Trajectory System Transform Buffer");
|
SHVkUtil::EnsureBufferAndCopyHostVisibleData(logicalDevice, transformBuffer, transformData.data(), sizeof (SHMatrix) * transformData.size(), vk::BufferUsageFlagBits::eVertexBuffer, "Trajectory System Transform Buffer");
|
||||||
|
@ -141,10 +149,13 @@ namespace SHADE
|
||||||
SHVkUtil::EnsureBufferAndCopyHostVisibleData(logicalDevice, drawDataBuffer, drawData.data(), sizeof(vk::DrawIndexedIndirectCommand) * drawData.size(), vk::BufferUsageFlagBits::eIndirectBuffer, "Trajectory System Draw Data Buffer");
|
SHVkUtil::EnsureBufferAndCopyHostVisibleData(logicalDevice, drawDataBuffer, drawData.data(), sizeof(vk::DrawIndexedIndirectCommand) * drawData.size(), vk::BufferUsageFlagBits::eIndirectBuffer, "Trajectory System Draw Data Buffer");
|
||||||
|
|
||||||
SHVkUtil::EnsureBufferAndCopyHostVisibleData(logicalDevice, colorBuffer, colorData.data(), sizeof(SHVec4) * colorData.size(), vk::BufferUsageFlagBits::eVertexBuffer, "Trajectory System Color Data Buffer");
|
SHVkUtil::EnsureBufferAndCopyHostVisibleData(logicalDevice, colorBuffer, colorData.data(), sizeof(SHVec4) * colorData.size(), vk::BufferUsageFlagBits::eVertexBuffer, "Trajectory System Color Data Buffer");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHTrajectoryRenderingSubSystem::Render(Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHRenderer> renderer, uint32_t frameIndex) noexcept
|
void SHTrajectoryRenderingSubSystem::Render(Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHRenderer> renderer, uint32_t frameIndex) noexcept
|
||||||
|
{
|
||||||
|
if (!transformData.empty())
|
||||||
{
|
{
|
||||||
auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::TRAJECTORY_RENDERING);
|
auto const& mappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::TRAJECTORY_RENDERING);
|
||||||
uint32_t staticGlobalSetIndex = mappings.at(SHPredefinedDescriptorTypes::STATIC_DATA);
|
uint32_t staticGlobalSetIndex = mappings.at(SHPredefinedDescriptorTypes::STATIC_DATA);
|
||||||
|
@ -168,6 +179,7 @@ namespace SHADE
|
||||||
transformData.clear();
|
transformData.clear();
|
||||||
drawData.clear();
|
drawData.clear();
|
||||||
colorData.clear();
|
colorData.clear();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace SHADE
|
||||||
public:
|
public:
|
||||||
void Init (Handle<SHVkLogicalDevice> device, Handle<SHVkRenderpass> compatibleRenderpass, Handle<SHSubpass> subpass, Handle<SHVkShaderModule> textVS, Handle<SHVkShaderModule> textFS) noexcept;
|
void Init (Handle<SHVkLogicalDevice> device, Handle<SHVkRenderpass> compatibleRenderpass, Handle<SHSubpass> subpass, Handle<SHVkShaderModule> textVS, Handle<SHVkShaderModule> textFS) noexcept;
|
||||||
|
|
||||||
void Run(uint32_t frameIndex, float dt) noexcept;
|
void Run(uint32_t frameIndex) noexcept;
|
||||||
|
|
||||||
void Render(Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHRenderer> renderer, uint32_t frameIndex) noexcept;
|
void Render(Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHRenderer> renderer, uint32_t frameIndex) noexcept;
|
||||||
void Exit(void) noexcept;
|
void Exit(void) noexcept;
|
||||||
|
|
Loading…
Reference in New Issue