overhauled physics engine
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include "Actor/CameraActor.h"
|
||||
#include "Math/Vector.h"
|
||||
#include "RenderGraph.h"
|
||||
#include "Material/MaterialAsset.h"
|
||||
#include "Material/MaterialInstance.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
@@ -29,7 +29,7 @@ void BasePassMeshProcessor::processMeshBatch(
|
||||
Array<Gfx::PDescriptorSet> descriptorSets,
|
||||
int32 /*staticMeshId*/)
|
||||
{
|
||||
PMaterialAsset material = batch.material;
|
||||
PMaterialInterface material = batch.material;
|
||||
//const Gfx::MaterialShadingModel shadingModel = material->getShadingModel();
|
||||
|
||||
const PVertexShaderInput vertexInput = batch.vertexInput;
|
||||
@@ -47,12 +47,7 @@ void BasePassMeshProcessor::processMeshBatch(
|
||||
descriptorSets[BasePass::INDEX_MATERIAL] = materialSet;
|
||||
for(uint32 i = 0; i < batch.elements.size(); ++i)
|
||||
{
|
||||
Gfx::PDescriptorSet descriptorSet = primitiveLayout->allocateDescriptorSet();
|
||||
descriptorSet->updateBuffer(0, batch.elements[i].uniformBuffer);
|
||||
descriptorSet->writeChanges();
|
||||
descriptorSets[BasePass::INDEX_SCENE_DATA] = descriptorSet;
|
||||
buildMeshDrawCommand(batch,
|
||||
// primitiveComponent,
|
||||
renderPass,
|
||||
pipelineLayout,
|
||||
renderCommand,
|
||||
@@ -104,9 +99,14 @@ BasePass::BasePass(Gfx::PGraphics graphics)
|
||||
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
||||
|
||||
primitiveLayout = graphics->createDescriptorLayout("PrimitiveLayout");
|
||||
primitiveLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
primitiveLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
primitiveLayout->create();
|
||||
basePassLayout->addDescriptorLayout(INDEX_SCENE_DATA, primitiveLayout);
|
||||
basePassLayout->addPushConstants(Gfx::SePushConstantRange{
|
||||
.stageFlags = (Gfx::SE_SHADER_STAGE_VERTEX_BIT | Gfx::SE_SHADER_STAGE_FRAGMENT_BIT),
|
||||
.offset = 0,
|
||||
.size = sizeof(uint32),
|
||||
});
|
||||
}
|
||||
|
||||
BasePass::~BasePass()
|
||||
@@ -121,13 +121,17 @@ void BasePass::beginFrame(const Component::Camera& cam)
|
||||
|
||||
viewParams.viewMatrix = cam.getViewMatrix();
|
||||
viewParams.projectionMatrix = viewport->getProjectionMatrix();
|
||||
viewParams.cameraPosition = Math::Vector4(cam.getCameraPosition(), 0);
|
||||
viewParams.screenDimensions = Math::Vector2(static_cast<float>(viewport->getSizeX()), static_cast<float>(viewport->getSizeY()));
|
||||
viewParams.cameraPosition = Vector4(cam.getCameraPosition(), 0);
|
||||
viewParams.screenDimensions = Vector2(static_cast<float>(viewport->getSizeX()), static_cast<float>(viewport->getSizeY()));
|
||||
uniformUpdate.size = sizeof(ViewParameter);
|
||||
uniformUpdate.data = (uint8*)&viewParams;
|
||||
viewParamBuffer->updateContents(uniformUpdate);
|
||||
viewLayout->reset();
|
||||
lightLayout->reset();
|
||||
|
||||
descriptorSets[INDEX_SCENE_DATA] = primitiveLayout->allocateDescriptorSet();
|
||||
descriptorSets[INDEX_SCENE_DATA]->updateBuffer(0, passData.sceneDataBuffer);
|
||||
descriptorSets[INDEX_SCENE_DATA]->writeChanges();
|
||||
descriptorSets[INDEX_LIGHT_ENV] = lightLayout->allocateDescriptorSet();
|
||||
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
||||
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
||||
@@ -152,6 +156,7 @@ void BasePass::render()
|
||||
descriptorSets[INDEX_LIGHT_ENV]->updateBuffer(4, oLightIndexList);
|
||||
descriptorSets[INDEX_LIGHT_ENV]->updateTexture(5, oLightGrid);
|
||||
descriptorSets[INDEX_LIGHT_ENV]->writeChanges();
|
||||
|
||||
graphics->beginRenderPass(renderPass);
|
||||
for (auto &&meshBatch : passData.staticDrawList)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ DECLARE_REF(CameraActor)
|
||||
struct BasePassData
|
||||
{
|
||||
Array<StaticMeshBatch> staticDrawList;
|
||||
Gfx::PStructuredBuffer sceneDataBuffer;
|
||||
};
|
||||
class BasePass : public RenderPass<BasePassData>
|
||||
{
|
||||
|
||||
@@ -2,6 +2,8 @@ target_sources(Engine
|
||||
PRIVATE
|
||||
BasePass.h
|
||||
BasePass.cpp
|
||||
DebugPass.h
|
||||
DebugPass.cpp
|
||||
DepthPrepass.h
|
||||
DepthPrepass.cpp
|
||||
LightCullingPass.h
|
||||
@@ -21,6 +23,7 @@ target_sources(Engine
|
||||
PUBLIC FILE_SET HEADERS
|
||||
FILES
|
||||
BasePass.h
|
||||
DebugPass.h
|
||||
DepthPrepass.h
|
||||
LightCullingPass.h
|
||||
MeshProcessor.h
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
#include "DebugPass.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
Array<DebugVertex> Seele::gDebugVertices;
|
||||
|
||||
DebugPass::DebugPass(Gfx::PGraphics graphics)
|
||||
: RenderPass(graphics)
|
||||
{
|
||||
|
||||
}
|
||||
DebugPass::~DebugPass()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DebugPass::beginFrame(const Component::Camera& cam)
|
||||
{
|
||||
BulkResourceData uniformUpdate;
|
||||
|
||||
viewParams.viewMatrix = cam.getViewMatrix();
|
||||
viewParams.projectionMatrix = viewport->getProjectionMatrix();
|
||||
viewParams.cameraPosition = Vector4(cam.getCameraPosition(), 0);
|
||||
viewParams.screenDimensions = Vector2(static_cast<float>(viewport->getSizeX()), static_cast<float>(viewport->getSizeY()));
|
||||
uniformUpdate.size = sizeof(ViewParameter);
|
||||
uniformUpdate.data = (uint8*)&viewParams;
|
||||
viewParamsBuffer->updateContents(uniformUpdate);
|
||||
descriptorLayout->reset();
|
||||
descriptorSet = descriptorLayout->allocateDescriptorSet();
|
||||
descriptorSet->updateBuffer(0, viewParamsBuffer);
|
||||
descriptorSet->writeChanges();
|
||||
|
||||
VertexBufferCreateInfo vertexBufferInfo = {
|
||||
.resourceData = {
|
||||
.size = sizeof(DebugVertex) * passData.vertices.size(),
|
||||
.data = (uint8*)passData.vertices.data(),
|
||||
},
|
||||
.vertexSize = sizeof(DebugVertex),
|
||||
.numVertices = (uint32)passData.vertices.size(),
|
||||
};
|
||||
debugVertices = graphics->createVertexBuffer(vertexBufferInfo);
|
||||
|
||||
}
|
||||
|
||||
void DebugPass::render()
|
||||
{
|
||||
graphics->beginRenderPass(renderPass);
|
||||
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand("DebugRender");
|
||||
renderCommand->setViewport(viewport);
|
||||
renderCommand->bindPipeline(pipeline);
|
||||
renderCommand->bindDescriptor(descriptorSet);
|
||||
renderCommand->bindVertexBuffer({VertexInputStream(0, 0, debugVertices)});
|
||||
renderCommand->draw((uint32)passData.vertices.size(), 1, 0, 0);
|
||||
graphics->executeCommands(Array{renderCommand});
|
||||
graphics->endRenderPass();
|
||||
}
|
||||
|
||||
void DebugPass::endFrame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DebugPass::publishOutputs()
|
||||
{
|
||||
UniformBufferCreateInfo viewCreateInfo = {
|
||||
.resourceData = BulkResourceData {
|
||||
.size = sizeof(ViewParameter),
|
||||
.data = nullptr,
|
||||
},
|
||||
.bDynamic = true
|
||||
};
|
||||
viewParamsBuffer = graphics->createUniformBuffer(viewCreateInfo);
|
||||
|
||||
descriptorLayout = graphics->createDescriptorLayout("DebugDescLayout");
|
||||
descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
descriptorLayout->create();
|
||||
|
||||
pipelineLayout = graphics->createPipelineLayout();
|
||||
pipelineLayout->addDescriptorLayout(0, descriptorLayout);
|
||||
pipelineLayout->create();
|
||||
}
|
||||
|
||||
void DebugPass::createRenderPass()
|
||||
{
|
||||
Gfx::PRenderTargetAttachment baseColorAttachment = resources->requestRenderTarget("BASEPASS_COLOR");
|
||||
baseColorAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
|
||||
Gfx::PRenderTargetAttachment depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
||||
depthAttachment->loadOp = Gfx::SE_ATTACHMENT_LOAD_OP_LOAD;
|
||||
Gfx::PRenderTargetLayout layout = new Gfx::RenderTargetLayout(baseColorAttachment, depthAttachment);
|
||||
renderPass = graphics->createRenderPass(layout, viewport);
|
||||
|
||||
ShaderCreateInfo createInfo;
|
||||
createInfo.name = "DebugVertex";
|
||||
createInfo.mainModule = "Debug";
|
||||
createInfo.entryPoint = "vertexMain";
|
||||
createInfo.defines["INDEX_VIEW_PARAMS"] = "0";
|
||||
Gfx::PVertexShader vertexShader = graphics->createVertexShader(createInfo);
|
||||
|
||||
createInfo.name = "DebugFragment";
|
||||
|
||||
createInfo.entryPoint = "fragmentMain";
|
||||
Gfx::PFragmentShader fragmentShader = graphics->createFragmentShader(createInfo);
|
||||
|
||||
Gfx::PVertexDeclaration vertexDecl = graphics->createVertexDeclaration({
|
||||
Gfx::VertexElement {
|
||||
.streamIndex = 0,
|
||||
.offset = offsetof(DebugVertex, position),
|
||||
.vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
|
||||
.attributeIndex = 0,
|
||||
.stride = sizeof(DebugVertex),
|
||||
},
|
||||
Gfx::VertexElement {
|
||||
.streamIndex = 0,
|
||||
.offset = offsetof(DebugVertex, color),
|
||||
.vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
|
||||
.attributeIndex = 1,
|
||||
.stride = sizeof(DebugVertex),
|
||||
}
|
||||
});
|
||||
|
||||
GraphicsPipelineCreateInfo gfxInfo;
|
||||
gfxInfo.vertexDeclaration = vertexDecl;
|
||||
gfxInfo.vertexShader = vertexShader;
|
||||
gfxInfo.fragmentShader = fragmentShader;
|
||||
gfxInfo.rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_LINE;
|
||||
gfxInfo.rasterizationState.lineWidth = 5.f;
|
||||
gfxInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_LINE_LIST;
|
||||
gfxInfo.pipelineLayout = pipelineLayout;
|
||||
gfxInfo.renderPass = renderPass;
|
||||
pipeline = graphics->createGraphicsPipeline(gfxInfo);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include "RenderPass.h"
|
||||
#include "Graphics/GraphicsResources.h"
|
||||
#include "Scene/Scene.h"
|
||||
#include "Graphics/DebugVertex.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
DECLARE_REF(CameraActor)
|
||||
DECLARE_REF(Scene)
|
||||
DECLARE_REF(Viewport)
|
||||
struct DebugPassData
|
||||
{
|
||||
Array<DebugVertex> vertices;
|
||||
};
|
||||
class DebugPass : public RenderPass<DebugPassData>
|
||||
{
|
||||
public:
|
||||
DebugPass(Gfx::PGraphics graphics);
|
||||
virtual ~DebugPass();
|
||||
virtual void beginFrame(const Component::Camera& cam) override;
|
||||
virtual void render() override;
|
||||
virtual void endFrame() override;
|
||||
virtual void publishOutputs() override;
|
||||
virtual void createRenderPass() override;
|
||||
private:
|
||||
Gfx::PVertexBuffer debugVertices;
|
||||
Gfx::PUniformBuffer viewParamsBuffer;
|
||||
Gfx::PDescriptorLayout descriptorLayout;
|
||||
Gfx::PDescriptorSet descriptorSet;
|
||||
Gfx::PPipelineLayout pipelineLayout;
|
||||
Gfx::PGraphicsPipeline pipeline;
|
||||
};
|
||||
DEFINE_REF(DebugPass)
|
||||
} // namespace Seele
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "Actor/CameraActor.h"
|
||||
#include "Math/Vector.h"
|
||||
#include "RenderGraph.h"
|
||||
#include "Material/MaterialAsset.h"
|
||||
#include "Material/MaterialInterface.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
@@ -28,7 +28,7 @@ void DepthPrepassMeshProcessor::processMeshBatch(
|
||||
int32 /*staticMeshId*/)
|
||||
{
|
||||
//std::cout << "Depth void started" << std::endl;
|
||||
PMaterialAsset material = batch.material;
|
||||
PMaterialInterface material = batch.material;
|
||||
//const Gfx::MaterialShadingModel shadingModel = material->getShadingModel();
|
||||
|
||||
const PVertexShaderInput vertexInput = batch.vertexInput;
|
||||
@@ -44,11 +44,7 @@ void DepthPrepassMeshProcessor::processMeshBatch(
|
||||
Gfx::PDescriptorSet materialSet = material->createDescriptorSet();
|
||||
descriptorSets[DepthPrepass::INDEX_MATERIAL] = materialSet;
|
||||
for(uint32 i = 0; i < batch.elements.size(); ++i)
|
||||
{
|
||||
Gfx::PDescriptorSet descriptorSet = primitiveLayout->allocateDescriptorSet();
|
||||
descriptorSet->updateBuffer(0, batch.elements[i].uniformBuffer);
|
||||
descriptorSet->writeChanges();
|
||||
descriptorSets[DepthPrepass::INDEX_SCENE_DATA] = descriptorSet;
|
||||
{
|
||||
buildMeshDrawCommand(batch,
|
||||
// primitiveComponent,
|
||||
renderPass,
|
||||
@@ -87,9 +83,14 @@ DepthPrepass::DepthPrepass(Gfx::PGraphics graphics)
|
||||
depthPrepassLayout->addDescriptorLayout(INDEX_VIEW_PARAMS, viewLayout);
|
||||
|
||||
primitiveLayout = graphics->createDescriptorLayout("PrimitiveLayout");
|
||||
primitiveLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
primitiveLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
primitiveLayout->create();
|
||||
depthPrepassLayout->addDescriptorLayout(INDEX_SCENE_DATA, primitiveLayout);
|
||||
depthPrepassLayout->addPushConstants(Gfx::SePushConstantRange{
|
||||
.stageFlags = (Gfx::SE_SHADER_STAGE_VERTEX_BIT | Gfx::SE_SHADER_STAGE_FRAGMENT_BIT),
|
||||
.offset = 0,
|
||||
.size = sizeof(uint32),
|
||||
});
|
||||
}
|
||||
|
||||
DepthPrepass::~DepthPrepass()
|
||||
@@ -104,12 +105,15 @@ void DepthPrepass::beginFrame(const Component::Camera& cam)
|
||||
|
||||
viewParams.viewMatrix = cam.getViewMatrix();
|
||||
viewParams.projectionMatrix = viewport->getProjectionMatrix();
|
||||
viewParams.cameraPosition = Math::Vector4(cam.getCameraPosition(), 0);
|
||||
viewParams.screenDimensions = Math::Vector2(static_cast<float>(viewport->getSizeX()), static_cast<float>(viewport->getSizeY()));
|
||||
viewParams.cameraPosition = Vector4(cam.getCameraPosition(), 0);
|
||||
viewParams.screenDimensions = Vector2(static_cast<float>(viewport->getSizeX()), static_cast<float>(viewport->getSizeY()));
|
||||
uniformUpdate.size = sizeof(ViewParameter);
|
||||
uniformUpdate.data = (uint8*)&viewParams;
|
||||
viewParamBuffer->updateContents(uniformUpdate);
|
||||
viewLayout->reset();
|
||||
descriptorSets[INDEX_SCENE_DATA] = primitiveLayout->allocateDescriptorSet();
|
||||
descriptorSets[INDEX_SCENE_DATA]->updateBuffer(0, passData.sceneDataBuffer);
|
||||
descriptorSets[INDEX_SCENE_DATA]->writeChanges();
|
||||
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
||||
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
||||
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
||||
|
||||
@@ -26,6 +26,7 @@ DEFINE_REF(DepthPrepassMeshProcessor)
|
||||
struct DepthPrepassData
|
||||
{
|
||||
Array<StaticMeshBatch> staticDrawList;
|
||||
Gfx::PStructuredBuffer sceneDataBuffer;
|
||||
};
|
||||
class DepthPrepass : public RenderPass<DepthPrepassData>
|
||||
{
|
||||
|
||||
@@ -25,8 +25,8 @@ void LightCullingPass::beginFrame(const Component::Camera& cam)
|
||||
BulkResourceData uniformUpdate;
|
||||
viewParams.viewMatrix = cam.getViewMatrix();
|
||||
viewParams.projectionMatrix = viewport->getProjectionMatrix();
|
||||
viewParams.cameraPosition = Math::Vector4(cam.getCameraPosition(), 0);
|
||||
viewParams.screenDimensions = Math::Vector2(static_cast<float>(viewportWidth), static_cast<float>(viewportHeight));
|
||||
viewParams.cameraPosition = Vector4(cam.getCameraPosition(), 0);
|
||||
viewParams.screenDimensions = Vector2(static_cast<float>(viewportWidth), static_cast<float>(viewportHeight));
|
||||
uniformUpdate.size = sizeof(ViewParameter);
|
||||
uniformUpdate.data = (uint8*)&viewParams;
|
||||
viewParamsBuffer->updateContents(uniformUpdate);
|
||||
@@ -261,9 +261,9 @@ void LightCullingPass::setupFrustums()
|
||||
glm::uvec3 numThreadGroups = glm::ceil(glm::vec3(numThreads.x / (float)BLOCK_SIZE, numThreads.y / (float)BLOCK_SIZE, 1));
|
||||
|
||||
viewParams = {
|
||||
.viewMatrix = Math::Matrix4(),
|
||||
.projectionMatrix = Math::Matrix4(),
|
||||
.cameraPosition = Math::Vector4(),
|
||||
.viewMatrix = Matrix4(),
|
||||
.projectionMatrix = Matrix4(),
|
||||
.cameraPosition = Vector4(),
|
||||
.screenDimensions = glm::vec2(viewportWidth, viewportHeight),
|
||||
};
|
||||
dispatchParams.numThreads = numThreads;
|
||||
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
} dispatchParams;
|
||||
struct Plane
|
||||
{
|
||||
Math::Vector n;
|
||||
Vector n;
|
||||
float d;
|
||||
};
|
||||
struct Frustum
|
||||
|
||||
@@ -56,10 +56,18 @@ void MeshProcessor::buildMeshDrawCommand(
|
||||
drawCommand->bindPipeline(pipeline);
|
||||
drawCommand->bindVertexBuffer(vertexStreams);
|
||||
drawCommand->bindDescriptor(descriptors);
|
||||
for(auto element : meshBatch.elements)
|
||||
for(const auto& element : meshBatch.elements)
|
||||
{
|
||||
drawCommand->bindIndexBuffer(element.indexBuffer);
|
||||
drawCommand->draw(element);
|
||||
drawCommand->pushConstants(pipelineLayout, Gfx::SE_SHADER_STAGE_VERTEX_BIT | Gfx::SE_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(uint32), &element.sceneDataIndex);
|
||||
if(element.indexBuffer != nullptr)
|
||||
{
|
||||
drawCommand->bindIndexBuffer(element.indexBuffer);
|
||||
drawCommand->draw(element);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawCommand->draw(vertexStreams[0].vertexBuffer->getNumVertices(), 1, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,11 +35,11 @@ public:
|
||||
protected:
|
||||
struct ViewParameter
|
||||
{
|
||||
Math::Matrix4 viewMatrix;
|
||||
Math::Matrix4 projectionMatrix;
|
||||
Math::Vector4 cameraPosition;
|
||||
Math::Vector2 screenDimensions;
|
||||
Math::Vector2 pad0;
|
||||
Matrix4 viewMatrix;
|
||||
Matrix4 projectionMatrix;
|
||||
Vector4 cameraPosition;
|
||||
Vector2 screenDimensions;
|
||||
Vector2 pad0;
|
||||
} viewParams;
|
||||
PRenderGraphResources resources;
|
||||
RenderPassDataType passData;
|
||||
|
||||
@@ -27,8 +27,8 @@ void TextPass::beginFrame(const Component::Camera&)
|
||||
for(uint32 c : render.text)
|
||||
{
|
||||
const GlyphData& glyph = fd.glyphDataSet[fd.characterToGlyphIndex[c]];
|
||||
Math::Vector2 bearing = glyph.bearing;
|
||||
Math::Vector2 size = glyph.size;
|
||||
Vector2 bearing = glyph.bearing;
|
||||
Vector2 size = glyph.size;
|
||||
float xpos = x + bearing.x * render.scale;
|
||||
float ypos = y - (size.y - bearing.y) * render.scale;
|
||||
|
||||
@@ -36,8 +36,8 @@ void TextPass::beginFrame(const Component::Camera&)
|
||||
float h = size.y * render.scale;
|
||||
|
||||
instanceData.add(GlyphInstanceData{
|
||||
.position = Math::Vector2(xpos, ypos),
|
||||
.widthHeight = Math::Vector2(w, h),
|
||||
.position = Vector2(xpos, ypos),
|
||||
.widthHeight = Vector2(w, h),
|
||||
.glyphIndex = fd.characterToGlyphIndex[c],
|
||||
});
|
||||
x += (glyph.advance >> 6) * render.scale;
|
||||
@@ -61,7 +61,7 @@ void TextPass::beginFrame(const Component::Camera&)
|
||||
}
|
||||
auto proj = viewport->getProjectionMatrix();
|
||||
BulkResourceData projectionUpdate = {
|
||||
.size = sizeof(Math::Matrix4),
|
||||
.size = sizeof(Matrix4),
|
||||
.data = (uint8*)&proj,
|
||||
};
|
||||
projectionBuffer->updateContents(projectionUpdate);
|
||||
@@ -157,7 +157,7 @@ void TextPass::createRenderPass()
|
||||
|
||||
projectionBuffer = graphics->createUniformBuffer({
|
||||
.resourceData = {
|
||||
.size = sizeof(Math::Matrix4),
|
||||
.size = sizeof(Matrix4),
|
||||
.data = nullptr,
|
||||
},
|
||||
.bDynamic = true,
|
||||
|
||||
@@ -13,8 +13,8 @@ struct TextRender
|
||||
{
|
||||
std::string text;
|
||||
PFontAsset font;
|
||||
Math::Vector4 textColor;
|
||||
Math::Vector2 position;
|
||||
Vector4 textColor;
|
||||
Vector2 position;
|
||||
float scale;
|
||||
};
|
||||
struct TextPassData
|
||||
@@ -35,19 +35,19 @@ public:
|
||||
private:
|
||||
struct GlyphData
|
||||
{
|
||||
Math::Vector2 bearing;
|
||||
Math::Vector2 size;
|
||||
Vector2 bearing;
|
||||
Vector2 size;
|
||||
uint32 advance;
|
||||
};
|
||||
struct GlyphInstanceData
|
||||
{
|
||||
Math::Vector2 position;
|
||||
Math::Vector2 widthHeight;
|
||||
Vector2 position;
|
||||
Vector2 widthHeight;
|
||||
uint32 glyphIndex;
|
||||
};
|
||||
struct TextData
|
||||
{
|
||||
Math::Vector4 textColor;
|
||||
Vector4 textColor;
|
||||
float scale;
|
||||
};
|
||||
struct FontData
|
||||
|
||||
@@ -144,10 +144,10 @@ void UIPass::createRenderPass()
|
||||
descriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 256, Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT | Gfx::SE_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT);
|
||||
descriptorLayout->create();
|
||||
|
||||
Math::Matrix4 projectionMatrix = glm::ortho(0, 1, 1, 0);
|
||||
Matrix4 projectionMatrix = glm::ortho(0, 1, 1, 0);
|
||||
UniformBufferCreateInfo info = {
|
||||
.resourceData = {
|
||||
.size = sizeof(Math::Matrix4),
|
||||
.size = sizeof(Matrix4),
|
||||
.data = (uint8*)&projectionMatrix,
|
||||
},
|
||||
.bDynamic = false,
|
||||
|
||||
Reference in New Issue
Block a user