Added UI functionality to the Graphics System #232
|
@ -0,0 +1,8 @@
|
|||
- VertexShader: 46580970
|
||||
FragmentShader: 35983630
|
||||
SubPass: G-Buffer Write
|
||||
Properties:
|
||||
data.color: {x: 1, y: 1, z: 1, w: 1}
|
||||
data.textureIndex: 0
|
||||
data.alpha: 0
|
||||
data.beta: {x: 1, y: 1, z: 1}
|
|
@ -0,0 +1,3 @@
|
|||
Name: UIMat
|
||||
ID: 129340704
|
||||
Type: 7
|
|
@ -0,0 +1,104 @@
|
|||
{
|
||||
"asset" : {
|
||||
"generator" : "Khronos glTF Blender I/O v3.3.27",
|
||||
"version" : "2.0"
|
||||
},
|
||||
"scene" : 0,
|
||||
"scenes" : [
|
||||
{
|
||||
"name" : "Scene",
|
||||
"nodes" : [
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes" : [
|
||||
{
|
||||
"mesh" : 0,
|
||||
"name" : "Quad"
|
||||
}
|
||||
],
|
||||
"meshes" : [
|
||||
{
|
||||
"name" : "Plane",
|
||||
"primitives" : [
|
||||
{
|
||||
"attributes" : {
|
||||
"POSITION" : 0,
|
||||
"NORMAL" : 1,
|
||||
"TEXCOORD_0" : 2
|
||||
},
|
||||
"indices" : 3
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"accessors" : [
|
||||
{
|
||||
"bufferView" : 0,
|
||||
"componentType" : 5126,
|
||||
"count" : 4,
|
||||
"max" : [
|
||||
0.5,
|
||||
0.5,
|
||||
3.774895063202166e-08
|
||||
],
|
||||
"min" : [
|
||||
-0.5,
|
||||
-0.5,
|
||||
-3.774895063202166e-08
|
||||
],
|
||||
"type" : "VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView" : 1,
|
||||
"componentType" : 5126,
|
||||
"count" : 4,
|
||||
"type" : "VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView" : 2,
|
||||
"componentType" : 5126,
|
||||
"count" : 4,
|
||||
"type" : "VEC2"
|
||||
},
|
||||
{
|
||||
"bufferView" : 3,
|
||||
"componentType" : 5123,
|
||||
"count" : 6,
|
||||
"type" : "SCALAR"
|
||||
}
|
||||
],
|
||||
"bufferViews" : [
|
||||
{
|
||||
"buffer" : 0,
|
||||
"byteLength" : 48,
|
||||
"byteOffset" : 0,
|
||||
"target" : 34962
|
||||
},
|
||||
{
|
||||
"buffer" : 0,
|
||||
"byteLength" : 48,
|
||||
"byteOffset" : 48,
|
||||
"target" : 34962
|
||||
},
|
||||
{
|
||||
"buffer" : 0,
|
||||
"byteLength" : 32,
|
||||
"byteOffset" : 96,
|
||||
"target" : 34962
|
||||
},
|
||||
{
|
||||
"buffer" : 0,
|
||||
"byteLength" : 12,
|
||||
"byteOffset" : 128,
|
||||
"target" : 34963
|
||||
}
|
||||
],
|
||||
"buffers" : [
|
||||
{
|
||||
"byteLength" : 140,
|
||||
"uri" : "data:application/octet-stream;base64,AAAAvwAAAL9pISIzAAAAPwAAAL9pISIzAAAAvwAAAD9pISKzAAAAPwAAAD9pISKzAAAAAGkhojMAAIA/AAAAAGkhojMAAIA/AAAAAGkhojMAAIA/AAAAAGkhojMAAIA/AAAAAAAAgD8AAIA/AACAPwAAAAAAAAAAAACAPwAAAAAAAAEAAwAAAAMAAgA="
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
Name: Quad
|
||||
ID: 80501355
|
||||
Type: 4
|
||||
Sub Assets:
|
||||
Name: Quad
|
||||
ID: 141771688
|
||||
Type: 8
|
|
@ -15,6 +15,9 @@ layout(set = 2, binding = 0) uniform CameraData
|
|||
{
|
||||
vec4 position;
|
||||
mat4 vpMat;
|
||||
mat4 viewMat;
|
||||
mat4 perspectiveMat;
|
||||
mat4 orthoMat;
|
||||
} cameraData;
|
||||
|
||||
void main()
|
||||
|
|
|
@ -34,7 +34,8 @@ layout(set = 2, binding = 0) uniform CameraData
|
|||
vec4 position;
|
||||
mat4 vpMat;
|
||||
mat4 viewMat;
|
||||
mat4 projMat;
|
||||
mat4 perspectiveMat;
|
||||
mat4 orthoMat;
|
||||
} cameraData;
|
||||
|
||||
void main()
|
||||
|
|
Binary file not shown.
|
@ -30,7 +30,8 @@ layout(set = 2, binding = 0) uniform CameraData
|
|||
vec4 position;
|
||||
mat4 vpMat;
|
||||
mat4 viewMat;
|
||||
mat4 projMat;
|
||||
mat4 perspectiveMat;
|
||||
mat4 orthoMat;
|
||||
} cameraData;
|
||||
|
||||
// push constants
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,48 @@
|
|||
#version 450
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
#extension GL_EXT_nonuniform_qualifier : require
|
||||
|
||||
struct MatPropData
|
||||
{
|
||||
vec4 color;
|
||||
int textureIndex;
|
||||
float alpha;
|
||||
vec3 beta;
|
||||
};
|
||||
|
||||
layout(location = 0) in struct
|
||||
{
|
||||
vec4 vertPos; // location 0
|
||||
vec2 uv; // location = 1
|
||||
vec4 normal; // location = 2
|
||||
|
||||
} In;
|
||||
|
||||
// material stuff
|
||||
layout(location = 3) flat in struct
|
||||
{
|
||||
int materialIndex;
|
||||
uint eid;
|
||||
uint lightLayerIndex;
|
||||
} In2;
|
||||
|
||||
layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global)
|
||||
layout (std430, set = 3, 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;
|
||||
|
||||
void main()
|
||||
{
|
||||
albedo = vec4(1.0f);
|
||||
|
||||
outEntityID = In2.eid;
|
||||
lightLayerIndices = In2.lightLayerIndex;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Name: UI_FS
|
||||
ID: 35983630
|
||||
Type: 2
|
|
@ -0,0 +1,64 @@
|
|||
#version 450
|
||||
#extension GL_KHR_vulkan_glsl : enable
|
||||
|
||||
//#include "ShaderDescriptorDefinitions.glsl"
|
||||
|
||||
|
||||
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 = 0) out struct
|
||||
{
|
||||
vec4 vertPos; // location 0
|
||||
vec2 uv; // location = 1
|
||||
vec4 normal; // location = 2
|
||||
|
||||
} Out;
|
||||
|
||||
// material stuff
|
||||
layout(location = 3) out struct
|
||||
{
|
||||
int materialIndex;
|
||||
uint eid;
|
||||
uint lightLayerIndex;
|
||||
|
||||
} Out2;
|
||||
|
||||
layout(set = 2, binding = 0) uniform CameraData
|
||||
{
|
||||
vec4 position;
|
||||
mat4 vpMat;
|
||||
mat4 viewMat;
|
||||
mat4 perspectiveMat;
|
||||
mat4 orthoMat;
|
||||
} cameraData;
|
||||
|
||||
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);
|
||||
|
||||
// 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);
|
||||
|
||||
// clip space for rendering
|
||||
gl_Position = cameraData.orthoMat * worldTransform * vec4 (aVertexPos, 1.0f);
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Name: UI_VS
|
||||
ID: 46580970
|
||||
Type: 2
|
|
@ -21,7 +21,7 @@ namespace SHADE
|
|||
template<typename T>
|
||||
static bool SetPayload(DragDropTag const& type, T* object, ImGuiCond const cond = 0)
|
||||
{
|
||||
ImGui::SetDragDropPayload(type.data(), static_cast<void*>(object), sizeof(T), cond);
|
||||
hasDragDrop = ImGui::SetDragDropPayload(type.data(), static_cast<void*>(object), sizeof(T), cond);
|
||||
|
||||
hasDragDrop = true;
|
||||
currentDragDropTag = type;
|
||||
|
|
|
@ -119,6 +119,11 @@ namespace SHADE
|
|||
|
||||
SHAssetManager::CompileAsset("../../Assets/Shaders/Text_VS.glsl", false);
|
||||
SHAssetManager::CompileAsset("../../Assets/Shaders/Text_FS.glsl", false);
|
||||
SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_VS.glsl", false);
|
||||
SHAssetManager::CompileAsset("../../Assets/Shaders/UI_VS.glsl", false);
|
||||
SHAssetManager::CompileAsset("../../Assets/Shaders/UI_FS.glsl", false);
|
||||
|
||||
SHAssetManager::CompileAsset("../../Assets/Models/Quad.gltf", false);
|
||||
|
||||
// Load Built In Shaders
|
||||
static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT);
|
||||
|
@ -574,7 +579,7 @@ namespace SHADE
|
|||
{
|
||||
auto editorSystem = SHSystemManager::GetSystem<SHEditor>();
|
||||
if (editorSystem->editorState != SHEditor::State::PLAY)
|
||||
worldRenderer->UpdateDataAndBind(currentCmdBuffer, frameIndex, cameraSystem->GetEditorCamera()->GetViewMatrix(), cameraSystem->GetEditorCamera()->GetProjMatrix());
|
||||
worldRenderer->UpdateDataAndBind(currentCmdBuffer, frameIndex, cameraSystem->GetEditorCamera()->GetViewMatrix(), cameraSystem->GetEditorCamera()->GetProjMatrix(), cameraSystem->GetEditorCamera()->GetOrthoMatrix());
|
||||
else
|
||||
renderers[renIndex]->UpdateDataAndBind(currentCmdBuffer, frameIndex);
|
||||
}
|
||||
|
|
|
@ -90,13 +90,13 @@ namespace SHADE
|
|||
if (camera && cameraDirector)
|
||||
{
|
||||
//UpdateDataAndBind(cmdBuffer, frameIndex, SHMatrix::Transpose(cameraDirector->GetVPMatrix()));
|
||||
UpdateDataAndBind(cmdBuffer, frameIndex, cameraDirector->GetViewMatrix(), cameraDirector->GetProjMatrix());
|
||||
UpdateDataAndBind(cmdBuffer, frameIndex, cameraDirector->GetViewMatrix(), cameraDirector->GetProjMatrix(), cameraDirector->GetOrthoMatrix());
|
||||
}
|
||||
}
|
||||
|
||||
void SHRenderer::UpdateDataAndBind(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex, SHMatrix const& viewMatrix, SHMatrix const& projMatrix) noexcept
|
||||
void SHRenderer::UpdateDataAndBind(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex, SHMatrix const& viewMatrix, SHMatrix const& projMatrix, SHMatrix const& orthoMatrix) noexcept
|
||||
{
|
||||
SetViewProjectionMatrix(viewMatrix, projMatrix);
|
||||
SetViewProjectionMatrix(viewMatrix, projMatrix, orthoMatrix);
|
||||
|
||||
//cpuCameraData.viewProjectionMatrix = camera->GetViewProjectionMatrix();
|
||||
cameraBuffer->WriteToMemory(&cpuCameraData, sizeof(SHShaderCameraData), 0, cameraDataAlignedSize * frameIndex);
|
||||
|
@ -116,12 +116,13 @@ namespace SHADE
|
|||
{
|
||||
}
|
||||
|
||||
void SHRenderer::SetViewProjectionMatrix(SHMatrix const& viewMatrix, SHMatrix const& projMatrix) noexcept
|
||||
void SHRenderer::SetViewProjectionMatrix(SHMatrix const& viewMatrix, SHMatrix const& projMatrix, SHMatrix const& orthoMatrix) noexcept
|
||||
{
|
||||
//cpuCameraData.viewProjectionMatrix = camera->GetViewMatrix() * camera->GetProjectionMatrix();
|
||||
cpuCameraData.viewProjectionMatrix = SHMatrix::Transpose(projMatrix * viewMatrix);
|
||||
cpuCameraData.viewMatrix = SHMatrix::Transpose(viewMatrix);
|
||||
cpuCameraData.projectionMatrix = SHMatrix::Transpose(projMatrix);
|
||||
cpuCameraData.orthoMatrix = SHMatrix::Transpose (orthoMatrix);
|
||||
}
|
||||
|
||||
Handle<SHRenderGraph> SHRenderer::GetRenderGraph(void) const noexcept
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace SHADE
|
|||
SHMatrix viewProjectionMatrix;
|
||||
SHMatrix viewMatrix;
|
||||
SHMatrix projectionMatrix;
|
||||
SHMatrix orthoMatrix;
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
@ -82,10 +83,10 @@ namespace SHADE
|
|||
/*-----------------------------------------------------------------------------*/
|
||||
void Draw(uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool) noexcept;
|
||||
void UpdateDataAndBind(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept;
|
||||
void UpdateDataAndBind(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex, SHMatrix const& viewMatrix, SHMatrix const& projMatrix) noexcept;
|
||||
void UpdateDataAndBind(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex, SHMatrix const& viewMatrix, SHMatrix const& projMatrix, SHMatrix const& orthoMatrix) noexcept;
|
||||
void BindDescSet (Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept;
|
||||
void UpdateCameraDataToBuffer (void) noexcept;
|
||||
void SetViewProjectionMatrix (SHMatrix const& viewMatrix, SHMatrix const& projMatrix) noexcept;
|
||||
void SetViewProjectionMatrix (SHMatrix const& viewMatrix, SHMatrix const& projMatrix, SHMatrix const& orthoMatrix) noexcept;
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Setters and Getters */
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace SHADE
|
|||
|
||||
// allocate GPU buffer for matrices
|
||||
matrixDataBuffer = logicalDevice->CreateBuffer(glyphDataSize, fontAsset.glyphTransformations.data(), glyphDataSize, vk::BufferUsageFlagBits::eTransferDst | vk::BufferUsageFlagBits::eStorageBuffer, VMA_MEMORY_USAGE_AUTO, {});
|
||||
|
||||
|
||||
sampler = logicalDevice->CreateSampler(SHVkSamplerParams{});
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue