Skip to content

Implemented a bbox renderer using etna and added it to shadowmap sample#46

Open
JackOfBlades232 wants to merge 1 commit intomsu-graphics-group:integrate_etna_frameworkfrom
JackOfBlades232:etna_bbox_renderer
Open

Implemented a bbox renderer using etna and added it to shadowmap sample#46
JackOfBlades232 wants to merge 1 commit intomsu-graphics-group:integrate_etna_frameworkfrom
JackOfBlades232:etna_bbox_renderer

Conversation

@JackOfBlades232
Copy link
Copy Markdown

Added the BboxRenderer class, which can handle rendering of a buffer of bounding boxes in wireframe mode, similarly to QuadRenderer, and added it to the shadowmap sample. I also added shaders for bbox rendering which are used in the class internally.

The class can be constructed with providing necessary info (attachment formats and framebuffer extent), and it also comes with an option whether to draw the boxes instanced in one draw call (which requires the boxes to be loaded as a buffer), or as separate draw calls (which requires no additional gpu buffer).

The SetBoxes method takes in an array or vector of LiteMath's bounding boxes (in world space coords), converts them to instance matrices for a simple 1x1x1 box and stores them in the class for drawing. If drawInstanced is true, it also loads the matrices to the GPU (currently, this is done inefficiently with a mapped buffer, didn't want to use vk_utils or do the staging buffer myself, will be fixed once etna has utilities for staging buffers).

The RecordCommands method adds all the necessary commands to a provided command buffer, similarly to QuadRenderer.

… (currently not the most efficient, uses memory mapped buffer for boxes)
{1.f, 1.f, 0.f, 1.f},
{1.f, 0.f, 1.f, 1.f},
{0.f, 1.f, 1.f, 1.f},
{1.f, 1.f, 1.f, 1.f}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем? Захардкодь это прямо в шейдер и делай рендеринг просто на N линий, высчитывая координаты из индекса вершины

4, 7
};

BboxRenderer::BboxRenderer(CreateInfo info) : m_drawInstanced(info.drawInstanced), m_extent(info.extent)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем пользователю может понадобится включать или выключать drawInstanced? ему, кажется, должно быть без разницы, главное чтобы боксы рисовались

vk::Image targetImage, vk::ImageView targetImageView,
const etna::Image &depthImage, const LiteMath::float4x4 &mViewProj)
{
etna::RenderTargetState renderTargets(cmdBuff,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем фигачить пасс прямо внтури этого класса? Пусть пользователь сам зовёт этот метод уже внутри пасса, проще класс будет, никаких размеров и форматов знать не нужно будет

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants