stage 3 tweaks

This commit is contained in:
Andrei Alexeyev 2017-10-23 03:55:21 +03:00
parent a1204d40b2
commit 57f6f9d891
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
3 changed files with 109 additions and 37 deletions

View file

@ -5,7 +5,7 @@ varying vec4 TexCoord0;
void main(void) {
gl_Position = ftransform();
gl_FrontColor = gl_Color;
TexCoord0 = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}
@ -14,6 +14,7 @@ void main(void) {
uniform sampler2D tex;
uniform vec3 color;
uniform float mixfactor;
varying vec4 TexCoord0;
@ -32,12 +33,12 @@ float lum(vec3 c) {
void main(void) {
vec3 rgb = texture2D(tex, vec2(TexCoord0.xy)).rgb;
float lum1 = lum(rgb);
float lum2 = lum(color);
vec3 white1 = vec3(min(rgb));
vec3 white2 = vec3(min(color));
vec3 newclr = white1 + (color - white2) * (lum2/lum1);
gl_FragColor = vec4(pow(newclr, vec3(1.3)), 1.0);
gl_FragColor = mix(vec4(rgb, 1.0), vec4(pow(newclr, vec3(1.3)), 1.0), mixfactor);
}

View file

@ -42,8 +42,10 @@ static struct {
float clr_r;
float clr_g;
float clr_b;
float clr_mixfactor;
float fog_exp;
float fog_brightness;
float tunnel_angle;
float tunnel_avel;
@ -89,10 +91,12 @@ void stage3_bg_tunnel_draw(Vector pos) {
void stage3_tunnel(FBO *fbo) {
Shader *shader = get_shader("tunnel");
assert(uniloc(shader, "mixfactor") >= 0); // just so people don't forget to 'make install'; remove this later
glColor4f(1,1,1,1);
glUseProgram(shader->prog);
glUniform3f(uniloc(shader, "color"),stgstate.clr_r,stgstate.clr_g,stgstate.clr_b);
glUniform1f(uniloc(shader, "mixfactor"), stgstate.clr_mixfactor);
glActiveTexture(GL_TEXTURE0 + 2);
glBindTexture(GL_TEXTURE_2D, fbo->depth);
glActiveTexture(GL_TEXTURE0);
@ -107,7 +111,7 @@ void stage3_fog(FBO *fbo) {
glColor4f(1,1,1,1);
glUseProgram(shader->prog);
glUniform1i(uniloc(shader, "depth"), 2);
glUniform4f(uniloc(shader, "fog_color"), .5, .5, .5, 1.0);
glUniform4f(uniloc(shader, "fog_color"), stgstate.fog_brightness, stgstate.fog_brightness, stgstate.fog_brightness, 1.0);
glUniform1f(uniloc(shader, "start"), 0.2);
glUniform1f(uniloc(shader, "end"), 0.8);
glUniform1f(uniloc(shader, "exponent"), stgstate.fog_exp/2);
@ -157,6 +161,8 @@ void stage3_start(void) {
stgstate.clr_r = 1.0;
stgstate.clr_g = 0.0;
stgstate.clr_b = 0.5;
stgstate.clr_mixfactor = 1.0;
stgstate.fog_brightness = 0.5;
}
void stage3_preload(void) {
@ -191,6 +197,12 @@ void stage3_draw(void) {
set_perspective(&bgcontext, 300, 5000);
stgstate.tunnel_angle += stgstate.tunnel_avel;
bgcontext.crot[2] = -(creal(global.plr.pos)-VIEWPORT_W/2)/80.0;
if(global.dialog) {
draw_stage3d(&bgcontext, 7000);
return;
}
#if 1
FROM_TO(0, 160, 1) {
bgcontext.cv[1] -= 0.5/2;
@ -269,6 +281,7 @@ void stage3_draw(void) {
FROM_TO(3300 + midboss_time, 3360 + midboss_time, 1) {
stgstate.tunnel_avel += 2 / 60.0;
stgstate.tunnel_side += 70 / 60.0;
bgcontext.cx[2] += (-30 - bgcontext.cx[2]) * 0.04;
}
FROM_TO(3600 + midboss_time, 3700 + midboss_time, 1) {
@ -290,6 +303,9 @@ void stage3_draw(void) {
FROM_TO(4390 + midboss_time, 4510 + midboss_time, 1) {
stgstate.clr_r += .5 / 120.0;
bgcontext.cx[2] += (0 - bgcontext.cx[2]) * 0.05;
stgstate.fog_exp = approach(stgstate.fog_exp, 4, 1/20.0);
log_debug("%f %f", bgcontext.cx[2], stgstate.fog_exp);
}
FROM_TO(4299 + midboss_time, 5299 + midboss_time, 1) {
@ -304,20 +320,32 @@ void stage3_draw(void) {
bgcontext.cv[1] += 90 / 200.0/2;
stgstate.tunnel_avel -= 1.1 / 200.0;
bgcontext.crot[0] -= 15 / 200.0;
//stgstate.fog_exp += 3.0 / 200.0;
stgstate.fog_exp = approach(stgstate.fog_exp, 2.5, 1/50.0);
log_debug("%f", stgstate.fog_exp);
}
FROM_TO(5200 + midboss_time, 5300 + midboss_time, 1) {
bgcontext.cx[2] += (-50 - bgcontext.cx[2]) * 0.02;
}
// 5300 - BOSS
FROM_TO(5301 + midboss_time, 5500 + midboss_time, 1) {
bgcontext.cv[1] -= 70 / 200.0/2;
stgstate.clr_r += 1.1 / 200.0;
}
FROM_TO(5301 + midboss_time, 5700 + midboss_time, 1) {
bgcontext.crot[0] -= 10 / 400.0;
stgstate.fog_exp -= 2.0 / 400.0;
//stgstate.tunnel_avel -= 0.5 / 200.0;
stgstate.tunnel_avel = (0 - stgstate.tunnel_avel) * 0.02;
bgcontext.cx[2] += (-500 - bgcontext.cx[2]) * 0.02;
bgcontext.crot[0] += (-180 - bgcontext.crot[0]) * 0.004;
stgstate.clr_mixfactor = approach(stgstate.clr_mixfactor, 0, 1/300.0);
stgstate.fog_brightness = approach(stgstate.fog_brightness, 1.0, 1/200.0);
stgstate.fog_exp = approach(stgstate.fog_exp, 3, 1/50.0);
bgcontext.cv[1] = approach(bgcontext.cv[1], -20, 1/10.0);
stgstate.clr_r = approach(stgstate.clr_r, 0.6, 1.0/200.0);
stgstate.clr_g = approach(stgstate.clr_g, 0.3, 1.0/200.0);
stgstate.clr_b = approach(stgstate.clr_b, 0.4, 1.0/200.0);
log_debug("%f %f %f %f %f", stgstate.fog_brightness, stgstate.fog_exp, bgcontext.cx[0], bgcontext.cx[1], bgcontext.cx[2]);
}
#endif
@ -345,6 +373,11 @@ void stage3_spellpractice_events(void) {
}
}
void stage3_skip(int t) {
skip_background_anim(&bgcontext, stage3_draw, t, &global.timer, &global.frames);
audio_backend_music_set_position(global.timer / (double)FPS);
}
ShaderRule stage3_shaders[] = { stage3_fog, stage3_tunnel, NULL };
ShaderRule stage3_postprocess[] = { stage3_glitch, NULL };

View file

@ -167,6 +167,18 @@ static int stage3_slavefairy2(Enemy *e, int t) {
return 1;
}
static void charge_effect(Enemy *e, int t, int chargetime) {
TIMER(&t);
FROM_TO(chargetime - 30, chargetime, 1) {
complex n = cexp(2.0*I*M_PI*frand());
float l = 50*frand()+25;
float s = 4+_i*0.01;
float alpha = 0.5;
create_particle2c("flare", e->pos+l*n, rgb(alpha, alpha, 0.5*alpha), FadeAdd, timeout_linear, l/s, -s*n);
}
}
static int stage3_burstfairy(Enemy *e, int t) {
TIMER(&t)
@ -179,19 +191,37 @@ static int stage3_burstfairy(Enemy *e, int t) {
e->alpha = 0;
}
int bursttime = e->args[3];
int bursttime = creal(e->args[3]);
int prebursttime = cimag(e->args[3]);
int burstspan = 30;
if(t < bursttime) {
GO_TO(e, e->args[0], 0.05)
GO_TO(e, e->args[0], 0.08)
}
int step = 3 - (global.diff > D_Normal);
if(prebursttime > 0) {
AT(prebursttime) {
play_sound("shot_special1");
int cnt = 6 + 4 * global.diff;
for(int p = 0; p < cnt; ++p) {
complex dir = cexp(I*M_PI*2*p/cnt);
create_projectile2c("ball", e->args[0],
rgb(0.2, 0.1, 0.5), asymptotic,
dir, 10 + 4 * global.diff
);
}
}
}
AT(bursttime) {
play_sound("shot_special1");
}
int step = 3 - (global.diff > D_Normal);
charge_effect(e, t, bursttime);
FROM_TO_SND("shot1_loop", bursttime, bursttime + burstspan, step) {
double phase = (t - bursttime) / (double)burstspan;
complex dir = cexp(I*M_PI*phase);
@ -263,18 +293,11 @@ static int stage3_chargefairy(Enemy *e, int t) {
}
int chargetime = e->args[1];
FROM_TO(chargetime - 30, chargetime, 1) {
complex n = cexp(2.0*I*M_PI*frand());
float l = 50*frand()+25;
float s = 4+_i*0.01;
float alpha = 0.5;
create_particle2c("flare", e->pos+l*n, rgb(alpha, alpha, 0.5*alpha), FadeAdd, timeout_linear, l/s, -s*n);
}
int cnt = 19 - 4 * (D_Lunatic - global.diff);
int step = 1;
charge_effect(e, t, chargetime);
FROM_TO_SND("shot1_loop", chargetime, chargetime + cnt * step - 1, step) {
complex aim = e->args[3] - e->pos;
aim /= cabs(aim);
@ -399,7 +422,7 @@ static int stage3_cornerfairy(Enemy *e, int t) {
bool wave = global.diff > D_Easy && cabs(e->args[2]);
create_projectile2c(wave ? "wave" : "thickrice", e->pos, cabs(e->args[2])? rgb(0.5 - c*0.2, 0.3 + c*0.7, 1.0) : rgb(1.0 - c*0.5, 0.6, 0.5 + c*0.5), asymptotic,
(1.2+0.3*global.diff-0.6*wave*!!(e->args[2]))*cexp(I*((2*i*M_PI/cnt)+carg((VIEWPORT_W+I*VIEWPORT_H)/2 - e->pos))),
(1.8-0.4*wave*!!(e->args[2]))*cexp(I*((2*i*M_PI/cnt)+carg((VIEWPORT_W+I*VIEWPORT_H)/2 - e->pos))),
1.5
);
}
@ -924,13 +947,22 @@ void wriggle_light_singularity(Boss *boss, int time) {
}
play_sound("charge_generic");
boss->ani.stdrow = 0;
}
if(time > 120) {
play_loop("shot1_loop");
}
if(time > 0 && !(time % 300)) {
if(time == 0) {
return;
}
if(!((time+30) % 300)) {
aniplayer_queue(&boss->ani, 2, 0, 0);
}
if(!(time % 300)) {
char *ptype = NULL;
switch(time / 300 - 1) {
@ -958,6 +990,8 @@ void wriggle_light_singularity(Boss *boss, int time) {
}
play_sound("shot_special1");
} else if(!(time % 150)) {
aniplayer_queue(&boss->ani, 1, 1, 0);
}
}
@ -1155,13 +1189,14 @@ Boss* stage3_create_boss(void) {
return wriggle;
}
void stage3_skip(int t);
void stage3_events(void) {
TIMER(&global.timer);
AT(0) {
stage_start_bgm("stage3");
global.frames = global.timer = getenvint("STAGE3_TEST", 0);
audio_backend_music_set_position(global.timer / (double)FPS);
stage3_skip(getenvint("STAGE3_TEST", 0));
}
FROM_TO(160, 300, 10) {
@ -1325,14 +1360,17 @@ void stage3_events(void) {
{
int cnt = 4;
int step = 60;
int step = 70;
int start = 4000 + midboss_time;
FROM_TO(start, start + step * cnt - 1, step) {
int i = _i % cnt;
double span = 300 - 60 * (1-i/2);
complex pos1 = VIEWPORT_W/2;
complex pos2 = VIEWPORT_W/2 + span * (-0.5 + (i&1)) + (VIEWPORT_H/3 + 100*(i/2))*I;
create_enemy4c(pos1, 3000, BigFairy, stage3_burstfairy, pos2, i&1, 0, start + step * 5 - global.timer);
create_enemy4c(pos1, 3000, BigFairy, stage3_burstfairy, pos2, i&1, 0,
(start + 300 - global.timer) + I *
(30)
);
}
}
@ -1354,7 +1392,7 @@ void stage3_events(void) {
create_enemy3c(p4, 500, Fairy, stage3_cornerfairy, p4 - offs + offs*I, p1 - offs - offs*I, 1);
}
if(global.diff > D_Normal) AT(4420 + midboss_time) {
if(global.diff > D_Normal) AT(4480 + midboss_time) {
double offs = -50;
complex p1 = VIEWPORT_W/2+0*I;
@ -1362,10 +1400,10 @@ void stage3_events(void) {
complex p3 = VIEWPORT_W/2+VIEWPORT_H*I;
complex p4 = 0+VIEWPORT_H/2*I;
create_enemy3c(p1, 500, Fairy, stage3_cornerfairy, p1 - offs*I, p2 + offs, 1);
create_enemy3c(p2, 500, Fairy, stage3_cornerfairy, p2 + offs, p3 + offs*I, 1);
create_enemy3c(p3, 500, Fairy, stage3_cornerfairy, p3 + offs*I, p4 - offs, 1);
create_enemy3c(p4, 500, Fairy, stage3_cornerfairy, p4 - offs, p1 + offs*I, 1);
create_enemy3c(p1, 500, Fairy, stage3_cornerfairy, p1 - offs*I, p2 + offs, 0);
create_enemy3c(p2, 500, Fairy, stage3_cornerfairy, p2 + offs, p3 + offs*I, 0);
create_enemy3c(p3, 500, Fairy, stage3_cornerfairy, p3 + offs*I, p4 - offs, 0);
create_enemy3c(p4, 500, Fairy, stage3_cornerfairy, p4 - offs, p1 + offs*I, 0);
}
FROM_TO(4760 + midboss_time, 4940 + midboss_time, 10+2*(D_Lunatic-global.diff)) {