vk: fix most of random sprite flickering

it was due to leaving garbage in vertex fields.

some animated spritest still flicker though
This commit is contained in:
Ivan 'provod' Avdeev 2023-02-23 20:05:58 -08:00
parent d6d9011dcc
commit 4f6d51c368
1 changed files with 19 additions and 8 deletions

View File

@ -645,47 +645,58 @@ qboolean R_SpriteOccluded( cl_entity_t *e, vec3_t origin, float *pscale )
return false;
}
static void R_DrawSpriteQuad( const char *debug_name, mspriteframe_t *frame, vec3_t org, vec3_t v_right, vec3_t v_up, float scale, int texture, int render_mode, vec3_t color )
{
vec3_t point;
vk_vertex_t *dst_vtx;
uint16_t *dst_idx;
// Get buffer region for vertices and indices
static void R_DrawSpriteQuad( const char *debug_name, mspriteframe_t *frame, vec3_t org, vec3_t v_right, vec3_t v_up, float scale, int texture, int render_mode, vec3_t color ) {
r_geometry_buffer_lock_t buffer;
if (!R_GeometryBufferAllocAndLock( &buffer, 4, 6, LifetimeSingleFrame )) {
gEngine.Con_Printf(S_ERROR "Cannot allocate geometry for sprite quad\n");
return;
}
vec3_t point;
vk_vertex_t *dst_vtx;
uint16_t *dst_idx;
dst_vtx = buffer.vertices.ptr;
dst_idx = buffer.indices.ptr;
// FIXME VK r_stats.c_sprite_polys++;
vec3_t v_normal;
CrossProduct(v_right, v_up, v_normal);
VectorMA( org, frame->down * scale, v_up, point );
VectorMA( point, frame->left * scale, v_right, dst_vtx[0].pos );
dst_vtx[0].gl_tc[0] = 0.f;
dst_vtx[0].gl_tc[1] = 1.f;
dst_vtx[0].lm_tc[0] = dst_vtx[0].lm_tc[1] = 0.f;
dst_vtx[0].flags = 1; // vertex lighting instead of lightmap lighting
Vector4Set(dst_vtx[0].color, 255, 255, 255, 255);
VectorCopy(v_normal, dst_vtx[0].normal);
VectorMA( org, frame->up * scale, v_up, point );
VectorMA( point, frame->left * scale, v_right, dst_vtx[1].pos );
dst_vtx[1].gl_tc[0] = 0.f;
dst_vtx[1].gl_tc[1] = 0.f;
dst_vtx[1].lm_tc[0] = dst_vtx[1].lm_tc[1] = 0.f;
dst_vtx[1].flags = 1; // vertex lighting instead of lightmap lighting
Vector4Set(dst_vtx[1].color, 255, 255, 255, 255);
VectorCopy(v_normal, dst_vtx[1].normal);
VectorMA( org, frame->up * scale, v_up, point );
VectorMA( point, frame->right * scale, v_right, dst_vtx[2].pos );
dst_vtx[2].gl_tc[0] = 1.f;
dst_vtx[2].gl_tc[1] = 0.f;
dst_vtx[2].lm_tc[0] = dst_vtx[2].lm_tc[1] = 0.f;
dst_vtx[2].flags = 1; // vertex lighting instead of lightmap lighting
Vector4Set(dst_vtx[2].color, 255, 255, 255, 255);
VectorCopy(v_normal, dst_vtx[2].normal);
VectorMA( org, frame->down * scale, v_up, point );
VectorMA( point, frame->right * scale, v_right, dst_vtx[3].pos );
dst_vtx[3].gl_tc[0] = 1.f;
dst_vtx[3].gl_tc[1] = 1.f;
dst_vtx[3].lm_tc[0] = dst_vtx[3].lm_tc[1] = 0.f;
dst_vtx[3].flags = 1; // vertex lighting instead of lightmap lighting
Vector4Set(dst_vtx[3].color, 255, 255, 255, 255);
VectorCopy(v_normal, dst_vtx[3].normal);
dst_idx[0] = 0;
dst_idx[1] = 1;