Implemented scanline and silhouette effect #363
|
@ -0,0 +1,8 @@
|
||||||
|
- VertexShader: 37048829
|
||||||
|
FragmentShader: 45685219
|
||||||
|
SubPass: G-Buffer Write
|
||||||
|
Properties:
|
||||||
|
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
data.textureIndex: 57342922
|
||||||
|
data.alpha: 0
|
||||||
|
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: ShinyHightlight
|
||||||
|
ID: 122370915
|
||||||
|
Type: 7
|
|
@ -8599,7 +8599,7 @@
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Renderable Component:
|
Renderable Component:
|
||||||
Mesh: 136892700
|
Mesh: 136892700
|
||||||
Material: 131956078
|
Material: 122370915
|
||||||
IsActive: true
|
IsActive: true
|
||||||
RigidBody Component:
|
RigidBody Component:
|
||||||
Type: Dynamic
|
Type: Dynamic
|
||||||
|
@ -9571,7 +9571,11 @@
|
||||||
Name: =====Text====
|
Name: =====Text====
|
||||||
IsActive: true
|
IsActive: true
|
||||||
NumberOfChildren: 3
|
NumberOfChildren: 3
|
||||||
Components: ~
|
Components:
|
||||||
|
Canvas Component:
|
||||||
|
Canvas Width: 1920
|
||||||
|
Canvas Height: 1080
|
||||||
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 237
|
- EID: 237
|
||||||
Name: Score
|
Name: Score
|
||||||
|
@ -9587,6 +9591,9 @@
|
||||||
Text: My name is Brandon.
|
Text: My name is Brandon.
|
||||||
Font: 176667660
|
Font: 176667660
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
UI Component:
|
||||||
|
Canvas ID: 199
|
||||||
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 206
|
- EID: 206
|
||||||
Name: Timer
|
Name: Timer
|
||||||
|
@ -9602,6 +9609,9 @@
|
||||||
Text: My name is Brandon.
|
Text: My name is Brandon.
|
||||||
Font: 176667660
|
Font: 176667660
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
UI Component:
|
||||||
|
Canvas ID: 199
|
||||||
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 139
|
- EID: 139
|
||||||
Name: Multiplier
|
Name: Multiplier
|
||||||
|
@ -9617,6 +9627,9 @@
|
||||||
Text: TEST
|
Text: TEST
|
||||||
Font: 176667660
|
Font: 176667660
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
UI Component:
|
||||||
|
Canvas ID: 199
|
||||||
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 198
|
- EID: 198
|
||||||
Name: ====Raccoon====
|
Name: ====Raccoon====
|
||||||
|
@ -9687,6 +9700,7 @@
|
||||||
aimingLength: 1
|
aimingLength: 1
|
||||||
throwItem: false
|
throwItem: false
|
||||||
rayDistance: 0.75
|
rayDistance: 0.75
|
||||||
|
rayHeight: 0.100000001
|
||||||
- EID: 3
|
- EID: 3
|
||||||
Name: HoldingPoint
|
Name: HoldingPoint
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -9713,11 +9727,12 @@
|
||||||
Pitch: 0
|
Pitch: 0
|
||||||
Yaw: 360
|
Yaw: 360
|
||||||
Roll: 1.28065994e-06
|
Roll: 1.28065994e-06
|
||||||
Width: 1920
|
Width: 1728
|
||||||
Height: 1080
|
Height: 832
|
||||||
Near: 0.00999999978
|
Near: 0.00999999978
|
||||||
Far: 10000
|
Far: 10000
|
||||||
Perspective: true
|
Perspective: true
|
||||||
|
FOV: 90
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Camera Arm Component:
|
Camera Arm Component:
|
||||||
Arm Pitch: 0
|
Arm Pitch: 0
|
||||||
|
|
|
@ -26,6 +26,7 @@ layout(set = 3, binding = 3, r32ui) 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;
|
||||||
|
layout(set = 3, binding = 7, rgba8) uniform image2D objectVFXImage;
|
||||||
|
|
||||||
layout (set = 4, binding = 0) uniform sampler2D shadowMaps[]; // for textures (global)
|
layout (set = 4, binding = 0) uniform sampler2D shadowMaps[]; // for textures (global)
|
||||||
|
|
||||||
|
@ -141,6 +142,9 @@ void main()
|
||||||
float ssaoVal = imageLoad (ssaoBlurredImage, globalThread).r;
|
float ssaoVal = imageLoad (ssaoBlurredImage, globalThread).r;
|
||||||
fragColor *= ssaoVal;
|
fragColor *= ssaoVal;
|
||||||
|
|
||||||
|
vec4 objectVFXColor = imageLoad (objectVFXImage, globalThread);
|
||||||
|
fragColor += objectVFXColor.rgb * objectVFXColor.a;
|
||||||
|
|
||||||
// store result into result image
|
// store result into result image
|
||||||
imageStore(targetImage, ivec2(gl_GlobalInvocationID.xy), vec4(fragColor.rgb, 1.0f));
|
imageStore(targetImage, ivec2(gl_GlobalInvocationID.xy), vec4(fragColor.rgb, 1.0f));
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,84 @@
|
||||||
|
#version 450
|
||||||
|
#extension GL_ARB_separate_shader_objects : enable
|
||||||
|
#extension GL_ARB_shading_language_420pack : enable
|
||||||
|
#extension GL_EXT_nonuniform_qualifier : require
|
||||||
|
|
||||||
|
struct MatPropData
|
||||||
|
{
|
||||||
|
int textureIndex;
|
||||||
|
float highlightPosition;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GenericData
|
||||||
|
{
|
||||||
|
//! Delta time
|
||||||
|
float dt;
|
||||||
|
|
||||||
|
//! Elapsed time of the application
|
||||||
|
float elapsedTime;
|
||||||
|
|
||||||
|
//! Viewport width of the scene (excluding imgui, that means smaller than window)
|
||||||
|
uint viewportWidth;
|
||||||
|
|
||||||
|
//! Ditto but for height
|
||||||
|
uint viewportHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
layout(location = 0) in struct
|
||||||
|
{
|
||||||
|
vec4 vertPos; // location 0
|
||||||
|
vec2 uv; // location = 1
|
||||||
|
vec4 normal; // location = 2
|
||||||
|
vec4 worldPos; // location = 3
|
||||||
|
} In;
|
||||||
|
|
||||||
|
// material stuff
|
||||||
|
layout(location = 4) flat in struct
|
||||||
|
{
|
||||||
|
int materialIndex;
|
||||||
|
uint eid;
|
||||||
|
uint lightLayerIndex;
|
||||||
|
vec3 screenSpacePos;
|
||||||
|
|
||||||
|
} In2;
|
||||||
|
|
||||||
|
layout (set = 0, binding = 0) uniform GenericDataBuffer
|
||||||
|
{
|
||||||
|
GenericData data;
|
||||||
|
} genericDataBuffer;
|
||||||
|
|
||||||
|
layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global)
|
||||||
|
layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials
|
||||||
|
{
|
||||||
|
MatPropData data[];
|
||||||
|
} MatProp;
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 position;
|
||||||
|
layout(location = 1) out uint outEntityID;
|
||||||
|
layout(location = 2) out uint lightLayerIndices;
|
||||||
|
layout(location = 3) out vec4 normals;
|
||||||
|
layout(location = 4) out vec4 albedo;
|
||||||
|
layout(location = 5) out vec4 worldSpacePosition;
|
||||||
|
layout(location = 6) out vec4 objectVFX;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
position = In.vertPos;
|
||||||
|
normals = In.normal;
|
||||||
|
albedo = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
|
||||||
|
worldSpacePosition = In.worldPos;
|
||||||
|
|
||||||
|
outEntityID = In2.eid;
|
||||||
|
lightLayerIndices = In2.lightLayerIndex;
|
||||||
|
|
||||||
|
float vpHeight = float (In2.screenSpacePos.y);
|
||||||
|
float scanlineScale = 300.0f * (1.0f - In2.screenSpacePos.z);
|
||||||
|
|
||||||
|
float lowerLimit = vpHeight - scanlineScale;
|
||||||
|
float upperLimit = vpHeight + scanlineScale;
|
||||||
|
if (gl_FragCoord.y > lowerLimit && gl_FragCoord.y < upperLimit)
|
||||||
|
objectVFX = vec4(1.0f);
|
||||||
|
else
|
||||||
|
objectVFX = vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
Name: ShinyHighlight_FS
|
||||||
|
ID: 45685219
|
||||||
|
Type: 2
|
|
@ -0,0 +1,99 @@
|
||||||
|
#version 450
|
||||||
|
#extension GL_KHR_vulkan_glsl : enable
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 aVertexPos;
|
||||||
|
layout(location = 1) in vec2 aUV;
|
||||||
|
layout(location = 2) in vec3 aNormal;
|
||||||
|
layout(location = 3) in vec3 aTangent;
|
||||||
|
layout(location = 4) in mat4 worldTransform;
|
||||||
|
layout(location = 8) in uvec2 integerData;
|
||||||
|
layout(location = 9) in uvec4 aBoneIndices;
|
||||||
|
layout(location = 10) in vec4 aBoneWeights;
|
||||||
|
layout(location = 11) in uint firstBoneIndex;
|
||||||
|
|
||||||
|
layout(location = 0) out struct
|
||||||
|
{
|
||||||
|
vec4 vertPos; // location 0
|
||||||
|
vec2 uv; // location = 1
|
||||||
|
vec4 normal; // location = 2
|
||||||
|
vec4 worldPos; // location = 3
|
||||||
|
|
||||||
|
} Out;
|
||||||
|
|
||||||
|
struct GenericData
|
||||||
|
{
|
||||||
|
//! Delta time
|
||||||
|
float dt;
|
||||||
|
|
||||||
|
//! Elapsed time of the application
|
||||||
|
float elapsedTime;
|
||||||
|
|
||||||
|
//! Viewport width of the scene (excluding imgui, that means smaller than window)
|
||||||
|
uint viewportWidth;
|
||||||
|
|
||||||
|
//! Ditto but for height
|
||||||
|
uint viewportHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
// material stuff
|
||||||
|
layout(location = 4) out struct
|
||||||
|
{
|
||||||
|
int materialIndex;
|
||||||
|
uint eid;
|
||||||
|
uint lightLayerIndex;
|
||||||
|
vec3 screenSpacePos;
|
||||||
|
|
||||||
|
|
||||||
|
} Out2;
|
||||||
|
|
||||||
|
layout(set = 1, binding = 0) uniform CameraData
|
||||||
|
{
|
||||||
|
vec4 position;
|
||||||
|
mat4 vpMat;
|
||||||
|
mat4 viewMat;
|
||||||
|
mat4 projMat;
|
||||||
|
} cameraData;
|
||||||
|
|
||||||
|
layout (set = 0, binding = 0) uniform GenericDataBuffer
|
||||||
|
{
|
||||||
|
GenericData data;
|
||||||
|
} genericDataBuffer;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
Out2.materialIndex = gl_InstanceIndex;
|
||||||
|
Out2.eid = integerData[0];
|
||||||
|
Out2.lightLayerIndex = integerData[1];
|
||||||
|
|
||||||
|
// for transforming gBuffer position and normal data
|
||||||
|
mat4 modelViewMat = cameraData.viewMat * worldTransform;
|
||||||
|
|
||||||
|
// gBuffer position will be in view space
|
||||||
|
Out.vertPos = modelViewMat * vec4(aVertexPos, 1.0f);
|
||||||
|
|
||||||
|
Out.worldPos = worldTransform * vec4 (aVertexPos, 1.0f);
|
||||||
|
|
||||||
|
// uvs for texturing in fragment shader
|
||||||
|
Out.uv = aUV;
|
||||||
|
|
||||||
|
mat3 transposeInv = mat3 (transpose(inverse(modelViewMat)));
|
||||||
|
|
||||||
|
// normals are also in view space
|
||||||
|
Out.normal.rgb = transposeInv * aNormal.rgb;
|
||||||
|
Out.normal.rgb = normalize (Out.normal.rgb);
|
||||||
|
|
||||||
|
// Get center of object in world position
|
||||||
|
vec4 worldPos = vec4(worldTransform[3][0], worldTransform[3][1], worldTransform[3][2], 1.0f);
|
||||||
|
|
||||||
|
// transform to clip space
|
||||||
|
worldPos = cameraData.vpMat * worldPos;
|
||||||
|
worldPos.xyz /= worldPos.w;
|
||||||
|
|
||||||
|
// transform to screen space
|
||||||
|
worldPos.xy = ((worldPos.xy + vec2(1.0f)) * vec2 (0.5f)) * vec2 (genericDataBuffer.data.viewportWidth, genericDataBuffer.data.viewportHeight);
|
||||||
|
|
||||||
|
Out2.screenSpacePos = worldPos.xyz;
|
||||||
|
|
||||||
|
// clip space for rendering
|
||||||
|
gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
Name: ShinyHighlight_VS
|
||||||
|
ID: 37048829
|
||||||
|
Type: 2
|
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
struct SHCompileAssetEvent
|
||||||
|
{
|
||||||
|
//! Name of the shader. Should just contain stem from file path.
|
||||||
|
std::string shaderName;
|
||||||
|
|
||||||
|
//! NEw binary data for shader module to use
|
||||||
|
std::vector<uint32_t> newBinaryData;
|
||||||
|
|
||||||
|
//! Extension to check for type
|
||||||
|
std::string ext;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
#include "SHShaderSourceCompiler.h"
|
#include "SHShaderSourceCompiler.h"
|
||||||
#include "shaderc/shaderc.hpp"
|
#include "shaderc/shaderc.hpp"
|
||||||
|
#include "Assets/Events/SHAssetManagerEvents.h"
|
||||||
|
#include "Events/SHEventManager.hpp"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -140,6 +142,14 @@ namespace SHADE
|
||||||
return{};
|
return{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHCompileAssetEvent compileShaderEvent
|
||||||
|
{
|
||||||
|
.shaderName = std::filesystem::path (data->name).stem().string(),
|
||||||
|
.newBinaryData = data->spirvBinary,
|
||||||
|
.ext = GLSL_EXTENSION.data(),
|
||||||
|
};
|
||||||
|
SHEventManager::BroadcastEvent<SHCompileAssetEvent>(compileShaderEvent, SH_ASSET_COMPILE_EVENT);
|
||||||
|
|
||||||
return CompileShaderSourceToBinary(path, *data);
|
return CompileShaderSourceToBinary(path, *data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,4 +26,5 @@ constexpr SHEventIdentifier SH_GRAPHICS_LIGHT_ENABLE_SHADOW_EVENT { 17 };
|
||||||
constexpr SHEventIdentifier SH_BUTTON_CLICK_EVENT { 18 };
|
constexpr SHEventIdentifier SH_BUTTON_CLICK_EVENT { 18 };
|
||||||
constexpr SHEventIdentifier SH_PHYSICS_COLLIDER_DRAW_EVENT { 19 };
|
constexpr SHEventIdentifier SH_PHYSICS_COLLIDER_DRAW_EVENT { 19 };
|
||||||
constexpr SHEventIdentifier SH_WINDOW_RESIZE_EVENT { 20 };
|
constexpr SHEventIdentifier SH_WINDOW_RESIZE_EVENT { 20 };
|
||||||
|
constexpr SHEventIdentifier SH_ASSET_COMPILE_EVENT { 21 };
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
#include "SHpch.h"
|
||||||
|
#include "SHGraphicsGenericData.h"
|
||||||
|
#include "Graphics/Devices/SHVkLogicalDevice.h"
|
||||||
|
#include "Graphics/MiddleEnd/Interface/SHGraphicsConstants.h"
|
||||||
|
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"
|
||||||
|
#include "Graphics/Buffers/SHVkBuffer.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
void SHGraphicsGenericData::Init(Handle<SHVkLogicalDevice> logicalDevice, Handle<SHVkDescriptorSetGroup> descSet) noexcept
|
||||||
|
{
|
||||||
|
alignedGpuStructSize = logicalDevice->PadUBOSize(sizeof (GpuStruct));
|
||||||
|
|
||||||
|
gpuBuffer = logicalDevice->CreateBuffer(alignedGpuStructSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, nullptr, alignedGpuStructSize * SHGraphicsConstants::NUM_FRAME_BUFFERS, vk::BufferUsageFlagBits::eUniformBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT, "Generic Data");
|
||||||
|
|
||||||
|
std::array gpuBufferArray{ gpuBuffer };
|
||||||
|
|
||||||
|
// We use index 0 because the descriptor set is standalone created from a single desc set layout. What the driver sees is that this set is at index 0 during updating.
|
||||||
|
static constexpr uint8_t SET_0 = 0;
|
||||||
|
|
||||||
|
descSet->ModifyWriteDescBuffer(SET_0, SHGraphicsConstants::DescriptorSetBindings::GENERIC_DATA, std::span<Handle<SHVkBuffer>>{ gpuBufferArray.data(), gpuBufferArray.size()}, 0, sizeof(GpuStruct));
|
||||||
|
|
||||||
|
descSet->UpdateDescriptorSetBuffer(SET_0, SHGraphicsConstants::DescriptorSetBindings::GENERIC_DATA);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsGenericData::UpdateBuffer(uint32_t frameIndex) noexcept
|
||||||
|
{
|
||||||
|
gpuBuffer->WriteToMemory(&data, sizeof(GpuStruct), 0, alignedGpuStructSize * frameIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsGenericData::SetDt(float dt) noexcept
|
||||||
|
{
|
||||||
|
data.dt = dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsGenericData::UpdateElapsedTime(float dt) noexcept
|
||||||
|
{
|
||||||
|
data.elapsedTime += dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsGenericData::SetViewportWidth(uint32_t width) noexcept
|
||||||
|
{
|
||||||
|
data.viewportWidth = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsGenericData::SetViewportHeight(uint32_t height) noexcept
|
||||||
|
{
|
||||||
|
data.viewportHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include "Resource/SHHandle.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
class SHVkDescriptorSetGroup;
|
||||||
|
class SHVkBuffer;
|
||||||
|
class SHVkLogicalDevice;
|
||||||
|
|
||||||
|
class SHGraphicsGenericData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct GpuStruct
|
||||||
|
{
|
||||||
|
//! Delta time
|
||||||
|
float dt{ 0.0f };
|
||||||
|
|
||||||
|
//! Elapsed time of the application
|
||||||
|
float elapsedTime{ 0.0f };
|
||||||
|
|
||||||
|
//! Viewport width of the scene (excluding imgui, that means smaller than window)
|
||||||
|
uint32_t viewportWidth{ 0 };
|
||||||
|
|
||||||
|
//! Ditto but for height
|
||||||
|
uint32_t viewportHeight{ 0 };
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
|
||||||
|
//! This will be access
|
||||||
|
GpuStruct data;
|
||||||
|
|
||||||
|
//! Buffer to hold the generic data
|
||||||
|
Handle<SHVkBuffer> gpuBuffer;
|
||||||
|
|
||||||
|
//! gpu struct size for GPU to use
|
||||||
|
uint32_t alignedGpuStructSize;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Init (Handle<SHVkLogicalDevice> logicalDevice, Handle<SHVkDescriptorSetGroup> descSet) noexcept;
|
||||||
|
void UpdateBuffer(uint32_t frameIndex) noexcept;
|
||||||
|
|
||||||
|
void SetDt (float dt) noexcept;
|
||||||
|
void UpdateElapsedTime (float dt) noexcept;
|
||||||
|
void SetViewportWidth(uint32_t width) noexcept;
|
||||||
|
void SetViewportHeight(uint32_t height) noexcept;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
#include "SHGlobalDescriptorSets.h"
|
#include "SHGlobalDescriptorSets.h"
|
||||||
#include "Graphics/MiddleEnd/Lights/SHLightingSubSystem.h"
|
#include "Graphics/MiddleEnd/Lights/SHLightingSubSystem.h"
|
||||||
#include "Graphics/Commands/SHVkCommandBuffer.h"
|
#include "Graphics/Commands/SHVkCommandBuffer.h"
|
||||||
|
#include "Graphics/MiddleEnd/GenericData/SHGraphicsGenericData.h"
|
||||||
|
#include "Graphics/Devices/SHVkLogicalDevice.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
||||||
Handle<SHVkDescriptorSetGroup> SHGlobalDescriptorSets::staticGlobalDataDescriptorSet;
|
Handle<SHVkDescriptorSetGroup> SHGlobalDescriptorSets::genericAndTextureDataDescSet;
|
||||||
Handle<SHLightingSubSystem> SHGlobalDescriptorSets::lightingSubSystem;
|
Handle<SHLightingSubSystem> SHGlobalDescriptorSets::lightingSubSystem;
|
||||||
|
|
||||||
//void SHGlobalDescriptorSets::BindLightingData(Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t firstSet) noexcept
|
//void SHGlobalDescriptorSets::BindLightingData(Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t firstSet) noexcept
|
||||||
|
@ -20,11 +22,13 @@ namespace SHADE
|
||||||
lightingSubSystem->BindDescSet(cmdBuffer, setIndex, frameIndex);
|
lightingSubSystem->BindDescSet(cmdBuffer, setIndex, frameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHGlobalDescriptorSets::BindStaticGlobalData(Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex) noexcept
|
void SHGlobalDescriptorSets::BindGenericAndTextureData(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept
|
||||||
{
|
{
|
||||||
|
uint32_t alignedGenericStructSize = device->PadUBOSize(sizeof(SHGraphicsGenericData::GpuStruct));
|
||||||
|
|
||||||
// Bind descriptor set for static global data
|
// Bind descriptor set for static global data
|
||||||
static std::array<uint32_t, 1> TEX_DYNAMIC_OFFSET{ 0 };
|
static std::array TEX_DYNAMIC_OFFSET = { alignedGenericStructSize, };
|
||||||
cmdBuffer->BindDescriptorSet(staticGlobalDataDescriptorSet, pipelineType, setIndex, std::span{ TEX_DYNAMIC_OFFSET.data(), 1 });
|
cmdBuffer->BindDescriptorSet(genericAndTextureDataDescSet, pipelineType, setIndex, std::span{ TEX_DYNAMIC_OFFSET.data(), 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
@ -43,9 +47,9 @@ namespace SHADE
|
||||||
lightingSubSystem = system;
|
lightingSubSystem = system;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(Handle<SHVkDescriptorSetGroup> staticGlobalDescSet) noexcept
|
void SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(Handle<SHVkDescriptorSetGroup> descSet) noexcept
|
||||||
{
|
{
|
||||||
staticGlobalDataDescriptorSet = staticGlobalDescSet;
|
genericAndTextureDataDescSet = descSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@ namespace SHADE
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Static global descriptor sets for miscellaneous data and textures
|
//! Static global descriptor sets for miscellaneous data and textures
|
||||||
static Handle<SHVkDescriptorSetGroup> staticGlobalDataDescriptorSet;
|
static Handle<SHVkDescriptorSetGroup> genericAndTextureDataDescSet;
|
||||||
|
|
||||||
//! Lighting sub system required to get information to bind descriptor sets for light data
|
//! Lighting sub system required to get information to bind descriptor sets for light data
|
||||||
static Handle<SHLightingSubSystem> lightingSubSystem;
|
static Handle<SHLightingSubSystem> lightingSubSystem;
|
||||||
|
@ -25,7 +25,7 @@ namespace SHADE
|
||||||
/* PUBLIC MEMBER FUNCTIONS */
|
/* PUBLIC MEMBER FUNCTIONS */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
static void BindLightingData (Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept;
|
static void BindLightingData (Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept;
|
||||||
static void BindStaticGlobalData (Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex) noexcept;
|
static void BindGenericAndTextureData (Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, SH_PIPELINE_TYPE pipelineType, uint32_t setIndex, uint32_t frameIndex) noexcept;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* SETTERS AND GETTERS */
|
/* SETTERS AND GETTERS */
|
||||||
|
|
|
@ -47,6 +47,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Events/SHEvent.h"
|
#include "Events/SHEvent.h"
|
||||||
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
|
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
|
||||||
#include "Input/SHInputManager.h"
|
#include "Input/SHInputManager.h"
|
||||||
|
#include "Assets/Events/SHAssetManagerEvents.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -210,6 +211,7 @@ namespace SHADE
|
||||||
renderGraph->Init("World Render Graph", device, swapchain, &resourceManager, renderContextCmdPools);
|
renderGraph->Init("World Render Graph", device, swapchain, &resourceManager, renderContextCmdPools);
|
||||||
renderGraph->AddResource("Position", { 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::eR32G32B32A32Sfloat);
|
renderGraph->AddResource("Position", { 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::eR32G32B32A32Sfloat);
|
||||||
renderGraph->AddResource("Position World Space", { 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::eR32G32B32A32Sfloat);
|
renderGraph->AddResource("Position World Space", { 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::eR32G32B32A32Sfloat);
|
||||||
|
renderGraph->AddResource("Object VFX", { 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::eR32G32B32A32Sfloat);
|
||||||
renderGraph->AddResource("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::eR32G32B32A32Sfloat);
|
renderGraph->AddResource("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::eR32G32B32A32Sfloat);
|
||||||
//worldRenderGraph->AddResource("Tangents", { SH_ATT_DESC_TYPE_FLAGS::COLOR, SH_ATT_DESC_TYPE_FLAGS::INPUT, SH_ATT_DESC_TYPE_FLAGS::STORAGE }, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat);
|
//worldRenderGraph->AddResource("Tangents", { SH_ATT_DESC_TYPE_FLAGS::COLOR, SH_ATT_DESC_TYPE_FLAGS::INPUT, SH_ATT_DESC_TYPE_FLAGS::STORAGE }, windowDims.first, windowDims.second, vk::Format::eR32G32B32A32Sfloat);
|
||||||
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);
|
||||||
|
@ -235,7 +237,8 @@ namespace SHADE
|
||||||
"Depth Buffer",
|
"Depth Buffer",
|
||||||
"SSAO",
|
"SSAO",
|
||||||
"SSAO Blur",
|
"SSAO Blur",
|
||||||
"Position World Space"
|
"Position World Space",
|
||||||
|
"Object VFX"
|
||||||
},
|
},
|
||||||
{}); // no predecessors
|
{}); // no predecessors
|
||||||
|
|
||||||
|
@ -249,6 +252,7 @@ namespace SHADE
|
||||||
gBufferSubpass->AddColorOutput("Normals");
|
gBufferSubpass->AddColorOutput("Normals");
|
||||||
gBufferSubpass->AddColorOutput("Albedo");
|
gBufferSubpass->AddColorOutput("Albedo");
|
||||||
gBufferSubpass->AddColorOutput("Position World Space");
|
gBufferSubpass->AddColorOutput("Position World Space");
|
||||||
|
gBufferSubpass->AddColorOutput("Object VFX");
|
||||||
gBufferSubpass->AddDepthOutput("Depth Buffer", SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL);
|
gBufferSubpass->AddDepthOutput("Depth Buffer", SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL);
|
||||||
|
|
||||||
usableSubpassesMapping.emplace (std::string (SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data()), gBufferSubpass);
|
usableSubpassesMapping.emplace (std::string (SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data()), gBufferSubpass);
|
||||||
|
@ -297,15 +301,15 @@ namespace SHADE
|
||||||
"Albedo",
|
"Albedo",
|
||||||
"Scene",
|
"Scene",
|
||||||
"SSAO Blur",
|
"SSAO Blur",
|
||||||
"Position World Space"
|
"Position World Space",
|
||||||
|
"Object VFX"
|
||||||
},
|
},
|
||||||
{ SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS .data()});
|
{ SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS .data()});
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* 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"}, {}, SHLightingSubSystem::MAX_SHADOWS);
|
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);
|
||||||
deferredCompositeCompute->AddPreComputeFunction([=](Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex)
|
deferredCompositeCompute->AddPreComputeFunction([=](Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex)
|
||||||
{
|
{
|
||||||
lightingSubSystem->PrepareShadowMapsForRead(cmdBuffer);
|
lightingSubSystem->PrepareShadowMapsForRead(cmdBuffer);
|
||||||
|
@ -409,7 +413,6 @@ namespace SHADE
|
||||||
|
|
||||||
InitRenderGraph();
|
InitRenderGraph();
|
||||||
|
|
||||||
|
|
||||||
// Create Semaphore
|
// Create Semaphore
|
||||||
for (auto& semaHandle : graphSemaphores)
|
for (auto& semaHandle : graphSemaphores)
|
||||||
{
|
{
|
||||||
|
@ -491,12 +494,34 @@ namespace SHADE
|
||||||
|
|
||||||
void SHGraphicsSystem::InitEvents(void) noexcept
|
void SHGraphicsSystem::InitEvents(void) noexcept
|
||||||
{
|
{
|
||||||
std::shared_ptr<SHEventReceiverSpec<SHGraphicsSystem>> thisReceiver
|
std::shared_ptr<SHEventReceiverSpec<SHGraphicsSystem>> lightEnableShadowReceiver
|
||||||
{
|
{
|
||||||
std::make_shared<SHEventReceiverSpec<SHGraphicsSystem>>(this, &SHGraphicsSystem::ReceiveLightEnableShadowEvent)
|
std::make_shared<SHEventReceiverSpec<SHGraphicsSystem>>(this, &SHGraphicsSystem::ReceiveLightEnableShadowEvent)
|
||||||
};
|
};
|
||||||
ReceiverPtr receiver = std::dynamic_pointer_cast<SHEventReceiver>(thisReceiver);
|
ReceiverPtr lightEnableShadowReceivePtr = std::dynamic_pointer_cast<SHEventReceiver>(lightEnableShadowReceiver);
|
||||||
SHEventManager::SubscribeTo(SH_GRAPHICS_LIGHT_ENABLE_SHADOW_EVENT, receiver);
|
SHEventManager::SubscribeTo(SH_GRAPHICS_LIGHT_ENABLE_SHADOW_EVENT, lightEnableShadowReceivePtr);
|
||||||
|
|
||||||
|
std::shared_ptr<SHEventReceiverSpec<SHGraphicsSystem>> compileAssetReceiever
|
||||||
|
{
|
||||||
|
std::make_shared<SHEventReceiverSpec<SHGraphicsSystem>>(this, &SHGraphicsSystem::ReceiveCompileAssetEvent)
|
||||||
|
};
|
||||||
|
ReceiverPtr compileAssetReceivePtr = std::dynamic_pointer_cast<SHEventReceiver>(compileAssetReceiever);
|
||||||
|
SHEventManager::SubscribeTo(SH_ASSET_COMPILE_EVENT, compileAssetReceivePtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHGraphicsSystem::InitGenericDataAndTexturesDescSet(void) noexcept
|
||||||
|
{
|
||||||
|
// descriptor set for generic data and textures
|
||||||
|
genericAndTextureDescSet = descPool->Allocate(SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA), { SHTextureLibrary::DEFAULT_MAX_TEXTURES });
|
||||||
|
|
||||||
|
for (auto set : genericAndTextureDescSet->GetVkHandle())
|
||||||
|
SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals");
|
||||||
|
|
||||||
|
SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(genericAndTextureDescSet);
|
||||||
|
|
||||||
|
// Create buffer for generic data and attach to descriptor set
|
||||||
|
graphicsGenericData.Init(device, genericAndTextureDescSet);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -507,6 +532,7 @@ namespace SHADE
|
||||||
InitBoilerplate();
|
InitBoilerplate();
|
||||||
InitMiddleEnd();
|
InitMiddleEnd();
|
||||||
InitSubsystems();
|
InitSubsystems();
|
||||||
|
InitGenericDataAndTexturesDescSet();
|
||||||
InitBuiltInResources();
|
InitBuiltInResources();
|
||||||
InitEvents();
|
InitEvents();
|
||||||
}
|
}
|
||||||
|
@ -536,7 +562,7 @@ namespace SHADE
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
void SHGraphicsSystem::Run(double) noexcept
|
void SHGraphicsSystem::Run(double dt) noexcept
|
||||||
{
|
{
|
||||||
if (window->IsMinimized() || renderContext.GetWindowIsDead())
|
if (window->IsMinimized() || renderContext.GetWindowIsDead())
|
||||||
{
|
{
|
||||||
|
@ -572,6 +598,9 @@ namespace SHADE
|
||||||
|
|
||||||
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||||
|
|
||||||
|
graphicsGenericData.SetDt(dt);
|
||||||
|
graphicsGenericData.UpdateElapsedTime(dt);
|
||||||
|
graphicsGenericData.UpdateBuffer(frameIndex);
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
|
@ -860,6 +889,23 @@ namespace SHADE
|
||||||
return eventPtr->handle;
|
return eventPtr->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHEventHandle SHGraphicsSystem::ReceiveCompileAssetEvent(SHEventPtr eventPtr) noexcept
|
||||||
|
{
|
||||||
|
auto const& EVENT_DATA = reinterpret_cast<const SHEventSpec<SHCompileAssetEvent>*>(eventPtr.get())->data;
|
||||||
|
|
||||||
|
auto denseIterators = SHVkInstance::GetResourceManager().GetDenseAccess<SHVkShaderModule>();
|
||||||
|
for (auto it = denseIterators.first; it != denseIterators.second; ++it)
|
||||||
|
{
|
||||||
|
if (it->GetName() == EVENT_DATA->shaderName)
|
||||||
|
{
|
||||||
|
it->OnChange();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return eventPtr->handle;
|
||||||
|
}
|
||||||
|
|
||||||
Handle<SHMaterial> SHGraphicsSystem::AddMaterial(Handle<SHVkShaderModule> vertShader, Handle<SHVkShaderModule> fragShader, Handle<SHSubpass> subpass)
|
Handle<SHMaterial> SHGraphicsSystem::AddMaterial(Handle<SHVkShaderModule> vertShader, Handle<SHVkShaderModule> fragShader, Handle<SHSubpass> subpass)
|
||||||
{
|
{
|
||||||
// Retrieve pipeline from pipeline storage or create if unavailable
|
// Retrieve pipeline from pipeline storage or create if unavailable
|
||||||
|
@ -980,12 +1026,11 @@ namespace SHADE
|
||||||
device->WaitIdle();
|
device->WaitIdle();
|
||||||
texLibrary.BuildTextures
|
texLibrary.BuildTextures
|
||||||
(
|
(
|
||||||
device, graphicsTexCmdBuffer, graphicsQueue, descPool
|
device, graphicsTexCmdBuffer, graphicsQueue, genericAndTextureDescSet
|
||||||
);
|
);
|
||||||
device->WaitIdle();
|
device->WaitIdle();
|
||||||
graphicsTexCmdBuffer.Free(); graphicsTexCmdBuffer = {};
|
graphicsTexCmdBuffer.Free(); graphicsTexCmdBuffer = {};
|
||||||
SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(texLibrary.GetTextureDescriptorSetGroup());
|
//SHGlobalDescriptorSets::SetStaticGlobalDataDescriptorSet(texLibrary.GetTextureDescriptorSetGroup());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle<SHTexture> SHGraphicsSystem::GetTextureHandle(SHTexture::Index textureId) const
|
Handle<SHTexture> SHGraphicsSystem::GetTextureHandle(SHTexture::Index textureId) const
|
||||||
|
@ -1134,6 +1179,10 @@ namespace SHADE
|
||||||
resizeWidth = newWidth;
|
resizeWidth = newWidth;
|
||||||
resizeHeight = newHeight;
|
resizeHeight = newHeight;
|
||||||
|
|
||||||
|
graphicsGenericData.SetViewportWidth(resizeWidth);
|
||||||
|
graphicsGenericData.SetViewportHeight(resizeHeight);
|
||||||
|
|
||||||
|
|
||||||
renderContext.SetIsResized(true);
|
renderContext.SetIsResized(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1186,6 +1235,7 @@ namespace SHADE
|
||||||
|
|
||||||
SHEventManager::BroadcastEvent<SHWindowResizeEvent>(newEvent, SH_WINDOW_RESIZE_EVENT);
|
SHEventManager::BroadcastEvent<SHWindowResizeEvent>(newEvent, SH_WINDOW_RESIZE_EVENT);
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -37,6 +37,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Graphics/MiddleEnd/Interface/SHRenderer.h"
|
#include "Graphics/MiddleEnd/Interface/SHRenderer.h"
|
||||||
#include "Graphics/Events/SHGraphicsEvents.h"
|
#include "Graphics/Events/SHGraphicsEvents.h"
|
||||||
#include "Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.h"
|
#include "Graphics/MiddleEnd/TrajectoryRendering/SHTrajectoryRenderingSubSystem.h"
|
||||||
|
#include "Graphics/MiddleEnd/GenericData/SHGraphicsGenericData.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -106,6 +107,7 @@ namespace SHADE
|
||||||
void InitSubsystems (void) noexcept;
|
void InitSubsystems (void) noexcept;
|
||||||
void InitBuiltInResources (void);
|
void InitBuiltInResources (void);
|
||||||
void InitEvents (void) noexcept;
|
void InitEvents (void) noexcept;
|
||||||
|
void InitGenericDataAndTexturesDescSet (void) noexcept;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class SH_API BeginRoutine final : public SHSystemRoutine
|
class SH_API BeginRoutine final : public SHSystemRoutine
|
||||||
|
@ -181,6 +183,11 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
SHEventHandle ReceiveLightEnableShadowEvent (SHEventPtr eventPtr) noexcept;
|
SHEventHandle ReceiveLightEnableShadowEvent (SHEventPtr eventPtr) noexcept;
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Asset Events */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
SHEventHandle ReceiveCompileAssetEvent (SHEventPtr eventPtr) noexcept;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Material Functions */
|
/* Material Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -433,6 +440,7 @@ namespace SHADE
|
||||||
SHResourceHub resourceManager;
|
SHResourceHub resourceManager;
|
||||||
SHMeshLibrary meshLibrary;
|
SHMeshLibrary meshLibrary;
|
||||||
SHTextureLibrary texLibrary;
|
SHTextureLibrary texLibrary;
|
||||||
|
SHGraphicsGenericData graphicsGenericData;
|
||||||
SHFontLibrary fontLibrary;
|
SHFontLibrary fontLibrary;
|
||||||
SHSamplerCache samplerCache;
|
SHSamplerCache samplerCache;
|
||||||
SHMaterialInstanceCache materialInstanceCache;
|
SHMaterialInstanceCache materialInstanceCache;
|
||||||
|
@ -490,6 +498,8 @@ namespace SHADE
|
||||||
Handle<SHVkPipeline> debugDrawFilledDepthPipeline;
|
Handle<SHVkPipeline> debugDrawFilledDepthPipeline;
|
||||||
Handle<SHVkPipeline> shadowMapPipeline; // initialized only when a shadow map is needed
|
Handle<SHVkPipeline> shadowMapPipeline; // initialized only when a shadow map is needed
|
||||||
|
|
||||||
|
Handle<SHVkDescriptorSetGroup> genericAndTextureDescSet;
|
||||||
|
|
||||||
// Built-In Textures
|
// Built-In Textures
|
||||||
Handle<SHTexture> defaultTexture;
|
Handle<SHTexture> defaultTexture;
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ namespace SHADE
|
||||||
cmdBuffer->BindPipeline(pipeline);
|
cmdBuffer->BindPipeline(pipeline);
|
||||||
|
|
||||||
// Bind global data
|
// Bind global data
|
||||||
SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, staticGlobalSetIndex);
|
SHGlobalDescriptorSets::BindGenericAndTextureData(logicalDevice, cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, staticGlobalSetIndex, frameIndex);
|
||||||
|
|
||||||
// Bind camera data
|
// Bind camera data
|
||||||
renderer->BindDescriptorSet(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, cameraSetIndex, frameIndex);
|
renderer->BindDescriptorSet(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, cameraSetIndex, frameIndex);
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace SHADE
|
||||||
isDirty = true;
|
isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHTextureLibrary::BuildTextures(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkQueue> graphicsQueue, Handle<SHVkDescriptorPool> descPool)
|
void SHTextureLibrary::BuildTextures(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkQueue> graphicsQueue, Handle<SHVkDescriptorSetGroup> descSet/*, Handle<SHVkDescriptorPool> descPool*/)
|
||||||
{
|
{
|
||||||
// Don't do anything if there are no updates
|
// Don't do anything if there are no updates
|
||||||
if (!isDirty)
|
if (!isDirty)
|
||||||
|
@ -162,27 +162,28 @@ namespace SHADE
|
||||||
/* Build Descriptor Set with all the Textures only if there are textures */
|
/* Build Descriptor Set with all the Textures only if there are textures */
|
||||||
if (!texOrder.empty())
|
if (!texOrder.empty())
|
||||||
{
|
{
|
||||||
if (texDescriptors)
|
|
||||||
{
|
// if (descSet)
|
||||||
texDescriptors.Free();
|
// {
|
||||||
}
|
// descSet.Free();
|
||||||
texDescriptors = descPool->Allocate
|
// }
|
||||||
(
|
// descSet = descPool->Allocate
|
||||||
{ SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA) },
|
// (
|
||||||
{ static_cast<uint32_t>(texOrder.size()) }
|
// { SHGraphicsPredefinedData::GetPredefinedDescSetLayouts(SHGraphicsPredefinedData::PredefinedDescSetLayoutTypes::STATIC_DATA) },
|
||||||
);
|
// { static_cast<uint32_t>(texOrder.size()) }
|
||||||
#ifdef _DEBUG
|
// );
|
||||||
for (auto set : texDescriptors->GetVkHandle())
|
//#ifdef _DEBUG
|
||||||
SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals");
|
// for (auto set : descSet->GetVkHandle())
|
||||||
#endif
|
// SET_VK_OBJ_NAME(device, vk::ObjectType::eDescriptorSet, set, "[Descriptor Set] Static Globals");
|
||||||
|
//#endif
|
||||||
static constexpr uint32_t TEX_DESCRIPTOR_SET_INDEX = 0;
|
static constexpr uint32_t TEX_DESCRIPTOR_SET_INDEX = 0;
|
||||||
texDescriptors->ModifyWriteDescImage
|
descSet->ModifyWriteDescImage
|
||||||
(
|
(
|
||||||
TEX_DESCRIPTOR_SET_INDEX,
|
TEX_DESCRIPTOR_SET_INDEX,
|
||||||
SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA,
|
SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA,
|
||||||
combinedImageSamplers
|
combinedImageSamplers
|
||||||
);
|
);
|
||||||
texDescriptors->UpdateDescriptorSetImages
|
descSet->UpdateDescriptorSetImages
|
||||||
(
|
(
|
||||||
TEX_DESCRIPTOR_SET_INDEX,
|
TEX_DESCRIPTOR_SET_INDEX,
|
||||||
SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA
|
SHGraphicsConstants::DescriptorSetBindings::IMAGE_AND_SAMPLERS_DATA
|
||||||
|
|
|
@ -66,6 +66,13 @@ namespace SHADE
|
||||||
class SHTextureLibrary
|
class SHTextureLibrary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//! This exists because a poor decision was made to place the textures and
|
||||||
|
//! generic data as 2 bindings in a single layout. Because of this, the recreation
|
||||||
|
//! of the texture library would mean the recreation of the desc set that also
|
||||||
|
//! involves the generic data, which is bad bad bad. Solution is to separate the
|
||||||
|
//! 2 desc sets.
|
||||||
|
static constexpr uint32_t DEFAULT_MAX_TEXTURES = 2000;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Usage Functions */
|
/* Usage Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -112,7 +119,7 @@ namespace SHADE
|
||||||
/*!
|
/*!
|
||||||
|
|
||||||
\brief
|
\brief
|
||||||
Finalises all changes to the Texture Library into the GPU buffers.
|
Finalizes all changes to the Texture Library into the GPU buffers.
|
||||||
|
|
||||||
\param device
|
\param device
|
||||||
Device used to create and update the buffers.
|
Device used to create and update the buffers.
|
||||||
|
@ -123,12 +130,12 @@ namespace SHADE
|
||||||
queue.
|
queue.
|
||||||
*/
|
*/
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
void BuildTextures(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkQueue> graphicsQueue, Handle<SHVkDescriptorPool> descPool);
|
void BuildTextures(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHVkQueue> graphicsQueue, Handle<SHVkDescriptorSetGroup> descSet/*, Handle<SHVkDescriptorPool> descPool*/);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Getter Functions */
|
/* Getter Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
Handle<SHVkDescriptorSetGroup> GetTextureDescriptorSetGroup() const noexcept { return texDescriptors; }
|
//Handle<SHVkDescriptorSetGroup> GetTextureDescriptorSetGroup() const noexcept { return descSet; }
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
|
@ -173,8 +180,8 @@ namespace SHADE
|
||||||
std::vector<Handle<SHTexture>> texOrder;
|
std::vector<Handle<SHTexture>> texOrder;
|
||||||
// CPU Storage
|
// CPU Storage
|
||||||
std::vector<std::tuple<Handle<SHVkImageView>, Handle<SHVkSampler>, vk::ImageLayout>> combinedImageSamplers;
|
std::vector<std::tuple<Handle<SHVkImageView>, Handle<SHVkSampler>, vk::ImageLayout>> combinedImageSamplers;
|
||||||
// GPU Storage
|
//// GPU Storage
|
||||||
Handle<SHVkDescriptorSetGroup> texDescriptors;
|
//Handle<SHVkDescriptorSetGroup> descSet;
|
||||||
// Flags
|
// Flags
|
||||||
bool isDirty = true;
|
bool isDirty = true;
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ namespace SHADE
|
||||||
cmdBuffer->BindPipeline(pipeline);
|
cmdBuffer->BindPipeline(pipeline);
|
||||||
|
|
||||||
// Bind global data
|
// Bind global data
|
||||||
SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, staticGlobalSetIndex);
|
SHGlobalDescriptorSets::BindGenericAndTextureData(logicalDevice, cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, staticGlobalSetIndex, frameIndex);
|
||||||
|
|
||||||
// Bind camera data
|
// Bind camera data
|
||||||
renderer->BindDescriptorSet(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, cameraSetIndex, frameIndex);
|
renderer->BindDescriptorSet(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, cameraSetIndex, frameIndex);
|
||||||
|
|
|
@ -584,7 +584,7 @@ namespace SHADE
|
||||||
if (node->renderpass)
|
if (node->renderpass)
|
||||||
{
|
{
|
||||||
// bind static global data
|
// bind static global data
|
||||||
SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA));
|
SHGlobalDescriptorSets::BindGenericAndTextureData(renderGraphStorage->logicalDevice, cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA), frameIndex);
|
||||||
|
|
||||||
// Bind all the buffers required for meshes
|
// Bind all the buffers required for meshes
|
||||||
for (auto& [buffer, bindingPoint] : MESH_DATA)
|
for (auto& [buffer, bindingPoint] : MESH_DATA)
|
||||||
|
|
|
@ -664,7 +664,7 @@ namespace SHADE
|
||||||
commandBuffer->ForceSetPipelineLayout(SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE);
|
commandBuffer->ForceSetPipelineLayout(SHGraphicsPredefinedData::GetSystemData(SHGraphicsPredefinedData::SystemType::RENDER_GRAPH_NODE_COMPUTE).dummyPipelineLayout, SH_PIPELINE_TYPE::COMPUTE);
|
||||||
|
|
||||||
// bind static global data
|
// bind static global data
|
||||||
SHGlobalDescriptorSets::BindStaticGlobalData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA));
|
SHGlobalDescriptorSets::BindGenericAndTextureData(graphStorage->logicalDevice, commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA), frameIndex);
|
||||||
|
|
||||||
// bind lighting data
|
// bind lighting data
|
||||||
SHGlobalDescriptorSets::BindLightingData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::LIGHTS), frameIndex);
|
SHGlobalDescriptorSets::BindLightingData(commandBuffer, SH_PIPELINE_TYPE::COMPUTE, descMappings.at(SHPredefinedDescriptorTypes::LIGHTS), frameIndex);
|
||||||
|
|
|
@ -112,4 +112,9 @@ namespace SHADE
|
||||||
return reflectedData;
|
return reflectedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SHVkShaderModule::GetName(void) const noexcept
|
||||||
|
{
|
||||||
|
return shaderName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -77,6 +77,7 @@ namespace SHADE
|
||||||
vk::ShaderStageFlagBits GetShaderStageFlagBits (void) const noexcept;
|
vk::ShaderStageFlagBits GetShaderStageFlagBits (void) const noexcept;
|
||||||
vk::ShaderModule GetVkShaderModule (void) const noexcept;
|
vk::ShaderModule GetVkShaderModule (void) const noexcept;
|
||||||
SHShaderReflected const& GetReflectedData (void) const noexcept;
|
SHShaderReflected const& GetReflectedData (void) const noexcept;
|
||||||
|
std::string GetName (void) const noexcept;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue