draw: increase far Z, separate path for space quads, fix billboard batching

This commit is contained in:
veclavtalica
2025-02-26 13:27:09 +03:00
parent 5f3920fdba
commit a36459397e
10 changed files with 190 additions and 59 deletions

View File

@@ -95,14 +95,15 @@ void finally_draw_billboard_batch(struct MeshBatch const *batch,
const Vec2 uv3c = { xr + wr, yr };
for (size_t batch_n = 0; batch_n <= (primitives_len - 1) / QUAD_ELEMENT_BUFFER_LENGTH; batch_n++) {
size_t const processing = MIN(primitives_len - batch_n * QUAD_ELEMENT_BUFFER_LENGTH, QUAD_ELEMENT_BUFFER_LENGTH);
/* emit vertex data */
VertexBuffer const buffer = get_scratch_vertex_array();
VertexBufferBuilder builder = build_vertex_buffer(
buffer,
sizeof (ElementIndexedBillboard) * MIN(primitives_len - batch_n * QUAD_ELEMENT_BUFFER_LENGTH, QUAD_ELEMENT_BUFFER_LENGTH));
sizeof (ElementIndexedBillboard) * processing);
for (size_t i = 0; i < primitives_len; ++i) {
for (size_t i = 0; i < processing; ++i) {
struct SpaceBillboard const billboard = ((SpaceBillboard *)(void *)batch->primitives)[batch_n * QUAD_ELEMENT_BUFFER_LENGTH + i];
/* a = (right + up) * size, b = (right - up) * size*/
@@ -179,20 +180,20 @@ void finally_draw_billboard_batch(struct MeshBatch const *batch,
.buffer = buffer
};
command.textured = true;
command.texture_key = texture_key;
command.textured = true;
command.element_buffer = get_quad_element_buffer();
command.element_count = 6 * (uint32_t)primitives_len;
command.range_end = 6 * (uint32_t)primitives_len;
command.element_count = 6 * (uint32_t)processing;
command.range_end = 6 * (uint32_t)processing;
/* TODO: support alpha blended case, with distance sort */
TextureMode mode = textures_get_mode(&ctx.texture_cache, texture_key);
if (mode == TEXTURE_MODE_GHOSTLY)
mode = TEXTURE_MODE_SEETHROUGH;
command.texture_mode = mode;
command.pipeline = PIPELINE_SPACE;
command.texture_mode = mode;
command.depth_range_high = depth_range_high;
command.depth_range_low = depth_range_low;