Skip to content

Commit 42dabd2

Browse files
committed
extra-animations: burn: Enhance effect by allowing flames to overflow on the sides
1 parent 960703e commit 42dabd2

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

metadata/extra-animations.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<option name="burn_flame_speed" type="double">
7979
<_short>Burn flame speed</_short>
8080
<_long>The speed at which the flames flicker.</_long>
81-
<default>5</default>
81+
<default>7</default>
8282
<min>1</min>
8383
<max>100</max>
8484
<precision>1</precision>

src/extra-animations/burn.hpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,17 @@ void main()
140140
141141
vec3 col = vec3(1.5 * c1, 1.5 * c1 * c1 * c1, c1 * c1 * c1 * c1 * c1 * c1);
142142
143-
float a = clamp(c * (1.0 - pow(uvpos.y, 3.0)), 0.0, 1.0);
143+
float a = clamp(c * (1.0 - pow(uvpos.y, 10.0)), 0.0, 1.0);
144144
vec4 wfrag = get_pixel(uvpos);
145-
float wa = wfrag.a;
146145
if (uvpos.y < progress)
147146
{
148147
wfrag = vec4(0.0);
149148
}
149+
float side_dither = width * 0.0025;
150150
a *= clamp(progress * 10.0, 0.0, 1.0);
151-
vec4 color = vec4(col * wa, wa) * a;
151+
a *= pow(clamp(uvpos.x * side_dither * 4.0 + side_dither * 0.2, 0.0, 1.0), side_dither);
152+
a *= pow(clamp(((1.0 - uvpos.x) * side_dither * 4.0) + side_dither * 0.2, 0.0, 1.0), side_dither);
153+
vec4 color = vec4(col * a, a);
152154
gl_FragColor = color + wfrag * (1.0 - a);
153155
}
154156
)";
@@ -223,7 +225,7 @@ class burn_transformer : public wf::scene::view_2d_transformer_t
223225
void render(const wf::scene::render_instruction_t& data) override
224226
{
225227
auto bb = self->get_children_bounding_box();
226-
auto pbb = self->get_bounding_box();
228+
auto pbb = self->get_padded_bounding_box();
227229
auto tex = wf::gles_texture_t{get_texture(1.0)};
228230

229231
const float vertices[] = {
@@ -294,7 +296,7 @@ class burn_transformer : public wf::scene::view_2d_transformer_t
294296
wf::gles::render_target_logic_scissor(data.target, wlr_box_from_pixman_box(box));
295297
OpenGL::render_transformed_texture(final_tex, pbb,
296298
wf::gles::render_target_orthographic_projection(data.target),
297-
glm::vec4(1.0, 1.0, 1.0, 1.0 / (1.0 + pow(2.718, -(progress * 15.0 - 3.0)))), 0);
299+
glm::vec4(1.0, 1.0, 1.0, std::clamp((progress - 0.07) * 10.0, 0.0, 1.0)), 0);
298300
}
299301

300302
GL_CALL(glBindTexture(GL_TEXTURE_2D, 0));
@@ -321,6 +323,22 @@ class burn_transformer : public wf::scene::view_2d_transformer_t
321323
});
322324
}
323325

326+
wf::geometry_t get_padded_bounding_box()
327+
{
328+
auto box = this->get_children_bounding_box();
329+
auto padding = 50;
330+
box.x -= padding;
331+
box.y -= padding;
332+
box.width += padding * 2;
333+
box.height += padding * 2;
334+
return box;
335+
}
336+
337+
wf::geometry_t get_bounding_box() override
338+
{
339+
return get_padded_bounding_box();
340+
}
341+
324342
wf::effect_hook_t pre_hook = [=] ()
325343
{
326344
output->render->damage(this->get_bounding_box());

0 commit comments

Comments
 (0)