stage3: update background
This commit is contained in:
parent
bed836f56c
commit
684a167611
35 changed files with 110 additions and 41 deletions
BIN
resources/00-taisei.pkgdir/gfx/stage3/envmap.basis
Normal file
BIN
resources/00-taisei.pkgdir/gfx/stage3/envmap.basis
Normal file
Binary file not shown.
|
@ -3,3 +3,5 @@ ambient_map = stage3/ground_ambient
|
|||
diffuse_map = stage3/ground_diffuse
|
||||
normal_map = stage3/ground_normal
|
||||
roughness_map = stage3/ground_roughness
|
||||
ao_map = stage3/ground_ao
|
||||
|
||||
|
|
Binary file not shown.
BIN
resources/00-taisei.pkgdir/gfx/stage3/ground_ao.basis
Normal file
BIN
resources/00-taisei.pkgdir/gfx/stage3/ground_ao.basis
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -3,3 +3,6 @@ ambient_map = stage3/leaves_ambient
|
|||
diffuse_map = stage3/leaves_diffuse
|
||||
normal_map = stage3/leaves_normal
|
||||
roughness_map = stage3/leaves_roughness
|
||||
roughness = 1.7
|
||||
ao_map = stage3/leaves_ao
|
||||
|
||||
|
|
Binary file not shown.
BIN
resources/00-taisei.pkgdir/gfx/stage3/leaves_ao.basis
Normal file
BIN
resources/00-taisei.pkgdir/gfx/stage3/leaves_ao.basis
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -3,3 +3,5 @@ ambient_map = stage3/rocks_ambient
|
|||
diffuse_map = stage3/rocks_diffuse
|
||||
normal_map = stage3/rocks_normal
|
||||
roughness_map = stage3/rocks_roughness
|
||||
ao_map = stage3/rocks_ao
|
||||
|
||||
|
|
Binary file not shown.
BIN
resources/00-taisei.pkgdir/gfx/stage3/rocks_ao.basis
Normal file
BIN
resources/00-taisei.pkgdir/gfx/stage3/rocks_ao.basis
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -3,3 +3,5 @@ ambient_map = stage3/trees_ambient
|
|||
diffuse_map = stage3/trees_diffuse
|
||||
normal_map = stage3/trees_normal
|
||||
roughness_map = stage3/trees_roughness
|
||||
ao_map = stage3/trees_ao
|
||||
|
||||
|
|
Binary file not shown.
BIN
resources/00-taisei.pkgdir/gfx/stage3/trees_ao.basis
Normal file
BIN
resources/00-taisei.pkgdir/gfx/stage3/trees_ao.basis
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -13,13 +13,47 @@
|
|||
|
||||
#include "global.h"
|
||||
#include "stageutils.h"
|
||||
|
||||
// TODO
|
||||
#include "util/glm.h"
|
||||
|
||||
TASK(animate_bg) {
|
||||
for(;;) {
|
||||
YIELD;
|
||||
Stage3DrawData *dd = stage3_get_draw_data();
|
||||
Camera3D *cam = &stage_3d_context.cam;
|
||||
|
||||
dd->target_swing_strength = 0.2f;
|
||||
|
||||
for(int t = 0;; ++t, YIELD) {
|
||||
float f = 1.0f / sqrtf(1.0f + t / 500.0f);
|
||||
glm_vec3_copy((vec3) { f, f, sqrtf(f) }, dd->ambient_color);
|
||||
|
||||
float swing = sin(t / 100.0) * dd->swing_strength;
|
||||
cam->pos[0] = swing;
|
||||
cam->rot.yaw = swing * -8.0f;
|
||||
|
||||
fapproach_asymptotic_p(&dd->swing_strength, dd->target_swing_strength, 0.005f, 1e-3f);
|
||||
|
||||
vec4 f0 = { 0.60, 0.30, 0.60, 1.0 };
|
||||
vec4 f1 = { 0.20, 0.10, 0.30, 1.0 };
|
||||
glm_vec4_lerp(f0, f1, 1 - f, dd->fog_color);
|
||||
|
||||
vec3 e0 = { 2.50, 0.80, 0.50 };
|
||||
vec3 e1 = { 0.20, 0.30, 0.50 };
|
||||
glm_vec3_lerp(e0, e1, 1 - f, dd->environment_color);
|
||||
glm_vec3_scale(dd->environment_color, 0.5 * f, dd->environment_color);
|
||||
|
||||
stage3d_update(&stage_3d_context);
|
||||
|
||||
if(global.boss && !boss_is_fleeing(global.boss)) {
|
||||
fapproach_asymptotic_p(&dd->boss_light_alpha, 1, 0.02f, 1e-3f);
|
||||
} else {
|
||||
fapproach_asymptotic_p(&dd->boss_light_alpha, 0, 0.02f, 1e-3f);
|
||||
}
|
||||
|
||||
if(dd->boss_light_alpha > 0 && global.boss) {
|
||||
vec3 r;
|
||||
camera3d_unprojected_ray(cam, global.boss->pos, r);
|
||||
glm_vec3_scale(r, 14, r);
|
||||
glm_vec3_add(cam->pos, r, dd->boss_light.pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,42 +29,39 @@ static uint stage3_bg_pos(Stage3D *s3d, vec3 cam, float maxrange) {
|
|||
}
|
||||
|
||||
static void stage3_bg_setup_pbr_lighting(Camera3D *cam) {
|
||||
PointLight3D lights[] = {
|
||||
// TODO animate colors
|
||||
{ { 0, 0, 10000 }, { 10, 42, 30 } },
|
||||
{ { 0, 0, 0 }, { 10, 10, 10 } },
|
||||
PointLight3D lights[2] = {
|
||||
{ { 0, 0, 0 }, { 10, 10, 10 } },
|
||||
};
|
||||
|
||||
if(global.boss) {
|
||||
vec3 r;
|
||||
cmplx bpos = global.boss->pos;
|
||||
if(cimag(bpos) < 0) { // to make the light (dis)appear continuously
|
||||
bpos = creal(bpos) + I*pow(fabs(cimag(bpos))*0.1,2)*cimag(bpos);
|
||||
}
|
||||
camera3d_unprojected_ray(cam,bpos,r);
|
||||
glm_vec3_scale(r, 9, r);
|
||||
glm_vec3_add(cam->pos, r, lights[0].pos);
|
||||
PointLight3D *boss_light = &lights[1];
|
||||
uint nlights = 1;
|
||||
|
||||
if(stage3_draw_data->boss_light_alpha > 0) {
|
||||
glm_vec3_scale(
|
||||
stage3_draw_data->boss_light.radiance,
|
||||
stage3_draw_data->boss_light_alpha,
|
||||
boss_light->radiance
|
||||
);
|
||||
glm_vec3_copy(stage3_draw_data->boss_light.pos, boss_light->pos);
|
||||
nlights++;
|
||||
}
|
||||
|
||||
vec3 r;
|
||||
camera3d_unprojected_ray(cam, global.plr.pos,r);
|
||||
camera3d_unprojected_ray(cam, global.plr.pos, r);
|
||||
glm_vec3_scale(r, 5, r);
|
||||
glm_vec3_add(cam->pos, r, lights[1].pos);
|
||||
glm_vec3_add(cam->pos, r, lights[0].pos);
|
||||
|
||||
if(global.frames > 6000) { // wriggle
|
||||
lights[0].radiance[0] = 20;
|
||||
lights[0].radiance[1] = 10;
|
||||
lights[0].radiance[2] = 40;
|
||||
}
|
||||
|
||||
camera3d_set_point_light_uniforms(cam, ARRAY_SIZE(lights), lights);
|
||||
camera3d_set_point_light_uniforms(cam, nlights, lights);
|
||||
}
|
||||
|
||||
static void stage3_bg_setup_pbr_env(Camera3D *cam, PBREnvironment *env) {
|
||||
Stage3DrawData *dd = stage3_get_draw_data();
|
||||
stage3_bg_setup_pbr_lighting(cam);
|
||||
|
||||
float f = 1.0f / (1.0f + global.frames / 1000.0f);
|
||||
glm_vec3_copy((vec3) { f, f, sqrtf(f) }, env->ambient_color);
|
||||
glm_vec3_copy(dd->ambient_color, env->ambient_color);
|
||||
glm_vec3_copy(dd->environment_color, env->environment_color);
|
||||
camera3d_apply_inverse_transforms(cam, env->cam_inverse_transform);
|
||||
env->environment_map = stage3_draw_data->envmap;
|
||||
env->disable_tonemap = true;
|
||||
}
|
||||
|
||||
static void stage3_bg_ground_draw(vec3 pos) {
|
||||
|
@ -114,6 +111,8 @@ void stage3_drawsys_init(void) {
|
|||
pbr_load_model(&stage3_draw_data->models.ground, "stage3/ground", "stage3/ground"); pbr_load_model(&stage3_draw_data->models.leaves, "stage3/leaves", "stage3/leaves");
|
||||
pbr_load_model(&stage3_draw_data->models.rocks, "stage3/rocks", "stage3/rocks");
|
||||
pbr_load_model(&stage3_draw_data->models.trees, "stage3/trees", "stage3/trees");
|
||||
|
||||
stage3_draw_data->envmap = res_texture("stage3/envmap");
|
||||
}
|
||||
|
||||
void stage3_drawsys_shutdown(void) {
|
||||
|
@ -122,13 +121,16 @@ void stage3_drawsys_shutdown(void) {
|
|||
}
|
||||
|
||||
static bool stage3_fog(Framebuffer *fb) {
|
||||
r_shader("zbuf_fog");
|
||||
Stage3DrawData *dd = stage3_get_draw_data();
|
||||
r_shader("zbuf_fog_tonemap");
|
||||
r_uniform_sampler("depth", r_framebuffer_get_attachment(fb, FRAMEBUFFER_ATTACH_DEPTH));
|
||||
r_uniform_vec4("fog_color", 0.8, 0.5, 1, 1.0);
|
||||
r_uniform_float("start", 0.6);
|
||||
r_uniform_vec4_vec("fog_color", dd->fog_color);
|
||||
r_uniform_float("start", 0.9);
|
||||
r_uniform_float("end", 2);
|
||||
r_uniform_float("exponent", 10);
|
||||
r_uniform_float("exponent", 1);
|
||||
r_uniform_float("curvature", 0);
|
||||
float e = 1;
|
||||
r_uniform_vec3("exposure", e, e, e);
|
||||
draw_framebuffer_tex(fb, VIEWPORT_W, VIEWPORT_H);
|
||||
r_shader_standard();
|
||||
return true;
|
||||
|
|
|
@ -20,6 +20,18 @@ typedef struct Stage3DrawData {
|
|||
PBRModel rocks;
|
||||
PBRModel trees;
|
||||
} models;
|
||||
|
||||
Texture *envmap;
|
||||
|
||||
vec3 environment_color;
|
||||
vec3 ambient_color;
|
||||
vec4 fog_color;
|
||||
|
||||
float boss_light_alpha;
|
||||
PointLight3D boss_light;
|
||||
|
||||
float swing_strength;
|
||||
float target_swing_strength;
|
||||
} Stage3DrawData;
|
||||
|
||||
Stage3DrawData *stage3_get_draw_data(void)
|
||||
|
|
|
@ -39,5 +39,6 @@ Boss *stage3_spawn_scuttle(cmplx pos) {
|
|||
boss_set_portrait(scuttle, "scuttle", NULL, "normal");
|
||||
scuttle->glowcolor = *RGB(0.5, 0.6, 0.3);
|
||||
scuttle->shadowcolor = *RGBA_MUL_ALPHA(0.7, 0.3, 0.1, 0.5);
|
||||
scuttle->zoomcolor = *RGB(0.4, 0.1, 0.4);
|
||||
return scuttle;
|
||||
}
|
||||
|
|
|
@ -86,6 +86,8 @@ static void stage3_preload(void) {
|
|||
portrait_preload_face_sprite("scuttle", "normal", RESF_DEFAULT);
|
||||
preload_resources(RES_BGM, RESF_OPTIONAL, "stage3", "stage3boss", NULL);
|
||||
preload_resources(RES_TEXTURE, RESF_DEFAULT,
|
||||
"ibl_brdf_lut",
|
||||
"stage3/envmap",
|
||||
"stage3/spellbg1",
|
||||
"stage3/spellbg2",
|
||||
"stage3/wspellbg",
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "spells/spells.h"
|
||||
#include "nonspells/nonspells.h"
|
||||
#include "background_anim.h"
|
||||
#include "draw.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "stagetext.h"
|
||||
|
@ -545,11 +546,13 @@ TASK(spawn_midboss) {
|
|||
STAGE_BOOKMARK_DELAYED(120, midboss);
|
||||
|
||||
Boss *boss = global.boss = stage3_spawn_scuttle(VIEWPORT_W/2 - 200.0*I);
|
||||
|
||||
glm_vec3_copy((vec3) { -10, -20, -30 }, stage3_get_draw_data()->boss_light.radiance);
|
||||
|
||||
boss_add_attack_task(boss, AT_Move, "Introduction", 1, 0, TASK_INDIRECT(BossAttack, midboss_intro), NULL);
|
||||
boss_add_attack_task(boss, AT_Normal, "Lethal Bite", 11, 20000, TASK_INDIRECT(BossAttack, stage3_midboss_nonspell_1), NULL);
|
||||
boss_add_attack_from_info(boss, &stage3_spells.mid.deadly_dance, false);
|
||||
boss_add_attack_task(boss, AT_Move, "Runaway", 2, 1, TASK_INDIRECT(BossAttack, midboss_outro), NULL);
|
||||
boss->zoomcolor = *RGB(0.4, 0.1, 0.4);
|
||||
|
||||
boss_engage(boss);
|
||||
}
|
||||
|
@ -564,6 +567,8 @@ TASK(spawn_boss) {
|
|||
|
||||
Boss *boss = global.boss = stage3_spawn_wriggle(VIEWPORT_W/2 - 200.0*I);
|
||||
|
||||
glm_vec3_copy((vec3) { 50, 30, 80 }, stage3_get_draw_data()->boss_light.radiance);
|
||||
|
||||
PlayerMode *pm = global.plr.mode;
|
||||
Stage3PreBossDialogEvents *e;
|
||||
INVOKE_TASK_INDIRECT(Stage3PreBossDialog, pm->dialog->Stage3PreBoss, &e);
|
||||
|
@ -680,6 +685,11 @@ static void welcome_swirls(void) {
|
|||
);
|
||||
}
|
||||
|
||||
TASK(set_swing, { float v; }) {
|
||||
Stage3DrawData *dd = stage3_get_draw_data();
|
||||
dd->target_swing_strength = ARGS.v;
|
||||
}
|
||||
|
||||
DEFINE_EXTERN_TASK(stage3_timeline) {
|
||||
stage_start_bgm("stage3");
|
||||
stage_set_voltage_thresholds(50, 125, 300, 600);
|
||||
|
@ -731,11 +741,14 @@ DEFINE_EXTERN_TASK(stage3_timeline) {
|
|||
|
||||
while(!global.boss) YIELD;
|
||||
WAIT_EVENT(&global.boss->events.defeated);
|
||||
STAGE_BOOKMARK(post-midboss);
|
||||
|
||||
INVOKE_TASK(bulletring_fairy_spawn,
|
||||
.count = 10,
|
||||
);
|
||||
|
||||
INVOKE_TASK_DELAYED(60, set_swing, 1.0f);
|
||||
|
||||
INVOKE_TASK_DELAYED(300, horde_fairy_spawn,
|
||||
.count = 20,
|
||||
.interval = 30,
|
||||
|
@ -796,13 +809,9 @@ DEFINE_EXTERN_TASK(stage3_timeline) {
|
|||
},
|
||||
);
|
||||
|
||||
WAIT(150);
|
||||
|
||||
STAGE_BOOKMARK(post-midboss);
|
||||
|
||||
STAGE_BOOKMARK_DELAYED(2800, pre-boss);
|
||||
|
||||
WAIT(3300);
|
||||
STAGE_BOOKMARK_DELAYED(2950, pre-boss);
|
||||
INVOKE_TASK_DELAYED(3200, set_swing, 0.2f);
|
||||
WAIT(3450);
|
||||
|
||||
stage_unlock_bgm("stage3boss");
|
||||
|
||||
|
|
Loading…
Reference in a new issue