stage3: remake wriggle's spellbg as a shader (and fix it)

Old version broke when we started using a floating point framebuffer for
the background.
This commit is contained in:
Andrei Alexeyev 2022-02-13 01:21:36 +02:00
parent 52a75e1610
commit 44ef44e24f
No known key found for this signature in database
GPG key ID: 72D26128040B9690
4 changed files with 43 additions and 20 deletions

View file

@ -80,6 +80,7 @@ glsl_files = files(
'ssr.vert.glsl',
'ssr_water.frag.glsl',
'stage1_water.frag.glsl',
'stage3_wriggle_bg.frag.glsl',
'stage6_sky.frag.glsl',
'stage6_sky.vert.glsl',
'standard.frag.glsl',

View file

@ -0,0 +1,26 @@
#version 330 core
#include "lib/render_context.glslh"
#include "interface/standard.glslh"
UNIFORM(1) float time;
UNIFORM(2) sampler2D tex_bg;
UNIFORM(3) sampler2D tex_clouds;
UNIFORM(4) sampler2D tex_swarm;
void main(void) {
vec2 uv = texCoord;
float r = 768.0/1024.0;
vec4 bg = texture(tex_bg, ((uv - 0.5) * vec2(r, 1)) + 0.5);
vec4 cl0 = texture(tex_clouds, uv + vec2(0.004 * sin(4 * time), 0.35 * time));
vec4 cl1 = texture(tex_clouds, uv + vec2(0.004 * cos(3 * time), -0.5 * time));
vec4 sw = texture(tex_swarm, uv + vec2(0, -0.75 * time));
vec4 c0 = bg;
vec4 c1 = clamp(cl0 - c0, 0, 1);
vec4 c2 = 0.5 * sw + c1;
vec4 c3 = clamp(0.4 * cl1 - 0.3*c2, 0, 1);
fragColor = c3;
}

View file

@ -0,0 +1,3 @@
objects = stage3_wriggle_bg.frag standardnotex.vert

View file

@ -15,26 +15,19 @@
MODERNIZE_THIS_FILE_AND_REMOVE_ME
void stage3_draw_wriggle_spellbg(Boss *b, int time) {
r_color4(1,1,1,1);
fill_viewport(0, 0, 768.0/1024.0, "stage3/wspellbg");
r_color4(1,1,1,0.5);
r_blend(r_blend_compose(
BLENDFACTOR_SRC_ALPHA, BLENDFACTOR_ONE, BLENDOP_SUB,
BLENDFACTOR_ZERO, BLENDFACTOR_ONE, BLENDOP_ADD
));
fill_viewport(sin(time) * 0.015, time / 50.0, 1, "stage3/wspellclouds");
r_blend(BLEND_PREMUL_ALPHA);
r_color4(0.5, 0.5, 0.5, 0.0);
fill_viewport(0, time / 70.0, 1, "stage3/wspellswarm");
r_blend(r_blend_compose(
BLENDFACTOR_SRC_ALPHA, BLENDFACTOR_ONE, BLENDOP_SUB,
BLENDFACTOR_ZERO, BLENDFACTOR_ONE, BLENDOP_ADD
));
r_color4(1,1,1,0.4);
fill_viewport(cos(time) * 0.02, time / 30.0, 1, "stage3/wspellclouds");
r_blend(BLEND_PREMUL_ALPHA);
r_color4(1, 1, 1, 1);
r_state_push();
r_blend(BLEND_NONE);
r_shader("stage3_wriggle_bg");
r_uniform_sampler("tex_bg", "stage3/wspellbg");
r_uniform_sampler("tex_clouds", "stage3/wspellclouds");
r_uniform_sampler("tex_swarm", "stage3/wspellswarm");
r_uniform_float("time", time / 60.0f);
r_mat_mv_push();
r_mat_mv_scale(VIEWPORT_W, VIEWPORT_H, 1);
r_mat_mv_translate(0.5, 0.5, 0);
r_draw_quad();
r_mat_mv_pop();
r_state_pop();
}
Boss *stage3_spawn_wriggle(cmplx pos) {