revamp stagetext effect
This commit is contained in:
parent
2237b43fbc
commit
09eb5e8814
3 changed files with 16 additions and 6 deletions
|
@ -12,14 +12,13 @@ void main(void) {
|
|||
float t = customParams.r;
|
||||
vec2 tc = texCoord;
|
||||
vec2 tc_overlay = texCoordOverlay;
|
||||
vec2 f = tc_overlay - vec2(0.5);
|
||||
|
||||
tc *= dimensions;
|
||||
tc += 5 * f * sin(10 * (length(f) + t)) * (1 - t);
|
||||
tc.x += sin(tc.y * 0.25 * (1 - pow(1 - t, 2))) * 2 * pow(1 - t, 1);
|
||||
tc.y += cos(tc.x * 0.25 * (1 - pow(1 - t, 2)) + pow(1 - t, 2) * pi * 2) * -2 * pow(1 - t, 0.5);
|
||||
tc /= dimensions;
|
||||
|
||||
float a = tc_mask(tc);
|
||||
|
||||
vec4 textfrag = color * texture(tex, uv_to_region(texRegion, tc)).r * a;
|
||||
|
||||
tc -= vec2(1) / dimensions;
|
||||
|
@ -30,6 +29,8 @@ void main(void) {
|
|||
fragColor = textfrag;
|
||||
fragColor = mix(shadowfrag, textfrag, sqrt(textfrag.a));
|
||||
|
||||
tc_overlay = clamp(tc_overlay,0.01,0.99); // The overlay coordinates are outside of [0,1] in the padding region, so we make sure there are no wrap around artifacts when a bit of text is distorted to this region.
|
||||
// The overlay coordinates are outside of [0,1] in the padding region, so we make sure there are no wrap around artifacts when a bit of text is distorted to this region.
|
||||
tc_overlay = clamp(tc_overlay, 0.01, 0.99);
|
||||
|
||||
fragColor *= clamp((texture(tex_aux[0], tc_overlay).r + 0.5) * 2.5 * t-0.5, 0.0, 1.0);
|
||||
}
|
||||
|
|
|
@ -184,6 +184,7 @@ void draw_main_menu(MenuData *menu) {
|
|||
.pos = { SCREEN_W-5, SCREEN_H-10 },
|
||||
.font = "small",
|
||||
});
|
||||
|
||||
r_shader_standard();
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,14 @@ static void stagetext_draw_single(StageText *txt) {
|
|||
|
||||
int t = global.frames - txt->time.spawn;
|
||||
float f = 1.0 - clamp((txt->time.life - t) / (float)txt->time.fadeout, 0, clamp(t / (float)txt->time.fadein, 0, 1));
|
||||
float ofs_x, ofs_y;
|
||||
|
||||
if(txt->time.life - t < txt->time.fadeout) {
|
||||
ofs_y = 10 * pow(f, 2);
|
||||
ofs_x = 0;
|
||||
} else {
|
||||
ofs_x = ofs_y = 10 * pow(f, 2);
|
||||
}
|
||||
|
||||
if(txt->custom.predraw) {
|
||||
txt->custom.predraw(txt, t, 1.0 - f);
|
||||
|
@ -81,8 +89,8 @@ static void stagetext_draw_single(StageText *txt) {
|
|||
params.shader_ptr = r_shader_get("text_stagetext");
|
||||
params.shader_params = &(ShaderCustomParams){{ 1 - f }},
|
||||
params.aux_textures[0] = get_tex("titletransition");
|
||||
params.pos.x = creal(txt->pos)+10*f*f;
|
||||
params.pos.y = cimag(txt->pos)+10*f*f;
|
||||
params.pos.x = creal(txt->pos) + ofs_x;
|
||||
params.pos.y = cimag(txt->pos) + ofs_y;
|
||||
params.color = &txt->color;
|
||||
|
||||
text_draw(txt->text, ¶ms);
|
||||
|
|
Loading…
Reference in a new issue