Shadows WIP
This commit is contained in:
parent
73c5a0ff4a
commit
826df94c96
|
@ -20,10 +20,11 @@ layout(location = 0) out struct
|
||||||
vec2 uv; // location = 1
|
vec2 uv; // location = 1
|
||||||
vec4 normal; // location = 2
|
vec4 normal; // location = 2
|
||||||
vec4 worldPos; // location = 3
|
vec4 worldPos; // location = 3
|
||||||
|
vec3 worldNormal; // location = 4
|
||||||
} Out;
|
} Out;
|
||||||
|
|
||||||
// material stuff
|
// material stuff
|
||||||
layout(location = 4) out struct
|
layout(location = 5) out struct
|
||||||
{
|
{
|
||||||
int materialIndex;
|
int materialIndex;
|
||||||
uint eid;
|
uint eid;
|
||||||
|
@ -61,11 +62,13 @@ void main()
|
||||||
// uvs for texturing in fragment shader
|
// uvs for texturing in fragment shader
|
||||||
Out.uv = aUV;
|
Out.uv = aUV;
|
||||||
|
|
||||||
mat3 transposeInv = mat3 (transpose(inverse(modelViewMat)));
|
mat3 mvTransInv = mat3 (transpose(inverse(modelViewMat)));
|
||||||
|
mat3 modelTransInv = mat3 (transpose(inverse(worldTransform)));
|
||||||
|
|
||||||
// normals are also in view space
|
// normals are also in view space
|
||||||
Out.normal.rgb = transposeInv * aNormal.rgb;
|
Out.normal.rgb = mvTransInv * aNormal.rgb;
|
||||||
Out.normal.rgb = normalize (Out.normal.rgb);
|
Out.normal.rgb = normalize (Out.normal.rgb);
|
||||||
|
Out.worldNormal = normalize (modelTransInv * aNormal);
|
||||||
|
|
||||||
// Compute bone matrix
|
// Compute bone matrix
|
||||||
mat4 boneMatrix = BoneMatrices.data[firstBoneIndex + aBoneIndices[0]] * aBoneWeights[0];
|
mat4 boneMatrix = BoneMatrices.data[firstBoneIndex + aBoneIndices[0]] * aBoneWeights[0];
|
||||||
|
|
Binary file not shown.
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
struct DirectionalLightStruct
|
struct DirectionalLightStruct
|
||||||
{
|
{
|
||||||
|
vec4 directionWorld;
|
||||||
vec3 direction;
|
vec3 direction;
|
||||||
uint isActive;
|
uint isActive;
|
||||||
uint cullingMask;
|
uint cullingMask;
|
||||||
|
@ -22,7 +23,7 @@ layout(local_size_x = 16, local_size_y = 16) in;
|
||||||
layout(set = 3, binding = 0, rgba32f) uniform image2D positions;
|
layout(set = 3, binding = 0, rgba32f) uniform image2D positions;
|
||||||
layout(set = 3, binding = 1, rgba32f) uniform image2D normals;
|
layout(set = 3, binding = 1, rgba32f) uniform image2D normals;
|
||||||
layout(set = 3, binding = 2, rgba8) uniform image2D albedo;
|
layout(set = 3, binding = 2, rgba8) uniform image2D albedo;
|
||||||
layout(set = 3, binding = 3, r32ui) uniform uimage2D lightLayerData;
|
layout(set = 3, binding = 3, rgba32ui) uniform uimage2D lightLayerData;
|
||||||
layout(set = 3, binding = 4, r8) uniform image2D ssaoBlurredImage;
|
layout(set = 3, binding = 4, r8) uniform image2D ssaoBlurredImage;
|
||||||
layout(set = 3, binding = 5, rgba8) uniform image2D positionWorldSpace;
|
layout(set = 3, binding = 5, rgba8) uniform image2D positionWorldSpace;
|
||||||
layout(set = 3, binding = 6, rgba8) uniform image2D targetImage;
|
layout(set = 3, binding = 6, rgba8) uniform image2D targetImage;
|
||||||
|
@ -54,7 +55,7 @@ float LinStep (float val, float low, float high)
|
||||||
return clamp ((val - low)/(high - low), 0.0f, 1.0f);
|
return clamp ((val - low)/(high - low), 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float CalcShadowValue (sampler2D shadowMap, vec4 worldSpaceFragPos, mat4 lightPV)
|
float CalcShadowValue (sampler2D shadowMap, vec4 worldSpaceFragPos, mat4 lightPV, vec3 worldNormal, vec3 lightDir)
|
||||||
{
|
{
|
||||||
// clip space for fragment from light view space
|
// clip space for fragment from light view space
|
||||||
vec4 fragPosLightPOV = lightPV * worldSpaceFragPos;
|
vec4 fragPosLightPOV = lightPV * worldSpaceFragPos;
|
||||||
|
@ -69,6 +70,13 @@ float CalcShadowValue (sampler2D shadowMap, vec4 worldSpaceFragPos, mat4 lightPV
|
||||||
if (converted.x < 0.0f || converted.x > 1.0f || converted.y < 0.0f || converted.y > 1.0f)
|
if (converted.x < 0.0f || converted.x > 1.0f || converted.y < 0.0f || converted.y > 1.0f)
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
|
|
||||||
|
float returnVal = 0.0f;
|
||||||
|
|
||||||
|
float worldNormalDotLight = dot (normalize (worldNormal), normalize(lightDir));
|
||||||
|
|
||||||
|
if (worldNormalDotLight < 0.0f)
|
||||||
|
return 0.7f;
|
||||||
|
|
||||||
if (fragPosLightPOV.z > moments.x && fragPosLightPOV.w > 0.0f)
|
if (fragPosLightPOV.z > moments.x && fragPosLightPOV.w > 0.0f)
|
||||||
{
|
{
|
||||||
float p = step (fragPosLightPOV.z, moments.x);
|
float p = step (fragPosLightPOV.z, moments.x);
|
||||||
|
@ -76,15 +84,19 @@ float CalcShadowValue (sampler2D shadowMap, vec4 worldSpaceFragPos, mat4 lightPV
|
||||||
|
|
||||||
float d = fragPosLightPOV.z - moments.x;
|
float d = fragPosLightPOV.z - moments.x;
|
||||||
float pMax = LinStep (variance / (variance + (d * d)), 0.9f, 1.0f);
|
float pMax = LinStep (variance / (variance + (d * d)), 0.9f, 1.0f);
|
||||||
return min (max (p, pMax), 1.0f);
|
|
||||||
|
returnVal = min (max (p, pMax) + 0.7f, 1.0f);
|
||||||
|
|
||||||
|
return returnVal;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (fragPosLightPOV.z > 1.0f)
|
else if (fragPosLightPOV.z > 1.0f)
|
||||||
{
|
{
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
// return step (fragPosLightPOV.z, );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
@ -104,8 +116,12 @@ void main()
|
||||||
// normal of fragment
|
// normal of fragment
|
||||||
vec3 normalView = imageLoad(normals, globalThread).rgb;
|
vec3 normalView = imageLoad(normals, globalThread).rgb;
|
||||||
|
|
||||||
|
uvec4 lightLayerAndNormal = imageLoad (lightLayerData, globalThread);
|
||||||
|
|
||||||
// light layer index
|
// light layer index
|
||||||
uint lightLayer = imageLoad (lightLayerData, globalThread).r;
|
uint lightLayer = lightLayerAndNormal.x;
|
||||||
|
|
||||||
|
vec3 worldNormal = vec3 (unpackHalf2x16 (lightLayerAndNormal.y).xy, unpackHalf2x16 (lightLayerAndNormal.z).x);
|
||||||
|
|
||||||
vec3 fragColor = vec3 (0.0f);
|
vec3 fragColor = vec3 (0.0f);
|
||||||
|
|
||||||
|
@ -138,7 +154,7 @@ void main()
|
||||||
if ((DirLightData.dLightData[i].shadowData & uint(1)) == 1)
|
if ((DirLightData.dLightData[i].shadowData & uint(1)) == 1)
|
||||||
{
|
{
|
||||||
// calculate shadow map here
|
// calculate shadow map here
|
||||||
fragColor *= CalcShadowValue (shadowMaps[0], positionWorld, DirLightData.dLightData[i].pvMatrix).xxx;
|
fragColor.rgb *= CalcShadowValue (shadowMaps[0], positionWorld, DirLightData.dLightData[i].pvMatrix, worldNormal, DirLightData.dLightData[i].directionWorld.xyz).xxx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,58 @@
|
||||||
|
#version 450
|
||||||
|
|
||||||
|
#define BLUR_WIDTH 7
|
||||||
|
#define BLUR_HALF_WIDTH BLUR_WIDTH / 2
|
||||||
|
#define SHM_WIDTH BLUR_WIDTH + 16 - 1
|
||||||
|
|
||||||
|
layout(local_size_x = 16, local_size_y = 16) in;
|
||||||
|
layout(set = 3, binding = 0, r8) uniform image2D shadowMap;
|
||||||
|
layout(set = 3, binding = 1, r8) uniform image2D shadowMapBlurred;
|
||||||
|
|
||||||
|
|
||||||
|
vec4 GetShadowMapValue(ivec2 uv, ivec2 imageSize)
|
||||||
|
{
|
||||||
|
if (uv.x >= 0 && uv.y >= 0 && uv.x < imageSize.x && uv.y < imageSize.y)
|
||||||
|
{
|
||||||
|
return imageLoad (shadowMap, uv);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vec4 (0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
shared vec4 sharedPixels[16 + BLUR_WIDTH - 1][16 + BLUR_WIDTH - 1];
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
ivec2 globalThread = ivec2 (gl_GlobalInvocationID.xy);
|
||||||
|
ivec2 localThread = ivec2 (gl_LocalInvocationID.xy);
|
||||||
|
ivec2 inputImageSize = imageSize(shadowMap);
|
||||||
|
|
||||||
|
// Load color into shared memory
|
||||||
|
ivec2 start = ivec2 (gl_WorkGroupID) * ivec2 (gl_WorkGroupSize) - (BLUR_HALF_WIDTH);
|
||||||
|
for (int i = localThread.x; i < SHM_WIDTH; i += int (gl_WorkGroupSize.x))
|
||||||
|
{
|
||||||
|
for (int j = localThread.y; j < SHM_WIDTH; j += int (gl_WorkGroupSize.y))
|
||||||
|
{
|
||||||
|
vec4 value = GetShadowMapValue (start + ivec2 (i, j), inputImageSize);
|
||||||
|
sharedPixels[i][j] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait for all shared memory to load
|
||||||
|
barrier();
|
||||||
|
|
||||||
|
ivec2 shmStart = ivec2 (localThread + (BLUR_HALF_WIDTH));
|
||||||
|
|
||||||
|
vec4 sum = vec4 (0.0f);
|
||||||
|
for (int i = -BLUR_HALF_WIDTH; i <= BLUR_HALF_WIDTH; ++i)
|
||||||
|
{
|
||||||
|
for (int j = -BLUR_HALF_WIDTH; j <= BLUR_HALF_WIDTH; ++j)
|
||||||
|
{
|
||||||
|
vec4 sharedVal = sharedPixels[shmStart.x + i][shmStart.y + j];
|
||||||
|
sum += sharedVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sum /= (BLUR_WIDTH * BLUR_WIDTH);
|
||||||
|
imageStore(shadowMapBlurred, globalThread, sum);
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
Name: ShadowMapBlur_CS
|
||||||
|
ID: 38004013
|
||||||
|
Type: 2
|
|
@ -57,7 +57,7 @@ layout (std430, set = 2, binding = 0) buffer MaterialProperties // For mater
|
||||||
|
|
||||||
layout(location = 0) out vec4 position;
|
layout(location = 0) out vec4 position;
|
||||||
layout(location = 1) out uint outEntityID;
|
layout(location = 1) out uint outEntityID;
|
||||||
layout(location = 2) out uint lightLayerIndices;
|
layout(location = 2) out uvec4 lightLayerIndices;
|
||||||
layout(location = 3) out vec4 normals;
|
layout(location = 3) out vec4 normals;
|
||||||
layout(location = 4) out vec4 albedo;
|
layout(location = 4) out vec4 albedo;
|
||||||
layout(location = 5) out vec4 worldSpacePosition;
|
layout(location = 5) out vec4 worldSpacePosition;
|
||||||
|
@ -76,7 +76,6 @@ void main()
|
||||||
worldSpacePosition = In.worldPos;
|
worldSpacePosition = In.worldPos;
|
||||||
|
|
||||||
outEntityID = In2.eid;
|
outEntityID = In2.eid;
|
||||||
lightLayerIndices = In2.lightLayerIndex;
|
|
||||||
|
|
||||||
// float vpHeight = float (In2.screenSpacePos.y) - MatProp.data[In2.materialIndex].highlightPosition;
|
// float vpHeight = float (In2.screenSpacePos.y) - MatProp.data[In2.materialIndex].highlightPosition;
|
||||||
// bring the frame of reference to the object's screen space pos
|
// bring the frame of reference to the object's screen space pos
|
||||||
|
|
Binary file not shown.
|
@ -17,10 +17,11 @@ layout(location = 0) in struct
|
||||||
vec2 uv; // location = 1
|
vec2 uv; // location = 1
|
||||||
vec4 normal; // location = 2
|
vec4 normal; // location = 2
|
||||||
vec4 worldPos; // location = 3
|
vec4 worldPos; // location = 3
|
||||||
|
vec3 worldNormal; // location = 4
|
||||||
} In;
|
} In;
|
||||||
|
|
||||||
// material stuff
|
// material stuff
|
||||||
layout(location = 4) flat in struct
|
layout(location = 5) flat in struct
|
||||||
{
|
{
|
||||||
int materialIndex;
|
int materialIndex;
|
||||||
uint eid;
|
uint eid;
|
||||||
|
@ -35,7 +36,7 @@ layout (std430, set = 2, binding = 0) buffer MaterialProperties // For mater
|
||||||
|
|
||||||
layout(location = 0) out vec4 position;
|
layout(location = 0) out vec4 position;
|
||||||
layout(location = 1) out uint outEntityID;
|
layout(location = 1) out uint outEntityID;
|
||||||
layout(location = 2) out uint lightLayerIndices;
|
layout(location = 2) out uvec4 lightLayerIndices;
|
||||||
layout(location = 3) out vec4 normals;
|
layout(location = 3) out vec4 normals;
|
||||||
layout(location = 4) out vec4 albedo;
|
layout(location = 4) out vec4 albedo;
|
||||||
layout(location = 5) out vec4 worldSpacePosition;
|
layout(location = 5) out vec4 worldSpacePosition;
|
||||||
|
@ -48,5 +49,5 @@ void main()
|
||||||
worldSpacePosition = In.worldPos;
|
worldSpacePosition = In.worldPos;
|
||||||
|
|
||||||
outEntityID = In2.eid;
|
outEntityID = In2.eid;
|
||||||
lightLayerIndices = In2.lightLayerIndex;
|
lightLayerIndices = uvec4 (In2.lightLayerIndex, packHalf2x16 (In.worldNormal.xy), packHalf2x16 (vec2 (In.worldNormal.z, 1.0f)), 1);
|
||||||
}
|
}
|
Binary file not shown.
|
@ -20,11 +20,12 @@ layout(location = 0) out struct
|
||||||
vec2 uv; // location = 1
|
vec2 uv; // location = 1
|
||||||
vec4 normal; // location = 2
|
vec4 normal; // location = 2
|
||||||
vec4 worldPos; // location = 3
|
vec4 worldPos; // location = 3
|
||||||
|
vec3 worldNormal; // location = 4
|
||||||
|
|
||||||
} Out;
|
} Out;
|
||||||
|
|
||||||
// material stuff
|
// material stuff
|
||||||
layout(location = 4) out struct
|
layout(location = 5) out struct
|
||||||
{
|
{
|
||||||
int materialIndex;
|
int materialIndex;
|
||||||
uint eid;
|
uint eid;
|
||||||
|
@ -57,11 +58,13 @@ void main()
|
||||||
// uvs for texturing in fragment shader
|
// uvs for texturing in fragment shader
|
||||||
Out.uv = aUV;
|
Out.uv = aUV;
|
||||||
|
|
||||||
mat3 transposeInv = mat3 (transpose(inverse(modelViewMat)));
|
mat3 mvTransInv = mat3 (transpose(inverse(modelViewMat)));
|
||||||
|
mat3 modelTransInv = mat3 (transpose(inverse(worldTransform)));
|
||||||
|
|
||||||
// normals are also in view space
|
// normals are also in view space
|
||||||
Out.normal.rgb = transposeInv * aNormal.rgb;
|
Out.normal.rgb = mvTransInv * aNormal.rgb;
|
||||||
Out.normal.rgb = normalize (Out.normal.rgb);
|
Out.normal.rgb = normalize (Out.normal.rgb);
|
||||||
|
Out.worldNormal = normalize (modelTransInv * aNormal);
|
||||||
|
|
||||||
// clip space for rendering
|
// clip space for rendering
|
||||||
gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
|
gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
|
||||||
|
|
Binary file not shown.
|
@ -141,6 +141,8 @@ namespace SHADE
|
||||||
//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_VS.glsl", false);
|
||||||
//SHAssetManager::CompileAsset("../../Assets/Shaders/Trajectory_FS.glsl", false);
|
//SHAssetManager::CompileAsset("../../Assets/Shaders/Trajectory_FS.glsl", false);
|
||||||
|
//SHAssetManager::CompileAsset("../../Assets/Shaders/ShadowMapBlur_CS.glsl", false);
|
||||||
|
//SHAssetManager::CompileAsset("../../Assets/Shaders/Anim_VS.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);
|
||||||
|
@ -160,6 +162,7 @@ namespace SHADE
|
||||||
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_VS = 41042628; trajectoryVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TRAJECTORY_VS);
|
||||||
static constexpr AssetID TRAJECTORY_FS = 45635685; trajectoryFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TRAJECTORY_FS);
|
static constexpr AssetID TRAJECTORY_FS = 45635685; trajectoryFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TRAJECTORY_FS);
|
||||||
|
static constexpr AssetID SHADOW_BLUR_CS = 38004013; shadowMapBlurCS = SHResourceManager::LoadOrGet<SHVkShaderModule>(SHADOW_BLUR_CS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +220,7 @@ namespace SHADE
|
||||||
renderGraph->AddResource("Albedo", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second);
|
renderGraph->AddResource("Albedo", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second);
|
||||||
renderGraph->AddResource("Depth Buffer", { SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT }, true, windowDims.first, windowDims.second, vk::Format::eD32SfloatS8Uint);
|
renderGraph->AddResource("Depth Buffer", { SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT }, true, windowDims.first, windowDims.second, vk::Format::eD32SfloatS8Uint);
|
||||||
renderGraph->AddResource("Entity ID", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, true, windowDims.first, windowDims.second, vk::Format::eR32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc);
|
renderGraph->AddResource("Entity ID", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, true, windowDims.first, windowDims.second, vk::Format::eR32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc);
|
||||||
renderGraph->AddResource("Light Layer Indices", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc);
|
renderGraph->AddResource("Light Layer Indices And World Normals", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Uint, 1, vk::ImageUsageFlagBits::eTransferSrc);
|
||||||
renderGraph->AddResource("Scene", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, true, windowDims.first, windowDims.second);
|
renderGraph->AddResource("Scene", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE, SH_RENDER_GRAPH_RESOURCE_FLAGS::SHARED }, true, windowDims.first, windowDims.second);
|
||||||
renderGraph->AddResource("SSAO", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR8Unorm);
|
renderGraph->AddResource("SSAO", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR8Unorm);
|
||||||
renderGraph->AddResource("SSAO Blur", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR8Unorm);
|
renderGraph->AddResource("SSAO Blur", { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, true, windowDims.first, windowDims.second, vk::Format::eR8Unorm);
|
||||||
|
@ -231,7 +234,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
"Position",
|
"Position",
|
||||||
"Entity ID",
|
"Entity ID",
|
||||||
"Light Layer Indices",
|
"Light Layer Indices And World Normals",
|
||||||
"Normals",
|
"Normals",
|
||||||
"Albedo",
|
"Albedo",
|
||||||
"Depth Buffer",
|
"Depth Buffer",
|
||||||
|
@ -248,7 +251,7 @@ namespace SHADE
|
||||||
auto gBufferSubpass = gBufferNode->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data(), worldViewport, worldRenderer);
|
auto gBufferSubpass = gBufferNode->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data(), worldViewport, worldRenderer);
|
||||||
gBufferSubpass->AddColorOutput("Position");
|
gBufferSubpass->AddColorOutput("Position");
|
||||||
gBufferSubpass->AddColorOutput("Entity ID");
|
gBufferSubpass->AddColorOutput("Entity ID");
|
||||||
gBufferSubpass->AddColorOutput("Light Layer Indices");
|
gBufferSubpass->AddColorOutput("Light Layer Indices And World Normals");
|
||||||
gBufferSubpass->AddColorOutput("Normals");
|
gBufferSubpass->AddColorOutput("Normals");
|
||||||
gBufferSubpass->AddColorOutput("Albedo");
|
gBufferSubpass->AddColorOutput("Albedo");
|
||||||
gBufferSubpass->AddColorOutput("Position World Space");
|
gBufferSubpass->AddColorOutput("Position World Space");
|
||||||
|
@ -258,7 +261,7 @@ namespace SHADE
|
||||||
auto gBufferVfxSubpass = gBufferNode->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_VFX_SUBPASS.data(), worldViewport, worldRenderer);
|
auto gBufferVfxSubpass = gBufferNode->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_VFX_SUBPASS.data(), worldViewport, worldRenderer);
|
||||||
gBufferVfxSubpass->AddColorOutput("Position");
|
gBufferVfxSubpass->AddColorOutput("Position");
|
||||||
gBufferVfxSubpass->AddColorOutput("Entity ID");
|
gBufferVfxSubpass->AddColorOutput("Entity ID");
|
||||||
gBufferVfxSubpass->AddColorOutput("Light Layer Indices");
|
gBufferVfxSubpass->AddColorOutput("Light Layer Indices And World Normals");
|
||||||
gBufferVfxSubpass->AddColorOutput("Normals");
|
gBufferVfxSubpass->AddColorOutput("Normals");
|
||||||
gBufferVfxSubpass->AddColorOutput("Albedo");
|
gBufferVfxSubpass->AddColorOutput("Albedo");
|
||||||
gBufferVfxSubpass->AddColorOutput("Position World Space");
|
gBufferVfxSubpass->AddColorOutput("Position World Space");
|
||||||
|
@ -314,7 +317,7 @@ namespace SHADE
|
||||||
auto deferredCompositeNode = renderGraph->AddNode(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data(),
|
auto deferredCompositeNode = renderGraph->AddNode(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data(),
|
||||||
{
|
{
|
||||||
"Position",
|
"Position",
|
||||||
"Light Layer Indices",
|
"Light Layer Indices And World Normals",
|
||||||
"Normals",
|
"Normals",
|
||||||
"Albedo",
|
"Albedo",
|
||||||
"Scene",
|
"Scene",
|
||||||
|
@ -327,7 +330,7 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* DEFERRED COMPOSITE SUBPASS INIT */
|
/* DEFERRED COMPOSITE SUBPASS INIT */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
auto deferredCompositeCompute = deferredCompositeNode->AddNodeCompute(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_COMPUTE.data(), deferredCompositeShader, {"Position", "Normals", "Albedo", "Light Layer Indices", "SSAO Blur", "Position World Space", "Scene", "Object VFX"}, {}, SHLightingSubSystem::MAX_SHADOWS);
|
auto deferredCompositeCompute = deferredCompositeNode->AddNodeCompute(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_COMPUTE.data(), deferredCompositeShader, {"Position", "Normals", "Albedo", "Light Layer Indices And World Normals", "SSAO Blur", "Position World Space", "Scene", "Object VFX"}, {}, SHLightingSubSystem::MAX_SHADOWS);
|
||||||
deferredCompositeCompute->AddPreComputeFunction([=](Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex)
|
deferredCompositeCompute->AddPreComputeFunction([=](Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex)
|
||||||
{
|
{
|
||||||
lightingSubSystem->PrepareShadowMapsForRead(cmdBuffer);
|
lightingSubSystem->PrepareShadowMapsForRead(cmdBuffer);
|
||||||
|
@ -669,21 +672,21 @@ namespace SHADE
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//static bool shadowAdded = false;
|
static bool shadowAdded = false;
|
||||||
|
|
||||||
//if (shadowAdded == false && SHInputManager::GetKey(SHInputManager::SH_KEYCODE::B))
|
if (shadowAdded == false && SHInputManager::GetKey(SHInputManager::SH_KEYCODE::B))
|
||||||
//{
|
{
|
||||||
// shadowAdded = true;
|
shadowAdded = true;
|
||||||
// auto& lightComps = SHComponentManager::GetDense<SHLightComponent>();
|
auto& lightComps = SHComponentManager::GetDense<SHLightComponent>();
|
||||||
// //if (lightComps.size() > 2)
|
if (lightComps.size() > 2)
|
||||||
// //{
|
{
|
||||||
// // lightComps[2].SetEnableShadow(true);
|
lightComps[2].SetEnableShadow(true);
|
||||||
// //}
|
}
|
||||||
// for (auto& comp : lightComps)
|
for (auto& comp : lightComps)
|
||||||
// {
|
{
|
||||||
// comp.SetEnableShadow(true);
|
comp.SetEnableShadow(true);
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
renderGraph->Begin(frameIndex);
|
renderGraph->Begin(frameIndex);
|
||||||
auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex);
|
auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex);
|
||||||
|
@ -866,6 +869,7 @@ namespace SHADE
|
||||||
auto* lightComp = SHComponentManager::GetComponent<SHLightComponent>(EVENT_DATA->lightEntity);
|
auto* lightComp = SHComponentManager::GetComponent<SHLightComponent>(EVENT_DATA->lightEntity);
|
||||||
std::string depthResourceName = "ShadowMap_Depth " + std::to_string(EVENT_DATA->lightEntity);
|
std::string depthResourceName = "ShadowMap_Depth " + std::to_string(EVENT_DATA->lightEntity);
|
||||||
std::string shadowMapResourceName = "ShadowMap " + std::to_string(EVENT_DATA->lightEntity);
|
std::string shadowMapResourceName = "ShadowMap " + std::to_string(EVENT_DATA->lightEntity);
|
||||||
|
std::string shadowMapBlurredResourceName = "ShadowMap Blurred" + std::to_string(EVENT_DATA->lightEntity);
|
||||||
Handle<SHSubpass> companionSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS);
|
Handle<SHSubpass> companionSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS);
|
||||||
|
|
||||||
if (EVENT_DATA->generateRenderer)
|
if (EVENT_DATA->generateRenderer)
|
||||||
|
@ -878,17 +882,31 @@ namespace SHADE
|
||||||
lightComp->SetShadowMapIndex (lightingSubSystem->GetNumShadowMaps());
|
lightComp->SetShadowMapIndex (lightingSubSystem->GetNumShadowMaps());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add the shadow map resource to the graph
|
// Add the shadow map resource to the graph
|
||||||
renderGraph->AddResource(depthResourceName, {SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH}, false, SHLightingSubSystem::SHADOW_MAP_WIDTH, SHLightingSubSystem::SHADOW_MAP_HEIGHT, vk::Format::eD32Sfloat);
|
renderGraph->AddResource(depthResourceName, {SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH}, false, SHLightingSubSystem::SHADOW_MAP_WIDTH, SHLightingSubSystem::SHADOW_MAP_HEIGHT, vk::Format::eD32Sfloat);
|
||||||
renderGraph->AddResource(shadowMapResourceName, { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT }, false, SHLightingSubSystem::SHADOW_MAP_WIDTH, SHLightingSubSystem::SHADOW_MAP_HEIGHT, vk::Format::eR32G32B32A32Sfloat);
|
renderGraph->AddResource(shadowMapResourceName, { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, false, SHLightingSubSystem::SHADOW_MAP_WIDTH, SHLightingSubSystem::SHADOW_MAP_HEIGHT, vk::Format::eR32G32B32A32Sfloat);
|
||||||
|
renderGraph->AddResource(shadowMapBlurredResourceName, { SH_RENDER_GRAPH_RESOURCE_FLAGS::COLOR, SH_RENDER_GRAPH_RESOURCE_FLAGS::INPUT, SH_RENDER_GRAPH_RESOURCE_FLAGS::STORAGE }, false, SHLightingSubSystem::SHADOW_MAP_WIDTH, SHLightingSubSystem::SHADOW_MAP_HEIGHT, vk::Format::eR32G32B32A32Sfloat);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// link resource to node. This means linking the resource and regenerating the node's renderpass and framebuffer.
|
// link resource to node. This means linking the resource and regenerating the node's renderpass and framebuffer.
|
||||||
auto shadowMapNode = renderGraph->AddNodeAfter(SHGraphicsConstants::RenderGraphEntityNames::SHADOW_MAP_PASS.data() + shadowMapResourceName, {depthResourceName.c_str(), shadowMapResourceName.c_str()}, SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data());
|
auto shadowMapNode = renderGraph->AddNodeAfter(SHGraphicsConstants::RenderGraphEntityNames::SHADOW_MAP_PASS.data() + shadowMapResourceName, {depthResourceName.c_str(), shadowMapResourceName.c_str(), shadowMapBlurredResourceName.c_str()}, SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data());
|
||||||
|
|
||||||
// Add a subpass to render to that shadow map
|
// Add a subpass to render to that shadow map
|
||||||
auto newSubpass = shadowMapNode->RuntimeAddSubpass(shadowMapResourceName + " Subpass", shadowMapViewport, lightComp->GetRenderer());
|
auto shadowMapDrawSubpass = shadowMapNode->RuntimeAddSubpass(shadowMapResourceName + " Subpass", shadowMapViewport, lightComp->GetRenderer());
|
||||||
newSubpass->AddColorOutput(shadowMapResourceName);
|
shadowMapDrawSubpass->AddColorOutput(shadowMapResourceName);
|
||||||
newSubpass->AddDepthOutput(depthResourceName, SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH);
|
shadowMapDrawSubpass->AddDepthOutput(depthResourceName, SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH);
|
||||||
|
|
||||||
|
// add dummy subpass to transition the shadow map images for compute shader usage
|
||||||
|
//auto dummySubpass = shadowMapNode->RuntimeAddSubpass(shadowMapResourceName + "Dummy", {}, {});
|
||||||
|
//dummySubpass->AddGeneralColorOutput(shadowMapResourceName);
|
||||||
|
//dummySubpass->AddGeneralColorOutput(shadowMapBlurredResourceName);
|
||||||
|
|
||||||
|
// add compute pass to blur shadow ma
|
||||||
|
shadowMapNode->AddNodeCompute(SHGraphicsConstants::RenderGraphEntityNames::SHADOW_MAP_PASS.data() + shadowMapResourceName, shadowMapBlurCS, { shadowMapResourceName.c_str(), shadowMapBlurredResourceName.c_str() });
|
||||||
|
//shadowMapNode->AddNodeCompute(SHGraphicsConstants::RenderGraphEntityNames::SHADOW_MAP_PASS.data() + shadowMapResourceName, shadowMapBlurCS, { shadowMapBlurredResourceName.c_str(), shadowMapResourceName.c_str() });
|
||||||
|
//shadowMapNode->AddNodeCompute(SHGraphicsConstants::RenderGraphEntityNames::SHADOW_MAP_PASS.data() + shadowMapResourceName, shadowMapBlurCS, { shadowMapResourceName.c_str(), shadowMapBlurredResourceName.c_str() });
|
||||||
|
|
||||||
// regenerate the node
|
// regenerate the node
|
||||||
shadowMapNode->RuntimeStandaloneRegenerate();
|
shadowMapNode->RuntimeStandaloneRegenerate();
|
||||||
|
@ -905,16 +923,16 @@ namespace SHADE
|
||||||
tempLibrary.Init(device);
|
tempLibrary.Init(device);
|
||||||
tempLibrary.CreateGraphicsPipelines
|
tempLibrary.CreateGraphicsPipelines
|
||||||
(
|
(
|
||||||
{ shadowMapVS, shadowMapFS }, shadowMapNode->GetRenderpass(), newSubpass,
|
{ shadowMapVS, shadowMapFS }, shadowMapNode->GetRenderpass(), shadowMapDrawSubpass,
|
||||||
SHGraphicsPredefinedData::SystemType::BATCHING,
|
SHGraphicsPredefinedData::SystemType::BATCHING,
|
||||||
SHGraphicsPredefinedData::GetShadowMapViState(), rasterState
|
SHGraphicsPredefinedData::GetShadowMapViState(), rasterState
|
||||||
);
|
);
|
||||||
shadowMapPipeline = tempLibrary.GetGraphicsPipeline({ shadowMapVS, shadowMapFS, newSubpass });
|
shadowMapPipeline = tempLibrary.GetGraphicsPipeline({ shadowMapVS, shadowMapFS, shadowMapDrawSubpass });
|
||||||
}
|
}
|
||||||
newSubpass->SetCompanionSubpass(companionSubpass, shadowMapPipeline); // set companion subpass and pipeline
|
shadowMapDrawSubpass->SetCompanionSubpass(companionSubpass, shadowMapPipeline); // set companion subpass and pipeline
|
||||||
|
|
||||||
// add the shadow map to the lighting system
|
// add the shadow map and the blurred version to the lighting system
|
||||||
uint32_t const NEW_SHADOW_MAP_INDEX = lightingSubSystem->AddShadowMap(renderGraph->GetRenderGraphResource(shadowMapResourceName), EVENT_DATA->lightEntity);
|
uint32_t const NEW_SHADOW_MAP_INDEX = lightingSubSystem->AddShadowMap(renderGraph->GetRenderGraphResource(shadowMapBlurredResourceName), EVENT_DATA->lightEntity);
|
||||||
|
|
||||||
auto nodeCompute = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data())->GetNodeCompute(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_COMPUTE.data());
|
auto nodeCompute = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data())->GetNodeCompute(SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_COMPUTE.data());
|
||||||
nodeCompute->ModifyWriteDescImageComputeResource(SHGraphicsConstants::DescriptorSetBindings::SHADOW_MAP_IMAGE_SAMPLER_DATA, lightingSubSystem->GetViewSamplerLayout(NEW_SHADOW_MAP_INDEX), NEW_SHADOW_MAP_INDEX);
|
nodeCompute->ModifyWriteDescImageComputeResource(SHGraphicsConstants::DescriptorSetBindings::SHADOW_MAP_IMAGE_SAMPLER_DATA, lightingSubSystem->GetViewSamplerLayout(NEW_SHADOW_MAP_INDEX), NEW_SHADOW_MAP_INDEX);
|
||||||
|
|
|
@ -481,6 +481,7 @@ namespace SHADE
|
||||||
Handle<SHVkShaderModule> shadowMapFS;
|
Handle<SHVkShaderModule> shadowMapFS;
|
||||||
Handle<SHVkShaderModule> trajectoryVS;
|
Handle<SHVkShaderModule> trajectoryVS;
|
||||||
Handle<SHVkShaderModule> trajectoryFS;
|
Handle<SHVkShaderModule> trajectoryFS;
|
||||||
|
Handle<SHVkShaderModule> shadowMapBlurCS;
|
||||||
|
|
||||||
// Fonts
|
// Fonts
|
||||||
Handle<SHFont> testFont;
|
Handle<SHFont> testFont;
|
||||||
|
|
|
@ -53,7 +53,8 @@ namespace SHADE
|
||||||
SHVec4 transformedDir = SHMatrix::Transpose(viewMat) * SHVec4(lightData.direction[0], lightData.direction[1], lightData.direction[2], 0.0f);
|
SHVec4 transformedDir = SHMatrix::Transpose(viewMat) * SHVec4(lightData.direction[0], lightData.direction[1], lightData.direction[2], 0.0f);
|
||||||
|
|
||||||
lightPtr->cullingMask = lightData.cullingMask;
|
lightPtr->cullingMask = lightData.cullingMask;
|
||||||
lightPtr->direction = SHVec3 (transformedDir.x, transformedDir.y, transformedDir.z);
|
lightPtr->directionWorld = SHVec4 (lightData.direction.x, lightData.direction.y, lightData.direction.z, 1.0f);
|
||||||
|
lightPtr->direction = SHVec3(transformedDir.x, transformedDir.y, transformedDir.z);
|
||||||
//lightPtr->direction = lightData.direction;
|
//lightPtr->direction = lightData.direction;
|
||||||
lightPtr->diffuseColor = lightData.color;
|
lightPtr->diffuseColor = lightData.color;
|
||||||
lightPtr->active = lightComp->isActive;
|
lightPtr->active = lightComp->isActive;
|
||||||
|
@ -601,14 +602,14 @@ namespace SHADE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SHLightingSubSystem::AddShadowMap(Handle<SHRenderGraphResource> newShadowMap, EntityID lightEntity) noexcept
|
uint32_t SHLightingSubSystem::AddShadowMap(Handle<SHRenderGraphResource> newShadowMapBlurred, EntityID lightEntity) noexcept
|
||||||
{
|
{
|
||||||
// Add to container of shadow maps
|
// Add to container of shadow maps
|
||||||
shadowMapIndexing.emplace(lightEntity, static_cast<uint32_t> (shadowMaps.size()));
|
shadowMapIndexing.emplace(lightEntity, static_cast<uint32_t> (shadowMaps.size()));
|
||||||
shadowMaps.emplace_back(newShadowMap);
|
shadowMaps.emplace_back(newShadowMapBlurred);
|
||||||
|
|
||||||
// Just use the image view stored in the resource
|
// Just use the image view stored in the resource
|
||||||
Handle<SHVkImageView> const NEW_IMAGE_VIEW = newShadowMap->GetImageView();
|
Handle<SHVkImageView> const NEW_IMAGE_VIEW = newShadowMapBlurred->GetImageView();
|
||||||
|
|
||||||
// Prepare to write to descriptor
|
// Prepare to write to descriptor
|
||||||
shadowMapImageSamplers.emplace_back(NEW_IMAGE_VIEW, shadowMapSampler, vk::ImageLayout::eShaderReadOnlyOptimal);
|
shadowMapImageSamplers.emplace_back(NEW_IMAGE_VIEW, shadowMapSampler, vk::ImageLayout::eShaderReadOnlyOptimal);
|
||||||
|
@ -634,13 +635,13 @@ namespace SHADE
|
||||||
// add to barriers
|
// add to barriers
|
||||||
shadowMapMemoryBarriers.push_back (vk::ImageMemoryBarrier
|
shadowMapMemoryBarriers.push_back (vk::ImageMemoryBarrier
|
||||||
{
|
{
|
||||||
.srcAccessMask = vk::AccessFlagBits::eColorAttachmentWrite | vk::AccessFlagBits::eColorAttachmentRead,
|
.srcAccessMask = vk::AccessFlagBits::eShaderWrite,
|
||||||
.dstAccessMask = vk::AccessFlagBits::eShaderRead,
|
.dstAccessMask = vk::AccessFlagBits::eShaderRead,
|
||||||
.oldLayout = vk::ImageLayout::eColorAttachmentOptimal,
|
.oldLayout = vk::ImageLayout::eGeneral,
|
||||||
.newLayout = vk::ImageLayout::eShaderReadOnlyOptimal,
|
.newLayout = vk::ImageLayout::eGeneral,
|
||||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
.image = newShadowMap->GetImage()->GetVkImage(),
|
.image = newShadowMapBlurred->GetImage()->GetVkImage(),
|
||||||
.subresourceRange = vk::ImageSubresourceRange
|
.subresourceRange = vk::ImageSubresourceRange
|
||||||
{
|
{
|
||||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||||
|
@ -658,7 +659,7 @@ namespace SHADE
|
||||||
void SHLightingSubSystem::PrepareShadowMapsForRead(Handle<SHVkCommandBuffer> cmdBuffer) noexcept
|
void SHLightingSubSystem::PrepareShadowMapsForRead(Handle<SHVkCommandBuffer> cmdBuffer) noexcept
|
||||||
{
|
{
|
||||||
// Issue barrier to transition shadow maps for reading in compute shader
|
// Issue barrier to transition shadow maps for reading in compute shader
|
||||||
cmdBuffer->PipelineBarrier(vk::PipelineStageFlagBits::eColorAttachmentOutput, vk::PipelineStageFlagBits::eComputeShader, {}, {}, {}, shadowMapMemoryBarriers);
|
cmdBuffer->PipelineBarrier(vk::PipelineStageFlagBits::eComputeShader, vk::PipelineStageFlagBits::eComputeShader, {}, {}, {}, shadowMapMemoryBarriers);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void SHLightingSubSystem::HandleResize(Handle<SHRenderGraphNodeCompute> compute) noexcept
|
//void SHLightingSubSystem::HandleResize(Handle<SHRenderGraphNodeCompute> compute) noexcept
|
||||||
|
|
|
@ -28,6 +28,9 @@ namespace SHADE
|
||||||
// Represents how the data will be interpreted in GPU. we want to copy to a container of these before passing to GPU.
|
// Represents how the data will be interpreted in GPU. we want to copy to a container of these before passing to GPU.
|
||||||
struct SHDirectionalLightData
|
struct SHDirectionalLightData
|
||||||
{
|
{
|
||||||
|
//! Direction of the light
|
||||||
|
SHVec4 directionWorld;
|
||||||
|
|
||||||
//! Direction of the light
|
//! Direction of the light
|
||||||
SHVec3 direction;
|
SHVec3 direction;
|
||||||
|
|
||||||
|
@ -213,7 +216,7 @@ namespace SHADE
|
||||||
void Run (SHMatrix const& viewMat, uint32_t frameIndex) noexcept;
|
void Run (SHMatrix const& viewMat, uint32_t frameIndex) noexcept;
|
||||||
void Exit (void) noexcept;
|
void Exit (void) noexcept;
|
||||||
void BindDescSet (Handle<SHVkCommandBuffer> cmdBuffer, uint32_t setIndex, uint32_t frameIndex) noexcept;
|
void BindDescSet (Handle<SHVkCommandBuffer> cmdBuffer, uint32_t setIndex, uint32_t frameIndex) noexcept;
|
||||||
uint32_t AddShadowMap (Handle<SHRenderGraphResource> newShadowMap, EntityID lightEntity) noexcept;
|
uint32_t AddShadowMap (Handle<SHRenderGraphResource> newShadowMapBlurred, EntityID lightEntity) noexcept;
|
||||||
void PrepareShadowMapsForRead (Handle<SHVkCommandBuffer> cmdBuffer) noexcept;
|
void PrepareShadowMapsForRead (Handle<SHVkCommandBuffer> cmdBuffer) noexcept;
|
||||||
//void HandleResize (Handle<SHRenderGraphNodeCompute> compute) noexcept;
|
//void HandleResize (Handle<SHRenderGraphNodeCompute> compute) noexcept;
|
||||||
//void RemoveShadowMap (uint32_t index) noexcept;
|
//void RemoveShadowMap (uint32_t index) noexcept;
|
||||||
|
|
|
@ -798,6 +798,7 @@ namespace SHADE
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
void SHRenderGraphNode::RuntimeStandaloneRegenerate(void) noexcept
|
void SHRenderGraphNode::RuntimeStandaloneRegenerate(void) noexcept
|
||||||
{
|
{
|
||||||
|
AddDummySubpassIfNeeded();
|
||||||
StandaloneConfigureAttDesc(false);
|
StandaloneConfigureAttDesc(false);
|
||||||
ConfigureSubpasses();
|
ConfigureSubpasses();
|
||||||
CreateRenderpass();
|
CreateRenderpass();
|
||||||
|
|
Loading…
Reference in New Issue