Skip to content

Commit a4d8435

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

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-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: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,16 @@ 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
}
150149
a *= clamp(progress * 10.0, 0.0, 1.0);
151-
vec4 color = vec4(col * wa, wa) * a;
150+
a *= clamp(uvpos.x * (width / 30.0), 0.0, 1.0);
151+
a *= clamp((1.0 - uvpos.x) * (width / 30.0), 0.0, 1.0);
152+
vec4 color = vec4(col * a, a);
152153
gl_FragColor = color + wfrag * (1.0 - a);
153154
}
154155
)";
@@ -223,7 +224,7 @@ class burn_transformer : public wf::scene::view_2d_transformer_t
223224
void render(const wf::scene::render_instruction_t& data) override
224225
{
225226
auto bb = self->get_children_bounding_box();
226-
auto pbb = self->get_bounding_box();
227+
auto pbb = self->get_padded_bounding_box();
227228
auto tex = wf::gles_texture_t{get_texture(1.0)};
228229

229230
const float vertices[] = {
@@ -294,7 +295,7 @@ class burn_transformer : public wf::scene::view_2d_transformer_t
294295
wf::gles::render_target_logic_scissor(data.target, wlr_box_from_pixman_box(box));
295296
OpenGL::render_transformed_texture(final_tex, pbb,
296297
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);
298+
glm::vec4(1.0, 1.0, 1.0, std::clamp((progress - 0.07) * 10.0, 0.0, 1.0)), 0);
298299
}
299300

300301
GL_CALL(glBindTexture(GL_TEXTURE_2D, 0));
@@ -321,6 +322,22 @@ class burn_transformer : public wf::scene::view_2d_transformer_t
321322
});
322323
}
323324

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

0 commit comments

Comments
 (0)