new bullet clear effect

This commit is contained in:
Andrei Alexeyev 2019-12-27 17:59:15 +02:00
parent 4182078d93
commit 3259a844fa
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
76 changed files with 288 additions and 83 deletions

2
.gitignore vendored
View file

@ -8,3 +8,5 @@ __pycache__
*.kdev4
.kdev4/
*.kate-swp
*~
*-autosave.kra

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 638 KiB

Before After
Before After

View file

@ -0,0 +1,3 @@
@sprite_count = 33
main = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 1609
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 1442
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 1776
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 774
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 1108
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 607
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 941
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 1275
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 1943
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 2110
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 2277
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 2778
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 2611
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 2444
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 2945
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 3112
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 3279
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 3613
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 3446
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 2
region_y = 169
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 3780
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 169
region_y = 169
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 336
region_y = 169
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 503
region_y = 169
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 837
region_y = 169
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 1338
region_y = 169
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 1004
region_y = 169
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 670
region_y = 169
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 1171
region_y = 169
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 1505
region_y = 169
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 273
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 106
region_y = 2
region_w = 163
region_h = 163

View file

@ -0,0 +1,7 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 440
region_y = 2
region_w = 163
region_h = 163

View file

@ -1,8 +1,8 @@
# Autogenerated by the atlas packer, do not modify
texture = atlas_coroutines_temp_0
region_x = 106
region_y = 2
region_x = 1672
region_y = 169
region_w = 42
region_h = 68

View file

@ -45,7 +45,6 @@ glsl_files = files(
'spellcard_walloftext.frag.glsl',
'sprite_bullet.frag.glsl',
'sprite_bullet.vert.glsl',
'sprite_bullet_dead.frag.glsl',
'sprite_circleclipped_indicator.frag.glsl',
'sprite_circleclipped_indicator.vert.glsl',
'sprite_default.frag.glsl',

View file

@ -1,14 +0,0 @@
#version 330 core
#include "lib/sprite_main.frag.glslh"
void spriteMain(out vec4 fragColor) {
vec4 texel = texture(tex, texCoord);
float oWhite = texel.b * (1 - clamp(2 * (1 - customParams.r), 0, 1));
float oColor = texel.g * (1 - clamp(2 * (1 - customParams.r) - 1, 0, 1));
float o = clamp(oWhite + oColor, 0, 1);
vec4 col = (texel.g * color + vec4(texel.b)) * o;
col.a *= o;
fragColor = col;
}

View file

@ -1 +0,0 @@
objects = sprite_bullet.vert sprite_bullet_dead.frag

View file

@ -1,4 +1,8 @@
#!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")"/.. || exit $?
find resources -type f -name "*.png" -or -name '*.webp' | parallel -j$(nproc) scripts/optimize-img.sh
opwd="$PWD"
cd "$(dirname "${BASH_SOURCE[0]}")" || exit $?
script_dir="$PWD"
cd "$opwd" || exit $?
find "$@" -type f -name "*.png" -or -name '*.webp' | parallel -j$(nproc) "$script_dir"/optimize-img.sh

View file

@ -507,15 +507,10 @@ Projectile* spawn_projectile_collision_effect(Projectile *proj) {
}
static void really_clear_projectile(ProjectileList *projlist, Projectile *proj) {
Projectile *effect = spawn_projectile_clear_effect(proj);
Item *clear_item = NULL;
spawn_projectile_clear_effect(proj);
if(!(proj->flags & PFLAG_NOCLEARBONUS)) {
clear_item = create_clear_item(proj->pos, proj->clear_flags);
}
if(clear_item != NULL && effect != NULL) {
effect->args[0] = add_ref(clear_item);
create_clear_item(proj->pos, proj->clear_flags);
}
delete_projectile(projlist, proj);
@ -550,7 +545,6 @@ void kill_projectile(Projectile* proj) {
void process_projectiles(ProjectileList *projlist, bool collision) {
ProjCollisionResult col = { 0 };
char killed = 0;
int action;
bool stage_cleared = stage_is_cleared();
@ -574,9 +568,8 @@ void process_projectiles(ProjectileList *projlist, bool collision) {
proj->graze_counter_reset_timer = global.frames;
}
if(proj->type == PROJ_DEAD && killed < 10 && !(proj->clear_flags & CLEAR_HAZARDS_NOW)) {
if(proj->type == PROJ_DEAD && !(proj->clear_flags & CLEAR_HAZARDS_NOW)) {
proj->clear_flags |= CLEAR_HAZARDS_NOW;
killed++;
}
if(action == ACTION_DESTROY) {
@ -826,49 +819,29 @@ static Projectile* spawn_bullet_spawning_effect(Projectile *p) {
}
static void projectile_clear_effect_draw(Projectile *p, int t, ProjDrawRuleArgs args) {
r_mat_mv_push();
apply_common_transforms(p, t);
float o_tf = projectile_timeout_factor(p);
float tf = glm_ease_circ_out(o_tf);
float timefactor = t / p->timeout;
float plrfactor = clamp(1 - (cabs(p->pos - global.plr.pos) - 64) / 128, 0, 1);
plrfactor *= clamp(timefactor * 10, 0, 1);
float opacity = timefactor * plrfactor;
Animation *ani = args[0].as_ptr;
AniSequence *seq = args[1].as_ptr;
float angle = args[2].as_float[0];
float scale = args[2].as_float[1];
Sprite spr = *p->sprite;
Sprite *ispr = get_sprite("item/bullet_point");
spr.w = lerpf(spr.w, ispr->w, opacity);
spr.h = lerpf(spr.h, ispr->h, opacity);
SpriteParamsBuffer spbuf;
SpriteParams sp = projectile_sprite_params(p, &spbuf);
r_draw_sprite(&(SpriteParams) {
.sprite_ptr = &spr,
.color = &p->color,
.shader_params = &(ShaderCustomParams){{ opacity }},
});
float o = spbuf.shader_params.vector[0];
spbuf.shader_params.vector[0] = o * fmaxf(0, 1.5 * (1 - tf) - 0.5);
r_mat_mv_pop();
}
r_draw_sprite(&sp);
static int projectile_clear_effect_logic(Projectile *p, int t) {
if(t == EVENT_DEATH) {
free_ref(p->args[0]);
return ACTION_ACK;
}
sp.sprite_ptr = animation_get_frame(ani, seq, o_tf * (seq->length - 1));
sp.scale.as_cmplx *= scale * (0.0 + 1.5*tf);
spbuf.color.a *= (1 - tf);
spbuf.shader_params.vector[0] = o;
sp.rotation.angle += t * 0.5*0 + angle;
if(t == EVENT_BIRTH) {
return ACTION_ACK;
}
if((int)p->args[0] < 0) {
return ACTION_NONE;
}
Item *i = REF(p->args[0]);
if(i != NULL) {
p->pos = i->pos;
}
return ACTION_NONE;
r_draw_sprite(&sp);
}
Projectile *spawn_projectile_clear_effect(Projectile *proj) {
@ -876,32 +849,36 @@ Projectile *spawn_projectile_clear_effect(Projectile *proj) {
return NULL;
}
// spawn_projectile_highlight_effect_internal(proj, false);
ShaderProgram *shader = proj->shader;
uint32_t layer = LAYER_PARTICLE_BULLET_CLEAR;
if(proj->shader == defaults_proj.shader_ptr) {
// HACK
shader = r_shader_get("sprite_bullet_dead");
layer |= 0x1;
cmplx v = proj->move.velocity;
if(!v) {
v = proj->pos - proj->prevpos;
}
Animation *ani = get_ani("part/bullet_clear");
AniSequence *seq = get_ani_sequence(ani, "main");
Sprite *sprite_ref = ani->sprites[seq->frames[0].spriteidx];
float scale = fmaxf(proj->sprite->w, proj->sprite->h) / sprite_ref->w;
return PARTICLE(
.sprite_ptr = proj->sprite,
.size = proj->size,
.pos = proj->pos,
.color = &proj->color,
.flags = proj->flags | PFLAG_NOREFLECT | PFLAG_REQUIREDPARTICLE,
.shader_ptr = shader,
.rule = projectile_clear_effect_logic,
.draw_rule = projectile_clear_effect_draw,
.shader_ptr = proj->shader,
.draw_rule = {
projectile_clear_effect_draw,
.args[0].as_ptr = ani,
.args[1].as_ptr = seq,
.args[2].as_float = { rng_angle(), scale },
},
.angle = proj->angle,
.opacity = proj->opacity,
.scale = proj->scale,
.timeout = 24,
.args = { -1 },
.layer = layer,
.timeout = seq->length - 1,
.layer = LAYER_PARTICLE_BULLET_CLEAR,
.move = move_asymptotic(v, 0, 0.85),
);
}
@ -1209,7 +1186,6 @@ void projectiles_preload(void) {
"sprite_silhouette",
defaults_proj.shader,
defaults_part.shader,
"sprite_bullet_dead",
};
const uint num_shaders = sizeof(shaders)/sizeof(*shaders);
@ -1240,6 +1216,10 @@ void projectiles_preload(void) {
"part/stardust_green",
NULL);
preload_resources(RES_ANIM, RESF_PERMANENT,
"part/bullet_clear",
NULL);
preload_resources(RES_SFX, RESF_PERMANENT,
"shot1",
"shot2",

View file

@ -40,6 +40,7 @@ typedef bool (*ProjPredicate)(Projectile *p);
typedef union {
float32 as_float[2];
cmplx32 as_cmplx;
void *as_ptr;
} ProjDrawRuleArgs[RULE_ARGC];
typedef struct ProjDrawRule {