Implemented Shadow maps (still needs improvement) #314
|
@ -1,4 +1,4 @@
|
|||
Start in Fullscreen: false
|
||||
Starting Scene ID: 97158628
|
||||
Starting Scene ID: 86098106
|
||||
Window Size: {x: 1920, y: 1080}
|
||||
Window Title: SHADE Engine
|
|
@ -6,6 +6,7 @@ struct DirectionalLightStruct
|
|||
uint isActive;
|
||||
uint cullingMask;
|
||||
vec4 diffuseColor;
|
||||
mat4 pvMatrix;
|
||||
};
|
||||
|
||||
struct AmbientLightStruct
|
||||
|
@ -24,6 +25,8 @@ layout(set = 3, binding = 3, r32ui) uniform uimage2D lightLayerData;
|
|||
layout(set = 3, binding = 4, r8) uniform image2D ssaoBlurredImage;
|
||||
layout(set = 3, binding = 5, rgba8) uniform image2D targetImage;
|
||||
|
||||
layout (set = 4, binding = 0) uniform sampler2D shadowMaps[]; // for textures (global)
|
||||
|
||||
layout(set = 1, binding = 0) uniform LightCounts
|
||||
{
|
||||
uint directionalLights;
|
||||
|
|
Binary file not shown.
|
@ -158,7 +158,7 @@ namespace SHADE
|
|||
.Type = vk::DescriptorType::eCombinedImageSampler,
|
||||
.Stage = vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment | vk::ShaderStageFlagBits::eCompute,
|
||||
.BindPoint = SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA,
|
||||
.DescriptorCount = 200, // we can have up to 2000 textures for now
|
||||
.DescriptorCount = 200, // we can have up to 200 textures for now
|
||||
.flags = vk::DescriptorBindingFlagBits::eVariableDescriptorCount,
|
||||
};
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace SHADE
|
|||
CAMERA,
|
||||
MATERIALS,
|
||||
FONT,
|
||||
RENDER_GRAPH_RESOURCE,
|
||||
RENDER_GRAPH_NODE_COMPUTE_RESOURCE,
|
||||
RENDER_GRAPH_RESOURCE,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -127,7 +127,10 @@ namespace SHADE
|
|||
|
||||
SHFreetypeInstance::Init();
|
||||
|
||||
SHAssetManager::CompileAsset("../../Assets/Shaders/ShadowMap_VS.glsl", false);
|
||||
SHAssetManager::CompileAsset("../../Assets/Shaders/DeferredComposite_CS.glsl", false);
|
||||
SHAssetManager::CompileAsset("../../Assets/Shaders/SSAO_CS.glsl", false);
|
||||
SHAssetManager::CompileAsset("../../Assets/Shaders/SSAOBlur_CS.glsl", false);
|
||||
SHAssetManager::CompileAsset("../../Assets/Shaders/PureCopy_CS.glsl", false);
|
||||
|
||||
// Load Built In Shaders
|
||||
static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT);
|
||||
|
@ -288,7 +291,7 @@ namespace SHADE
|
|||
/*-----------------------------------------------------------------------*/
|
||||
/* DEFERRED COMPOSITE SUBPASS INIT */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
auto deferredCompositeCompute = deferredCompositeNode->AddNodeCompute("Deferred Composite", deferredCompositeShader, { "Position", "Normals", "Albedo", "Light Layer Indices", "SSAO Blur", "Scene" });
|
||||
auto deferredCompositeCompute = deferredCompositeNode->AddNodeCompute("Deferred Composite", deferredCompositeShader, { "Position", "Normals", "Albedo", "Light Layer Indices", "SSAO Blur", "Scene" }, {}/*SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::SHADOW)[0]*/);
|
||||
deferredCompositeCompute->AddPreComputeFunction([=](Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex)
|
||||
{
|
||||
lightingSubSystem->PrepareShadowMapsForRead(cmdBuffer);
|
||||
|
|
|
@ -122,4 +122,9 @@ namespace SHADE
|
|||
return cameraDirector;
|
||||
}
|
||||
|
||||
SHShaderCameraData SHRenderer::GetCPUCameraData(void) const noexcept
|
||||
{
|
||||
return cpuCameraData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ namespace SHADE
|
|||
/* Setters and Getters */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
Handle<SHCameraDirector> GetCameraDirector (void) const noexcept;
|
||||
SHShaderCameraData GetCPUCameraData (void) const noexcept;
|
||||
|
||||
private:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -56,6 +56,11 @@ namespace SHADE
|
|||
//lightPtr->direction = lightData.direction;
|
||||
lightPtr->diffuseColor = lightData.color;
|
||||
lightPtr->active = lightComp->isActive;
|
||||
|
||||
// write view projection matrix if renderer is available
|
||||
auto lightRenderer = lightComp->GetRenderer();
|
||||
if (lightRenderer)
|
||||
lightPtr->pvMatrix = lightRenderer->GetCPUCameraData().viewProjectionMatrix;
|
||||
break;
|
||||
}
|
||||
case SH_LIGHT_TYPE::POINT:
|
||||
|
@ -499,6 +504,12 @@ namespace SHADE
|
|||
|
||||
for (auto& light : lightComps)
|
||||
{
|
||||
if (auto renderer = light.GetRenderer())
|
||||
{
|
||||
//SHMatrix orthoMatrix = SHMatrix::OrthographicRH()
|
||||
renderer->UpdateDataManual(frameIndex, GetViewMatrix(&light), SHMatrix::OrthographicLH(12.0f, 12.0f, 0.1f, 20.0f));
|
||||
}
|
||||
|
||||
auto enumValue = SHUtilities::ConvertEnum(light.GetLightData().type);
|
||||
|
||||
// First we want to make sure the light is already bound to the system. if it
|
||||
|
@ -520,14 +531,6 @@ namespace SHADE
|
|||
// Light is now updated in the container
|
||||
//light.ClearDirtyFlag();
|
||||
}
|
||||
|
||||
|
||||
if (auto renderer = light.GetRenderer())
|
||||
{
|
||||
//SHMatrix orthoMatrix = SHMatrix::OrthographicRH()
|
||||
renderer->UpdateDataManual (frameIndex, GetViewMatrix(&light), SHMatrix::OrthographicLH(12.0f, 12.0f, 0.1f, 20.0f));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Write data to GPU
|
||||
|
|
|
@ -3,12 +3,14 @@
|
|||
#include "Resource/SHHandle.h"
|
||||
#include "Math/Vector/SHVec3.h"
|
||||
#include "Math/Vector/SHVec4.h"
|
||||
#include "Math/SHMatrix.h"
|
||||
#include "SHLightData.h"
|
||||
#include <array>
|
||||
#include "Graphics/MiddleEnd/Interface/SHGraphicsConstants.h"
|
||||
#include "Graphics/RenderGraph/SHRenderGraphResource.h"
|
||||
#include "ECS_Base/SHECSMacros.h"
|
||||
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
class SHVkLogicalDevice;
|
||||
|
@ -39,6 +41,9 @@ namespace SHADE
|
|||
//! Diffuse color emitted by the light
|
||||
alignas (16) SHVec4 diffuseColor;
|
||||
|
||||
//! Matrix for world to projection from light's perspective
|
||||
SHMatrix pvMatrix;
|
||||
|
||||
};
|
||||
|
||||
// Represents how the data will be interpreted in GPU. we want to copy to a container of these before passing to GPU.
|
||||
|
|
|
@ -208,7 +208,9 @@ namespace SHADE
|
|||
newBinding.flags = vk::DescriptorBindingFlagBits::eVariableDescriptorCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
SHLOG_ERROR("Variable size binding is detected, but the binding is not the last binding of the set and is therefore invalid. ");
|
||||
}
|
||||
}
|
||||
|
||||
setsWithBindings[CURRENT_SET].emplace_back(newBinding);
|
||||
|
|
Loading…
Reference in New Issue