Text Rendering WIP

This commit is contained in:
Brandon Mak 2022-11-10 08:28:44 +08:00
parent 67f7d0ea2e
commit be6a11c629
4 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,50 @@
#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()
{
position = In.vertPos;
normals = In.normal;
albedo = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv) * MatProp.data[In2.materialIndex].color;
outEntityID = In2.eid;
lightLayerIndices = In2.lightLayerIndex;
}

View File

@ -0,0 +1,39 @@
#version 450
#extension GL_KHR_vulkan_glsl : enable
//#include "ShaderDescriptorDefinitions.glsl"
layout(location = 0) in vec4 positionalOffset;
layout(location = 1) in unsigned int glyphIndex;
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
{
uint eid;
} Out2;
layout(set = 2, binding = 0) uniform CameraData
{
vec4 position;
mat4 vpMat;
mat4 viewMat;
mat4 projMat;
} cameraData;
void main()
{
Out2.eid = integerData[0];
// clip space for rendering
gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
}

View File

@ -89,6 +89,8 @@ namespace SHADE
void SHTextRenderingSubSystem::Init(Handle<SHVkLogicalDevice> device, Handle<SHVkDescriptorPool> descPool) noexcept
{
logicalDevice = device;
}
void SHTextRenderingSubSystem::Run(uint32_t frameIndex) noexcept
@ -114,6 +116,13 @@ namespace SHADE
{
// draw the component
// bind the pipeline
// bind the pipeline layout
// bind VBO (position and indices)
// bind descriptors for font (matrices)
// call draw call
}
}

View File

@ -12,6 +12,8 @@ namespace SHADE
class SHLightComponent;
class SHVkCommandBuffer;
class SHTextRendererComponent;
class SHVkPipeline;
class SHVkPipelineLayout;
class SHTextRenderingSubSystem
{
@ -20,6 +22,12 @@ namespace SHADE
//! Logical device for creation and destruction
Handle<SHVkLogicalDevice> logicalDevice;
//! Pipeline for rendering the text
Handle<SHVkPipeline> pipeline;
//! Pipeline layout for the pipeline
Handle<SHVkPipelineLayout> pipelineLayout;
private:
void RecomputePositions(SHTextRendererComponent& textComp) noexcept;