item: use sprite_particle shader for better batching

This commit is contained in:
Andrei Alexeyev 2024-10-03 18:28:53 +02:00
parent 321ba481d9
commit bcc5b17430
No known key found for this signature in database
GPG key ID: 72D26128040B9690

View file

@ -92,6 +92,9 @@ static void ent_draw_item(EntityInterface *ent) {
const int indicator_display_y = 6;
float y = im(i->pos);
ShaderCustomParams shader_params = { 1.0f };
ShaderProgram *shader = res_shader("sprite_particle");
if(y < 0) {
Sprite *s = i->sprites.indicator;
@ -99,6 +102,8 @@ static void ent_draw_item(EntityInterface *ent) {
float alpha = -tanhf(y * 0.1f) / (1 + 0.1 * fabsf(y));
r_draw_sprite(&(SpriteParams) {
.sprite_ptr = s,
.shader_ptr = shader,
.shader_params = &shader_params,
.pos = { re(i->pos), indicator_display_y },
.color = RGBA_MUL_ALPHA(1, 1, 1, alpha),
});
@ -114,6 +119,8 @@ static void ent_draw_item(EntityInterface *ent) {
r_draw_sprite(&(SpriteParams) {
.sprite_ptr = i->sprites.pickup,
.shader_ptr = shader,
.shader_params = &shader_params,
.pos = { re(i->pos), y },
.color = c,
});