BlueGit

timfa kwin-marble

Marble: KWin close effect (Burn-My-Windows variant)

timfa Tim Falken · pushed by timfa

Authored 2026-11-02 · 2 weeks ago

Hash
096df69f8b996b4a857cdf4a5f2d715cd2d769ca
10 files changed +2618 −0
LICENSE added +674 −0
@@ -0,0 +1,674 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 3, 29 June 2007
3
4 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8 Preamble
9
10 The GNU General Public License is a free, copyleft license for
11 software and other kinds of works.
12
13 The licenses for most software and other practical works are designed
14 to take away your freedom to share and change the works. By contrast,
15 the GNU General Public License is intended to guarantee your freedom to
16 share and change all versions of a program--to make sure it remains free
17 software for all its users. We, the Free Software Foundation, use the
18 GNU General Public License for most of our software; it applies also to
19 any other work released this way by its authors. You can apply it to
20 your programs, too.
21
22 When we speak of free software, we are referring to freedom, not
23 price. Our General Public Licenses are designed to make sure that you
24 have the freedom to distribute copies of free software (and charge for
25 them if you wish), that you receive source code or can get it if you
26 want it, that you can change the software or use pieces of it in new
27 free programs, and that you know you can do these things.
28
29 To protect your rights, we need to prevent others from denying you
30 these rights or asking you to surrender the rights. Therefore, you have
31 certain responsibilities if you distribute copies of the software, or if
32 you modify it: responsibilities to respect the freedom of others.
33
34 For example, if you distribute copies of such a program, whether
35 gratis or for a fee, you must pass on to the recipients the same
36 freedoms that you received. You must make sure that they, too, receive
37 or can get the source code. And you must show them these terms so they
38 know their rights.
39
40 Developers that use the GNU GPL protect your rights with two steps:
41 (1) assert copyright on the software, and (2) offer you this License
42 giving you legal permission to copy, distribute and/or modify it.
43
44 For the developers' and authors' protection, the GPL clearly explains
45 that there is no warranty for this free software. For both users' and
46 authors' sake, the GPL requires that modified versions be marked as
47 changed, so that their problems will not be attributed erroneously to
48 authors of previous versions.
49
50 Some devices are designed to deny users access to install or run
51 modified versions of the software inside them, although the manufacturer
52 can do so. This is fundamentally incompatible with the aim of
53 protecting users' freedom to change the software. The systematic
54 pattern of such abuse occurs in the area of products for individuals to
55 use, which is precisely where it is most unacceptable. Therefore, we
56 have designed this version of the GPL to prohibit the practice for those
57 products. If such problems arise substantially in other domains, we
58 stand ready to extend this provision to those domains in future versions
59 of the GPL, as needed to protect the freedom of users.
60
61 Finally, every program is threatened constantly by software patents.
62 States should not allow patents to restrict development and use of
63 software on general-purpose computers, but in those that do, we wish to
64 avoid the special danger that patents applied to a free program could
65 make it effectively proprietary. To prevent this, the GPL assures that
66 patents cannot be used to render the program non-free.
67
68 The precise terms and conditions for copying, distribution and
69 modification follow.
70
71 TERMS AND CONDITIONS
72
73 0. Definitions.
74
75 "This License" refers to version 3 of the GNU General Public License.
76
77 "Copyright" also means copyright-like laws that apply to other kinds of
78 works, such as semiconductor masks.
79
80 "The Program" refers to any copyrightable work licensed under this
81 License. Each licensee is addressed as "you". "Licensees" and
82 "recipients" may be individuals or organizations.
83
84 To "modify" a work means to copy from or adapt all or part of the work
85 in a fashion requiring copyright permission, other than the making of an
86 exact copy. The resulting work is called a "modified version" of the
87 earlier work or a work "based on" the earlier work.
88
89 A "covered work" means either the unmodified Program or a work based
90 on the Program.
91
92 To "propagate" a work means to do anything with it that, without
93 permission, would make you directly or secondarily liable for
94 infringement under applicable copyright law, except executing it on a
95 computer or modifying a private copy. Propagation includes copying,
96 distribution (with or without modification), making available to the
97 public, and in some countries other activities as well.
98
99 To "convey" a work means any kind of propagation that enables other
100 parties to make or receive copies. Mere interaction with a user through
101 a computer network, with no transfer of a copy, is not conveying.
102
103 An interactive user interface displays "Appropriate Legal Notices"
104 to the extent that it includes a convenient and prominently visible
105 feature that (1) displays an appropriate copyright notice, and (2)
106 tells the user that there is no warranty for the work (except to the
107 extent that warranties are provided), that licensees may convey the
108 work under this License, and how to view a copy of this License. If
109 the interface presents a list of user commands or options, such as a
110 menu, a prominent item in the list meets this criterion.
111
112 1. Source Code.
113
114 The "source code" for a work means the preferred form of the work
115 for making modifications to it. "Object code" means any non-source
116 form of a work.
117
118 A "Standard Interface" means an interface that either is an official
119 standard defined by a recognized standards body, or, in the case of
120 interfaces specified for a particular programming language, one that
121 is widely used among developers working in that language.
122
123 The "System Libraries" of an executable work include anything, other
124 than the work as a whole, that (a) is included in the normal form of
125 packaging a Major Component, but which is not part of that Major
126 Component, and (b) serves only to enable use of the work with that
127 Major Component, or to implement a Standard Interface for which an
128 implementation is available to the public in source code form. A
129 "Major Component", in this context, means a major essential component
130 (kernel, window system, and so on) of the specific operating system
131 (if any) on which the executable work runs, or a compiler used to
132 produce the work, or an object code interpreter used to run it.
133
134 The "Corresponding Source" for a work in object code form means all
135 the source code needed to generate, install, and (for an executable
136 work) run the object code and to modify the work, including scripts to
137 control those activities. However, it does not include the work's
138 System Libraries, or general-purpose tools or generally available free
139 programs which are used unmodified in performing those activities but
140 which are not part of the work. For example, Corresponding Source
141 includes interface definition files associated with source files for
142 the work, and the source code for shared libraries and dynamically
143 linked subprograms that the work is specifically designed to require,
144 such as by intimate data communication or control flow between those
145 subprograms and other parts of the work.
146
147 The Corresponding Source need not include anything that users
148 can regenerate automatically from other parts of the Corresponding
149 Source.
150
151 The Corresponding Source for a work in source code form is that
152 same work.
153
154 2. Basic Permissions.
155
156 All rights granted under this License are granted for the term of
157 copyright on the Program, and are irrevocable provided the stated
158 conditions are met. This License explicitly affirms your unlimited
159 permission to run the unmodified Program. The output from running a
160 covered work is covered by this License only if the output, given its
161 content, constitutes a covered work. This License acknowledges your
162 rights of fair use or other equivalent, as provided by copyright law.
163
164 You may make, run and propagate covered works that you do not
165 convey, without conditions so long as your license otherwise remains
166 in force. You may convey covered works to others for the sole purpose
167 of having them make modifications exclusively for you, or provide you
168 with facilities for running those works, provided that you comply with
169 the terms of this License in conveying all material for which you do
170 not control copyright. Those thus making or running the covered works
171 for you must do so exclusively on your behalf, under your direction
172 and control, on terms that prohibit them from making any copies of
173 your copyrighted material outside their relationship with you.
174
175 Conveying under any other circumstances is permitted solely under
176 the conditions stated below. Sublicensing is not allowed; section 10
177 makes it unnecessary.
178
179 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
181 No covered work shall be deemed part of an effective technological
182 measure under any applicable law fulfilling obligations under article
183 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 similar laws prohibiting or restricting circumvention of such
185 measures.
186
187 When you convey a covered work, you waive any legal power to forbid
188 circumvention of technological measures to the extent such circumvention
189 is effected by exercising rights under this License with respect to
190 the covered work, and you disclaim any intention to limit operation or
191 modification of the work as a means of enforcing, against the work's
192 users, your or third parties' legal rights to forbid circumvention of
193 technological measures.
194
195 4. Conveying Verbatim Copies.
196
197 You may convey verbatim copies of the Program's source code as you
198 receive it, in any medium, provided that you conspicuously and
199 appropriately publish on each copy an appropriate copyright notice;
200 keep intact all notices stating that this License and any
201 non-permissive terms added in accord with section 7 apply to the code;
202 keep intact all notices of the absence of any warranty; and give all
203 recipients a copy of this License along with the Program.
204
205 You may charge any price or no price for each copy that you convey,
206 and you may offer support or warranty protection for a fee.
207
208 5. Conveying Modified Source Versions.
209
210 You may convey a work based on the Program, or the modifications to
211 produce it from the Program, in the form of source code under the
212 terms of section 4, provided that you also meet all of these conditions:
213
214 a) The work must carry prominent notices stating that you modified
215 it, and giving a relevant date.
216
217 b) The work must carry prominent notices stating that it is
218 released under this License and any conditions added under section
219 7. This requirement modifies the requirement in section 4 to
220 "keep intact all notices".
221
222 c) You must license the entire work, as a whole, under this
223 License to anyone who comes into possession of a copy. This
224 License will therefore apply, along with any applicable section 7
225 additional terms, to the whole of the work, and all its parts,
226 regardless of how they are packaged. This License gives no
227 permission to license the work in any other way, but it does not
228 invalidate such permission if you have separately received it.
229
230 d) If the work has interactive user interfaces, each must display
231 Appropriate Legal Notices; however, if the Program has interactive
232 interfaces that do not display Appropriate Legal Notices, your
233 work need not make them do so.
234
235 A compilation of a covered work with other separate and independent
236 works, which are not by their nature extensions of the covered work,
237 and which are not combined with it such as to form a larger program,
238 in or on a volume of a storage or distribution medium, is called an
239 "aggregate" if the compilation and its resulting copyright are not
240 used to limit the access or legal rights of the compilation's users
241 beyond what the individual works permit. Inclusion of a covered work
242 in an aggregate does not cause this License to apply to the other
243 parts of the aggregate.
244
245 6. Conveying Non-Source Forms.
246
247 You may convey a covered work in object code form under the terms
248 of sections 4 and 5, provided that you also convey the
249 machine-readable Corresponding Source under the terms of this License,
250 in one of these ways:
251
252 a) Convey the object code in, or embodied in, a physical product
253 (including a physical distribution medium), accompanied by the
254 Corresponding Source fixed on a durable physical medium
255 customarily used for software interchange.
256
257 b) Convey the object code in, or embodied in, a physical product
258 (including a physical distribution medium), accompanied by a
259 written offer, valid for at least three years and valid for as
260 long as you offer spare parts or customer support for that product
261 model, to give anyone who possesses the object code either (1) a
262 copy of the Corresponding Source for all the software in the
263 product that is covered by this License, on a durable physical
264 medium customarily used for software interchange, for a price no
265 more than your reasonable cost of physically performing this
266 conveying of source, or (2) access to copy the
267 Corresponding Source from a network server at no charge.
268
269 c) Convey individual copies of the object code with a copy of the
270 written offer to provide the Corresponding Source. This
271 alternative is allowed only occasionally and noncommercially, and
272 only if you received the object code with such an offer, in accord
273 with subsection 6b.
274
275 d) Convey the object code by offering access from a designated
276 place (gratis or for a charge), and offer equivalent access to the
277 Corresponding Source in the same way through the same place at no
278 further charge. You need not require recipients to copy the
279 Corresponding Source along with the object code. If the place to
280 copy the object code is a network server, the Corresponding Source
281 may be on a different server (operated by you or a third party)
282 that supports equivalent copying facilities, provided you maintain
283 clear directions next to the object code saying where to find the
284 Corresponding Source. Regardless of what server hosts the
285 Corresponding Source, you remain obligated to ensure that it is
286 available for as long as needed to satisfy these requirements.
287
288 e) Convey the object code using peer-to-peer transmission, provided
289 you inform other peers where the object code and Corresponding
290 Source of the work are being offered to the general public at no
291 charge under subsection 6d.
292
293 A separable portion of the object code, whose source code is excluded
294 from the Corresponding Source as a System Library, need not be
295 included in conveying the object code work.
296
297 A "User Product" is either (1) a "consumer product", which means any
298 tangible personal property which is normally used for personal, family,
299 or household purposes, or (2) anything designed or sold for incorporation
300 into a dwelling. In determining whether a product is a consumer product,
301 doubtful cases shall be resolved in favor of coverage. For a particular
302 product received by a particular user, "normally used" refers to a
303 typical or common use of that class of product, regardless of the status
304 of the particular user or of the way in which the particular user
305 actually uses, or expects or is expected to use, the product. A product
306 is a consumer product regardless of whether the product has substantial
307 commercial, industrial or non-consumer uses, unless such uses represent
308 the only significant mode of use of the product.
309
310 "Installation Information" for a User Product means any methods,
311 procedures, authorization keys, or other information required to install
312 and execute modified versions of a covered work in that User Product from
313 a modified version of its Corresponding Source. The information must
314 suffice to ensure that the continued functioning of the modified object
315 code is in no case prevented or interfered with solely because
316 modification has been made.
317
318 If you convey an object code work under this section in, or with, or
319 specifically for use in, a User Product, and the conveying occurs as
320 part of a transaction in which the right of possession and use of the
321 User Product is transferred to the recipient in perpetuity or for a
322 fixed term (regardless of how the transaction is characterized), the
323 Corresponding Source conveyed under this section must be accompanied
324 by the Installation Information. But this requirement does not apply
325 if neither you nor any third party retains the ability to install
326 modified object code on the User Product (for example, the work has
327 been installed in ROM).
328
329 The requirement to provide Installation Information does not include a
330 requirement to continue to provide support service, warranty, or updates
331 for a work that has been modified or installed by the recipient, or for
332 the User Product in which it has been modified or installed. Access to a
333 network may be denied when the modification itself materially and
334 adversely affects the operation of the network or violates the rules and
335 protocols for communication across the network.
336
337 Corresponding Source conveyed, and Installation Information provided,
338 in accord with this section must be in a format that is publicly
339 documented (and with an implementation available to the public in
340 source code form), and must require no special password or key for
341 unpacking, reading or copying.
342
343 7. Additional Terms.
344
345 "Additional permissions" are terms that supplement the terms of this
346 License by making exceptions from one or more of its conditions.
347 Additional permissions that are applicable to the entire Program shall
348 be treated as though they were included in this License, to the extent
349 that they are valid under applicable law. If additional permissions
350 apply only to part of the Program, that part may be used separately
351 under those permissions, but the entire Program remains governed by
352 this License without regard to the additional permissions.
353
354 When you convey a copy of a covered work, you may at your option
355 remove any additional permissions from that copy, or from any part of
356 it. (Additional permissions may be written to require their own
357 removal in certain cases when you modify the work.) You may place
358 additional permissions on material, added by you to a covered work,
359 for which you have or can give appropriate copyright permission.
360
361 Notwithstanding any other provision of this License, for material you
362 add to a covered work, you may (if authorized by the copyright holders of
363 that material) supplement the terms of this License with terms:
364
365 a) Disclaiming warranty or limiting liability differently from the
366 terms of sections 15 and 16 of this License; or
367
368 b) Requiring preservation of specified reasonable legal notices or
369 author attributions in that material or in the Appropriate Legal
370 Notices displayed by works containing it; or
371
372 c) Prohibiting misrepresentation of the origin of that material, or
373 requiring that modified versions of such material be marked in
374 reasonable ways as different from the original version; or
375
376 d) Limiting the use for publicity purposes of names of licensors or
377 authors of the material; or
378
379 e) Declining to grant rights under trademark law for use of some
380 trade names, trademarks, or service marks; or
381
382 f) Requiring indemnification of licensors and authors of that
383 material by anyone who conveys the material (or modified versions of
384 it) with contractual assumptions of liability to the recipient, for
385 any liability that these contractual assumptions directly impose on
386 those licensors and authors.
387
388 All other non-permissive additional terms are considered "further
389 restrictions" within the meaning of section 10. If the Program as you
390 received it, or any part of it, contains a notice stating that it is
391 governed by this License along with a term that is a further
392 restriction, you may remove that term. If a license document contains
393 a further restriction but permits relicensing or conveying under this
394 License, you may add to a covered work material governed by the terms
395 of that license document, provided that the further restriction does
396 not survive such relicensing or conveying.
397
398 If you add terms to a covered work in accord with this section, you
399 must place, in the relevant source files, a statement of the
400 additional terms that apply to those files, or a notice indicating
401 where to find the applicable terms.
402
403 Additional terms, permissive or non-permissive, may be stated in the
404 form of a separately written license, or stated as exceptions;
405 the above requirements apply either way.
406
407 8. Termination.
408
409 You may not propagate or modify a covered work except as expressly
410 provided under this License. Any attempt otherwise to propagate or
411 modify it is void, and will automatically terminate your rights under
412 this License (including any patent licenses granted under the third
413 paragraph of section 11).
414
415 However, if you cease all violation of this License, then your
416 license from a particular copyright holder is reinstated (a)
417 provisionally, unless and until the copyright holder explicitly and
418 finally terminates your license, and (b) permanently, if the copyright
419 holder fails to notify you of the violation by some reasonable means
420 prior to 60 days after the cessation.
421
422 Moreover, your license from a particular copyright holder is
423 reinstated permanently if the copyright holder notifies you of the
424 violation by some reasonable means, this is the first time you have
425 received notice of violation of this License (for any work) from that
426 copyright holder, and you cure the violation prior to 30 days after
427 your receipt of the notice.
428
429 Termination of your rights under this section does not terminate the
430 licenses of parties who have received copies or rights from you under
431 this License. If your rights have been terminated and not permanently
432 reinstated, you do not qualify to receive new licenses for the same
433 material under section 10.
434
435 9. Acceptance Not Required for Having Copies.
436
437 You are not required to accept this License in order to receive or
438 run a copy of the Program. Ancillary propagation of a covered work
439 occurring solely as a consequence of using peer-to-peer transmission
440 to receive a copy likewise does not require acceptance. However,
441 nothing other than this License grants you permission to propagate or
442 modify any covered work. These actions infringe copyright if you do
443 not accept this License. Therefore, by modifying or propagating a
444 covered work, you indicate your acceptance of this License to do so.
445
446 10. Automatic Licensing of Downstream Recipients.
447
448 Each time you convey a covered work, the recipient automatically
449 receives a license from the original licensors, to run, modify and
450 propagate that work, subject to this License. You are not responsible
451 for enforcing compliance by third parties with this License.
452
453 An "entity transaction" is a transaction transferring control of an
454 organization, or substantially all assets of one, or subdividing an
455 organization, or merging organizations. If propagation of a covered
456 work results from an entity transaction, each party to that
457 transaction who receives a copy of the work also receives whatever
458 licenses to the work the party's predecessor in interest had or could
459 give under the previous paragraph, plus a right to possession of the
460 Corresponding Source of the work from the predecessor in interest, if
461 the predecessor has it or can get it with reasonable efforts.
462
463 You may not impose any further restrictions on the exercise of the
464 rights granted or affirmed under this License. For example, you may
465 not impose a license fee, royalty, or other charge for exercise of
466 rights granted under this License, and you may not initiate litigation
467 (including a cross-claim or counterclaim in a lawsuit) alleging that
468 any patent claim is infringed by making, using, selling, offering for
469 sale, or importing the Program or any portion of it.
470
471 11. Patents.
472
473 A "contributor" is a copyright holder who authorizes use under this
474 License of the Program or a work on which the Program is based. The
475 work thus licensed is called the contributor's "contributor version".
476
477 A contributor's "essential patent claims" are all patent claims
478 owned or controlled by the contributor, whether already acquired or
479 hereafter acquired, that would be infringed by some manner, permitted
480 by this License, of making, using, or selling its contributor version,
481 but do not include claims that would be infringed only as a
482 consequence of further modification of the contributor version. For
483 purposes of this definition, "control" includes the right to grant
484 patent sublicenses in a manner consistent with the requirements of
485 this License.
486
487 Each contributor grants you a non-exclusive, worldwide, royalty-free
488 patent license under the contributor's essential patent claims, to
489 make, use, sell, offer for sale, import and otherwise run, modify and
490 propagate the contents of its contributor version.
491
492 In the following three paragraphs, a "patent license" is any express
493 agreement or commitment, however denominated, not to enforce a patent
494 (such as an express permission to practice a patent or covenant not to
495 sue for patent infringement). To "grant" such a patent license to a
496 party means to make such an agreement or commitment not to enforce a
497 patent against the party.
498
499 If you convey a covered work, knowingly relying on a patent license,
500 and the Corresponding Source of the work is not available for anyone
501 to copy, free of charge and under the terms of this License, through a
502 publicly available network server or other readily accessible means,
503 then you must either (1) cause the Corresponding Source to be so
504 available, or (2) arrange to deprive yourself of the benefit of the
505 patent license for this particular work, or (3) arrange, in a manner
506 consistent with the requirements of this License, to extend the patent
507 license to downstream recipients. "Knowingly relying" means you have
508 actual knowledge that, but for the patent license, your conveying the
509 covered work in a country, or your recipient's use of the covered work
510 in a country, would infringe one or more identifiable patents in that
511 country that you have reason to believe are valid.
512
513 If, pursuant to or in connection with a single transaction or
514 arrangement, you convey, or propagate by procuring conveyance of, a
515 covered work, and grant a patent license to some of the parties
516 receiving the covered work authorizing them to use, propagate, modify
517 or convey a specific copy of the covered work, then the patent license
518 you grant is automatically extended to all recipients of the covered
519 work and works based on it.
520
521 A patent license is "discriminatory" if it does not include within
522 the scope of its coverage, prohibits the exercise of, or is
523 conditioned on the non-exercise of one or more of the rights that are
524 specifically granted under this License. You may not convey a covered
525 work if you are a party to an arrangement with a third party that is
526 in the business of distributing software, under which you make payment
527 to the third party based on the extent of your activity of conveying
528 the work, and under which the third party grants, to any of the
529 parties who would receive the covered work from you, a discriminatory
530 patent license (a) in connection with copies of the covered work
531 conveyed by you (or copies made from those copies), or (b) primarily
532 for and in connection with specific products or compilations that
533 contain the covered work, unless you entered into that arrangement,
534 or that patent license was granted, prior to 28 March 2007.
535
536 Nothing in this License shall be construed as excluding or limiting
537 any implied license or other defenses to infringement that may
538 otherwise be available to you under applicable patent law.
539
540 12. No Surrender of Others' Freedom.
541
542 If conditions are imposed on you (whether by court order, agreement or
543 otherwise) that contradict the conditions of this License, they do not
544 excuse you from the conditions of this License. If you cannot convey a
545 covered work so as to satisfy simultaneously your obligations under this
546 License and any other pertinent obligations, then as a consequence you may
547 not convey it at all. For example, if you agree to terms that obligate you
548 to collect a royalty for further conveying from those to whom you convey
549 the Program, the only way you could satisfy both those terms and this
550 License would be to refrain entirely from conveying the Program.
551
552 13. Use with the GNU Affero General Public License.
553
554 Notwithstanding any other provision of this License, you have
555 permission to link or combine any covered work with a work licensed
556 under version 3 of the GNU Affero General Public License into a single
557 combined work, and to convey the resulting work. The terms of this
558 License will continue to apply to the part which is the covered work,
559 but the special requirements of the GNU Affero General Public License,
560 section 13, concerning interaction through a network will apply to the
561 combination as such.
562
563 14. Revised Versions of this License.
564
565 The Free Software Foundation may publish revised and/or new versions of
566 the GNU General Public License from time to time. Such new versions will
567 be similar in spirit to the present version, but may differ in detail to
568 address new problems or concerns.
569
570 Each version is given a distinguishing version number. If the
571 Program specifies that a certain numbered version of the GNU General
572 Public License "or any later version" applies to it, you have the
573 option of following the terms and conditions either of that numbered
574 version or of any later version published by the Free Software
575 Foundation. If the Program does not specify a version number of the
576 GNU General Public License, you may choose any version ever published
577 by the Free Software Foundation.
578
579 If the Program specifies that a proxy can decide which future
580 versions of the GNU General Public License can be used, that proxy's
581 public statement of acceptance of a version permanently authorizes you
582 to choose that version for the Program.
583
584 Later license versions may give you additional or different
585 permissions. However, no additional obligations are imposed on any
586 author or copyright holder as a result of your choosing to follow a
587 later version.
588
589 15. Disclaimer of Warranty.
590
591 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
600 16. Limitation of Liability.
601
602 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 SUCH DAMAGES.
611
612 17. Interpretation of Sections 15 and 16.
613
614 If the disclaimer of warranty and limitation of liability provided
615 above cannot be given local legal effect according to their terms,
616 reviewing courts shall apply local law that most closely approximates
617 an absolute waiver of all civil liability in connection with the
618 Program, unless a warranty or assumption of liability accompanies a
619 copy of the Program in return for a fee.
620
621 END OF TERMS AND CONDITIONS
622
623 How to Apply These Terms to Your New Programs
624
625 If you develop a new program, and you want it to be of the greatest
626 possible use to the public, the best way to achieve this is to make it
627 free software which everyone can redistribute and change under these terms.
628
629 To do so, attach the following notices to the program. It is safest
630 to attach them to the start of each source file to most effectively
631 state the exclusion of warranty; and each file should have at least
632 the "copyright" line and a pointer to where the full notice is found.
633
634 <one line to give the program's name and a brief idea of what it does.>
635 Copyright (C) <year> <name of author>
636
637 This program is free software: you can redistribute it and/or modify
638 it under the terms of the GNU General Public License as published by
639 the Free Software Foundation, either version 3 of the License, or
640 (at your option) any later version.
641
642 This program is distributed in the hope that it will be useful,
643 but WITHOUT ANY WARRANTY; without even the implied warranty of
644 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 GNU General Public License for more details.
646
647 You should have received a copy of the GNU General Public License
648 along with this program. If not, see <https://www.gnu.org/licenses/>.
649
650 Also add information on how to contact you by electronic and paper mail.
651
652 If the program does terminal interaction, make it output a short
653 notice like this when it starts in an interactive mode:
654
655 <program> Copyright (C) <year> <name of author>
656 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 This is free software, and you are welcome to redistribute it
658 under certain conditions; type `show c' for details.
659
660 The hypothetical commands `show w' and `show c' should show the appropriate
661 parts of the General Public License. Of course, your program's commands
662 might be different; for a GUI interface, you would use an "about box".
663
664 You should also get your employer (if you work as a programmer) or school,
665 if any, to sign a "copyright disclaimer" for the program, if necessary.
666 For more information on this, and how to apply and follow the GNU GPL, see
667 <https://www.gnu.org/licenses/>.
668
669 The GNU General Public License does not permit incorporating your program
670 into proprietary programs. If your program is a subroutine library, you
671 may consider it more useful to permit linking proprietary applications with
672 the library. If this is what you want to do, use the GNU Lesser General
673 Public License instead of this License. But first, please read
674 <https://www.gnu.org/licenses/why-not-lgpl.html>.
@@ -0,0 +1,674 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 3, 29 June 2007
3
4 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8 Preamble
9
10 The GNU General Public License is a free, copyleft license for
11software and other kinds of works.
12
13 The licenses for most software and other practical works are designed
14to take away your freedom to share and change the works. By contrast,
15the GNU General Public License is intended to guarantee your freedom to
16share and change all versions of a program--to make sure it remains free
17software for all its users. We, the Free Software Foundation, use the
18GNU General Public License for most of our software; it applies also to
19any other work released this way by its authors. You can apply it to
20your programs, too.
21
22 When we speak of free software, we are referring to freedom, not
23price. Our General Public Licenses are designed to make sure that you
24have the freedom to distribute copies of free software (and charge for
25them if you wish), that you receive source code or can get it if you
26want it, that you can change the software or use pieces of it in new
27free programs, and that you know you can do these things.
28
29 To protect your rights, we need to prevent others from denying you
30these rights or asking you to surrender the rights. Therefore, you have
31certain responsibilities if you distribute copies of the software, or if
32you modify it: responsibilities to respect the freedom of others.
33
34 For example, if you distribute copies of such a program, whether
35gratis or for a fee, you must pass on to the recipients the same
36freedoms that you received. You must make sure that they, too, receive
37or can get the source code. And you must show them these terms so they
38know their rights.
39
40 Developers that use the GNU GPL protect your rights with two steps:
41(1) assert copyright on the software, and (2) offer you this License
42giving you legal permission to copy, distribute and/or modify it.
43
44 For the developers' and authors' protection, the GPL clearly explains
45that there is no warranty for this free software. For both users' and
46authors' sake, the GPL requires that modified versions be marked as
47changed, so that their problems will not be attributed erroneously to
48authors of previous versions.
49
50 Some devices are designed to deny users access to install or run
51modified versions of the software inside them, although the manufacturer
52can do so. This is fundamentally incompatible with the aim of
53protecting users' freedom to change the software. The systematic
54pattern of such abuse occurs in the area of products for individuals to
55use, which is precisely where it is most unacceptable. Therefore, we
56have designed this version of the GPL to prohibit the practice for those
57products. If such problems arise substantially in other domains, we
58stand ready to extend this provision to those domains in future versions
59of the GPL, as needed to protect the freedom of users.
60
61 Finally, every program is threatened constantly by software patents.
62States should not allow patents to restrict development and use of
63software on general-purpose computers, but in those that do, we wish to
64avoid the special danger that patents applied to a free program could
65make it effectively proprietary. To prevent this, the GPL assures that
66patents cannot be used to render the program non-free.
67
68 The precise terms and conditions for copying, distribution and
69modification follow.
70
71 TERMS AND CONDITIONS
72
73 0. Definitions.
74
75 "This License" refers to version 3 of the GNU General Public License.
76
77 "Copyright" also means copyright-like laws that apply to other kinds of
78works, such as semiconductor masks.
79
80 "The Program" refers to any copyrightable work licensed under this
81License. Each licensee is addressed as "you". "Licensees" and
82"recipients" may be individuals or organizations.
83
84 To "modify" a work means to copy from or adapt all or part of the work
85in a fashion requiring copyright permission, other than the making of an
86exact copy. The resulting work is called a "modified version" of the
87earlier work or a work "based on" the earlier work.
88
89 A "covered work" means either the unmodified Program or a work based
90on the Program.
91
92 To "propagate" a work means to do anything with it that, without
93permission, would make you directly or secondarily liable for
94infringement under applicable copyright law, except executing it on a
95computer or modifying a private copy. Propagation includes copying,
96distribution (with or without modification), making available to the
97public, and in some countries other activities as well.
98
99 To "convey" a work means any kind of propagation that enables other
100parties to make or receive copies. Mere interaction with a user through
101a computer network, with no transfer of a copy, is not conveying.
102
103 An interactive user interface displays "Appropriate Legal Notices"
104to the extent that it includes a convenient and prominently visible
105feature that (1) displays an appropriate copyright notice, and (2)
106tells the user that there is no warranty for the work (except to the
107extent that warranties are provided), that licensees may convey the
108work under this License, and how to view a copy of this License. If
109the interface presents a list of user commands or options, such as a
110menu, a prominent item in the list meets this criterion.
111
112 1. Source Code.
113
114 The "source code" for a work means the preferred form of the work
115for making modifications to it. "Object code" means any non-source
116form of a work.
117
118 A "Standard Interface" means an interface that either is an official
119standard defined by a recognized standards body, or, in the case of
120interfaces specified for a particular programming language, one that
121is widely used among developers working in that language.
122
123 The "System Libraries" of an executable work include anything, other
124than the work as a whole, that (a) is included in the normal form of
125packaging a Major Component, but which is not part of that Major
126Component, and (b) serves only to enable use of the work with that
127Major Component, or to implement a Standard Interface for which an
128implementation is available to the public in source code form. A
129"Major Component", in this context, means a major essential component
130(kernel, window system, and so on) of the specific operating system
131(if any) on which the executable work runs, or a compiler used to
132produce the work, or an object code interpreter used to run it.
133
134 The "Corresponding Source" for a work in object code form means all
135the source code needed to generate, install, and (for an executable
136work) run the object code and to modify the work, including scripts to
137control those activities. However, it does not include the work's
138System Libraries, or general-purpose tools or generally available free
139programs which are used unmodified in performing those activities but
140which are not part of the work. For example, Corresponding Source
141includes interface definition files associated with source files for
142the work, and the source code for shared libraries and dynamically
143linked subprograms that the work is specifically designed to require,
144such as by intimate data communication or control flow between those
145subprograms and other parts of the work.
146
147 The Corresponding Source need not include anything that users
148can regenerate automatically from other parts of the Corresponding
149Source.
150
151 The Corresponding Source for a work in source code form is that
152same work.
153
154 2. Basic Permissions.
155
156 All rights granted under this License are granted for the term of
157copyright on the Program, and are irrevocable provided the stated
158conditions are met. This License explicitly affirms your unlimited
159permission to run the unmodified Program. The output from running a
160covered work is covered by this License only if the output, given its
161content, constitutes a covered work. This License acknowledges your
162rights of fair use or other equivalent, as provided by copyright law.
163
164 You may make, run and propagate covered works that you do not
165convey, without conditions so long as your license otherwise remains
166in force. You may convey covered works to others for the sole purpose
167of having them make modifications exclusively for you, or provide you
168with facilities for running those works, provided that you comply with
169the terms of this License in conveying all material for which you do
170not control copyright. Those thus making or running the covered works
171for you must do so exclusively on your behalf, under your direction
172and control, on terms that prohibit them from making any copies of
173your copyrighted material outside their relationship with you.
174
175 Conveying under any other circumstances is permitted solely under
176the conditions stated below. Sublicensing is not allowed; section 10
177makes it unnecessary.
178
179 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
181 No covered work shall be deemed part of an effective technological
182measure under any applicable law fulfilling obligations under article
18311 of the WIPO copyright treaty adopted on 20 December 1996, or
184similar laws prohibiting or restricting circumvention of such
185measures.
186
187 When you convey a covered work, you waive any legal power to forbid
188circumvention of technological measures to the extent such circumvention
189is effected by exercising rights under this License with respect to
190the covered work, and you disclaim any intention to limit operation or
191modification of the work as a means of enforcing, against the work's
192users, your or third parties' legal rights to forbid circumvention of
193technological measures.
194
195 4. Conveying Verbatim Copies.
196
197 You may convey verbatim copies of the Program's source code as you
198receive it, in any medium, provided that you conspicuously and
199appropriately publish on each copy an appropriate copyright notice;
200keep intact all notices stating that this License and any
201non-permissive terms added in accord with section 7 apply to the code;
202keep intact all notices of the absence of any warranty; and give all
203recipients a copy of this License along with the Program.
204
205 You may charge any price or no price for each copy that you convey,
206and you may offer support or warranty protection for a fee.
207
208 5. Conveying Modified Source Versions.
209
210 You may convey a work based on the Program, or the modifications to
211produce it from the Program, in the form of source code under the
212terms of section 4, provided that you also meet all of these conditions:
213
214 a) The work must carry prominent notices stating that you modified
215 it, and giving a relevant date.
216
217 b) The work must carry prominent notices stating that it is
218 released under this License and any conditions added under section
219 7. This requirement modifies the requirement in section 4 to
220 "keep intact all notices".
221
222 c) You must license the entire work, as a whole, under this
223 License to anyone who comes into possession of a copy. This
224 License will therefore apply, along with any applicable section 7
225 additional terms, to the whole of the work, and all its parts,
226 regardless of how they are packaged. This License gives no
227 permission to license the work in any other way, but it does not
228 invalidate such permission if you have separately received it.
229
230 d) If the work has interactive user interfaces, each must display
231 Appropriate Legal Notices; however, if the Program has interactive
232 interfaces that do not display Appropriate Legal Notices, your
233 work need not make them do so.
234
235 A compilation of a covered work with other separate and independent
236works, which are not by their nature extensions of the covered work,
237and which are not combined with it such as to form a larger program,
238in or on a volume of a storage or distribution medium, is called an
239"aggregate" if the compilation and its resulting copyright are not
240used to limit the access or legal rights of the compilation's users
241beyond what the individual works permit. Inclusion of a covered work
242in an aggregate does not cause this License to apply to the other
243parts of the aggregate.
244
245 6. Conveying Non-Source Forms.
246
247 You may convey a covered work in object code form under the terms
248of sections 4 and 5, provided that you also convey the
249machine-readable Corresponding Source under the terms of this License,
250in one of these ways:
251
252 a) Convey the object code in, or embodied in, a physical product
253 (including a physical distribution medium), accompanied by the
254 Corresponding Source fixed on a durable physical medium
255 customarily used for software interchange.
256
257 b) Convey the object code in, or embodied in, a physical product
258 (including a physical distribution medium), accompanied by a
259 written offer, valid for at least three years and valid for as
260 long as you offer spare parts or customer support for that product
261 model, to give anyone who possesses the object code either (1) a
262 copy of the Corresponding Source for all the software in the
263 product that is covered by this License, on a durable physical
264 medium customarily used for software interchange, for a price no
265 more than your reasonable cost of physically performing this
266 conveying of source, or (2) access to copy the
267 Corresponding Source from a network server at no charge.
268
269 c) Convey individual copies of the object code with a copy of the
270 written offer to provide the Corresponding Source. This
271 alternative is allowed only occasionally and noncommercially, and
272 only if you received the object code with such an offer, in accord
273 with subsection 6b.
274
275 d) Convey the object code by offering access from a designated
276 place (gratis or for a charge), and offer equivalent access to the
277 Corresponding Source in the same way through the same place at no
278 further charge. You need not require recipients to copy the
279 Corresponding Source along with the object code. If the place to
280 copy the object code is a network server, the Corresponding Source
281 may be on a different server (operated by you or a third party)
282 that supports equivalent copying facilities, provided you maintain
283 clear directions next to the object code saying where to find the
284 Corresponding Source. Regardless of what server hosts the
285 Corresponding Source, you remain obligated to ensure that it is
286 available for as long as needed to satisfy these requirements.
287
288 e) Convey the object code using peer-to-peer transmission, provided
289 you inform other peers where the object code and Corresponding
290 Source of the work are being offered to the general public at no
291 charge under subsection 6d.
292
293 A separable portion of the object code, whose source code is excluded
294from the Corresponding Source as a System Library, need not be
295included in conveying the object code work.
296
297 A "User Product" is either (1) a "consumer product", which means any
298tangible personal property which is normally used for personal, family,
299or household purposes, or (2) anything designed or sold for incorporation
300into a dwelling. In determining whether a product is a consumer product,
301doubtful cases shall be resolved in favor of coverage. For a particular
302product received by a particular user, "normally used" refers to a
303typical or common use of that class of product, regardless of the status
304of the particular user or of the way in which the particular user
305actually uses, or expects or is expected to use, the product. A product
306is a consumer product regardless of whether the product has substantial
307commercial, industrial or non-consumer uses, unless such uses represent
308the only significant mode of use of the product.
309
310 "Installation Information" for a User Product means any methods,
311procedures, authorization keys, or other information required to install
312and execute modified versions of a covered work in that User Product from
313a modified version of its Corresponding Source. The information must
314suffice to ensure that the continued functioning of the modified object
315code is in no case prevented or interfered with solely because
316modification has been made.
317
318 If you convey an object code work under this section in, or with, or
319specifically for use in, a User Product, and the conveying occurs as
320part of a transaction in which the right of possession and use of the
321User Product is transferred to the recipient in perpetuity or for a
322fixed term (regardless of how the transaction is characterized), the
323Corresponding Source conveyed under this section must be accompanied
324by the Installation Information. But this requirement does not apply
325if neither you nor any third party retains the ability to install
326modified object code on the User Product (for example, the work has
327been installed in ROM).
328
329 The requirement to provide Installation Information does not include a
330requirement to continue to provide support service, warranty, or updates
331for a work that has been modified or installed by the recipient, or for
332the User Product in which it has been modified or installed. Access to a
333network may be denied when the modification itself materially and
334adversely affects the operation of the network or violates the rules and
335protocols for communication across the network.
336
337 Corresponding Source conveyed, and Installation Information provided,
338in accord with this section must be in a format that is publicly
339documented (and with an implementation available to the public in
340source code form), and must require no special password or key for
341unpacking, reading or copying.
342
343 7. Additional Terms.
344
345 "Additional permissions" are terms that supplement the terms of this
346License by making exceptions from one or more of its conditions.
347Additional permissions that are applicable to the entire Program shall
348be treated as though they were included in this License, to the extent
349that they are valid under applicable law. If additional permissions
350apply only to part of the Program, that part may be used separately
351under those permissions, but the entire Program remains governed by
352this License without regard to the additional permissions.
353
354 When you convey a copy of a covered work, you may at your option
355remove any additional permissions from that copy, or from any part of
356it. (Additional permissions may be written to require their own
357removal in certain cases when you modify the work.) You may place
358additional permissions on material, added by you to a covered work,
359for which you have or can give appropriate copyright permission.
360
361 Notwithstanding any other provision of this License, for material you
362add to a covered work, you may (if authorized by the copyright holders of
363that material) supplement the terms of this License with terms:
364
365 a) Disclaiming warranty or limiting liability differently from the
366 terms of sections 15 and 16 of this License; or
367
368 b) Requiring preservation of specified reasonable legal notices or
369 author attributions in that material or in the Appropriate Legal
370 Notices displayed by works containing it; or
371
372 c) Prohibiting misrepresentation of the origin of that material, or
373 requiring that modified versions of such material be marked in
374 reasonable ways as different from the original version; or
375
376 d) Limiting the use for publicity purposes of names of licensors or
377 authors of the material; or
378
379 e) Declining to grant rights under trademark law for use of some
380 trade names, trademarks, or service marks; or
381
382 f) Requiring indemnification of licensors and authors of that
383 material by anyone who conveys the material (or modified versions of
384 it) with contractual assumptions of liability to the recipient, for
385 any liability that these contractual assumptions directly impose on
386 those licensors and authors.
387
388 All other non-permissive additional terms are considered "further
389restrictions" within the meaning of section 10. If the Program as you
390received it, or any part of it, contains a notice stating that it is
391governed by this License along with a term that is a further
392restriction, you may remove that term. If a license document contains
393a further restriction but permits relicensing or conveying under this
394License, you may add to a covered work material governed by the terms
395of that license document, provided that the further restriction does
396not survive such relicensing or conveying.
397
398 If you add terms to a covered work in accord with this section, you
399must place, in the relevant source files, a statement of the
400additional terms that apply to those files, or a notice indicating
401where to find the applicable terms.
402
403 Additional terms, permissive or non-permissive, may be stated in the
404form of a separately written license, or stated as exceptions;
405the above requirements apply either way.
406
407 8. Termination.
408
409 You may not propagate or modify a covered work except as expressly
410provided under this License. Any attempt otherwise to propagate or
411modify it is void, and will automatically terminate your rights under
412this License (including any patent licenses granted under the third
413paragraph of section 11).
414
415 However, if you cease all violation of this License, then your
416license from a particular copyright holder is reinstated (a)
417provisionally, unless and until the copyright holder explicitly and
418finally terminates your license, and (b) permanently, if the copyright
419holder fails to notify you of the violation by some reasonable means
420prior to 60 days after the cessation.
421
422 Moreover, your license from a particular copyright holder is
423reinstated permanently if the copyright holder notifies you of the
424violation by some reasonable means, this is the first time you have
425received notice of violation of this License (for any work) from that
426copyright holder, and you cure the violation prior to 30 days after
427your receipt of the notice.
428
429 Termination of your rights under this section does not terminate the
430licenses of parties who have received copies or rights from you under
431this License. If your rights have been terminated and not permanently
432reinstated, you do not qualify to receive new licenses for the same
433material under section 10.
434
435 9. Acceptance Not Required for Having Copies.
436
437 You are not required to accept this License in order to receive or
438run a copy of the Program. Ancillary propagation of a covered work
439occurring solely as a consequence of using peer-to-peer transmission
440to receive a copy likewise does not require acceptance. However,
441nothing other than this License grants you permission to propagate or
442modify any covered work. These actions infringe copyright if you do
443not accept this License. Therefore, by modifying or propagating a
444covered work, you indicate your acceptance of this License to do so.
445
446 10. Automatic Licensing of Downstream Recipients.
447
448 Each time you convey a covered work, the recipient automatically
449receives a license from the original licensors, to run, modify and
450propagate that work, subject to this License. You are not responsible
451for enforcing compliance by third parties with this License.
452
453 An "entity transaction" is a transaction transferring control of an
454organization, or substantially all assets of one, or subdividing an
455organization, or merging organizations. If propagation of a covered
456work results from an entity transaction, each party to that
457transaction who receives a copy of the work also receives whatever
458licenses to the work the party's predecessor in interest had or could
459give under the previous paragraph, plus a right to possession of the
460Corresponding Source of the work from the predecessor in interest, if
461the predecessor has it or can get it with reasonable efforts.
462
463 You may not impose any further restrictions on the exercise of the
464rights granted or affirmed under this License. For example, you may
465not impose a license fee, royalty, or other charge for exercise of
466rights granted under this License, and you may not initiate litigation
467(including a cross-claim or counterclaim in a lawsuit) alleging that
468any patent claim is infringed by making, using, selling, offering for
469sale, or importing the Program or any portion of it.
470
471 11. Patents.
472
473 A "contributor" is a copyright holder who authorizes use under this
474License of the Program or a work on which the Program is based. The
475work thus licensed is called the contributor's "contributor version".
476
477 A contributor's "essential patent claims" are all patent claims
478owned or controlled by the contributor, whether already acquired or
479hereafter acquired, that would be infringed by some manner, permitted
480by this License, of making, using, or selling its contributor version,
481but do not include claims that would be infringed only as a
482consequence of further modification of the contributor version. For
483purposes of this definition, "control" includes the right to grant
484patent sublicenses in a manner consistent with the requirements of
485this License.
486
487 Each contributor grants you a non-exclusive, worldwide, royalty-free
488patent license under the contributor's essential patent claims, to
489make, use, sell, offer for sale, import and otherwise run, modify and
490propagate the contents of its contributor version.
491
492 In the following three paragraphs, a "patent license" is any express
493agreement or commitment, however denominated, not to enforce a patent
494(such as an express permission to practice a patent or covenant not to
495sue for patent infringement). To "grant" such a patent license to a
496party means to make such an agreement or commitment not to enforce a
497patent against the party.
498
499 If you convey a covered work, knowingly relying on a patent license,
500and the Corresponding Source of the work is not available for anyone
501to copy, free of charge and under the terms of this License, through a
502publicly available network server or other readily accessible means,
503then you must either (1) cause the Corresponding Source to be so
504available, or (2) arrange to deprive yourself of the benefit of the
505patent license for this particular work, or (3) arrange, in a manner
506consistent with the requirements of this License, to extend the patent
507license to downstream recipients. "Knowingly relying" means you have
508actual knowledge that, but for the patent license, your conveying the
509covered work in a country, or your recipient's use of the covered work
510in a country, would infringe one or more identifiable patents in that
511country that you have reason to believe are valid.
512
513 If, pursuant to or in connection with a single transaction or
514arrangement, you convey, or propagate by procuring conveyance of, a
515covered work, and grant a patent license to some of the parties
516receiving the covered work authorizing them to use, propagate, modify
517or convey a specific copy of the covered work, then the patent license
518you grant is automatically extended to all recipients of the covered
519work and works based on it.
520
521 A patent license is "discriminatory" if it does not include within
522the scope of its coverage, prohibits the exercise of, or is
523conditioned on the non-exercise of one or more of the rights that are
524specifically granted under this License. You may not convey a covered
525work if you are a party to an arrangement with a third party that is
526in the business of distributing software, under which you make payment
527to the third party based on the extent of your activity of conveying
528the work, and under which the third party grants, to any of the
529parties who would receive the covered work from you, a discriminatory
530patent license (a) in connection with copies of the covered work
531conveyed by you (or copies made from those copies), or (b) primarily
532for and in connection with specific products or compilations that
533contain the covered work, unless you entered into that arrangement,
534or that patent license was granted, prior to 28 March 2007.
535
536 Nothing in this License shall be construed as excluding or limiting
537any implied license or other defenses to infringement that may
538otherwise be available to you under applicable patent law.
539
540 12. No Surrender of Others' Freedom.
541
542 If conditions are imposed on you (whether by court order, agreement or
543otherwise) that contradict the conditions of this License, they do not
544excuse you from the conditions of this License. If you cannot convey a
545covered work so as to satisfy simultaneously your obligations under this
546License and any other pertinent obligations, then as a consequence you may
547not convey it at all. For example, if you agree to terms that obligate you
548to collect a royalty for further conveying from those to whom you convey
549the Program, the only way you could satisfy both those terms and this
550License would be to refrain entirely from conveying the Program.
551
552 13. Use with the GNU Affero General Public License.
553
554 Notwithstanding any other provision of this License, you have
555permission to link or combine any covered work with a work licensed
556under version 3 of the GNU Affero General Public License into a single
557combined work, and to convey the resulting work. The terms of this
558License will continue to apply to the part which is the covered work,
559but the special requirements of the GNU Affero General Public License,
560section 13, concerning interaction through a network will apply to the
561combination as such.
562
563 14. Revised Versions of this License.
564
565 The Free Software Foundation may publish revised and/or new versions of
566the GNU General Public License from time to time. Such new versions will
567be similar in spirit to the present version, but may differ in detail to
568address new problems or concerns.
569
570 Each version is given a distinguishing version number. If the
571Program specifies that a certain numbered version of the GNU General
572Public License "or any later version" applies to it, you have the
573option of following the terms and conditions either of that numbered
574version or of any later version published by the Free Software
575Foundation. If the Program does not specify a version number of the
576GNU General Public License, you may choose any version ever published
577by the Free Software Foundation.
578
579 If the Program specifies that a proxy can decide which future
580versions of the GNU General Public License can be used, that proxy's
581public statement of acceptance of a version permanently authorizes you
582to choose that version for the Program.
583
584 Later license versions may give you additional or different
585permissions. However, no additional obligations are imposed on any
586author or copyright holder as a result of your choosing to follow a
587later version.
588
589 15. Disclaimer of Warranty.
590
591 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
600 16. Limitation of Liability.
601
602 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610SUCH DAMAGES.
611
612 17. Interpretation of Sections 15 and 16.
613
614 If the disclaimer of warranty and limitation of liability provided
615above cannot be given local legal effect according to their terms,
616reviewing courts shall apply local law that most closely approximates
617an absolute waiver of all civil liability in connection with the
618Program, unless a warranty or assumption of liability accompanies a
619copy of the Program in return for a fee.
620
621 END OF TERMS AND CONDITIONS
622
623 How to Apply These Terms to Your New Programs
624
625 If you develop a new program, and you want it to be of the greatest
626possible use to the public, the best way to achieve this is to make it
627free software which everyone can redistribute and change under these terms.
628
629 To do so, attach the following notices to the program. It is safest
630to attach them to the start of each source file to most effectively
631state the exclusion of warranty; and each file should have at least
632the "copyright" line and a pointer to where the full notice is found.
633
634 <one line to give the program's name and a brief idea of what it does.>
635 Copyright (C) <year> <name of author>
636
637 This program is free software: you can redistribute it and/or modify
638 it under the terms of the GNU General Public License as published by
639 the Free Software Foundation, either version 3 of the License, or
640 (at your option) any later version.
641
642 This program is distributed in the hope that it will be useful,
643 but WITHOUT ANY WARRANTY; without even the implied warranty of
644 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 GNU General Public License for more details.
646
647 You should have received a copy of the GNU General Public License
648 along with this program. If not, see <https://www.gnu.org/licenses/>.
649
650Also add information on how to contact you by electronic and paper mail.
651
652 If the program does terminal interaction, make it output a short
653notice like this when it starts in an interactive mode:
654
655 <program> Copyright (C) <year> <name of author>
656 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 This is free software, and you are welcome to redistribute it
658 under certain conditions; type `show c' for details.
659
660The hypothetical commands `show w' and `show c' should show the appropriate
661parts of the General Public License. Of course, your program's commands
662might be different; for a GUI interface, you would use an "about box".
663
664 You should also get your employer (if you work as a programmer) or school,
665if any, to sign a "copyright disclaimer" for the program, if necessary.
666For more information on this, and how to apply and follow the GNU GPL, see
667<https://www.gnu.org/licenses/>.
668
669 The GNU General Public License does not permit incorporating your program
670into proprietary programs. If your program is a subroutine library, you
671may consider it more useful to permit linking proprietary applications with
672the library. If this is what you want to do, use the GNU Lesser General
673Public License instead of this License. But first, please read
674<https://www.gnu.org/licenses/why-not-lgpl.html>.
README.md added +40 −0
@@ -0,0 +1,40 @@
1 # Marble – KWin close effect (Burn-My-Windows variant)
2
3 **NL** – KWin 6 (Plasma 6) sluit-animatie: het venster vormt zich soepel om tot een kleine,
4 glanzende knikker (inhoud blijft zichtbaar), blijft even stil liggen en valt daarna met echte
5 zwaartekracht (constante versnelling vanuit stilstand) 1,5 schermhoogte omlaag, uit beeld.
6
7 **EN** – KWin 6 (Plasma 6) window-close animation: the window smoothly morphs into a small glossy
8 marble (content stays visible), pauses, then drops off-screen under real gravity (constant
9 acceleration from rest) for 1.5 screen heights.
10
11 ![filmstrip](docs/filmstrip.png)
12
13 ## Installatie / Installation
14
15 ```sh
16 cp -r kwin6_effect_marble ~/.local/share/kwin/effects/
17 ```
18
19 Then enable **Marble [Burn-My-Windows variant]** in System Settings → Window Management →
20 Desktop Effects (it replaces the active close animation; only one can be active). Log out/in if
21 it does not show up.
22
23 ## Instellingen / Settings
24
25 | Key | Default | Meaning |
26 |------------|---------|-----------------------------------------------------------------|
27 | `Duration` | 300 ms | Morph into the marble |
28 | `Pause` | 600 ms | Marble rests before falling |
29 | `Gravity` | 4000 px/s² | Fall acceleration; fall time = sqrt(2·1.5·screen height / g) |
30
31 All durations are scaled by Plasma's global animation speed.
32
33 ## Licentie / License & attribution
34
35 GPL-3.0-or-later (see `LICENSE`). This effect is a modified derivative of the KWin port of
36 **Energize B** from [Burn-My-Windows](https://github.com/Schneegans/Burn-My-Windows) by
37 Simon Schneegans (GPL-3.0-or-later), whose KWin effect code also credits Martin Flöser and
38 Vlad Zahorodnii. The common shader prelude and `main.js` structure come from that project; the
39 marble shader, gravity fall and settings are new. Original copyright notices are kept in the
40 source files. Modified by Tim Falken, 2026.
@@ -0,0 +1,40 @@
1# Marble – KWin close effect (Burn-My-Windows variant)
2
3**NL** – KWin 6 (Plasma 6) sluit-animatie: het venster vormt zich soepel om tot een kleine,
4glanzende knikker (inhoud blijft zichtbaar), blijft even stil liggen en valt daarna met echte
5zwaartekracht (constante versnelling vanuit stilstand) 1,5 schermhoogte omlaag, uit beeld.
6
7**EN** – KWin 6 (Plasma 6) window-close animation: the window smoothly morphs into a small glossy
8marble (content stays visible), pauses, then drops off-screen under real gravity (constant
9acceleration from rest) for 1.5 screen heights.
10
11![filmstrip](docs/filmstrip.png)
12
13## Installatie / Installation
14
15```sh
16cp -r kwin6_effect_marble ~/.local/share/kwin/effects/
17```
18
19Then enable **Marble [Burn-My-Windows variant]** in System Settings → Window Management →
20Desktop Effects (it replaces the active close animation; only one can be active). Log out/in if
21it does not show up.
22
23## Instellingen / Settings
24
25| Key | Default | Meaning |
26|------------|---------|-----------------------------------------------------------------|
27| `Duration` | 300 ms | Morph into the marble |
28| `Pause` | 600 ms | Marble rests before falling |
29| `Gravity` | 4000 px/s² | Fall acceleration; fall time = sqrt(2·1.5·screen height / g) |
30
31All durations are scaled by Plasma's global animation speed.
32
33## Licentie / License & attribution
34
35GPL-3.0-or-later (see `LICENSE`). This effect is a modified derivative of the KWin port of
36**Energize B** from [Burn-My-Windows](https://github.com/Schneegans/Burn-My-Windows) by
37Simon Schneegans (GPL-3.0-or-later), whose KWin effect code also credits Martin Flöser and
38Vlad Zahorodnii. The common shader prelude and `main.js` structure come from that project; the
39marble shader, gravity fall and settings are new. Original copyright notices are kept in the
40source files. Modified by Tim Falken, 2026.
docs/filmstrip.png added Binary file +0 −0

The contents of this binary file are not shown.

docs/marble.gif added Binary file +0 −0

The contents of this binary file are not shown.

kwin6_effect_marble/contents/code/main.js added +270 −0
@@ -0,0 +1,270 @@
1 // SPDX-FileCopyrightText: Vlad Zahorodnii <vlad.zahorodnii@kde.org>, Martin Flöser
2 // <mgraesslin@kde.org>, Simon Schneegans <code@simonschneegans.de>
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 'use strict';
6
7 const classBlacklist = [
8 // The logout screen has to be animated only by the logout effect.
9 'ksmserver ksmserver', 'ksmserver-logout-greeter ksmserver-logout-greeter',
10
11 // KDE Plasma splash screen has to be animated only by the login effect.
12 'ksplashqml ksplashqml',
13
14 // All the tooltips of IntelliJ IDEs use the same window class as their main window.
15 // This results in many awkward animations, so we have to blacklist them all.
16 // See https://github.com/Schneegans/Burn-My-Windows/issues/284 for details.
17 'jetbrains-studio jetbrains-studio', 'jetbrains-aqua jetbrains-aqua',
18 'jetbrains-clion jetbrains-clion', 'jetbrains-datagrip jetbrains-datagrip',
19 'jetbrains-dataspell jetbrains-dataspell', 'jetbrains-goland jetbrains-goland',
20 'jetbrains-idea jetbrains-idea', 'jetbrains-idea-ce jetbrains-idea-ce',
21 'jetbrains-phpstorm jetbrains-phpstorm', 'jetbrains-pycharm jetbrains-pycharm',
22 'jetbrains-pycharm-ce jetbrains-pycharm-ce', 'jetbrains-rider jetbrains-rider',
23 'jetbrains-rubymine jetbrains-rubymine', 'jetbrains-webstorm jetbrains-webstorm',
24
25 // Spectacle (KDE screenshot tool) should not be animated.
26 'spectacle org.kde.spectacle'
27 ];
28
29 const nameBlacklist = [
30 // Kando uses a normal window, but it should look like a popup menu. We do not
31 // blacklist it by class as this would also affect the settings window.
32 'Kando Menu'
33 ];
34
35 class BurnMyWindowsMarbleEffect {
36 constructor() {
37 effect.configChanged.connect(this.loadConfig.bind(this));
38 effect.animationEnded.connect(this.cleanupForcedRoles.bind(this));
39 effect.animationEnded.connect(this.slotAnimationEnded.bind(this));
40 //effects.windowAdded.connect(this.slotWindowAdded.bind(this));
41 effects.windowClosed.connect(this.slotWindowClosed.bind(this));
42 effects.windowDataChanged.connect(this.slotWindowDataChanged.bind(this));
43
44 this.shader = effect.addFragmentShader(Effect.MapTexture, 'marble.frag');
45
46 this.loadConfig();
47 }
48
49 // A small helper which can be used to read a hex color string (e.g. #ff3244) from the
50 // settings. This method will return an array of four floating point values
51 // [r, g, b, a]. If the settings key only refers to an rgb value, the alpha component
52 // will be set to 1.0.
53 readRGBAConfig(key) {
54 const raw = String(effect.readConfig(key, '#ffffff'));
55 const parts = raw.split(',').map(x => parseFloat(x.trim()));
56 if (parts.length >= 3 && parts.every(x => !isNaN(x))) {
57 const c = parts.map(x => x / 255);
58 return [c[0], c[1], c[2], c.length > 3 ? c[3] : 1.0];
59 }
60 const color = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?([a-f\d]{2})?$/i
61 .exec(effect.readConfig(key, '#ffffff'))
62 .slice(1)
63 .filter(x => x !== undefined)
64 .map(x => parseInt(x, 16) / 255);
65 return color.length == 3 ? [color[0], color[1], color[2], 1.0] :
66 [color[1], color[2], color[3], color[0]];
67 }
68
69 // A small helper which can be used to read a hex color string (e.g. #ff3244) from the
70 // settings. This method will return an array of three floating point values [r, g, b]
71 // regardless of whether the settings key actually refers to an argb hex string.
72 readRGBConfig(key) {
73 const color = this.readRGBAConfig(key);
74 color.pop();
75 return color;
76 }
77
78 // This is called when the effect is loaded and whenever the settings of the effect
79 // are changed by the user.
80 loadConfig() {
81 this.duration = animationTime(effect.readConfig("Duration", 300));
82 this.pause = animationTime(Number(effect.readConfig("Pause", 600)));
83 this.gravity = Math.max(100, Number(effect.readConfig('Gravity', 4000))); // px/s^2
84 let sh = 1080;
85 try { sh = effects.virtualScreenGeometry.height || sh; } catch (e) {}
86 this.fallDistance = 1.5 * sh;
87 // free fall from rest: d = 0.5 g t^2 -> t = sqrt(2d/g); scaled by the global speed factor
88 this.fallDuration = animationTime(Math.round(1000 * Math.sqrt(2 * this.fallDistance / this.gravity)));
89 effect.setUniform(this.shader, 'uDuration', (this.duration + this.pause + this.fallDuration) * 0.001);
90 effect.setUniform(this.shader, 'uCrumpleEnd', this.duration / Math.max(1, this.duration + this.pause + this.fallDuration));
91 }
92
93 static shouldAnimateWindow(window) {
94
95 // We don't want to animate most of plasmashell's windows, yet, some
96 // of them we want to, for example, Task Manager Settings window.
97 // The problem is that all those window share single window class.
98 // So, the only way to decide whether a window should be animated is
99 // to use a heuristic: if a window has decoration, then it's most
100 // likely a dialog or a settings window so we have to animate it.
101 if (window.windowClass == 'plasmashell plasmashell' ||
102 window.windowClass == 'plasmashell org.kde.plasmashell') {
103 return window.hasDecoration;
104 }
105
106 // This is primarily to avoid animating the AltTab popup.
107 // See https://github.com/Schneegans/Burn-My-Windows/issues/384 for details.
108 if (!window.hasDecoration && window.onAllDesktops) {
109 return false
110 }
111
112 if (classBlacklist.indexOf(window.windowClass) != -1) {
113 return false;
114 }
115
116 if (nameBlacklist.indexOf(window.caption) != -1) {
117 return false;
118 }
119
120 if (window.hasDecoration) {
121 return true;
122 }
123
124 // Don't animate combobox popups, tooltips, popup menus, etc.
125 if (window.popupWindow) {
126 return false;
127 }
128
129 // Dont't animate the outline and the screenlocker as it looks bad.
130 if (window.lockScreen || window.outline) {
131 return false;
132 }
133
134 // Override-redirect windows are usually used for user interface
135 // concepts that are not expected to be animated by this effect.
136 if (!window.managed) {
137 return false;
138 }
139
140 return window.normalWindow || window.dialog;
141 }
142
143 setupForcedRoles(window) {
144 // marble: no forced blur/contrast (blurred window-sized rect + cost)
145 // window.setData(Effect.WindowForceBackgroundContrastRole, true);
146 // marble: no forced blur/contrast (blurred window-sized rect + cost)
147 // window.setData(Effect.WindowForceBlurRole, true);
148 }
149
150 cleanupForcedRoles(window) {
151 window.setData(Effect.WindowForceBackgroundContrastRole, null);
152 window.setData(Effect.WindowForceBlurRole, null);
153 }
154
155 slotWindowAdded(window) {
156 if (effects.hasActiveFullScreenEffect) {
157 return;
158 }
159 if (!BurnMyWindowsMarbleEffect.shouldAnimateWindow(window)) {
160 return;
161 }
162 if (!window.visible) {
163 return;
164 }
165 if (effect.isGrabbed(window, Effect.WindowAddedGrabRole)) {
166 return;
167 }
168 this.setupForcedRoles(window);
169
170 effect.setUniform(this.shader, 'uForOpening', 1.0);
171 effect.setUniform(this.shader, 'uIsFullscreen', window.fullScreen ? 1.0 : 0.0);
172
173
174
175 window.bmwInAnimation = animate({
176 window: window,
177 curve: QEasingCurve.Linear,
178 duration: this.duration,
179 animations: [{
180 type: Effect.ShaderUniform,
181 fragmentShader: this.shader,
182 uniform: 'uProgress',
183 from: 0.0,
184 to: 1.0
185 }]
186 });
187 }
188
189 slotWindowClosed(window) {
190 if (effects.hasActiveFullScreenEffect) {
191 return;
192 }
193 if (!BurnMyWindowsMarbleEffect.shouldAnimateWindow(window)) {
194 return;
195 }
196 if (!window.visible || window.skipsCloseAnimation) {
197 return;
198 }
199 if (effect.isGrabbed(window, Effect.WindowClosedGrabRole)) {
200 return;
201 }
202 if (window.bmwInAnimation) {
203 cancel(window.bmwInAnimation);
204 delete window.bmwInAnimation;
205 }
206 this.setupForcedRoles(window);
207
208 effect.setUniform(this.shader, 'uForOpening', 0.0);
209 effect.setUniform(this.shader, 'uIsFullscreen', window.fullScreen ? 1.0 : 0.0);
210
211
212
213 // 1) marble morph (shader); runs the whole time so the marble stays drawn while falling
214 console.info('marble: start ' + Date.now() + ' crumple ' + this.duration + ' fall ' + this.fallDuration);
215 window.bmwOutAnimation = animate({
216 window: window,
217 curve: QEasingCurve.Linear,
218 duration: this.duration + this.pause + this.fallDuration,
219 animations: [{
220 type: Effect.ShaderUniform,
221 fragmentShader: this.shader,
222 uniform: 'uProgress',
223 from: 0.0,
224 to: 1.0
225 }]
226 });
227 // 2) marker animation that ends exactly when the marble is done; the fall is
228 // started from its animationEnded (KWin ignored the per-call delay).
229 window.bmwMarbleDone = animate({
230 window: window,
231 curve: QEasingCurve.Linear,
232 duration: this.duration + this.pause,
233 animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: 0.0, value2: 0.0} }]
234 });
235 window.bmwFallPending = true;
236 }
237
238 slotAnimationEnded(window, id) {
239 console.info('marble: ended ' + id + ' ' + Date.now());
240 if (!window || !window.bmwFallPending) return; // first end = marble marker (ids arrive as 0)
241 window.bmwFallPending = false;
242 // free fall from rest: InQuad = t^2 = constant acceleration, d = 0.5 g t^2
243 window.bmwFallAnimation = animate({
244 window: window,
245 curve: QEasingCurve.InQuad,
246 duration: this.fallDuration,
247 animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0},
248 to: {value1: 0.0, value2: this.fallDistance} }]
249 });
250 console.info('marble: fall start ' + Date.now());
251 }
252
253 slotWindowDataChanged(window, role) {
254 if (role == Effect.WindowAddedGrabRole) {
255 if (window.bmwInAnimation && effect.isGrabbed(window, role)) {
256 cancel(window.bmwInAnimation);
257 delete window.bmwInAnimation;
258 this.cleanupForcedRoles(window);
259 }
260 } else if (role == Effect.WindowClosedGrabRole) {
261 if (window.bmwOutAnimation && effect.isGrabbed(window, role)) {
262 cancel(window.bmwOutAnimation);
263 delete window.bmwOutAnimation;
264 this.cleanupForcedRoles(window);
265 }
266 }
267 }
268 }
269
270 new BurnMyWindowsMarbleEffect();
@@ -0,0 +1,270 @@
1// SPDX-FileCopyrightText: Vlad Zahorodnii <vlad.zahorodnii@kde.org>, Martin Flöser
2// <mgraesslin@kde.org>, Simon Schneegans <code@simonschneegans.de>
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5'use strict';
6
7const classBlacklist = [
8 // The logout screen has to be animated only by the logout effect.
9 'ksmserver ksmserver', 'ksmserver-logout-greeter ksmserver-logout-greeter',
10
11 // KDE Plasma splash screen has to be animated only by the login effect.
12 'ksplashqml ksplashqml',
13
14 // All the tooltips of IntelliJ IDEs use the same window class as their main window.
15 // This results in many awkward animations, so we have to blacklist them all.
16 // See https://github.com/Schneegans/Burn-My-Windows/issues/284 for details.
17 'jetbrains-studio jetbrains-studio', 'jetbrains-aqua jetbrains-aqua',
18 'jetbrains-clion jetbrains-clion', 'jetbrains-datagrip jetbrains-datagrip',
19 'jetbrains-dataspell jetbrains-dataspell', 'jetbrains-goland jetbrains-goland',
20 'jetbrains-idea jetbrains-idea', 'jetbrains-idea-ce jetbrains-idea-ce',
21 'jetbrains-phpstorm jetbrains-phpstorm', 'jetbrains-pycharm jetbrains-pycharm',
22 'jetbrains-pycharm-ce jetbrains-pycharm-ce', 'jetbrains-rider jetbrains-rider',
23 'jetbrains-rubymine jetbrains-rubymine', 'jetbrains-webstorm jetbrains-webstorm',
24
25 // Spectacle (KDE screenshot tool) should not be animated.
26 'spectacle org.kde.spectacle'
27];
28
29const nameBlacklist = [
30 // Kando uses a normal window, but it should look like a popup menu. We do not
31 // blacklist it by class as this would also affect the settings window.
32 'Kando Menu'
33];
34
35class BurnMyWindowsMarbleEffect {
36 constructor() {
37 effect.configChanged.connect(this.loadConfig.bind(this));
38 effect.animationEnded.connect(this.cleanupForcedRoles.bind(this));
39 effect.animationEnded.connect(this.slotAnimationEnded.bind(this));
40 //effects.windowAdded.connect(this.slotWindowAdded.bind(this));
41 effects.windowClosed.connect(this.slotWindowClosed.bind(this));
42 effects.windowDataChanged.connect(this.slotWindowDataChanged.bind(this));
43
44 this.shader = effect.addFragmentShader(Effect.MapTexture, 'marble.frag');
45
46 this.loadConfig();
47 }
48
49 // A small helper which can be used to read a hex color string (e.g. #ff3244) from the
50 // settings. This method will return an array of four floating point values
51 // [r, g, b, a]. If the settings key only refers to an rgb value, the alpha component
52 // will be set to 1.0.
53 readRGBAConfig(key) {
54 const raw = String(effect.readConfig(key, '#ffffff'));
55 const parts = raw.split(',').map(x => parseFloat(x.trim()));
56 if (parts.length >= 3 && parts.every(x => !isNaN(x))) {
57 const c = parts.map(x => x / 255);
58 return [c[0], c[1], c[2], c.length > 3 ? c[3] : 1.0];
59 }
60 const color = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?([a-f\d]{2})?$/i
61 .exec(effect.readConfig(key, '#ffffff'))
62 .slice(1)
63 .filter(x => x !== undefined)
64 .map(x => parseInt(x, 16) / 255);
65 return color.length == 3 ? [color[0], color[1], color[2], 1.0] :
66 [color[1], color[2], color[3], color[0]];
67 }
68
69 // A small helper which can be used to read a hex color string (e.g. #ff3244) from the
70 // settings. This method will return an array of three floating point values [r, g, b]
71 // regardless of whether the settings key actually refers to an argb hex string.
72 readRGBConfig(key) {
73 const color = this.readRGBAConfig(key);
74 color.pop();
75 return color;
76 }
77
78 // This is called when the effect is loaded and whenever the settings of the effect
79 // are changed by the user.
80 loadConfig() {
81 this.duration = animationTime(effect.readConfig("Duration", 300));
82 this.pause = animationTime(Number(effect.readConfig("Pause", 600)));
83 this.gravity = Math.max(100, Number(effect.readConfig('Gravity', 4000))); // px/s^2
84 let sh = 1080;
85 try { sh = effects.virtualScreenGeometry.height || sh; } catch (e) {}
86 this.fallDistance = 1.5 * sh;
87 // free fall from rest: d = 0.5 g t^2 -> t = sqrt(2d/g); scaled by the global speed factor
88 this.fallDuration = animationTime(Math.round(1000 * Math.sqrt(2 * this.fallDistance / this.gravity)));
89 effect.setUniform(this.shader, 'uDuration', (this.duration + this.pause + this.fallDuration) * 0.001);
90 effect.setUniform(this.shader, 'uCrumpleEnd', this.duration / Math.max(1, this.duration + this.pause + this.fallDuration));
91 }
92
93 static shouldAnimateWindow(window) {
94
95 // We don't want to animate most of plasmashell's windows, yet, some
96 // of them we want to, for example, Task Manager Settings window.
97 // The problem is that all those window share single window class.
98 // So, the only way to decide whether a window should be animated is
99 // to use a heuristic: if a window has decoration, then it's most
100 // likely a dialog or a settings window so we have to animate it.
101 if (window.windowClass == 'plasmashell plasmashell' ||
102 window.windowClass == 'plasmashell org.kde.plasmashell') {
103 return window.hasDecoration;
104 }
105
106 // This is primarily to avoid animating the AltTab popup.
107 // See https://github.com/Schneegans/Burn-My-Windows/issues/384 for details.
108 if (!window.hasDecoration && window.onAllDesktops) {
109 return false
110 }
111
112 if (classBlacklist.indexOf(window.windowClass) != -1) {
113 return false;
114 }
115
116 if (nameBlacklist.indexOf(window.caption) != -1) {
117 return false;
118 }
119
120 if (window.hasDecoration) {
121 return true;
122 }
123
124 // Don't animate combobox popups, tooltips, popup menus, etc.
125 if (window.popupWindow) {
126 return false;
127 }
128
129 // Dont't animate the outline and the screenlocker as it looks bad.
130 if (window.lockScreen || window.outline) {
131 return false;
132 }
133
134 // Override-redirect windows are usually used for user interface
135 // concepts that are not expected to be animated by this effect.
136 if (!window.managed) {
137 return false;
138 }
139
140 return window.normalWindow || window.dialog;
141 }
142
143 setupForcedRoles(window) {
144 // marble: no forced blur/contrast (blurred window-sized rect + cost)
145 // window.setData(Effect.WindowForceBackgroundContrastRole, true);
146 // marble: no forced blur/contrast (blurred window-sized rect + cost)
147 // window.setData(Effect.WindowForceBlurRole, true);
148 }
149
150 cleanupForcedRoles(window) {
151 window.setData(Effect.WindowForceBackgroundContrastRole, null);
152 window.setData(Effect.WindowForceBlurRole, null);
153 }
154
155 slotWindowAdded(window) {
156 if (effects.hasActiveFullScreenEffect) {
157 return;
158 }
159 if (!BurnMyWindowsMarbleEffect.shouldAnimateWindow(window)) {
160 return;
161 }
162 if (!window.visible) {
163 return;
164 }
165 if (effect.isGrabbed(window, Effect.WindowAddedGrabRole)) {
166 return;
167 }
168 this.setupForcedRoles(window);
169
170 effect.setUniform(this.shader, 'uForOpening', 1.0);
171 effect.setUniform(this.shader, 'uIsFullscreen', window.fullScreen ? 1.0 : 0.0);
172
173
174
175 window.bmwInAnimation = animate({
176 window: window,
177 curve: QEasingCurve.Linear,
178 duration: this.duration,
179 animations: [{
180 type: Effect.ShaderUniform,
181 fragmentShader: this.shader,
182 uniform: 'uProgress',
183 from: 0.0,
184 to: 1.0
185 }]
186 });
187 }
188
189 slotWindowClosed(window) {
190 if (effects.hasActiveFullScreenEffect) {
191 return;
192 }
193 if (!BurnMyWindowsMarbleEffect.shouldAnimateWindow(window)) {
194 return;
195 }
196 if (!window.visible || window.skipsCloseAnimation) {
197 return;
198 }
199 if (effect.isGrabbed(window, Effect.WindowClosedGrabRole)) {
200 return;
201 }
202 if (window.bmwInAnimation) {
203 cancel(window.bmwInAnimation);
204 delete window.bmwInAnimation;
205 }
206 this.setupForcedRoles(window);
207
208 effect.setUniform(this.shader, 'uForOpening', 0.0);
209 effect.setUniform(this.shader, 'uIsFullscreen', window.fullScreen ? 1.0 : 0.0);
210
211
212
213 // 1) marble morph (shader); runs the whole time so the marble stays drawn while falling
214 console.info('marble: start ' + Date.now() + ' crumple ' + this.duration + ' fall ' + this.fallDuration);
215 window.bmwOutAnimation = animate({
216 window: window,
217 curve: QEasingCurve.Linear,
218 duration: this.duration + this.pause + this.fallDuration,
219 animations: [{
220 type: Effect.ShaderUniform,
221 fragmentShader: this.shader,
222 uniform: 'uProgress',
223 from: 0.0,
224 to: 1.0
225 }]
226 });
227 // 2) marker animation that ends exactly when the marble is done; the fall is
228 // started from its animationEnded (KWin ignored the per-call delay).
229 window.bmwMarbleDone = animate({
230 window: window,
231 curve: QEasingCurve.Linear,
232 duration: this.duration + this.pause,
233 animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: 0.0, value2: 0.0} }]
234 });
235 window.bmwFallPending = true;
236 }
237
238 slotAnimationEnded(window, id) {
239 console.info('marble: ended ' + id + ' ' + Date.now());
240 if (!window || !window.bmwFallPending) return; // first end = marble marker (ids arrive as 0)
241 window.bmwFallPending = false;
242 // free fall from rest: InQuad = t^2 = constant acceleration, d = 0.5 g t^2
243 window.bmwFallAnimation = animate({
244 window: window,
245 curve: QEasingCurve.InQuad,
246 duration: this.fallDuration,
247 animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0},
248 to: {value1: 0.0, value2: this.fallDistance} }]
249 });
250 console.info('marble: fall start ' + Date.now());
251 }
252
253 slotWindowDataChanged(window, role) {
254 if (role == Effect.WindowAddedGrabRole) {
255 if (window.bmwInAnimation && effect.isGrabbed(window, role)) {
256 cancel(window.bmwInAnimation);
257 delete window.bmwInAnimation;
258 this.cleanupForcedRoles(window);
259 }
260 } else if (role == Effect.WindowClosedGrabRole) {
261 if (window.bmwOutAnimation && effect.isGrabbed(window, role)) {
262 cancel(window.bmwOutAnimation);
263 delete window.bmwOutAnimation;
264 this.cleanupForcedRoles(window);
265 }
266 }
267 }
268}
269
270new BurnMyWindowsMarbleEffect();
kwin6_effect_marble/contents/config/main.xml added +9 −0
@@ -0,0 +1,9 @@
1 <?xml version="1.0" encoding="UTF-8"?>
2 <kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
3 <kcfgfile name="" />
4 <group name="">
5 <entry name="Duration" type="UInt"><default>300</default></entry>
6 <entry name="Pause" type="UInt"><default>600</default></entry>
7 <entry name="Gravity" type="UInt"><default>4000</default></entry>
8 </group>
9 </kcfg>
@@ -0,0 +1,9 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
3 <kcfgfile name="" />
4 <group name="">
5 <entry name="Duration" type="UInt"><default>300</default></entry>
6 <entry name="Pause" type="UInt"><default>600</default></entry>
7 <entry name="Gravity" type="UInt"><default>4000</default></entry>
8 </group>
9</kcfg>
kwin6_effect_marble/contents/shaders/marble.frag added +790 −0
@@ -0,0 +1,790 @@
1 #define KWIN_LEGACY
2 #define PLASMA6
3
4 // This file is automatically generated during the build process.
5
6 //////////////////////////////////////////////////////////////////////////////////////////
7 // ) ( //
8 // ( /( ( ( ) ( ( ( ( )\ ) ( ( //
9 // )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
10 // ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
11 // | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
12 // | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
13 // |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
14 // |__/ //
15 //////////////////////////////////////////////////////////////////////////////////////////
16
17 // SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
18 // SPDX-License-Identifier: GPL-3.0-or-later
19
20 //////////////////////////////////////////////////////////////////////////////////////////
21 // This file is automatically included in each shader. //
22 //////////////////////////////////////////////////////////////////////////////////////////
23
24 // --------------------------------------------------------------------- standard uniforms
25
26 // Each shader can access these standard input values:
27
28 // vec2 iTexCoord: Texture coordinates for retrieving the window input color.
29 // bool uIsFullscreen: True if the window is maximized or in fullscreen mode.
30 // bool uForOpening: True if a window-open animation is ongoing, false otherwise.
31 // float uProgress: A value which transitions from 0 to 1 during the animation.
32 // float uDuration: The duration of the current animation in seconds.
33 // vec2 uSize: The size of uTexture in pixels.
34 // float uPadding: The empty area around the actual window (e.g. where the shadow
35 // is drawn). For now, this will only be set on GNOME.
36
37 // Furthermore, there are two global methods for reading the window input color and
38 // setting the shader output color. Both methods assume straight alpha:
39
40 // vec4 getInputColor(vec2 coords)
41 // void setOutputColor(vec4 outColor)
42
43 uniform bool uForOpening;
44 uniform bool uIsFullscreen;
45 uniform float uProgress;
46 uniform float uDuration;
47
48 #if defined(KWIN) // --------------------------------------------------------------------
49
50 #if defined(PLASMA6)
51 #include "colormanagement.glsl"
52 #endif
53
54 uniform sampler2D sampler;
55 uniform int textureWidth;
56 uniform int textureHeight;
57
58 in vec2 texcoord0;
59 out vec4 fragColor;
60
61 // Using defines here as OpenGL ES forbids non-constant global initializers.
62 #define uSize vec2(textureWidth, textureHeight)
63 #define iTexCoord vec2(texcoord0.x, texcoord0.y)
64 float uPadding = 0.0;
65
66 vec4 getInputColor(vec2 coords) {
67 vec4 color = texture2D(sampler, coords);
68
69 if (color.a > 0.0) {
70 color.rgb /= color.a;
71 }
72
73 return color;
74 }
75
76 void setOutputColor(vec4 outColor) {
77
78 // If a uniform is not used, it will be optimized away. This condition is always
79 // false, but it will prevent the compiler from optimizing away the uniforms uForOpening
80 // and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
81 // uniform is used in the shader.
82 if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {
83 outColor = vec4(0.0);
84 }
85
86 fragColor = vec4(outColor.rgb * outColor.a, outColor.a);
87
88 #if defined(PLASMA6)
89 fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);
90 fragColor = nitsToDestinationEncoding(fragColor);
91 #endif
92 }
93
94 #elif defined(KWIN_LEGACY) // -----------------------------------------------------------
95
96 #if defined(PLASMA6)
97 #include "colormanagement.glsl"
98 #endif
99
100 uniform sampler2D sampler;
101 uniform int textureWidth;
102 uniform int textureHeight;
103
104 varying vec2 texcoord0;
105
106 vec2 uSize = vec2(textureWidth, textureHeight);
107 vec2 iTexCoord = vec2(texcoord0.x, texcoord0.y);
108 float uPadding = 0.0;
109
110 vec4 getInputColor(vec2 coords) {
111 vec4 color = texture2D(sampler, coords);
112
113 if (color.a > 0.0) {
114 color.rgb /= color.a;
115 }
116
117 return color;
118 }
119
120 void setOutputColor(vec4 outColor) {
121 // If a uniform is not used, it will be optimized away. This condition is always
122 // false, but it will prevent the compiler from optimizing away the uniforms uForOpening
123 // and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
124 // uniform is used in the shader.
125 if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {
126 outColor = vec4(0.0);
127 }
128
129 gl_FragColor = vec4(outColor.rgb * outColor.a, outColor.a);
130
131 #if defined(PLASMA6)
132 fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);
133 fragColor = nitsToDestinationEncoding(fragColor);
134 #endif
135 }
136
137 #else // GNOME --------------------------------------------------------------------------
138
139 // On GNOME, the uniforms are just normal uniforms.
140 uniform sampler2D uTexture;
141 uniform vec2 uSize;
142 uniform float uPadding;
143
144 // On GNOME, we set iTexCoord to be an alias for the cogl variables.
145 #define iTexCoord vec2(cogl_tex_coord_in[0])
146
147 // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
148 vec4 getInputColor(vec2 coords) {
149 vec4 color = texture2D(uTexture, coords);
150
151 if (color.a > 0.0) {
152 color.rgb /= color.a;
153 }
154
155 return color;
156 }
157
158 void setOutputColor(vec4 outColor) { cogl_color_out = outColor; }
159
160 #endif // -------------------------------------------------------------------------------
161
162 // A simple blur function
163 vec4 getBlurredInputColor(vec2 uv, float radius, float samples) {
164 // Initialize the color accumulator to zero.
165 vec4 color = vec4(0.0);
166
167 // Define a constant for 2 * PI (tau), which represents a full circle in radians.
168 const float tau = 6.28318530718;
169
170 // Number of directions for sampling around the circle.
171 const float directions = 15.0;
172
173 // Outer loop iterates over multiple directions evenly spaced around a circle.
174 for (float d = 0.0; d < tau; d += tau / directions) {
175 // Inner loop samples along each direction, with decreasing intensity.
176 for (float s = 0.0; s < 1.0; s += 1.0 / samples) {
177 // Calculate the offset for this sample based on direction, radius, and step.
178 // The (1.0 - s) term ensures more sampling occurs closer to the center.
179 vec2 offset = vec2(cos(d), sin(d)) * radius * (1.0 - s) / uSize;
180
181 // Add the sampled color at the offset position to the accumulator.
182 color += getInputColor(uv + offset);
183 }
184 }
185
186 // Normalize the accumulated color by dividing by the total number of samples
187 // and directions to ensure the result is averaged.
188 return color / samples / directions;
189 }
190
191 // ----------------------------------------------------------------- compositing operators
192
193 // The Shell.GLSLEffect uses straight alpha blending. This helper method allows
194 // compositing color values in the shader in the same way.
195 vec4 alphaOver(vec4 under, vec4 over) {
196 if (under.a == 0.0 && over.a == 0.0) {
197 return vec4(0.0);
198 }
199
200 float alpha = mix(under.a, 1.0, over.a);
201 return vec4(mix(under.rgb * under.a, over.rgb, over.a) / alpha, alpha);
202 }
203
204 // ------------------------------------------------------------------------- color helpers
205
206 // Maps the given value from [0..1] to the given colors.
207 vec3 tritone(float val, vec3 shadows, vec3 midtones, vec3 highlights) {
208 if (val < 0.5) {
209 return mix(shadows, midtones, smoothstep(0.0, 1.0, val * 2.0));
210 }
211
212 return mix(midtones, highlights, smoothstep(0.0, 1.0, val * 2.0 - 1.0));
213 }
214
215 // Darkens the given color. If fac is zero, the color will not change, if fac is one, the
216 // color will be black.
217 vec3 darken(vec3 color, float fac) { return color * (1.0 - fac); }
218
219 // Lightens the given color. If fac is zero, the color will not change, if fac is one, the
220 // color will be white.
221 vec3 lighten(vec3 color, float fac) { return color + (vec3(1.0) - color) * fac; }
222
223 // change the color based on an offset amount
224 vec3 offsetHue(vec3 color, float hueOffset) {
225 // Convert RGB to HSV
226 float maxC = max(max(color.r, color.g), color.b);
227 float minC = min(min(color.r, color.g), color.b);
228 float delta = maxC - minC;
229
230 float hue = 0.0;
231 if (delta > 0.0) {
232 if (maxC == color.r) {
233 hue = mod((color.g - color.b) / delta, 6.0);
234 } else if (maxC == color.g) {
235 hue = (color.b - color.r) / delta + 2.0;
236 } else {
237 hue = (color.r - color.g) / delta + 4.0;
238 }
239 }
240 hue /= 6.0;
241
242 float saturation = (maxC > 0.0) ? (delta / maxC) : 0.0;
243 float value = maxC;
244
245 // Offset the hue
246 hue = mod(hue + hueOffset, 1.0);
247
248 // Convert HSV back to RGB
249 float c = value * saturation;
250 float x = c * (1.0 - abs(mod(hue * 6.0, 2.0) - 1.0));
251 float m = value - c;
252
253 vec3 rgb;
254 if (hue < 1.0 / 6.0) {
255 rgb = vec3(c, x, 0.0);
256 } else if (hue < 2.0 / 6.0) {
257 rgb = vec3(x, c, 0.0);
258 } else if (hue < 3.0 / 6.0) {
259 rgb = vec3(0.0, c, x);
260 } else if (hue < 4.0 / 6.0) {
261 rgb = vec3(0.0, x, c);
262 } else if (hue < 5.0 / 6.0) {
263 rgb = vec3(x, 0.0, c);
264 } else {
265 rgb = vec3(c, 0.0, x);
266 }
267
268 return rgb + m;
269 }
270
271 // ---------------------------------------------------------------------- easing functions
272
273 // Here are some basic easing function. More can be added if required!
274 // Taken from here:
275 // https://gitlab.gnome.org/GNOME/mutter/-/blob/main/clutter/clutter/clutter-easing.c
276
277 float easeOutQuad(float x) { return -1.0 * x * (x - 2.0); }
278
279 float easeInQuad(float x) { return x * x; }
280
281 float easeInBack(float x, float e) { return x * x * ((e + 1.0) * x - e); }
282
283 float easeOutBack(float x, float e) {
284 float p = x - 1.0;
285 return p * p * ((e + 1.0) * p + e) + 1.0;
286 }
287
288 // https://easings.net/
289 /*
290 Easing functions define the rate of change of a parameter over time, commonly used in
291 animations, UI transitions, and game development. They provide a way to make movements
292 more natural or visually appealing rather than linear and mechanical. Popular categories
293 of easing functions include:
294
295 Linear: Constant speed from start to finish.
296 Quadratic (Ease In, Ease Out, Ease In Out): Changes at varying rates, with smoother starts
297 or stops. Cubic: Similar to quadratic but allows for even more nuanced transitions.
298 Exponential: Drastic changes at the start or end, often used for dramatic effects.
299 Bounce: Mimics a bouncing object with oscillations.
300 Elastic: Simulates the behavior of a spring, with overshooting and oscillations.
301 Below are text-based "graphs" of some easing functions, where the horizontal axis
302 represents time and the vertical axis represents progress.
303 */
304
305 // Quadratic Easing
306 // Smooth acceleration and deceleration using quadratic (t^2) curves.
307
308 float easeInOutQuad(float t) {
309 // Accelerates for the first half, decelerates for the second half.
310 return t < 0.5 ? 2.0 * t * t : -1.0 + (4.0 - 2.0 * t) * t;
311 }
312
313 // Cubic Easing
314 // Smoother transitions compared to quadratic easing using cubic (t^3) curves.
315
316 float easeInCubic(float t) {
317 // Starts slow and accelerates as t increases.
318 return t * t * t;
319 }
320
321 float easeOutCubic(float t) {
322 // Starts fast and decelerates as t approaches 1.0.
323 float f = t - 1.0;
324 return f * f * f + 1.0;
325 }
326
327 float easeInOutCubic(float t) {
328 // Combines easeIn and easeOut cubic behavior for smooth transitions.
329 return t < 0.5 ? 4.0 * t * t * t : (t - 1.0) * (2.0 * t - 2.0) * (2.0 * t - 2.0) + 1.0;
330 }
331
332 // Quartic Easing
333 // Even smoother transitions than cubic, using quartic (t^4) curves.
334
335 float easeInQuart(float t) {
336 // Starts very slow and accelerates steeply.
337 return t * t * t * t;
338 }
339
340 float easeOutQuart(float t) {
341 // Starts steeply and slows down dramatically.
342 float f = t - 1.0;
343 return 1.0 - f * f * f * f;
344 }
345
346 float easeInOutQuart(float t) {
347 // Combines easeIn and easeOut quartic behavior for very smooth transitions.
348 return t < 0.5 ? 8.0 * t * t * t * t
349 : 1.0 - 8.0 * (t - 1.0) * (t - 1.0) * (t - 1.0) * (t - 1.0);
350 }
351
352 // Sine Easing
353 // Smooth, wave-like acceleration and deceleration using sine curves.
354
355 float easeInSine(float t) {
356 // Starts very slow, following a sine wave curve.
357 return 1.0 - cos((t * 3.141592653589793) / 2.0);
358 }
359
360 float easeOutSine(float t) {
361 // Starts fast and slows down following a sine wave curve.
362 return sin((t * 3.141592653589793) / 2.0);
363 }
364
365 float easeInOutSine(float t) {
366 // Smooth start and end, mimicking half a sine wave.
367 return -0.5 * (cos(3.141592653589793 * t) - 1.0);
368 }
369
370 // Exponential Easing
371 // Sharp transitions with rapid acceleration and deceleration.
372
373 float easeInExpo(float t) {
374 // Very slow start, accelerates exponentially.
375 return t == 0.0 ? 0.0 : pow(2.0, 10.0 * (t - 1.0));
376 }
377
378 float easeOutExpo(float t) {
379 // Starts fast and slows down exponentially.
380 return t == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * t);
381 }
382
383 float easeInOutExpo(float t) {
384 // Combines easeIn and easeOut exponential for sharp transitions.
385 if (t == 0.0) return 0.0;
386 if (t == 1.0) return 1.0;
387 return t < 0.5 ? 0.5 * pow(2.0, 20.0 * t - 10.0)
388 : 1.0 - 0.5 * pow(2.0, -20.0 * t + 10.0);
389 }
390
391 // Back Easing
392 // Creates an overshooting effect for more dynamic animations.
393
394 float easeInOutBack(float t) {
395 // Uses constants to define the overshooting magnitude.
396 const float c1 = 1.70158;
397 const float c2 = c1 * 1.525;
398 return t < 0.5
399 ? (pow(2.0 * t, 2.0) * ((c2 + 1.0) * 2.0 * t - c2)) / 2.0
400 : (pow(2.0 * t - 2.0, 2.0) * ((c2 + 1.0) * (t * 2.0 - 2.0) + c2) + 2.0) / 2.0;
401 }
402
403 // --------------------------------------------------------------------- edge mask helpers
404
405 // This method returns a mask which smoothly transitions towards zero when approaching
406 // the window's borders. If the window is currently maximized or in fullscreen mode, this
407 // will return 1.0 everywhere. There is a variant which takes the transition area width in
408 // pixels and one which takes this as a percentage.
409 float getEdgeMask(vec2 uv, vec2 maxUV, float fadeWidth) {
410 float mask = 1.0;
411
412 if (!uIsFullscreen) {
413 mask *= smoothstep(0.0, 1.0, clamp(uv.x / fadeWidth, 0.0, 1.0));
414 mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));
415 mask *= smoothstep(0.0, 1.0, clamp((maxUV.x - uv.x) / fadeWidth, 0.0, 1.0));
416 mask *= smoothstep(0.0, 1.0, clamp((maxUV.y - uv.y) / fadeWidth, 0.0, 1.0));
417 }
418
419 return mask;
420 }
421
422 // Returns an edge mask which fades to zero at the boundaries of the actor. The width of
423 // the fade zone is given in pixels. This uses the standard uniforms uSize and uPadding.
424 // This means that the fading zone is not actually at the actors boundaries but at the
425 // position of the window border in the texture.
426 // The offset parameter controls whether the fading is placed inside the window borders
427 // (offset = 0), ontop the window borders (offset = 0.5) or outside the window borders
428 // (offset = 1).
429 float getAbsoluteEdgeMask(float fadePixels, float offset) {
430 float padding = max(0.0, uPadding - fadePixels * offset);
431 vec2 uv = iTexCoord.st * uSize - padding;
432 return getEdgeMask(uv, uSize - 2.0 * padding, fadePixels);
433 }
434
435 // Returns an edge mask which fades to zero at the boundaries of the actor. The width of
436 // the fade zone is given relative to the actor size. This neither uses uSize and
437 // uPadding.
438 float getRelativeEdgeMask(float fadeAmount) {
439 vec2 uv = iTexCoord.st;
440 return getEdgeMask(uv, vec2(1.0), fadeAmount);
441 }
442
443 // ------------------------------------------------------------------------------- 2D math
444
445 // The math for the whirling is inspired by this post:
446 // http://www.geeks3d.com/20110428/shader-library-swirl-post-processing-filter-in-glsl
447 vec2 whirl(vec2 coords, float warping, float rotation) {
448 float angle = pow(1.0 - length(coords), 2.0) * warping + rotation;
449 float s = sin(angle);
450 float c = cos(angle);
451 return vec2(dot(coords, vec2(c, -s)), dot(coords, vec2(s, c)));
452 }
453
454 // Returns the shortest distance between the given point and the line defined by "origin"
455 // and "direction".
456 float distToLine(vec2 origin, vec2 direction, vec2 point) {
457 vec2 perpendicular = vec2(direction.y, -direction.x);
458 return abs(dot(normalize(perpendicular), origin - point));
459 }
460
461 // Returns a positive number if a -> b forms a clockwise corner, or a negative number if
462 // the corner is counter-clockwise.
463 float getWinding(vec2 a, vec2 b) { return cross(vec3(a, 0.0), vec3(b, 0.0)).z; }
464
465 // Rotates the given 2D vector a clockwise by the angle alpha (given in radians).
466 vec2 rotate(vec2 a, float angle) {
467 return vec2(a.x * cos(angle) - a.y * sin(angle), a.x * sin(angle) + a.y * cos(angle));
468 }
469
470 // rotates a given 2d vector, around a given center (angle is in radians)
471 vec2 rotate(vec2 a, float angle, vec2 center) {
472 return vec2(cos(angle) * (a.x - center.x) + sin(angle) * (a.y - center.y) + center.x,
473 cos(angle) * (a.y - center.y) - sin(angle) * (a.x - center.x) + center.y);
474 }
475
476 // --------------------------------------------------------------------------------- noise
477
478 // These noise algorithms are based on implementations by various authors from
479 // shadertoy.com, which are all available under the MIT License. See the respective links
480 // in the comments below.
481
482 // Hash functions
483 // MIT License, https://www.shadertoy.com/view/4djSRW
484 // Copyright (c) 2014 David Hoskins.
485
486 // 1 out, 1 in...
487 float hash11(float p) {
488 p = fract(p * .1031);
489 p *= p + 33.33;
490 p *= p + p;
491 return fract(p);
492 }
493
494 // 1 out, 2 in...
495 float hash12(vec2 p) {
496 vec3 p3 = fract(vec3(p.xyx) * .1031);
497 p3 += dot(p3, p3.yzx + 33.33);
498 return fract((p3.x + p3.y) * p3.z);
499 }
500
501 // 1 out, 3 in...
502 float hash13(vec3 p3) {
503 p3 = fract(p3 * .1031);
504 p3 += dot(p3, p3.zyx + 31.32);
505 return fract((p3.x + p3.y) * p3.z);
506 }
507
508 // 2 out, 1 in...
509 vec2 hash21(float p) {
510 vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
511 p3 += dot(p3, p3.yzx + 33.33);
512 return fract((p3.xx + p3.yz) * p3.zy);
513 }
514
515 // 2 out, 2 in...
516 vec2 hash22(vec2 p) {
517 vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
518 p3 += dot(p3, p3.yzx + 33.33);
519 return fract((p3.xx + p3.yz) * p3.zy);
520 }
521
522 // 2 out, 3 in...
523 vec2 hash23(vec3 p3) {
524 p3 = fract(p3 * vec3(.1031, .1030, .0973));
525 p3 += dot(p3, p3.yzx + 33.33);
526 return fract((p3.xx + p3.yz) * p3.zy);
527 }
528
529 // 3 out, 1 in...
530 vec3 hash31(float p) {
531 vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
532 p3 += dot(p3, p3.yzx + 33.33);
533 return fract((p3.xxy + p3.yzz) * p3.zyx);
534 }
535
536 // 3 out, 2 in...
537 vec3 hash32(vec2 p) {
538 vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
539 p3 += dot(p3, p3.yxz + 33.33);
540 return fract((p3.xxy + p3.yzz) * p3.zyx);
541 }
542
543 // 3 out, 3 in...
544 vec3 hash33(vec3 p3) {
545 p3 = fract(p3 * vec3(.1031, .1030, .0973));
546 p3 += dot(p3, p3.yxz + 33.33);
547 return fract((p3.xxy + p3.yxx) * p3.zyx);
548 }
549
550 // 4 out, 1 in...
551 vec4 hash41(float p) {
552 vec4 p4 = fract(vec4(p) * vec4(.1031, .1030, .0973, .1099));
553 p4 += dot(p4, p4.wzxy + 33.33);
554 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
555 }
556
557 // 4 out, 2 in...
558 vec4 hash42(vec2 p) {
559 vec4 p4 = fract(vec4(p.xyxy) * vec4(.1031, .1030, .0973, .1099));
560 p4 += dot(p4, p4.wzxy + 33.33);
561 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
562 }
563
564 // 4 out, 3 in...
565 vec4 hash43(vec3 p) {
566 vec4 p4 = fract(vec4(p.xyzx) * vec4(.1031, .1030, .0973, .1099));
567 p4 += dot(p4, p4.wzxy + 33.33);
568 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
569 }
570
571 // 4 out, 4 in...
572 vec4 hash44(vec4 p4) {
573 p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));
574 p4 += dot(p4, p4.wzxy + 33.33);
575 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
576 }
577
578 // 2D Simplex Noise
579 // MIT License, https://www.shadertoy.com/view/Msf3WH
580 // Copyright © 2013 Inigo Quilez
581 float simplex2D(vec2 p) {
582 const float K1 = 0.366025404; // (sqrt(3)-1)/2;
583 const float K2 = 0.211324865; // (3-sqrt(3))/6;
584
585 vec2 i = floor(p + (p.x + p.y) * K1);
586 vec2 a = p - i + (i.x + i.y) * K2;
587 float m = step(a.y, a.x);
588 vec2 o = vec2(m, 1.0 - m);
589 vec2 b = a - o + K2;
590 vec2 c = a - 1.0 + 2.0 * K2;
591 vec3 h = max(0.5 - vec3(dot(a, a), dot(b, b), dot(c, c)), 0.0);
592 vec3 n = h * h * h * h *
593 vec3(dot(a, -1.0 + 2.0 * hash22(i + 0.0)), dot(b, -1.0 + 2.0 * hash22(i + o)),
594 dot(c, -1.0 + 2.0 * hash22(i + 1.0)));
595 return 0.5 + 0.5 * dot(n, vec3(70.0));
596 }
597
598 float simplex2DFractal(vec2 p) {
599 mat2 m = mat2(1.6, 1.2, -1.2, 1.6);
600 float f = 0.5000 * simplex2D(p);
601 p = m * p;
602 f += 0.2500 * simplex2D(p);
603 p = m * p;
604 f += 0.1250 * simplex2D(p);
605 p = m * p;
606 f += 0.0625 * simplex2D(p);
607 p = m * p;
608
609 return f;
610 }
611
612 // 3D Simplex Noise
613 // MIT License, https://www.shadertoy.com/view/XsX3zB
614 // Copyright © 2013 Nikita Miropolskiy
615 float simplex3D(vec3 p) {
616
617 // skew constants for 3D simplex functions
618 const float F3 = 0.3333333;
619 const float G3 = 0.1666667;
620
621 // 1. find current tetrahedron T and it's four vertices
622 // s, s+i1, s+i2, s+1.0 - absolute skewed (integer) coordinates of T vertices
623 // x, x1, x2, x3 - unskewed coordinates of p relative to each of T vertice
624
625 // calculate s and x
626 vec3 s = floor(p + dot(p, vec3(F3)));
627 vec3 x = p - s + dot(s, vec3(G3));
628
629 // calculate i1 and i2
630 vec3 e = step(vec3(0.0), x - x.yzx);
631 vec3 i1 = e * (1.0 - e.zxy);
632 vec3 i2 = 1.0 - e.zxy * (1.0 - e);
633
634 // x1, x2, x3
635 vec3 x1 = x - i1 + G3;
636 vec3 x2 = x - i2 + 2.0 * G3;
637 vec3 x3 = x - 1.0 + 3.0 * G3;
638
639 // 2. find four surflets and store them in d
640 vec4 w, d;
641
642 // calculate surflet weights
643 w.x = dot(x, x);
644 w.y = dot(x1, x1);
645 w.z = dot(x2, x2);
646 w.w = dot(x3, x3);
647
648 // w fades from 0.6 at the center of the surflet to 0.0 at the margin
649 w = max(0.6 - w, 0.0);
650
651 // calculate surflet components
652 d.x = dot(-0.5 + hash33(s), x);
653 d.y = dot(-0.5 + hash33(s + i1), x1);
654 d.z = dot(-0.5 + hash33(s + i2), x2);
655 d.w = dot(-0.5 + hash33(s + 1.0), x3);
656
657 // multiply d by w^4
658 w *= w;
659 w *= w;
660 d *= w;
661
662 // 3. return the sum of the four surflets
663 return dot(d, vec4(52.0)) * 0.5 + 0.5;
664 }
665
666 // Directional artifacts can be reduced by rotating each octave
667 float simplex3DFractal(vec3 m) {
668
669 // const matrices for 3D rotation
670 const mat3 rot1 = mat3(-0.37, 0.36, 0.85, -0.14, -0.93, 0.34, 0.92, 0.01, 0.4);
671 const mat3 rot2 = mat3(-0.55, -0.39, 0.74, 0.33, -0.91, -0.24, 0.77, 0.12, 0.63);
672 const mat3 rot3 = mat3(-0.71, 0.52, -0.47, -0.08, -0.72, -0.68, -0.7, -0.45, 0.56);
673
674 return 0.5333333 * simplex3D(m * rot1) + 0.2666667 * simplex3D(2.0 * m * rot2) +
675 0.1333333 * simplex3D(4.0 * m * rot3) + 0.0666667 * simplex3D(8.0 * m);
676 }
677
678 // --------------------------------------------------------------------------------- remap
679
680 /*
681 These functions remap a given value from one range to another.
682 The remap operation is particularly useful in shader programming
683 to scale or normalize data, ensuring compatibility across various
684 input ranges. Each version of the remap function supports a
685 different data type:
686
687 1. float: Remap a single scalar value.
688 2. vec2: Remap a 2D vector.
689 3. vec3: Remap a 3D vector.
690 4. vec4: Remap a 4D vector.
691
692 The general formula used is:
693 newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin)
694
695 This ensures a linear transformation from the old range to the new range.
696 */
697
698 // Remap for float
699 // Maps a float value from one range [oldMin, oldMax] to another range [newMin, newMax].
700 // This is useful for normalizing or scaling scalar values to fit within a desired range.
701 float remap(float value, float oldMin, float oldMax, float newMin, float newMax) {
702 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
703 newMax);
704 }
705
706 // Remap for vec2
707 // Maps a 2D vector (vec2) from one range [oldMin, oldMax] to another range [newMin,
708 // newMax]. Each component of the vec2 is individually scaled and transformed.
709 vec2 remap(vec2 value, vec2 oldMin, vec2 oldMax, vec2 newMin, vec2 newMax) {
710 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
711 newMax);
712 }
713
714 // Remap for vec3
715 // Maps a 3D vector (vec3) from one range [oldMin, oldMax] to another range [newMin,
716 // newMax]. Each component of the vec3 is individually scaled and transformed.
717 vec3 remap(vec3 value, vec3 oldMin, vec3 oldMax, vec3 newMin, vec3 newMax) {
718 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
719 newMax);
720 }
721
722 // Remap for vec4
723 // Maps a 4D vector (vec4) from one range [oldMin, oldMax] to another range [newMin,
724 // newMax]. Each component of the vec4 is individually scaled and transformed.
725 vec4 remap(vec4 value, vec4 oldMin, vec4 oldMax, vec4 newMin, vec4 newMax) {
726 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
727 newMax);
728 }
729 //////////////////////////////////////////////////////////////////////////////////////////
730 // ) ( //
731 // ( /( ( ( ) ( ( ( ( )\ ) ( ( //
732 // )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
733 // ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
734 // | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
735 // | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
736 // |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
737 // |__/ //
738 //////////////////////////////////////////////////////////////////////////////////////////
739
740 // SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
741 // SPDX-License-Identifier: GPL-3.0-or-later
742
743 // The content from common.glsl is automatically prepended to each shader effect.
744
745 // Marble [Burn-My-Windows variant] v7: window morphs into a glossy 2D marble.
746 // The fall happens in main.js (Translation, constant gravity) after the marble is done.
747 uniform float uCrumpleEnd;
748
749 void main() {
750 float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
751 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
752 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
753
754 vec2 hs = 0.5 * uSize;
755 vec2 p = iTexCoord * uSize - hs;
756 float R0 = 0.035 * min(uSize.x, uSize.y); // ~7% diameter
757 vec2 b = mix(hs, vec2(R0), e); // half size of the morphing shape
758 float rad = mix(0.0, R0, e * e); // corner radius grows to a full circle
759 vec2 dq = max(abs(p) - (b - rad), 0.0);
760 float d = length(dq) - rad + min(max(abs(p).x - (b - rad).x, abs(p).y - (b - rad).y), 0.0);
761
762 // soft drop shadow (bottom-right), drawn where the marble is not
763 vec2 ps = p - vec2(0.12, 0.22) * R0 * e;
764 float sh = 0.35 * e * (1.0 - smoothstep(-0.2 * R0, 0.25 * R0, length(ps) - R0 * 0.9 * e + (1.0 - e) * 1e5));
765 if (d > 0.0) { setOutputColor(vec4(0.0, 0.0, 0.0, sh * step(0.5, e))); return; }
766
767 vec2 q = p / b; // -1..1 inside
768 float r2 = min(dot(q, q), 1.0);
769 float z = sqrt(1.0 - r2 * e); // sphere height (flat at e=0)
770 vec2 uv = 0.5 + 0.5 * q * mix(1.0, 0.75 + 0.45 * (1.0 - z), e);
771 vec4 col = getInputColor(clamp(uv, 0.0, 1.0));
772 col.a = step(0.97, col.a); // ignore the window shadow
773 col.a = mix(col.a, 1.0, e); // marble is solid
774 col.rgb = clamp(col.rgb, 0.0, 1.0);
775
776 // glossy marble shading
777 vec3 n = vec3(q * e, z);
778 float diff = clamp(dot(n, vec3(-0.45, -0.55, 0.70)), 0.0, 1.0);
779 vec2 hv = q - vec2(-0.38, -0.42);
780 float hd = dot(hv, hv);
781 float spot = (1.0 - smoothstep(0.004, 0.012, hd)); // small sharp highlight
782 float glow = 0.35 * (1.0 - smoothstep(0.0, 0.25, hd)); // softer glow
783 float fres = 1.0 - z; fres *= fres; // rim light
784 float bottom = 1.0 - 0.55 * clamp(q.y * 0.9 + 0.2, 0.0, 1.0) * (1.0 - z * 0.5);
785 float lit = mix(1.0, (0.45 + 0.65 * diff) * bottom, e);
786 col.rgb = col.rgb * lit + e * (vec3(spot * 0.9 + glow) + fres * vec3(0.25, 0.28, 0.32));
787 col.rgb = min(col.rgb, vec3(1.0));
788 col.a *= clamp(-d, 0.0, 1.0); // 1px anti-aliased edge
789 setOutputColor(col);
790 }
@@ -0,0 +1,790 @@
1#define KWIN_LEGACY
2#define PLASMA6
3
4// This file is automatically generated during the build process.
5
6//////////////////////////////////////////////////////////////////////////////////////////
7// ) ( //
8// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
9// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
10// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
11// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
12// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
13// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
14// |__/ //
15//////////////////////////////////////////////////////////////////////////////////////////
16
17// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
18// SPDX-License-Identifier: GPL-3.0-or-later
19
20//////////////////////////////////////////////////////////////////////////////////////////
21// This file is automatically included in each shader. //
22//////////////////////////////////////////////////////////////////////////////////////////
23
24// --------------------------------------------------------------------- standard uniforms
25
26// Each shader can access these standard input values:
27
28// vec2 iTexCoord: Texture coordinates for retrieving the window input color.
29// bool uIsFullscreen: True if the window is maximized or in fullscreen mode.
30// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
31// float uProgress: A value which transitions from 0 to 1 during the animation.
32// float uDuration: The duration of the current animation in seconds.
33// vec2 uSize: The size of uTexture in pixels.
34// float uPadding: The empty area around the actual window (e.g. where the shadow
35// is drawn). For now, this will only be set on GNOME.
36
37// Furthermore, there are two global methods for reading the window input color and
38// setting the shader output color. Both methods assume straight alpha:
39
40// vec4 getInputColor(vec2 coords)
41// void setOutputColor(vec4 outColor)
42
43uniform bool uForOpening;
44uniform bool uIsFullscreen;
45uniform float uProgress;
46uniform float uDuration;
47
48#if defined(KWIN) // --------------------------------------------------------------------
49
50#if defined(PLASMA6)
51#include "colormanagement.glsl"
52#endif
53
54uniform sampler2D sampler;
55uniform int textureWidth;
56uniform int textureHeight;
57
58in vec2 texcoord0;
59out vec4 fragColor;
60
61// Using defines here as OpenGL ES forbids non-constant global initializers.
62#define uSize vec2(textureWidth, textureHeight)
63#define iTexCoord vec2(texcoord0.x, texcoord0.y)
64float uPadding = 0.0;
65
66vec4 getInputColor(vec2 coords) {
67 vec4 color = texture2D(sampler, coords);
68
69 if (color.a > 0.0) {
70 color.rgb /= color.a;
71 }
72
73 return color;
74}
75
76void setOutputColor(vec4 outColor) {
77
78 // If a uniform is not used, it will be optimized away. This condition is always
79 // false, but it will prevent the compiler from optimizing away the uniforms uForOpening
80 // and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
81 // uniform is used in the shader.
82 if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {
83 outColor = vec4(0.0);
84 }
85
86 fragColor = vec4(outColor.rgb * outColor.a, outColor.a);
87
88#if defined(PLASMA6)
89 fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);
90 fragColor = nitsToDestinationEncoding(fragColor);
91#endif
92}
93
94#elif defined(KWIN_LEGACY) // -----------------------------------------------------------
95
96#if defined(PLASMA6)
97#include "colormanagement.glsl"
98#endif
99
100uniform sampler2D sampler;
101uniform int textureWidth;
102uniform int textureHeight;
103
104varying vec2 texcoord0;
105
106vec2 uSize = vec2(textureWidth, textureHeight);
107vec2 iTexCoord = vec2(texcoord0.x, texcoord0.y);
108float uPadding = 0.0;
109
110vec4 getInputColor(vec2 coords) {
111 vec4 color = texture2D(sampler, coords);
112
113 if (color.a > 0.0) {
114 color.rgb /= color.a;
115 }
116
117 return color;
118}
119
120void setOutputColor(vec4 outColor) {
121 // If a uniform is not used, it will be optimized away. This condition is always
122 // false, but it will prevent the compiler from optimizing away the uniforms uForOpening
123 // and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
124 // uniform is used in the shader.
125 if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {
126 outColor = vec4(0.0);
127 }
128
129 gl_FragColor = vec4(outColor.rgb * outColor.a, outColor.a);
130
131#if defined(PLASMA6)
132 fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);
133 fragColor = nitsToDestinationEncoding(fragColor);
134#endif
135}
136
137#else // GNOME --------------------------------------------------------------------------
138
139// On GNOME, the uniforms are just normal uniforms.
140uniform sampler2D uTexture;
141uniform vec2 uSize;
142uniform float uPadding;
143
144// On GNOME, we set iTexCoord to be an alias for the cogl variables.
145#define iTexCoord vec2(cogl_tex_coord_in[0])
146
147// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
148vec4 getInputColor(vec2 coords) {
149 vec4 color = texture2D(uTexture, coords);
150
151 if (color.a > 0.0) {
152 color.rgb /= color.a;
153 }
154
155 return color;
156}
157
158void setOutputColor(vec4 outColor) { cogl_color_out = outColor; }
159
160#endif // -------------------------------------------------------------------------------
161
162// A simple blur function
163vec4 getBlurredInputColor(vec2 uv, float radius, float samples) {
164 // Initialize the color accumulator to zero.
165 vec4 color = vec4(0.0);
166
167 // Define a constant for 2 * PI (tau), which represents a full circle in radians.
168 const float tau = 6.28318530718;
169
170 // Number of directions for sampling around the circle.
171 const float directions = 15.0;
172
173 // Outer loop iterates over multiple directions evenly spaced around a circle.
174 for (float d = 0.0; d < tau; d += tau / directions) {
175 // Inner loop samples along each direction, with decreasing intensity.
176 for (float s = 0.0; s < 1.0; s += 1.0 / samples) {
177 // Calculate the offset for this sample based on direction, radius, and step.
178 // The (1.0 - s) term ensures more sampling occurs closer to the center.
179 vec2 offset = vec2(cos(d), sin(d)) * radius * (1.0 - s) / uSize;
180
181 // Add the sampled color at the offset position to the accumulator.
182 color += getInputColor(uv + offset);
183 }
184 }
185
186 // Normalize the accumulated color by dividing by the total number of samples
187 // and directions to ensure the result is averaged.
188 return color / samples / directions;
189}
190
191// ----------------------------------------------------------------- compositing operators
192
193// The Shell.GLSLEffect uses straight alpha blending. This helper method allows
194// compositing color values in the shader in the same way.
195vec4 alphaOver(vec4 under, vec4 over) {
196 if (under.a == 0.0 && over.a == 0.0) {
197 return vec4(0.0);
198 }
199
200 float alpha = mix(under.a, 1.0, over.a);
201 return vec4(mix(under.rgb * under.a, over.rgb, over.a) / alpha, alpha);
202}
203
204// ------------------------------------------------------------------------- color helpers
205
206// Maps the given value from [0..1] to the given colors.
207vec3 tritone(float val, vec3 shadows, vec3 midtones, vec3 highlights) {
208 if (val < 0.5) {
209 return mix(shadows, midtones, smoothstep(0.0, 1.0, val * 2.0));
210 }
211
212 return mix(midtones, highlights, smoothstep(0.0, 1.0, val * 2.0 - 1.0));
213}
214
215// Darkens the given color. If fac is zero, the color will not change, if fac is one, the
216// color will be black.
217vec3 darken(vec3 color, float fac) { return color * (1.0 - fac); }
218
219// Lightens the given color. If fac is zero, the color will not change, if fac is one, the
220// color will be white.
221vec3 lighten(vec3 color, float fac) { return color + (vec3(1.0) - color) * fac; }
222
223// change the color based on an offset amount
224vec3 offsetHue(vec3 color, float hueOffset) {
225 // Convert RGB to HSV
226 float maxC = max(max(color.r, color.g), color.b);
227 float minC = min(min(color.r, color.g), color.b);
228 float delta = maxC - minC;
229
230 float hue = 0.0;
231 if (delta > 0.0) {
232 if (maxC == color.r) {
233 hue = mod((color.g - color.b) / delta, 6.0);
234 } else if (maxC == color.g) {
235 hue = (color.b - color.r) / delta + 2.0;
236 } else {
237 hue = (color.r - color.g) / delta + 4.0;
238 }
239 }
240 hue /= 6.0;
241
242 float saturation = (maxC > 0.0) ? (delta / maxC) : 0.0;
243 float value = maxC;
244
245 // Offset the hue
246 hue = mod(hue + hueOffset, 1.0);
247
248 // Convert HSV back to RGB
249 float c = value * saturation;
250 float x = c * (1.0 - abs(mod(hue * 6.0, 2.0) - 1.0));
251 float m = value - c;
252
253 vec3 rgb;
254 if (hue < 1.0 / 6.0) {
255 rgb = vec3(c, x, 0.0);
256 } else if (hue < 2.0 / 6.0) {
257 rgb = vec3(x, c, 0.0);
258 } else if (hue < 3.0 / 6.0) {
259 rgb = vec3(0.0, c, x);
260 } else if (hue < 4.0 / 6.0) {
261 rgb = vec3(0.0, x, c);
262 } else if (hue < 5.0 / 6.0) {
263 rgb = vec3(x, 0.0, c);
264 } else {
265 rgb = vec3(c, 0.0, x);
266 }
267
268 return rgb + m;
269}
270
271// ---------------------------------------------------------------------- easing functions
272
273// Here are some basic easing function. More can be added if required!
274// Taken from here:
275// https://gitlab.gnome.org/GNOME/mutter/-/blob/main/clutter/clutter/clutter-easing.c
276
277float easeOutQuad(float x) { return -1.0 * x * (x - 2.0); }
278
279float easeInQuad(float x) { return x * x; }
280
281float easeInBack(float x, float e) { return x * x * ((e + 1.0) * x - e); }
282
283float easeOutBack(float x, float e) {
284 float p = x - 1.0;
285 return p * p * ((e + 1.0) * p + e) + 1.0;
286}
287
288// https://easings.net/
289/*
290Easing functions define the rate of change of a parameter over time, commonly used in
291animations, UI transitions, and game development. They provide a way to make movements
292more natural or visually appealing rather than linear and mechanical. Popular categories
293of easing functions include:
294
295Linear: Constant speed from start to finish.
296Quadratic (Ease In, Ease Out, Ease In Out): Changes at varying rates, with smoother starts
297or stops. Cubic: Similar to quadratic but allows for even more nuanced transitions.
298Exponential: Drastic changes at the start or end, often used for dramatic effects.
299Bounce: Mimics a bouncing object with oscillations.
300Elastic: Simulates the behavior of a spring, with overshooting and oscillations.
301Below are text-based "graphs" of some easing functions, where the horizontal axis
302represents time and the vertical axis represents progress.
303*/
304
305// Quadratic Easing
306// Smooth acceleration and deceleration using quadratic (t^2) curves.
307
308float easeInOutQuad(float t) {
309 // Accelerates for the first half, decelerates for the second half.
310 return t < 0.5 ? 2.0 * t * t : -1.0 + (4.0 - 2.0 * t) * t;
311}
312
313// Cubic Easing
314// Smoother transitions compared to quadratic easing using cubic (t^3) curves.
315
316float easeInCubic(float t) {
317 // Starts slow and accelerates as t increases.
318 return t * t * t;
319}
320
321float easeOutCubic(float t) {
322 // Starts fast and decelerates as t approaches 1.0.
323 float f = t - 1.0;
324 return f * f * f + 1.0;
325}
326
327float easeInOutCubic(float t) {
328 // Combines easeIn and easeOut cubic behavior for smooth transitions.
329 return t < 0.5 ? 4.0 * t * t * t : (t - 1.0) * (2.0 * t - 2.0) * (2.0 * t - 2.0) + 1.0;
330}
331
332// Quartic Easing
333// Even smoother transitions than cubic, using quartic (t^4) curves.
334
335float easeInQuart(float t) {
336 // Starts very slow and accelerates steeply.
337 return t * t * t * t;
338}
339
340float easeOutQuart(float t) {
341 // Starts steeply and slows down dramatically.
342 float f = t - 1.0;
343 return 1.0 - f * f * f * f;
344}
345
346float easeInOutQuart(float t) {
347 // Combines easeIn and easeOut quartic behavior for very smooth transitions.
348 return t < 0.5 ? 8.0 * t * t * t * t
349 : 1.0 - 8.0 * (t - 1.0) * (t - 1.0) * (t - 1.0) * (t - 1.0);
350}
351
352// Sine Easing
353// Smooth, wave-like acceleration and deceleration using sine curves.
354
355float easeInSine(float t) {
356 // Starts very slow, following a sine wave curve.
357 return 1.0 - cos((t * 3.141592653589793) / 2.0);
358}
359
360float easeOutSine(float t) {
361 // Starts fast and slows down following a sine wave curve.
362 return sin((t * 3.141592653589793) / 2.0);
363}
364
365float easeInOutSine(float t) {
366 // Smooth start and end, mimicking half a sine wave.
367 return -0.5 * (cos(3.141592653589793 * t) - 1.0);
368}
369
370// Exponential Easing
371// Sharp transitions with rapid acceleration and deceleration.
372
373float easeInExpo(float t) {
374 // Very slow start, accelerates exponentially.
375 return t == 0.0 ? 0.0 : pow(2.0, 10.0 * (t - 1.0));
376}
377
378float easeOutExpo(float t) {
379 // Starts fast and slows down exponentially.
380 return t == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * t);
381}
382
383float easeInOutExpo(float t) {
384 // Combines easeIn and easeOut exponential for sharp transitions.
385 if (t == 0.0) return 0.0;
386 if (t == 1.0) return 1.0;
387 return t < 0.5 ? 0.5 * pow(2.0, 20.0 * t - 10.0)
388 : 1.0 - 0.5 * pow(2.0, -20.0 * t + 10.0);
389}
390
391// Back Easing
392// Creates an overshooting effect for more dynamic animations.
393
394float easeInOutBack(float t) {
395 // Uses constants to define the overshooting magnitude.
396 const float c1 = 1.70158;
397 const float c2 = c1 * 1.525;
398 return t < 0.5
399 ? (pow(2.0 * t, 2.0) * ((c2 + 1.0) * 2.0 * t - c2)) / 2.0
400 : (pow(2.0 * t - 2.0, 2.0) * ((c2 + 1.0) * (t * 2.0 - 2.0) + c2) + 2.0) / 2.0;
401}
402
403// --------------------------------------------------------------------- edge mask helpers
404
405// This method returns a mask which smoothly transitions towards zero when approaching
406// the window's borders. If the window is currently maximized or in fullscreen mode, this
407// will return 1.0 everywhere. There is a variant which takes the transition area width in
408// pixels and one which takes this as a percentage.
409float getEdgeMask(vec2 uv, vec2 maxUV, float fadeWidth) {
410 float mask = 1.0;
411
412 if (!uIsFullscreen) {
413 mask *= smoothstep(0.0, 1.0, clamp(uv.x / fadeWidth, 0.0, 1.0));
414 mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));
415 mask *= smoothstep(0.0, 1.0, clamp((maxUV.x - uv.x) / fadeWidth, 0.0, 1.0));
416 mask *= smoothstep(0.0, 1.0, clamp((maxUV.y - uv.y) / fadeWidth, 0.0, 1.0));
417 }
418
419 return mask;
420}
421
422// Returns an edge mask which fades to zero at the boundaries of the actor. The width of
423// the fade zone is given in pixels. This uses the standard uniforms uSize and uPadding.
424// This means that the fading zone is not actually at the actors boundaries but at the
425// position of the window border in the texture.
426// The offset parameter controls whether the fading is placed inside the window borders
427// (offset = 0), ontop the window borders (offset = 0.5) or outside the window borders
428// (offset = 1).
429float getAbsoluteEdgeMask(float fadePixels, float offset) {
430 float padding = max(0.0, uPadding - fadePixels * offset);
431 vec2 uv = iTexCoord.st * uSize - padding;
432 return getEdgeMask(uv, uSize - 2.0 * padding, fadePixels);
433}
434
435// Returns an edge mask which fades to zero at the boundaries of the actor. The width of
436// the fade zone is given relative to the actor size. This neither uses uSize and
437// uPadding.
438float getRelativeEdgeMask(float fadeAmount) {
439 vec2 uv = iTexCoord.st;
440 return getEdgeMask(uv, vec2(1.0), fadeAmount);
441}
442
443// ------------------------------------------------------------------------------- 2D math
444
445// The math for the whirling is inspired by this post:
446// http://www.geeks3d.com/20110428/shader-library-swirl-post-processing-filter-in-glsl
447vec2 whirl(vec2 coords, float warping, float rotation) {
448 float angle = pow(1.0 - length(coords), 2.0) * warping + rotation;
449 float s = sin(angle);
450 float c = cos(angle);
451 return vec2(dot(coords, vec2(c, -s)), dot(coords, vec2(s, c)));
452}
453
454// Returns the shortest distance between the given point and the line defined by "origin"
455// and "direction".
456float distToLine(vec2 origin, vec2 direction, vec2 point) {
457 vec2 perpendicular = vec2(direction.y, -direction.x);
458 return abs(dot(normalize(perpendicular), origin - point));
459}
460
461// Returns a positive number if a -> b forms a clockwise corner, or a negative number if
462// the corner is counter-clockwise.
463float getWinding(vec2 a, vec2 b) { return cross(vec3(a, 0.0), vec3(b, 0.0)).z; }
464
465// Rotates the given 2D vector a clockwise by the angle alpha (given in radians).
466vec2 rotate(vec2 a, float angle) {
467 return vec2(a.x * cos(angle) - a.y * sin(angle), a.x * sin(angle) + a.y * cos(angle));
468}
469
470// rotates a given 2d vector, around a given center (angle is in radians)
471vec2 rotate(vec2 a, float angle, vec2 center) {
472 return vec2(cos(angle) * (a.x - center.x) + sin(angle) * (a.y - center.y) + center.x,
473 cos(angle) * (a.y - center.y) - sin(angle) * (a.x - center.x) + center.y);
474}
475
476// --------------------------------------------------------------------------------- noise
477
478// These noise algorithms are based on implementations by various authors from
479// shadertoy.com, which are all available under the MIT License. See the respective links
480// in the comments below.
481
482// Hash functions
483// MIT License, https://www.shadertoy.com/view/4djSRW
484// Copyright (c) 2014 David Hoskins.
485
486// 1 out, 1 in...
487float hash11(float p) {
488 p = fract(p * .1031);
489 p *= p + 33.33;
490 p *= p + p;
491 return fract(p);
492}
493
494// 1 out, 2 in...
495float hash12(vec2 p) {
496 vec3 p3 = fract(vec3(p.xyx) * .1031);
497 p3 += dot(p3, p3.yzx + 33.33);
498 return fract((p3.x + p3.y) * p3.z);
499}
500
501// 1 out, 3 in...
502float hash13(vec3 p3) {
503 p3 = fract(p3 * .1031);
504 p3 += dot(p3, p3.zyx + 31.32);
505 return fract((p3.x + p3.y) * p3.z);
506}
507
508// 2 out, 1 in...
509vec2 hash21(float p) {
510 vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
511 p3 += dot(p3, p3.yzx + 33.33);
512 return fract((p3.xx + p3.yz) * p3.zy);
513}
514
515// 2 out, 2 in...
516vec2 hash22(vec2 p) {
517 vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
518 p3 += dot(p3, p3.yzx + 33.33);
519 return fract((p3.xx + p3.yz) * p3.zy);
520}
521
522// 2 out, 3 in...
523vec2 hash23(vec3 p3) {
524 p3 = fract(p3 * vec3(.1031, .1030, .0973));
525 p3 += dot(p3, p3.yzx + 33.33);
526 return fract((p3.xx + p3.yz) * p3.zy);
527}
528
529// 3 out, 1 in...
530vec3 hash31(float p) {
531 vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
532 p3 += dot(p3, p3.yzx + 33.33);
533 return fract((p3.xxy + p3.yzz) * p3.zyx);
534}
535
536// 3 out, 2 in...
537vec3 hash32(vec2 p) {
538 vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
539 p3 += dot(p3, p3.yxz + 33.33);
540 return fract((p3.xxy + p3.yzz) * p3.zyx);
541}
542
543// 3 out, 3 in...
544vec3 hash33(vec3 p3) {
545 p3 = fract(p3 * vec3(.1031, .1030, .0973));
546 p3 += dot(p3, p3.yxz + 33.33);
547 return fract((p3.xxy + p3.yxx) * p3.zyx);
548}
549
550// 4 out, 1 in...
551vec4 hash41(float p) {
552 vec4 p4 = fract(vec4(p) * vec4(.1031, .1030, .0973, .1099));
553 p4 += dot(p4, p4.wzxy + 33.33);
554 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
555}
556
557// 4 out, 2 in...
558vec4 hash42(vec2 p) {
559 vec4 p4 = fract(vec4(p.xyxy) * vec4(.1031, .1030, .0973, .1099));
560 p4 += dot(p4, p4.wzxy + 33.33);
561 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
562}
563
564// 4 out, 3 in...
565vec4 hash43(vec3 p) {
566 vec4 p4 = fract(vec4(p.xyzx) * vec4(.1031, .1030, .0973, .1099));
567 p4 += dot(p4, p4.wzxy + 33.33);
568 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
569}
570
571// 4 out, 4 in...
572vec4 hash44(vec4 p4) {
573 p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));
574 p4 += dot(p4, p4.wzxy + 33.33);
575 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
576}
577
578// 2D Simplex Noise
579// MIT License, https://www.shadertoy.com/view/Msf3WH
580// Copyright © 2013 Inigo Quilez
581float simplex2D(vec2 p) {
582 const float K1 = 0.366025404; // (sqrt(3)-1)/2;
583 const float K2 = 0.211324865; // (3-sqrt(3))/6;
584
585 vec2 i = floor(p + (p.x + p.y) * K1);
586 vec2 a = p - i + (i.x + i.y) * K2;
587 float m = step(a.y, a.x);
588 vec2 o = vec2(m, 1.0 - m);
589 vec2 b = a - o + K2;
590 vec2 c = a - 1.0 + 2.0 * K2;
591 vec3 h = max(0.5 - vec3(dot(a, a), dot(b, b), dot(c, c)), 0.0);
592 vec3 n = h * h * h * h *
593 vec3(dot(a, -1.0 + 2.0 * hash22(i + 0.0)), dot(b, -1.0 + 2.0 * hash22(i + o)),
594 dot(c, -1.0 + 2.0 * hash22(i + 1.0)));
595 return 0.5 + 0.5 * dot(n, vec3(70.0));
596}
597
598float simplex2DFractal(vec2 p) {
599 mat2 m = mat2(1.6, 1.2, -1.2, 1.6);
600 float f = 0.5000 * simplex2D(p);
601 p = m * p;
602 f += 0.2500 * simplex2D(p);
603 p = m * p;
604 f += 0.1250 * simplex2D(p);
605 p = m * p;
606 f += 0.0625 * simplex2D(p);
607 p = m * p;
608
609 return f;
610}
611
612// 3D Simplex Noise
613// MIT License, https://www.shadertoy.com/view/XsX3zB
614// Copyright © 2013 Nikita Miropolskiy
615float simplex3D(vec3 p) {
616
617 // skew constants for 3D simplex functions
618 const float F3 = 0.3333333;
619 const float G3 = 0.1666667;
620
621 // 1. find current tetrahedron T and it's four vertices
622 // s, s+i1, s+i2, s+1.0 - absolute skewed (integer) coordinates of T vertices
623 // x, x1, x2, x3 - unskewed coordinates of p relative to each of T vertice
624
625 // calculate s and x
626 vec3 s = floor(p + dot(p, vec3(F3)));
627 vec3 x = p - s + dot(s, vec3(G3));
628
629 // calculate i1 and i2
630 vec3 e = step(vec3(0.0), x - x.yzx);
631 vec3 i1 = e * (1.0 - e.zxy);
632 vec3 i2 = 1.0 - e.zxy * (1.0 - e);
633
634 // x1, x2, x3
635 vec3 x1 = x - i1 + G3;
636 vec3 x2 = x - i2 + 2.0 * G3;
637 vec3 x3 = x - 1.0 + 3.0 * G3;
638
639 // 2. find four surflets and store them in d
640 vec4 w, d;
641
642 // calculate surflet weights
643 w.x = dot(x, x);
644 w.y = dot(x1, x1);
645 w.z = dot(x2, x2);
646 w.w = dot(x3, x3);
647
648 // w fades from 0.6 at the center of the surflet to 0.0 at the margin
649 w = max(0.6 - w, 0.0);
650
651 // calculate surflet components
652 d.x = dot(-0.5 + hash33(s), x);
653 d.y = dot(-0.5 + hash33(s + i1), x1);
654 d.z = dot(-0.5 + hash33(s + i2), x2);
655 d.w = dot(-0.5 + hash33(s + 1.0), x3);
656
657 // multiply d by w^4
658 w *= w;
659 w *= w;
660 d *= w;
661
662 // 3. return the sum of the four surflets
663 return dot(d, vec4(52.0)) * 0.5 + 0.5;
664}
665
666// Directional artifacts can be reduced by rotating each octave
667float simplex3DFractal(vec3 m) {
668
669 // const matrices for 3D rotation
670 const mat3 rot1 = mat3(-0.37, 0.36, 0.85, -0.14, -0.93, 0.34, 0.92, 0.01, 0.4);
671 const mat3 rot2 = mat3(-0.55, -0.39, 0.74, 0.33, -0.91, -0.24, 0.77, 0.12, 0.63);
672 const mat3 rot3 = mat3(-0.71, 0.52, -0.47, -0.08, -0.72, -0.68, -0.7, -0.45, 0.56);
673
674 return 0.5333333 * simplex3D(m * rot1) + 0.2666667 * simplex3D(2.0 * m * rot2) +
675 0.1333333 * simplex3D(4.0 * m * rot3) + 0.0666667 * simplex3D(8.0 * m);
676}
677
678// --------------------------------------------------------------------------------- remap
679
680/*
681These functions remap a given value from one range to another.
682The remap operation is particularly useful in shader programming
683to scale or normalize data, ensuring compatibility across various
684input ranges. Each version of the remap function supports a
685different data type:
686
6871. float: Remap a single scalar value.
6882. vec2: Remap a 2D vector.
6893. vec3: Remap a 3D vector.
6904. vec4: Remap a 4D vector.
691
692The general formula used is:
693 newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin)
694
695This ensures a linear transformation from the old range to the new range.
696*/
697
698// Remap for float
699// Maps a float value from one range [oldMin, oldMax] to another range [newMin, newMax].
700// This is useful for normalizing or scaling scalar values to fit within a desired range.
701float remap(float value, float oldMin, float oldMax, float newMin, float newMax) {
702 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
703 newMax);
704}
705
706// Remap for vec2
707// Maps a 2D vector (vec2) from one range [oldMin, oldMax] to another range [newMin,
708// newMax]. Each component of the vec2 is individually scaled and transformed.
709vec2 remap(vec2 value, vec2 oldMin, vec2 oldMax, vec2 newMin, vec2 newMax) {
710 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
711 newMax);
712}
713
714// Remap for vec3
715// Maps a 3D vector (vec3) from one range [oldMin, oldMax] to another range [newMin,
716// newMax]. Each component of the vec3 is individually scaled and transformed.
717vec3 remap(vec3 value, vec3 oldMin, vec3 oldMax, vec3 newMin, vec3 newMax) {
718 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
719 newMax);
720}
721
722// Remap for vec4
723// Maps a 4D vector (vec4) from one range [oldMin, oldMax] to another range [newMin,
724// newMax]. Each component of the vec4 is individually scaled and transformed.
725vec4 remap(vec4 value, vec4 oldMin, vec4 oldMax, vec4 newMin, vec4 newMax) {
726 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
727 newMax);
728}
729//////////////////////////////////////////////////////////////////////////////////////////
730// ) ( //
731// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
732// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
733// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
734// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
735// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
736// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
737// |__/ //
738//////////////////////////////////////////////////////////////////////////////////////////
739
740// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
741// SPDX-License-Identifier: GPL-3.0-or-later
742
743// The content from common.glsl is automatically prepended to each shader effect.
744
745// Marble [Burn-My-Windows variant] v7: window morphs into a glossy 2D marble.
746// The fall happens in main.js (Translation, constant gravity) after the marble is done.
747uniform float uCrumpleEnd;
748
749void main() {
750 float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
751 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
752 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
753
754 vec2 hs = 0.5 * uSize;
755 vec2 p = iTexCoord * uSize - hs;
756 float R0 = 0.035 * min(uSize.x, uSize.y); // ~7% diameter
757 vec2 b = mix(hs, vec2(R0), e); // half size of the morphing shape
758 float rad = mix(0.0, R0, e * e); // corner radius grows to a full circle
759 vec2 dq = max(abs(p) - (b - rad), 0.0);
760 float d = length(dq) - rad + min(max(abs(p).x - (b - rad).x, abs(p).y - (b - rad).y), 0.0);
761
762 // soft drop shadow (bottom-right), drawn where the marble is not
763 vec2 ps = p - vec2(0.12, 0.22) * R0 * e;
764 float sh = 0.35 * e * (1.0 - smoothstep(-0.2 * R0, 0.25 * R0, length(ps) - R0 * 0.9 * e + (1.0 - e) * 1e5));
765 if (d > 0.0) { setOutputColor(vec4(0.0, 0.0, 0.0, sh * step(0.5, e))); return; }
766
767 vec2 q = p / b; // -1..1 inside
768 float r2 = min(dot(q, q), 1.0);
769 float z = sqrt(1.0 - r2 * e); // sphere height (flat at e=0)
770 vec2 uv = 0.5 + 0.5 * q * mix(1.0, 0.75 + 0.45 * (1.0 - z), e);
771 vec4 col = getInputColor(clamp(uv, 0.0, 1.0));
772 col.a = step(0.97, col.a); // ignore the window shadow
773 col.a = mix(col.a, 1.0, e); // marble is solid
774 col.rgb = clamp(col.rgb, 0.0, 1.0);
775
776 // glossy marble shading
777 vec3 n = vec3(q * e, z);
778 float diff = clamp(dot(n, vec3(-0.45, -0.55, 0.70)), 0.0, 1.0);
779 vec2 hv = q - vec2(-0.38, -0.42);
780 float hd = dot(hv, hv);
781 float spot = (1.0 - smoothstep(0.004, 0.012, hd)); // small sharp highlight
782 float glow = 0.35 * (1.0 - smoothstep(0.0, 0.25, hd)); // softer glow
783 float fres = 1.0 - z; fres *= fres; // rim light
784 float bottom = 1.0 - 0.55 * clamp(q.y * 0.9 + 0.2, 0.0, 1.0) * (1.0 - z * 0.5);
785 float lit = mix(1.0, (0.45 + 0.65 * diff) * bottom, e);
786 col.rgb = col.rgb * lit + e * (vec3(spot * 0.9 + glow) + fres * vec3(0.25, 0.28, 0.32));
787 col.rgb = min(col.rgb, vec3(1.0));
788 col.a *= clamp(-d, 0.0, 1.0); // 1px anti-aliased edge
789 setOutputColor(col);
790}
kwin6_effect_marble/contents/shaders/marble_core.frag added +791 −0
@@ -0,0 +1,791 @@
1 #version 140
2 #define KWIN
3 #define PLASMA6
4
5 // This file is automatically generated during the build process.
6
7 //////////////////////////////////////////////////////////////////////////////////////////
8 // ) ( //
9 // ( /( ( ( ) ( ( ( ( )\ ) ( ( //
10 // )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
11 // ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
12 // | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
13 // | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
14 // |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
15 // |__/ //
16 //////////////////////////////////////////////////////////////////////////////////////////
17
18 // SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
19 // SPDX-License-Identifier: GPL-3.0-or-later
20
21 //////////////////////////////////////////////////////////////////////////////////////////
22 // This file is automatically included in each shader. //
23 //////////////////////////////////////////////////////////////////////////////////////////
24
25 // --------------------------------------------------------------------- standard uniforms
26
27 // Each shader can access these standard input values:
28
29 // vec2 iTexCoord: Texture coordinates for retrieving the window input color.
30 // bool uIsFullscreen: True if the window is maximized or in fullscreen mode.
31 // bool uForOpening: True if a window-open animation is ongoing, false otherwise.
32 // float uProgress: A value which transitions from 0 to 1 during the animation.
33 // float uDuration: The duration of the current animation in seconds.
34 // vec2 uSize: The size of uTexture in pixels.
35 // float uPadding: The empty area around the actual window (e.g. where the shadow
36 // is drawn). For now, this will only be set on GNOME.
37
38 // Furthermore, there are two global methods for reading the window input color and
39 // setting the shader output color. Both methods assume straight alpha:
40
41 // vec4 getInputColor(vec2 coords)
42 // void setOutputColor(vec4 outColor)
43
44 uniform bool uForOpening;
45 uniform bool uIsFullscreen;
46 uniform float uProgress;
47 uniform float uDuration;
48
49 #if defined(KWIN) // --------------------------------------------------------------------
50
51 #if defined(PLASMA6)
52 #include "colormanagement.glsl"
53 #endif
54
55 uniform sampler2D sampler;
56 uniform int textureWidth;
57 uniform int textureHeight;
58
59 in vec2 texcoord0;
60 out vec4 fragColor;
61
62 // Using defines here as OpenGL ES forbids non-constant global initializers.
63 #define uSize vec2(textureWidth, textureHeight)
64 #define iTexCoord vec2(texcoord0.x, texcoord0.y)
65 float uPadding = 0.0;
66
67 vec4 getInputColor(vec2 coords) {
68 vec4 color = texture2D(sampler, coords);
69
70 if (color.a > 0.0) {
71 color.rgb /= color.a;
72 }
73
74 return color;
75 }
76
77 void setOutputColor(vec4 outColor) {
78
79 // If a uniform is not used, it will be optimized away. This condition is always
80 // false, but it will prevent the compiler from optimizing away the uniforms uForOpening
81 // and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
82 // uniform is used in the shader.
83 if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {
84 outColor = vec4(0.0);
85 }
86
87 fragColor = vec4(outColor.rgb * outColor.a, outColor.a);
88
89 #if defined(PLASMA6)
90 fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);
91 fragColor = nitsToDestinationEncoding(fragColor);
92 #endif
93 }
94
95 #elif defined(KWIN_LEGACY) // -----------------------------------------------------------
96
97 #if defined(PLASMA6)
98 #include "colormanagement.glsl"
99 #endif
100
101 uniform sampler2D sampler;
102 uniform int textureWidth;
103 uniform int textureHeight;
104
105 varying vec2 texcoord0;
106
107 vec2 uSize = vec2(textureWidth, textureHeight);
108 vec2 iTexCoord = vec2(texcoord0.x, texcoord0.y);
109 float uPadding = 0.0;
110
111 vec4 getInputColor(vec2 coords) {
112 vec4 color = texture2D(sampler, coords);
113
114 if (color.a > 0.0) {
115 color.rgb /= color.a;
116 }
117
118 return color;
119 }
120
121 void setOutputColor(vec4 outColor) {
122 // If a uniform is not used, it will be optimized away. This condition is always
123 // false, but it will prevent the compiler from optimizing away the uniforms uForOpening
124 // and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
125 // uniform is used in the shader.
126 if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {
127 outColor = vec4(0.0);
128 }
129
130 gl_FragColor = vec4(outColor.rgb * outColor.a, outColor.a);
131
132 #if defined(PLASMA6)
133 fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);
134 fragColor = nitsToDestinationEncoding(fragColor);
135 #endif
136 }
137
138 #else // GNOME --------------------------------------------------------------------------
139
140 // On GNOME, the uniforms are just normal uniforms.
141 uniform sampler2D uTexture;
142 uniform vec2 uSize;
143 uniform float uPadding;
144
145 // On GNOME, we set iTexCoord to be an alias for the cogl variables.
146 #define iTexCoord vec2(cogl_tex_coord_in[0])
147
148 // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
149 vec4 getInputColor(vec2 coords) {
150 vec4 color = texture2D(uTexture, coords);
151
152 if (color.a > 0.0) {
153 color.rgb /= color.a;
154 }
155
156 return color;
157 }
158
159 void setOutputColor(vec4 outColor) { cogl_color_out = outColor; }
160
161 #endif // -------------------------------------------------------------------------------
162
163 // A simple blur function
164 vec4 getBlurredInputColor(vec2 uv, float radius, float samples) {
165 // Initialize the color accumulator to zero.
166 vec4 color = vec4(0.0);
167
168 // Define a constant for 2 * PI (tau), which represents a full circle in radians.
169 const float tau = 6.28318530718;
170
171 // Number of directions for sampling around the circle.
172 const float directions = 15.0;
173
174 // Outer loop iterates over multiple directions evenly spaced around a circle.
175 for (float d = 0.0; d < tau; d += tau / directions) {
176 // Inner loop samples along each direction, with decreasing intensity.
177 for (float s = 0.0; s < 1.0; s += 1.0 / samples) {
178 // Calculate the offset for this sample based on direction, radius, and step.
179 // The (1.0 - s) term ensures more sampling occurs closer to the center.
180 vec2 offset = vec2(cos(d), sin(d)) * radius * (1.0 - s) / uSize;
181
182 // Add the sampled color at the offset position to the accumulator.
183 color += getInputColor(uv + offset);
184 }
185 }
186
187 // Normalize the accumulated color by dividing by the total number of samples
188 // and directions to ensure the result is averaged.
189 return color / samples / directions;
190 }
191
192 // ----------------------------------------------------------------- compositing operators
193
194 // The Shell.GLSLEffect uses straight alpha blending. This helper method allows
195 // compositing color values in the shader in the same way.
196 vec4 alphaOver(vec4 under, vec4 over) {
197 if (under.a == 0.0 && over.a == 0.0) {
198 return vec4(0.0);
199 }
200
201 float alpha = mix(under.a, 1.0, over.a);
202 return vec4(mix(under.rgb * under.a, over.rgb, over.a) / alpha, alpha);
203 }
204
205 // ------------------------------------------------------------------------- color helpers
206
207 // Maps the given value from [0..1] to the given colors.
208 vec3 tritone(float val, vec3 shadows, vec3 midtones, vec3 highlights) {
209 if (val < 0.5) {
210 return mix(shadows, midtones, smoothstep(0.0, 1.0, val * 2.0));
211 }
212
213 return mix(midtones, highlights, smoothstep(0.0, 1.0, val * 2.0 - 1.0));
214 }
215
216 // Darkens the given color. If fac is zero, the color will not change, if fac is one, the
217 // color will be black.
218 vec3 darken(vec3 color, float fac) { return color * (1.0 - fac); }
219
220 // Lightens the given color. If fac is zero, the color will not change, if fac is one, the
221 // color will be white.
222 vec3 lighten(vec3 color, float fac) { return color + (vec3(1.0) - color) * fac; }
223
224 // change the color based on an offset amount
225 vec3 offsetHue(vec3 color, float hueOffset) {
226 // Convert RGB to HSV
227 float maxC = max(max(color.r, color.g), color.b);
228 float minC = min(min(color.r, color.g), color.b);
229 float delta = maxC - minC;
230
231 float hue = 0.0;
232 if (delta > 0.0) {
233 if (maxC == color.r) {
234 hue = mod((color.g - color.b) / delta, 6.0);
235 } else if (maxC == color.g) {
236 hue = (color.b - color.r) / delta + 2.0;
237 } else {
238 hue = (color.r - color.g) / delta + 4.0;
239 }
240 }
241 hue /= 6.0;
242
243 float saturation = (maxC > 0.0) ? (delta / maxC) : 0.0;
244 float value = maxC;
245
246 // Offset the hue
247 hue = mod(hue + hueOffset, 1.0);
248
249 // Convert HSV back to RGB
250 float c = value * saturation;
251 float x = c * (1.0 - abs(mod(hue * 6.0, 2.0) - 1.0));
252 float m = value - c;
253
254 vec3 rgb;
255 if (hue < 1.0 / 6.0) {
256 rgb = vec3(c, x, 0.0);
257 } else if (hue < 2.0 / 6.0) {
258 rgb = vec3(x, c, 0.0);
259 } else if (hue < 3.0 / 6.0) {
260 rgb = vec3(0.0, c, x);
261 } else if (hue < 4.0 / 6.0) {
262 rgb = vec3(0.0, x, c);
263 } else if (hue < 5.0 / 6.0) {
264 rgb = vec3(x, 0.0, c);
265 } else {
266 rgb = vec3(c, 0.0, x);
267 }
268
269 return rgb + m;
270 }
271
272 // ---------------------------------------------------------------------- easing functions
273
274 // Here are some basic easing function. More can be added if required!
275 // Taken from here:
276 // https://gitlab.gnome.org/GNOME/mutter/-/blob/main/clutter/clutter/clutter-easing.c
277
278 float easeOutQuad(float x) { return -1.0 * x * (x - 2.0); }
279
280 float easeInQuad(float x) { return x * x; }
281
282 float easeInBack(float x, float e) { return x * x * ((e + 1.0) * x - e); }
283
284 float easeOutBack(float x, float e) {
285 float p = x - 1.0;
286 return p * p * ((e + 1.0) * p + e) + 1.0;
287 }
288
289 // https://easings.net/
290 /*
291 Easing functions define the rate of change of a parameter over time, commonly used in
292 animations, UI transitions, and game development. They provide a way to make movements
293 more natural or visually appealing rather than linear and mechanical. Popular categories
294 of easing functions include:
295
296 Linear: Constant speed from start to finish.
297 Quadratic (Ease In, Ease Out, Ease In Out): Changes at varying rates, with smoother starts
298 or stops. Cubic: Similar to quadratic but allows for even more nuanced transitions.
299 Exponential: Drastic changes at the start or end, often used for dramatic effects.
300 Bounce: Mimics a bouncing object with oscillations.
301 Elastic: Simulates the behavior of a spring, with overshooting and oscillations.
302 Below are text-based "graphs" of some easing functions, where the horizontal axis
303 represents time and the vertical axis represents progress.
304 */
305
306 // Quadratic Easing
307 // Smooth acceleration and deceleration using quadratic (t^2) curves.
308
309 float easeInOutQuad(float t) {
310 // Accelerates for the first half, decelerates for the second half.
311 return t < 0.5 ? 2.0 * t * t : -1.0 + (4.0 - 2.0 * t) * t;
312 }
313
314 // Cubic Easing
315 // Smoother transitions compared to quadratic easing using cubic (t^3) curves.
316
317 float easeInCubic(float t) {
318 // Starts slow and accelerates as t increases.
319 return t * t * t;
320 }
321
322 float easeOutCubic(float t) {
323 // Starts fast and decelerates as t approaches 1.0.
324 float f = t - 1.0;
325 return f * f * f + 1.0;
326 }
327
328 float easeInOutCubic(float t) {
329 // Combines easeIn and easeOut cubic behavior for smooth transitions.
330 return t < 0.5 ? 4.0 * t * t * t : (t - 1.0) * (2.0 * t - 2.0) * (2.0 * t - 2.0) + 1.0;
331 }
332
333 // Quartic Easing
334 // Even smoother transitions than cubic, using quartic (t^4) curves.
335
336 float easeInQuart(float t) {
337 // Starts very slow and accelerates steeply.
338 return t * t * t * t;
339 }
340
341 float easeOutQuart(float t) {
342 // Starts steeply and slows down dramatically.
343 float f = t - 1.0;
344 return 1.0 - f * f * f * f;
345 }
346
347 float easeInOutQuart(float t) {
348 // Combines easeIn and easeOut quartic behavior for very smooth transitions.
349 return t < 0.5 ? 8.0 * t * t * t * t
350 : 1.0 - 8.0 * (t - 1.0) * (t - 1.0) * (t - 1.0) * (t - 1.0);
351 }
352
353 // Sine Easing
354 // Smooth, wave-like acceleration and deceleration using sine curves.
355
356 float easeInSine(float t) {
357 // Starts very slow, following a sine wave curve.
358 return 1.0 - cos((t * 3.141592653589793) / 2.0);
359 }
360
361 float easeOutSine(float t) {
362 // Starts fast and slows down following a sine wave curve.
363 return sin((t * 3.141592653589793) / 2.0);
364 }
365
366 float easeInOutSine(float t) {
367 // Smooth start and end, mimicking half a sine wave.
368 return -0.5 * (cos(3.141592653589793 * t) - 1.0);
369 }
370
371 // Exponential Easing
372 // Sharp transitions with rapid acceleration and deceleration.
373
374 float easeInExpo(float t) {
375 // Very slow start, accelerates exponentially.
376 return t == 0.0 ? 0.0 : pow(2.0, 10.0 * (t - 1.0));
377 }
378
379 float easeOutExpo(float t) {
380 // Starts fast and slows down exponentially.
381 return t == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * t);
382 }
383
384 float easeInOutExpo(float t) {
385 // Combines easeIn and easeOut exponential for sharp transitions.
386 if (t == 0.0) return 0.0;
387 if (t == 1.0) return 1.0;
388 return t < 0.5 ? 0.5 * pow(2.0, 20.0 * t - 10.0)
389 : 1.0 - 0.5 * pow(2.0, -20.0 * t + 10.0);
390 }
391
392 // Back Easing
393 // Creates an overshooting effect for more dynamic animations.
394
395 float easeInOutBack(float t) {
396 // Uses constants to define the overshooting magnitude.
397 const float c1 = 1.70158;
398 const float c2 = c1 * 1.525;
399 return t < 0.5
400 ? (pow(2.0 * t, 2.0) * ((c2 + 1.0) * 2.0 * t - c2)) / 2.0
401 : (pow(2.0 * t - 2.0, 2.0) * ((c2 + 1.0) * (t * 2.0 - 2.0) + c2) + 2.0) / 2.0;
402 }
403
404 // --------------------------------------------------------------------- edge mask helpers
405
406 // This method returns a mask which smoothly transitions towards zero when approaching
407 // the window's borders. If the window is currently maximized or in fullscreen mode, this
408 // will return 1.0 everywhere. There is a variant which takes the transition area width in
409 // pixels and one which takes this as a percentage.
410 float getEdgeMask(vec2 uv, vec2 maxUV, float fadeWidth) {
411 float mask = 1.0;
412
413 if (!uIsFullscreen) {
414 mask *= smoothstep(0.0, 1.0, clamp(uv.x / fadeWidth, 0.0, 1.0));
415 mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));
416 mask *= smoothstep(0.0, 1.0, clamp((maxUV.x - uv.x) / fadeWidth, 0.0, 1.0));
417 mask *= smoothstep(0.0, 1.0, clamp((maxUV.y - uv.y) / fadeWidth, 0.0, 1.0));
418 }
419
420 return mask;
421 }
422
423 // Returns an edge mask which fades to zero at the boundaries of the actor. The width of
424 // the fade zone is given in pixels. This uses the standard uniforms uSize and uPadding.
425 // This means that the fading zone is not actually at the actors boundaries but at the
426 // position of the window border in the texture.
427 // The offset parameter controls whether the fading is placed inside the window borders
428 // (offset = 0), ontop the window borders (offset = 0.5) or outside the window borders
429 // (offset = 1).
430 float getAbsoluteEdgeMask(float fadePixels, float offset) {
431 float padding = max(0.0, uPadding - fadePixels * offset);
432 vec2 uv = iTexCoord.st * uSize - padding;
433 return getEdgeMask(uv, uSize - 2.0 * padding, fadePixels);
434 }
435
436 // Returns an edge mask which fades to zero at the boundaries of the actor. The width of
437 // the fade zone is given relative to the actor size. This neither uses uSize and
438 // uPadding.
439 float getRelativeEdgeMask(float fadeAmount) {
440 vec2 uv = iTexCoord.st;
441 return getEdgeMask(uv, vec2(1.0), fadeAmount);
442 }
443
444 // ------------------------------------------------------------------------------- 2D math
445
446 // The math for the whirling is inspired by this post:
447 // http://www.geeks3d.com/20110428/shader-library-swirl-post-processing-filter-in-glsl
448 vec2 whirl(vec2 coords, float warping, float rotation) {
449 float angle = pow(1.0 - length(coords), 2.0) * warping + rotation;
450 float s = sin(angle);
451 float c = cos(angle);
452 return vec2(dot(coords, vec2(c, -s)), dot(coords, vec2(s, c)));
453 }
454
455 // Returns the shortest distance between the given point and the line defined by "origin"
456 // and "direction".
457 float distToLine(vec2 origin, vec2 direction, vec2 point) {
458 vec2 perpendicular = vec2(direction.y, -direction.x);
459 return abs(dot(normalize(perpendicular), origin - point));
460 }
461
462 // Returns a positive number if a -> b forms a clockwise corner, or a negative number if
463 // the corner is counter-clockwise.
464 float getWinding(vec2 a, vec2 b) { return cross(vec3(a, 0.0), vec3(b, 0.0)).z; }
465
466 // Rotates the given 2D vector a clockwise by the angle alpha (given in radians).
467 vec2 rotate(vec2 a, float angle) {
468 return vec2(a.x * cos(angle) - a.y * sin(angle), a.x * sin(angle) + a.y * cos(angle));
469 }
470
471 // rotates a given 2d vector, around a given center (angle is in radians)
472 vec2 rotate(vec2 a, float angle, vec2 center) {
473 return vec2(cos(angle) * (a.x - center.x) + sin(angle) * (a.y - center.y) + center.x,
474 cos(angle) * (a.y - center.y) - sin(angle) * (a.x - center.x) + center.y);
475 }
476
477 // --------------------------------------------------------------------------------- noise
478
479 // These noise algorithms are based on implementations by various authors from
480 // shadertoy.com, which are all available under the MIT License. See the respective links
481 // in the comments below.
482
483 // Hash functions
484 // MIT License, https://www.shadertoy.com/view/4djSRW
485 // Copyright (c) 2014 David Hoskins.
486
487 // 1 out, 1 in...
488 float hash11(float p) {
489 p = fract(p * .1031);
490 p *= p + 33.33;
491 p *= p + p;
492 return fract(p);
493 }
494
495 // 1 out, 2 in...
496 float hash12(vec2 p) {
497 vec3 p3 = fract(vec3(p.xyx) * .1031);
498 p3 += dot(p3, p3.yzx + 33.33);
499 return fract((p3.x + p3.y) * p3.z);
500 }
501
502 // 1 out, 3 in...
503 float hash13(vec3 p3) {
504 p3 = fract(p3 * .1031);
505 p3 += dot(p3, p3.zyx + 31.32);
506 return fract((p3.x + p3.y) * p3.z);
507 }
508
509 // 2 out, 1 in...
510 vec2 hash21(float p) {
511 vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
512 p3 += dot(p3, p3.yzx + 33.33);
513 return fract((p3.xx + p3.yz) * p3.zy);
514 }
515
516 // 2 out, 2 in...
517 vec2 hash22(vec2 p) {
518 vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
519 p3 += dot(p3, p3.yzx + 33.33);
520 return fract((p3.xx + p3.yz) * p3.zy);
521 }
522
523 // 2 out, 3 in...
524 vec2 hash23(vec3 p3) {
525 p3 = fract(p3 * vec3(.1031, .1030, .0973));
526 p3 += dot(p3, p3.yzx + 33.33);
527 return fract((p3.xx + p3.yz) * p3.zy);
528 }
529
530 // 3 out, 1 in...
531 vec3 hash31(float p) {
532 vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
533 p3 += dot(p3, p3.yzx + 33.33);
534 return fract((p3.xxy + p3.yzz) * p3.zyx);
535 }
536
537 // 3 out, 2 in...
538 vec3 hash32(vec2 p) {
539 vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
540 p3 += dot(p3, p3.yxz + 33.33);
541 return fract((p3.xxy + p3.yzz) * p3.zyx);
542 }
543
544 // 3 out, 3 in...
545 vec3 hash33(vec3 p3) {
546 p3 = fract(p3 * vec3(.1031, .1030, .0973));
547 p3 += dot(p3, p3.yxz + 33.33);
548 return fract((p3.xxy + p3.yxx) * p3.zyx);
549 }
550
551 // 4 out, 1 in...
552 vec4 hash41(float p) {
553 vec4 p4 = fract(vec4(p) * vec4(.1031, .1030, .0973, .1099));
554 p4 += dot(p4, p4.wzxy + 33.33);
555 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
556 }
557
558 // 4 out, 2 in...
559 vec4 hash42(vec2 p) {
560 vec4 p4 = fract(vec4(p.xyxy) * vec4(.1031, .1030, .0973, .1099));
561 p4 += dot(p4, p4.wzxy + 33.33);
562 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
563 }
564
565 // 4 out, 3 in...
566 vec4 hash43(vec3 p) {
567 vec4 p4 = fract(vec4(p.xyzx) * vec4(.1031, .1030, .0973, .1099));
568 p4 += dot(p4, p4.wzxy + 33.33);
569 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
570 }
571
572 // 4 out, 4 in...
573 vec4 hash44(vec4 p4) {
574 p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));
575 p4 += dot(p4, p4.wzxy + 33.33);
576 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
577 }
578
579 // 2D Simplex Noise
580 // MIT License, https://www.shadertoy.com/view/Msf3WH
581 // Copyright © 2013 Inigo Quilez
582 float simplex2D(vec2 p) {
583 const float K1 = 0.366025404; // (sqrt(3)-1)/2;
584 const float K2 = 0.211324865; // (3-sqrt(3))/6;
585
586 vec2 i = floor(p + (p.x + p.y) * K1);
587 vec2 a = p - i + (i.x + i.y) * K2;
588 float m = step(a.y, a.x);
589 vec2 o = vec2(m, 1.0 - m);
590 vec2 b = a - o + K2;
591 vec2 c = a - 1.0 + 2.0 * K2;
592 vec3 h = max(0.5 - vec3(dot(a, a), dot(b, b), dot(c, c)), 0.0);
593 vec3 n = h * h * h * h *
594 vec3(dot(a, -1.0 + 2.0 * hash22(i + 0.0)), dot(b, -1.0 + 2.0 * hash22(i + o)),
595 dot(c, -1.0 + 2.0 * hash22(i + 1.0)));
596 return 0.5 + 0.5 * dot(n, vec3(70.0));
597 }
598
599 float simplex2DFractal(vec2 p) {
600 mat2 m = mat2(1.6, 1.2, -1.2, 1.6);
601 float f = 0.5000 * simplex2D(p);
602 p = m * p;
603 f += 0.2500 * simplex2D(p);
604 p = m * p;
605 f += 0.1250 * simplex2D(p);
606 p = m * p;
607 f += 0.0625 * simplex2D(p);
608 p = m * p;
609
610 return f;
611 }
612
613 // 3D Simplex Noise
614 // MIT License, https://www.shadertoy.com/view/XsX3zB
615 // Copyright © 2013 Nikita Miropolskiy
616 float simplex3D(vec3 p) {
617
618 // skew constants for 3D simplex functions
619 const float F3 = 0.3333333;
620 const float G3 = 0.1666667;
621
622 // 1. find current tetrahedron T and it's four vertices
623 // s, s+i1, s+i2, s+1.0 - absolute skewed (integer) coordinates of T vertices
624 // x, x1, x2, x3 - unskewed coordinates of p relative to each of T vertice
625
626 // calculate s and x
627 vec3 s = floor(p + dot(p, vec3(F3)));
628 vec3 x = p - s + dot(s, vec3(G3));
629
630 // calculate i1 and i2
631 vec3 e = step(vec3(0.0), x - x.yzx);
632 vec3 i1 = e * (1.0 - e.zxy);
633 vec3 i2 = 1.0 - e.zxy * (1.0 - e);
634
635 // x1, x2, x3
636 vec3 x1 = x - i1 + G3;
637 vec3 x2 = x - i2 + 2.0 * G3;
638 vec3 x3 = x - 1.0 + 3.0 * G3;
639
640 // 2. find four surflets and store them in d
641 vec4 w, d;
642
643 // calculate surflet weights
644 w.x = dot(x, x);
645 w.y = dot(x1, x1);
646 w.z = dot(x2, x2);
647 w.w = dot(x3, x3);
648
649 // w fades from 0.6 at the center of the surflet to 0.0 at the margin
650 w = max(0.6 - w, 0.0);
651
652 // calculate surflet components
653 d.x = dot(-0.5 + hash33(s), x);
654 d.y = dot(-0.5 + hash33(s + i1), x1);
655 d.z = dot(-0.5 + hash33(s + i2), x2);
656 d.w = dot(-0.5 + hash33(s + 1.0), x3);
657
658 // multiply d by w^4
659 w *= w;
660 w *= w;
661 d *= w;
662
663 // 3. return the sum of the four surflets
664 return dot(d, vec4(52.0)) * 0.5 + 0.5;
665 }
666
667 // Directional artifacts can be reduced by rotating each octave
668 float simplex3DFractal(vec3 m) {
669
670 // const matrices for 3D rotation
671 const mat3 rot1 = mat3(-0.37, 0.36, 0.85, -0.14, -0.93, 0.34, 0.92, 0.01, 0.4);
672 const mat3 rot2 = mat3(-0.55, -0.39, 0.74, 0.33, -0.91, -0.24, 0.77, 0.12, 0.63);
673 const mat3 rot3 = mat3(-0.71, 0.52, -0.47, -0.08, -0.72, -0.68, -0.7, -0.45, 0.56);
674
675 return 0.5333333 * simplex3D(m * rot1) + 0.2666667 * simplex3D(2.0 * m * rot2) +
676 0.1333333 * simplex3D(4.0 * m * rot3) + 0.0666667 * simplex3D(8.0 * m);
677 }
678
679 // --------------------------------------------------------------------------------- remap
680
681 /*
682 These functions remap a given value from one range to another.
683 The remap operation is particularly useful in shader programming
684 to scale or normalize data, ensuring compatibility across various
685 input ranges. Each version of the remap function supports a
686 different data type:
687
688 1. float: Remap a single scalar value.
689 2. vec2: Remap a 2D vector.
690 3. vec3: Remap a 3D vector.
691 4. vec4: Remap a 4D vector.
692
693 The general formula used is:
694 newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin)
695
696 This ensures a linear transformation from the old range to the new range.
697 */
698
699 // Remap for float
700 // Maps a float value from one range [oldMin, oldMax] to another range [newMin, newMax].
701 // This is useful for normalizing or scaling scalar values to fit within a desired range.
702 float remap(float value, float oldMin, float oldMax, float newMin, float newMax) {
703 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
704 newMax);
705 }
706
707 // Remap for vec2
708 // Maps a 2D vector (vec2) from one range [oldMin, oldMax] to another range [newMin,
709 // newMax]. Each component of the vec2 is individually scaled and transformed.
710 vec2 remap(vec2 value, vec2 oldMin, vec2 oldMax, vec2 newMin, vec2 newMax) {
711 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
712 newMax);
713 }
714
715 // Remap for vec3
716 // Maps a 3D vector (vec3) from one range [oldMin, oldMax] to another range [newMin,
717 // newMax]. Each component of the vec3 is individually scaled and transformed.
718 vec3 remap(vec3 value, vec3 oldMin, vec3 oldMax, vec3 newMin, vec3 newMax) {
719 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
720 newMax);
721 }
722
723 // Remap for vec4
724 // Maps a 4D vector (vec4) from one range [oldMin, oldMax] to another range [newMin,
725 // newMax]. Each component of the vec4 is individually scaled and transformed.
726 vec4 remap(vec4 value, vec4 oldMin, vec4 oldMax, vec4 newMin, vec4 newMax) {
727 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
728 newMax);
729 }
730 //////////////////////////////////////////////////////////////////////////////////////////
731 // ) ( //
732 // ( /( ( ( ) ( ( ( ( )\ ) ( ( //
733 // )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
734 // ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
735 // | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
736 // | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
737 // |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
738 // |__/ //
739 //////////////////////////////////////////////////////////////////////////////////////////
740
741 // SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
742 // SPDX-License-Identifier: GPL-3.0-or-later
743
744 // The content from common.glsl is automatically prepended to each shader effect.
745
746 // Marble [Burn-My-Windows variant] v7: window morphs into a glossy 2D marble.
747 // The fall happens in main.js (Translation, constant gravity) after the marble is done.
748 uniform float uCrumpleEnd;
749
750 void main() {
751 float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
752 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
753 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
754
755 vec2 hs = 0.5 * uSize;
756 vec2 p = iTexCoord * uSize - hs;
757 float R0 = 0.035 * min(uSize.x, uSize.y); // ~7% diameter
758 vec2 b = mix(hs, vec2(R0), e); // half size of the morphing shape
759 float rad = mix(0.0, R0, e * e); // corner radius grows to a full circle
760 vec2 dq = max(abs(p) - (b - rad), 0.0);
761 float d = length(dq) - rad + min(max(abs(p).x - (b - rad).x, abs(p).y - (b - rad).y), 0.0);
762
763 // soft drop shadow (bottom-right), drawn where the marble is not
764 vec2 ps = p - vec2(0.12, 0.22) * R0 * e;
765 float sh = 0.35 * e * (1.0 - smoothstep(-0.2 * R0, 0.25 * R0, length(ps) - R0 * 0.9 * e + (1.0 - e) * 1e5));
766 if (d > 0.0) { setOutputColor(vec4(0.0, 0.0, 0.0, sh * step(0.5, e))); return; }
767
768 vec2 q = p / b; // -1..1 inside
769 float r2 = min(dot(q, q), 1.0);
770 float z = sqrt(1.0 - r2 * e); // sphere height (flat at e=0)
771 vec2 uv = 0.5 + 0.5 * q * mix(1.0, 0.75 + 0.45 * (1.0 - z), e);
772 vec4 col = getInputColor(clamp(uv, 0.0, 1.0));
773 col.a = step(0.97, col.a); // ignore the window shadow
774 col.a = mix(col.a, 1.0, e); // marble is solid
775 col.rgb = clamp(col.rgb, 0.0, 1.0);
776
777 // glossy marble shading
778 vec3 n = vec3(q * e, z);
779 float diff = clamp(dot(n, vec3(-0.45, -0.55, 0.70)), 0.0, 1.0);
780 vec2 hv = q - vec2(-0.38, -0.42);
781 float hd = dot(hv, hv);
782 float spot = (1.0 - smoothstep(0.004, 0.012, hd)); // small sharp highlight
783 float glow = 0.35 * (1.0 - smoothstep(0.0, 0.25, hd)); // softer glow
784 float fres = 1.0 - z; fres *= fres; // rim light
785 float bottom = 1.0 - 0.55 * clamp(q.y * 0.9 + 0.2, 0.0, 1.0) * (1.0 - z * 0.5);
786 float lit = mix(1.0, (0.45 + 0.65 * diff) * bottom, e);
787 col.rgb = col.rgb * lit + e * (vec3(spot * 0.9 + glow) + fres * vec3(0.25, 0.28, 0.32));
788 col.rgb = min(col.rgb, vec3(1.0));
789 col.a *= clamp(-d, 0.0, 1.0); // 1px anti-aliased edge
790 setOutputColor(col);
791 }
@@ -0,0 +1,791 @@
1#version 140
2#define KWIN
3#define PLASMA6
4
5// This file is automatically generated during the build process.
6
7//////////////////////////////////////////////////////////////////////////////////////////
8// ) ( //
9// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
10// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
11// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
12// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
13// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
14// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
15// |__/ //
16//////////////////////////////////////////////////////////////////////////////////////////
17
18// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
19// SPDX-License-Identifier: GPL-3.0-or-later
20
21//////////////////////////////////////////////////////////////////////////////////////////
22// This file is automatically included in each shader. //
23//////////////////////////////////////////////////////////////////////////////////////////
24
25// --------------------------------------------------------------------- standard uniforms
26
27// Each shader can access these standard input values:
28
29// vec2 iTexCoord: Texture coordinates for retrieving the window input color.
30// bool uIsFullscreen: True if the window is maximized or in fullscreen mode.
31// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
32// float uProgress: A value which transitions from 0 to 1 during the animation.
33// float uDuration: The duration of the current animation in seconds.
34// vec2 uSize: The size of uTexture in pixels.
35// float uPadding: The empty area around the actual window (e.g. where the shadow
36// is drawn). For now, this will only be set on GNOME.
37
38// Furthermore, there are two global methods for reading the window input color and
39// setting the shader output color. Both methods assume straight alpha:
40
41// vec4 getInputColor(vec2 coords)
42// void setOutputColor(vec4 outColor)
43
44uniform bool uForOpening;
45uniform bool uIsFullscreen;
46uniform float uProgress;
47uniform float uDuration;
48
49#if defined(KWIN) // --------------------------------------------------------------------
50
51#if defined(PLASMA6)
52#include "colormanagement.glsl"
53#endif
54
55uniform sampler2D sampler;
56uniform int textureWidth;
57uniform int textureHeight;
58
59in vec2 texcoord0;
60out vec4 fragColor;
61
62// Using defines here as OpenGL ES forbids non-constant global initializers.
63#define uSize vec2(textureWidth, textureHeight)
64#define iTexCoord vec2(texcoord0.x, texcoord0.y)
65float uPadding = 0.0;
66
67vec4 getInputColor(vec2 coords) {
68 vec4 color = texture2D(sampler, coords);
69
70 if (color.a > 0.0) {
71 color.rgb /= color.a;
72 }
73
74 return color;
75}
76
77void setOutputColor(vec4 outColor) {
78
79 // If a uniform is not used, it will be optimized away. This condition is always
80 // false, but it will prevent the compiler from optimizing away the uniforms uForOpening
81 // and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
82 // uniform is used in the shader.
83 if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {
84 outColor = vec4(0.0);
85 }
86
87 fragColor = vec4(outColor.rgb * outColor.a, outColor.a);
88
89#if defined(PLASMA6)
90 fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);
91 fragColor = nitsToDestinationEncoding(fragColor);
92#endif
93}
94
95#elif defined(KWIN_LEGACY) // -----------------------------------------------------------
96
97#if defined(PLASMA6)
98#include "colormanagement.glsl"
99#endif
100
101uniform sampler2D sampler;
102uniform int textureWidth;
103uniform int textureHeight;
104
105varying vec2 texcoord0;
106
107vec2 uSize = vec2(textureWidth, textureHeight);
108vec2 iTexCoord = vec2(texcoord0.x, texcoord0.y);
109float uPadding = 0.0;
110
111vec4 getInputColor(vec2 coords) {
112 vec4 color = texture2D(sampler, coords);
113
114 if (color.a > 0.0) {
115 color.rgb /= color.a;
116 }
117
118 return color;
119}
120
121void setOutputColor(vec4 outColor) {
122 // If a uniform is not used, it will be optimized away. This condition is always
123 // false, but it will prevent the compiler from optimizing away the uniforms uForOpening
124 // and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
125 // uniform is used in the shader.
126 if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {
127 outColor = vec4(0.0);
128 }
129
130 gl_FragColor = vec4(outColor.rgb * outColor.a, outColor.a);
131
132#if defined(PLASMA6)
133 fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);
134 fragColor = nitsToDestinationEncoding(fragColor);
135#endif
136}
137
138#else // GNOME --------------------------------------------------------------------------
139
140// On GNOME, the uniforms are just normal uniforms.
141uniform sampler2D uTexture;
142uniform vec2 uSize;
143uniform float uPadding;
144
145// On GNOME, we set iTexCoord to be an alias for the cogl variables.
146#define iTexCoord vec2(cogl_tex_coord_in[0])
147
148// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
149vec4 getInputColor(vec2 coords) {
150 vec4 color = texture2D(uTexture, coords);
151
152 if (color.a > 0.0) {
153 color.rgb /= color.a;
154 }
155
156 return color;
157}
158
159void setOutputColor(vec4 outColor) { cogl_color_out = outColor; }
160
161#endif // -------------------------------------------------------------------------------
162
163// A simple blur function
164vec4 getBlurredInputColor(vec2 uv, float radius, float samples) {
165 // Initialize the color accumulator to zero.
166 vec4 color = vec4(0.0);
167
168 // Define a constant for 2 * PI (tau), which represents a full circle in radians.
169 const float tau = 6.28318530718;
170
171 // Number of directions for sampling around the circle.
172 const float directions = 15.0;
173
174 // Outer loop iterates over multiple directions evenly spaced around a circle.
175 for (float d = 0.0; d < tau; d += tau / directions) {
176 // Inner loop samples along each direction, with decreasing intensity.
177 for (float s = 0.0; s < 1.0; s += 1.0 / samples) {
178 // Calculate the offset for this sample based on direction, radius, and step.
179 // The (1.0 - s) term ensures more sampling occurs closer to the center.
180 vec2 offset = vec2(cos(d), sin(d)) * radius * (1.0 - s) / uSize;
181
182 // Add the sampled color at the offset position to the accumulator.
183 color += getInputColor(uv + offset);
184 }
185 }
186
187 // Normalize the accumulated color by dividing by the total number of samples
188 // and directions to ensure the result is averaged.
189 return color / samples / directions;
190}
191
192// ----------------------------------------------------------------- compositing operators
193
194// The Shell.GLSLEffect uses straight alpha blending. This helper method allows
195// compositing color values in the shader in the same way.
196vec4 alphaOver(vec4 under, vec4 over) {
197 if (under.a == 0.0 && over.a == 0.0) {
198 return vec4(0.0);
199 }
200
201 float alpha = mix(under.a, 1.0, over.a);
202 return vec4(mix(under.rgb * under.a, over.rgb, over.a) / alpha, alpha);
203}
204
205// ------------------------------------------------------------------------- color helpers
206
207// Maps the given value from [0..1] to the given colors.
208vec3 tritone(float val, vec3 shadows, vec3 midtones, vec3 highlights) {
209 if (val < 0.5) {
210 return mix(shadows, midtones, smoothstep(0.0, 1.0, val * 2.0));
211 }
212
213 return mix(midtones, highlights, smoothstep(0.0, 1.0, val * 2.0 - 1.0));
214}
215
216// Darkens the given color. If fac is zero, the color will not change, if fac is one, the
217// color will be black.
218vec3 darken(vec3 color, float fac) { return color * (1.0 - fac); }
219
220// Lightens the given color. If fac is zero, the color will not change, if fac is one, the
221// color will be white.
222vec3 lighten(vec3 color, float fac) { return color + (vec3(1.0) - color) * fac; }
223
224// change the color based on an offset amount
225vec3 offsetHue(vec3 color, float hueOffset) {
226 // Convert RGB to HSV
227 float maxC = max(max(color.r, color.g), color.b);
228 float minC = min(min(color.r, color.g), color.b);
229 float delta = maxC - minC;
230
231 float hue = 0.0;
232 if (delta > 0.0) {
233 if (maxC == color.r) {
234 hue = mod((color.g - color.b) / delta, 6.0);
235 } else if (maxC == color.g) {
236 hue = (color.b - color.r) / delta + 2.0;
237 } else {
238 hue = (color.r - color.g) / delta + 4.0;
239 }
240 }
241 hue /= 6.0;
242
243 float saturation = (maxC > 0.0) ? (delta / maxC) : 0.0;
244 float value = maxC;
245
246 // Offset the hue
247 hue = mod(hue + hueOffset, 1.0);
248
249 // Convert HSV back to RGB
250 float c = value * saturation;
251 float x = c * (1.0 - abs(mod(hue * 6.0, 2.0) - 1.0));
252 float m = value - c;
253
254 vec3 rgb;
255 if (hue < 1.0 / 6.0) {
256 rgb = vec3(c, x, 0.0);
257 } else if (hue < 2.0 / 6.0) {
258 rgb = vec3(x, c, 0.0);
259 } else if (hue < 3.0 / 6.0) {
260 rgb = vec3(0.0, c, x);
261 } else if (hue < 4.0 / 6.0) {
262 rgb = vec3(0.0, x, c);
263 } else if (hue < 5.0 / 6.0) {
264 rgb = vec3(x, 0.0, c);
265 } else {
266 rgb = vec3(c, 0.0, x);
267 }
268
269 return rgb + m;
270}
271
272// ---------------------------------------------------------------------- easing functions
273
274// Here are some basic easing function. More can be added if required!
275// Taken from here:
276// https://gitlab.gnome.org/GNOME/mutter/-/blob/main/clutter/clutter/clutter-easing.c
277
278float easeOutQuad(float x) { return -1.0 * x * (x - 2.0); }
279
280float easeInQuad(float x) { return x * x; }
281
282float easeInBack(float x, float e) { return x * x * ((e + 1.0) * x - e); }
283
284float easeOutBack(float x, float e) {
285 float p = x - 1.0;
286 return p * p * ((e + 1.0) * p + e) + 1.0;
287}
288
289// https://easings.net/
290/*
291Easing functions define the rate of change of a parameter over time, commonly used in
292animations, UI transitions, and game development. They provide a way to make movements
293more natural or visually appealing rather than linear and mechanical. Popular categories
294of easing functions include:
295
296Linear: Constant speed from start to finish.
297Quadratic (Ease In, Ease Out, Ease In Out): Changes at varying rates, with smoother starts
298or stops. Cubic: Similar to quadratic but allows for even more nuanced transitions.
299Exponential: Drastic changes at the start or end, often used for dramatic effects.
300Bounce: Mimics a bouncing object with oscillations.
301Elastic: Simulates the behavior of a spring, with overshooting and oscillations.
302Below are text-based "graphs" of some easing functions, where the horizontal axis
303represents time and the vertical axis represents progress.
304*/
305
306// Quadratic Easing
307// Smooth acceleration and deceleration using quadratic (t^2) curves.
308
309float easeInOutQuad(float t) {
310 // Accelerates for the first half, decelerates for the second half.
311 return t < 0.5 ? 2.0 * t * t : -1.0 + (4.0 - 2.0 * t) * t;
312}
313
314// Cubic Easing
315// Smoother transitions compared to quadratic easing using cubic (t^3) curves.
316
317float easeInCubic(float t) {
318 // Starts slow and accelerates as t increases.
319 return t * t * t;
320}
321
322float easeOutCubic(float t) {
323 // Starts fast and decelerates as t approaches 1.0.
324 float f = t - 1.0;
325 return f * f * f + 1.0;
326}
327
328float easeInOutCubic(float t) {
329 // Combines easeIn and easeOut cubic behavior for smooth transitions.
330 return t < 0.5 ? 4.0 * t * t * t : (t - 1.0) * (2.0 * t - 2.0) * (2.0 * t - 2.0) + 1.0;
331}
332
333// Quartic Easing
334// Even smoother transitions than cubic, using quartic (t^4) curves.
335
336float easeInQuart(float t) {
337 // Starts very slow and accelerates steeply.
338 return t * t * t * t;
339}
340
341float easeOutQuart(float t) {
342 // Starts steeply and slows down dramatically.
343 float f = t - 1.0;
344 return 1.0 - f * f * f * f;
345}
346
347float easeInOutQuart(float t) {
348 // Combines easeIn and easeOut quartic behavior for very smooth transitions.
349 return t < 0.5 ? 8.0 * t * t * t * t
350 : 1.0 - 8.0 * (t - 1.0) * (t - 1.0) * (t - 1.0) * (t - 1.0);
351}
352
353// Sine Easing
354// Smooth, wave-like acceleration and deceleration using sine curves.
355
356float easeInSine(float t) {
357 // Starts very slow, following a sine wave curve.
358 return 1.0 - cos((t * 3.141592653589793) / 2.0);
359}
360
361float easeOutSine(float t) {
362 // Starts fast and slows down following a sine wave curve.
363 return sin((t * 3.141592653589793) / 2.0);
364}
365
366float easeInOutSine(float t) {
367 // Smooth start and end, mimicking half a sine wave.
368 return -0.5 * (cos(3.141592653589793 * t) - 1.0);
369}
370
371// Exponential Easing
372// Sharp transitions with rapid acceleration and deceleration.
373
374float easeInExpo(float t) {
375 // Very slow start, accelerates exponentially.
376 return t == 0.0 ? 0.0 : pow(2.0, 10.0 * (t - 1.0));
377}
378
379float easeOutExpo(float t) {
380 // Starts fast and slows down exponentially.
381 return t == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * t);
382}
383
384float easeInOutExpo(float t) {
385 // Combines easeIn and easeOut exponential for sharp transitions.
386 if (t == 0.0) return 0.0;
387 if (t == 1.0) return 1.0;
388 return t < 0.5 ? 0.5 * pow(2.0, 20.0 * t - 10.0)
389 : 1.0 - 0.5 * pow(2.0, -20.0 * t + 10.0);
390}
391
392// Back Easing
393// Creates an overshooting effect for more dynamic animations.
394
395float easeInOutBack(float t) {
396 // Uses constants to define the overshooting magnitude.
397 const float c1 = 1.70158;
398 const float c2 = c1 * 1.525;
399 return t < 0.5
400 ? (pow(2.0 * t, 2.0) * ((c2 + 1.0) * 2.0 * t - c2)) / 2.0
401 : (pow(2.0 * t - 2.0, 2.0) * ((c2 + 1.0) * (t * 2.0 - 2.0) + c2) + 2.0) / 2.0;
402}
403
404// --------------------------------------------------------------------- edge mask helpers
405
406// This method returns a mask which smoothly transitions towards zero when approaching
407// the window's borders. If the window is currently maximized or in fullscreen mode, this
408// will return 1.0 everywhere. There is a variant which takes the transition area width in
409// pixels and one which takes this as a percentage.
410float getEdgeMask(vec2 uv, vec2 maxUV, float fadeWidth) {
411 float mask = 1.0;
412
413 if (!uIsFullscreen) {
414 mask *= smoothstep(0.0, 1.0, clamp(uv.x / fadeWidth, 0.0, 1.0));
415 mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));
416 mask *= smoothstep(0.0, 1.0, clamp((maxUV.x - uv.x) / fadeWidth, 0.0, 1.0));
417 mask *= smoothstep(0.0, 1.0, clamp((maxUV.y - uv.y) / fadeWidth, 0.0, 1.0));
418 }
419
420 return mask;
421}
422
423// Returns an edge mask which fades to zero at the boundaries of the actor. The width of
424// the fade zone is given in pixels. This uses the standard uniforms uSize and uPadding.
425// This means that the fading zone is not actually at the actors boundaries but at the
426// position of the window border in the texture.
427// The offset parameter controls whether the fading is placed inside the window borders
428// (offset = 0), ontop the window borders (offset = 0.5) or outside the window borders
429// (offset = 1).
430float getAbsoluteEdgeMask(float fadePixels, float offset) {
431 float padding = max(0.0, uPadding - fadePixels * offset);
432 vec2 uv = iTexCoord.st * uSize - padding;
433 return getEdgeMask(uv, uSize - 2.0 * padding, fadePixels);
434}
435
436// Returns an edge mask which fades to zero at the boundaries of the actor. The width of
437// the fade zone is given relative to the actor size. This neither uses uSize and
438// uPadding.
439float getRelativeEdgeMask(float fadeAmount) {
440 vec2 uv = iTexCoord.st;
441 return getEdgeMask(uv, vec2(1.0), fadeAmount);
442}
443
444// ------------------------------------------------------------------------------- 2D math
445
446// The math for the whirling is inspired by this post:
447// http://www.geeks3d.com/20110428/shader-library-swirl-post-processing-filter-in-glsl
448vec2 whirl(vec2 coords, float warping, float rotation) {
449 float angle = pow(1.0 - length(coords), 2.0) * warping + rotation;
450 float s = sin(angle);
451 float c = cos(angle);
452 return vec2(dot(coords, vec2(c, -s)), dot(coords, vec2(s, c)));
453}
454
455// Returns the shortest distance between the given point and the line defined by "origin"
456// and "direction".
457float distToLine(vec2 origin, vec2 direction, vec2 point) {
458 vec2 perpendicular = vec2(direction.y, -direction.x);
459 return abs(dot(normalize(perpendicular), origin - point));
460}
461
462// Returns a positive number if a -> b forms a clockwise corner, or a negative number if
463// the corner is counter-clockwise.
464float getWinding(vec2 a, vec2 b) { return cross(vec3(a, 0.0), vec3(b, 0.0)).z; }
465
466// Rotates the given 2D vector a clockwise by the angle alpha (given in radians).
467vec2 rotate(vec2 a, float angle) {
468 return vec2(a.x * cos(angle) - a.y * sin(angle), a.x * sin(angle) + a.y * cos(angle));
469}
470
471// rotates a given 2d vector, around a given center (angle is in radians)
472vec2 rotate(vec2 a, float angle, vec2 center) {
473 return vec2(cos(angle) * (a.x - center.x) + sin(angle) * (a.y - center.y) + center.x,
474 cos(angle) * (a.y - center.y) - sin(angle) * (a.x - center.x) + center.y);
475}
476
477// --------------------------------------------------------------------------------- noise
478
479// These noise algorithms are based on implementations by various authors from
480// shadertoy.com, which are all available under the MIT License. See the respective links
481// in the comments below.
482
483// Hash functions
484// MIT License, https://www.shadertoy.com/view/4djSRW
485// Copyright (c) 2014 David Hoskins.
486
487// 1 out, 1 in...
488float hash11(float p) {
489 p = fract(p * .1031);
490 p *= p + 33.33;
491 p *= p + p;
492 return fract(p);
493}
494
495// 1 out, 2 in...
496float hash12(vec2 p) {
497 vec3 p3 = fract(vec3(p.xyx) * .1031);
498 p3 += dot(p3, p3.yzx + 33.33);
499 return fract((p3.x + p3.y) * p3.z);
500}
501
502// 1 out, 3 in...
503float hash13(vec3 p3) {
504 p3 = fract(p3 * .1031);
505 p3 += dot(p3, p3.zyx + 31.32);
506 return fract((p3.x + p3.y) * p3.z);
507}
508
509// 2 out, 1 in...
510vec2 hash21(float p) {
511 vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
512 p3 += dot(p3, p3.yzx + 33.33);
513 return fract((p3.xx + p3.yz) * p3.zy);
514}
515
516// 2 out, 2 in...
517vec2 hash22(vec2 p) {
518 vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
519 p3 += dot(p3, p3.yzx + 33.33);
520 return fract((p3.xx + p3.yz) * p3.zy);
521}
522
523// 2 out, 3 in...
524vec2 hash23(vec3 p3) {
525 p3 = fract(p3 * vec3(.1031, .1030, .0973));
526 p3 += dot(p3, p3.yzx + 33.33);
527 return fract((p3.xx + p3.yz) * p3.zy);
528}
529
530// 3 out, 1 in...
531vec3 hash31(float p) {
532 vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
533 p3 += dot(p3, p3.yzx + 33.33);
534 return fract((p3.xxy + p3.yzz) * p3.zyx);
535}
536
537// 3 out, 2 in...
538vec3 hash32(vec2 p) {
539 vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
540 p3 += dot(p3, p3.yxz + 33.33);
541 return fract((p3.xxy + p3.yzz) * p3.zyx);
542}
543
544// 3 out, 3 in...
545vec3 hash33(vec3 p3) {
546 p3 = fract(p3 * vec3(.1031, .1030, .0973));
547 p3 += dot(p3, p3.yxz + 33.33);
548 return fract((p3.xxy + p3.yxx) * p3.zyx);
549}
550
551// 4 out, 1 in...
552vec4 hash41(float p) {
553 vec4 p4 = fract(vec4(p) * vec4(.1031, .1030, .0973, .1099));
554 p4 += dot(p4, p4.wzxy + 33.33);
555 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
556}
557
558// 4 out, 2 in...
559vec4 hash42(vec2 p) {
560 vec4 p4 = fract(vec4(p.xyxy) * vec4(.1031, .1030, .0973, .1099));
561 p4 += dot(p4, p4.wzxy + 33.33);
562 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
563}
564
565// 4 out, 3 in...
566vec4 hash43(vec3 p) {
567 vec4 p4 = fract(vec4(p.xyzx) * vec4(.1031, .1030, .0973, .1099));
568 p4 += dot(p4, p4.wzxy + 33.33);
569 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
570}
571
572// 4 out, 4 in...
573vec4 hash44(vec4 p4) {
574 p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));
575 p4 += dot(p4, p4.wzxy + 33.33);
576 return fract((p4.xxyz + p4.yzzw) * p4.zywx);
577}
578
579// 2D Simplex Noise
580// MIT License, https://www.shadertoy.com/view/Msf3WH
581// Copyright © 2013 Inigo Quilez
582float simplex2D(vec2 p) {
583 const float K1 = 0.366025404; // (sqrt(3)-1)/2;
584 const float K2 = 0.211324865; // (3-sqrt(3))/6;
585
586 vec2 i = floor(p + (p.x + p.y) * K1);
587 vec2 a = p - i + (i.x + i.y) * K2;
588 float m = step(a.y, a.x);
589 vec2 o = vec2(m, 1.0 - m);
590 vec2 b = a - o + K2;
591 vec2 c = a - 1.0 + 2.0 * K2;
592 vec3 h = max(0.5 - vec3(dot(a, a), dot(b, b), dot(c, c)), 0.0);
593 vec3 n = h * h * h * h *
594 vec3(dot(a, -1.0 + 2.0 * hash22(i + 0.0)), dot(b, -1.0 + 2.0 * hash22(i + o)),
595 dot(c, -1.0 + 2.0 * hash22(i + 1.0)));
596 return 0.5 + 0.5 * dot(n, vec3(70.0));
597}
598
599float simplex2DFractal(vec2 p) {
600 mat2 m = mat2(1.6, 1.2, -1.2, 1.6);
601 float f = 0.5000 * simplex2D(p);
602 p = m * p;
603 f += 0.2500 * simplex2D(p);
604 p = m * p;
605 f += 0.1250 * simplex2D(p);
606 p = m * p;
607 f += 0.0625 * simplex2D(p);
608 p = m * p;
609
610 return f;
611}
612
613// 3D Simplex Noise
614// MIT License, https://www.shadertoy.com/view/XsX3zB
615// Copyright © 2013 Nikita Miropolskiy
616float simplex3D(vec3 p) {
617
618 // skew constants for 3D simplex functions
619 const float F3 = 0.3333333;
620 const float G3 = 0.1666667;
621
622 // 1. find current tetrahedron T and it's four vertices
623 // s, s+i1, s+i2, s+1.0 - absolute skewed (integer) coordinates of T vertices
624 // x, x1, x2, x3 - unskewed coordinates of p relative to each of T vertice
625
626 // calculate s and x
627 vec3 s = floor(p + dot(p, vec3(F3)));
628 vec3 x = p - s + dot(s, vec3(G3));
629
630 // calculate i1 and i2
631 vec3 e = step(vec3(0.0), x - x.yzx);
632 vec3 i1 = e * (1.0 - e.zxy);
633 vec3 i2 = 1.0 - e.zxy * (1.0 - e);
634
635 // x1, x2, x3
636 vec3 x1 = x - i1 + G3;
637 vec3 x2 = x - i2 + 2.0 * G3;
638 vec3 x3 = x - 1.0 + 3.0 * G3;
639
640 // 2. find four surflets and store them in d
641 vec4 w, d;
642
643 // calculate surflet weights
644 w.x = dot(x, x);
645 w.y = dot(x1, x1);
646 w.z = dot(x2, x2);
647 w.w = dot(x3, x3);
648
649 // w fades from 0.6 at the center of the surflet to 0.0 at the margin
650 w = max(0.6 - w, 0.0);
651
652 // calculate surflet components
653 d.x = dot(-0.5 + hash33(s), x);
654 d.y = dot(-0.5 + hash33(s + i1), x1);
655 d.z = dot(-0.5 + hash33(s + i2), x2);
656 d.w = dot(-0.5 + hash33(s + 1.0), x3);
657
658 // multiply d by w^4
659 w *= w;
660 w *= w;
661 d *= w;
662
663 // 3. return the sum of the four surflets
664 return dot(d, vec4(52.0)) * 0.5 + 0.5;
665}
666
667// Directional artifacts can be reduced by rotating each octave
668float simplex3DFractal(vec3 m) {
669
670 // const matrices for 3D rotation
671 const mat3 rot1 = mat3(-0.37, 0.36, 0.85, -0.14, -0.93, 0.34, 0.92, 0.01, 0.4);
672 const mat3 rot2 = mat3(-0.55, -0.39, 0.74, 0.33, -0.91, -0.24, 0.77, 0.12, 0.63);
673 const mat3 rot3 = mat3(-0.71, 0.52, -0.47, -0.08, -0.72, -0.68, -0.7, -0.45, 0.56);
674
675 return 0.5333333 * simplex3D(m * rot1) + 0.2666667 * simplex3D(2.0 * m * rot2) +
676 0.1333333 * simplex3D(4.0 * m * rot3) + 0.0666667 * simplex3D(8.0 * m);
677}
678
679// --------------------------------------------------------------------------------- remap
680
681/*
682These functions remap a given value from one range to another.
683The remap operation is particularly useful in shader programming
684to scale or normalize data, ensuring compatibility across various
685input ranges. Each version of the remap function supports a
686different data type:
687
6881. float: Remap a single scalar value.
6892. vec2: Remap a 2D vector.
6903. vec3: Remap a 3D vector.
6914. vec4: Remap a 4D vector.
692
693The general formula used is:
694 newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin)
695
696This ensures a linear transformation from the old range to the new range.
697*/
698
699// Remap for float
700// Maps a float value from one range [oldMin, oldMax] to another range [newMin, newMax].
701// This is useful for normalizing or scaling scalar values to fit within a desired range.
702float remap(float value, float oldMin, float oldMax, float newMin, float newMax) {
703 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
704 newMax);
705}
706
707// Remap for vec2
708// Maps a 2D vector (vec2) from one range [oldMin, oldMax] to another range [newMin,
709// newMax]. Each component of the vec2 is individually scaled and transformed.
710vec2 remap(vec2 value, vec2 oldMin, vec2 oldMax, vec2 newMin, vec2 newMax) {
711 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
712 newMax);
713}
714
715// Remap for vec3
716// Maps a 3D vector (vec3) from one range [oldMin, oldMax] to another range [newMin,
717// newMax]. Each component of the vec3 is individually scaled and transformed.
718vec3 remap(vec3 value, vec3 oldMin, vec3 oldMax, vec3 newMin, vec3 newMax) {
719 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
720 newMax);
721}
722
723// Remap for vec4
724// Maps a 4D vector (vec4) from one range [oldMin, oldMax] to another range [newMin,
725// newMax]. Each component of the vec4 is individually scaled and transformed.
726vec4 remap(vec4 value, vec4 oldMin, vec4 oldMax, vec4 newMin, vec4 newMax) {
727 return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
728 newMax);
729}
730//////////////////////////////////////////////////////////////////////////////////////////
731// ) ( //
732// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
733// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
734// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
735// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
736// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
737// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
738// |__/ //
739//////////////////////////////////////////////////////////////////////////////////////////
740
741// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
742// SPDX-License-Identifier: GPL-3.0-or-later
743
744// The content from common.glsl is automatically prepended to each shader effect.
745
746// Marble [Burn-My-Windows variant] v7: window morphs into a glossy 2D marble.
747// The fall happens in main.js (Translation, constant gravity) after the marble is done.
748uniform float uCrumpleEnd;
749
750void main() {
751 float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
752 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
753 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
754
755 vec2 hs = 0.5 * uSize;
756 vec2 p = iTexCoord * uSize - hs;
757 float R0 = 0.035 * min(uSize.x, uSize.y); // ~7% diameter
758 vec2 b = mix(hs, vec2(R0), e); // half size of the morphing shape
759 float rad = mix(0.0, R0, e * e); // corner radius grows to a full circle
760 vec2 dq = max(abs(p) - (b - rad), 0.0);
761 float d = length(dq) - rad + min(max(abs(p).x - (b - rad).x, abs(p).y - (b - rad).y), 0.0);
762
763 // soft drop shadow (bottom-right), drawn where the marble is not
764 vec2 ps = p - vec2(0.12, 0.22) * R0 * e;
765 float sh = 0.35 * e * (1.0 - smoothstep(-0.2 * R0, 0.25 * R0, length(ps) - R0 * 0.9 * e + (1.0 - e) * 1e5));
766 if (d > 0.0) { setOutputColor(vec4(0.0, 0.0, 0.0, sh * step(0.5, e))); return; }
767
768 vec2 q = p / b; // -1..1 inside
769 float r2 = min(dot(q, q), 1.0);
770 float z = sqrt(1.0 - r2 * e); // sphere height (flat at e=0)
771 vec2 uv = 0.5 + 0.5 * q * mix(1.0, 0.75 + 0.45 * (1.0 - z), e);
772 vec4 col = getInputColor(clamp(uv, 0.0, 1.0));
773 col.a = step(0.97, col.a); // ignore the window shadow
774 col.a = mix(col.a, 1.0, e); // marble is solid
775 col.rgb = clamp(col.rgb, 0.0, 1.0);
776
777 // glossy marble shading
778 vec3 n = vec3(q * e, z);
779 float diff = clamp(dot(n, vec3(-0.45, -0.55, 0.70)), 0.0, 1.0);
780 vec2 hv = q - vec2(-0.38, -0.42);
781 float hd = dot(hv, hv);
782 float spot = (1.0 - smoothstep(0.004, 0.012, hd)); // small sharp highlight
783 float glow = 0.35 * (1.0 - smoothstep(0.0, 0.25, hd)); // softer glow
784 float fres = 1.0 - z; fres *= fres; // rim light
785 float bottom = 1.0 - 0.55 * clamp(q.y * 0.9 + 0.2, 0.0, 1.0) * (1.0 - z * 0.5);
786 float lit = mix(1.0, (0.45 + 0.65 * diff) * bottom, e);
787 col.rgb = col.rgb * lit + e * (vec3(spot * 0.9 + glow) + fres * vec3(0.25, 0.28, 0.32));
788 col.rgb = min(col.rgb, vec3(1.0));
789 col.a *= clamp(-d, 0.0, 1.0); // 1px anti-aliased edge
790 setOutputColor(col);
791}
kwin6_effect_marble/contents/ui/config.ui added +14 −0
@@ -0,0 +1,14 @@
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>MarbleConfig</class>
4 <widget class="QWidget" name="MarbleConfig">
5 <layout class="QFormLayout" name="formLayout">
6 <item row="0" column="0"><widget class="QLabel" name="l1"><property name="text"><string>Marble morph duration (ms)</string></property></widget></item>
7 <item row="0" column="1"><widget class="QSpinBox" name="kcfg_Duration"><property name="maximum"><number>5000</number></property></widget></item>
8 <item row="2" column="0"><widget class="QLabel" name="l2"><property name="text"><string>Gravity (px/s²)</string></property></widget></item>
9 <item row="2" column="1"><widget class="QSpinBox" name="kcfg_Gravity"><property name="maximum"><number>50000</number></property></widget></item>
10 <item row="1" column="0"><widget class="QLabel" name="l3"><property name="text"><string>Pause before fall (ms)</string></property></widget></item>
11 <item row="1" column="1"><widget class="QSpinBox" name="kcfg_Pause"><property name="maximum"><number>5000</number></property></widget></item>
12 </layout>
13 </widget>
14 </ui>
@@ -0,0 +1,14 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ui version="4.0">
3 <class>MarbleConfig</class>
4 <widget class="QWidget" name="MarbleConfig">
5 <layout class="QFormLayout" name="formLayout">
6 <item row="0" column="0"><widget class="QLabel" name="l1"><property name="text"><string>Marble morph duration (ms)</string></property></widget></item>
7 <item row="0" column="1"><widget class="QSpinBox" name="kcfg_Duration"><property name="maximum"><number>5000</number></property></widget></item>
8 <item row="2" column="0"><widget class="QLabel" name="l2"><property name="text"><string>Gravity (px/s²)</string></property></widget></item>
9 <item row="2" column="1"><widget class="QSpinBox" name="kcfg_Gravity"><property name="maximum"><number>50000</number></property></widget></item>
10 <item row="1" column="0"><widget class="QLabel" name="l3"><property name="text"><string>Pause before fall (ms)</string></property></widget></item>
11 <item row="1" column="1"><widget class="QSpinBox" name="kcfg_Pause"><property name="maximum"><number>5000</number></property></widget></item>
12 </layout>
13 </widget>
14</ui>
kwin6_effect_marble/metadata.json added +30 −0
@@ -0,0 +1,30 @@
1 {
2 "KPackageStructure": "KWin/Effect",
3 "KPlugin": {
4 "Name": "Marble [Burn-My-Windows variant]",
5 "Description": "Turns the closing window into a glossy marble that drops off the screen",
6 "Icon": "preferences-system-windows-effect",
7 "Category": "Window Open/Close Animation",
8 "Authors": [
9 { "Name": "Simon Schneegans", "Email": "code@simonschneegans.de" },
10 { "Name": "Martin Flöser", "Email": "mgraesslin@kde.org" },
11 { "Name": "Vlad Zahorodnii", "Email": "vlad.zahorodnii@kde.org" }
12 ],
13 "Id": "kwin6_effect_marble",
14 "License": "GPLv3",
15 "Version": "1.0",
16 "EnabledByDefault": false,
17 "Website": "https://github.com/Schneegans/Burn-My-Windows/",
18 "BugReportUrl": "https://github.com/Schneegans/Burn-My-Windows/issues",
19 "ServiceTypes": [
20 "KWin/Effect"
21 ]
22 },
23 "X-KDE-ConfigModule": "kcm_kwin4_genericscripted",
24 "X-KDE-Ordering": "60",
25 "X-KDE-PluginKeyword": "kwin6_effect_marble",
26 "X-KWin-Config-TranslationDomain": "burn-my-windows",
27 "X-KWin-Exclusive-Category": "toplevel-open-close-animation",
28 "X-Plasma-API": "javascript",
29 "X-Plasma-MainScript": "code/main.js"
30 }
@@ -0,0 +1,30 @@
1{
2 "KPackageStructure": "KWin/Effect",
3 "KPlugin": {
4 "Name": "Marble [Burn-My-Windows variant]",
5 "Description": "Turns the closing window into a glossy marble that drops off the screen",
6 "Icon": "preferences-system-windows-effect",
7 "Category": "Window Open/Close Animation",
8 "Authors": [
9 { "Name": "Simon Schneegans", "Email": "code@simonschneegans.de" },
10 { "Name": "Martin Flöser", "Email": "mgraesslin@kde.org" },
11 { "Name": "Vlad Zahorodnii", "Email": "vlad.zahorodnii@kde.org" }
12 ],
13 "Id": "kwin6_effect_marble",
14 "License": "GPLv3",
15 "Version": "1.0",
16 "EnabledByDefault": false,
17 "Website": "https://github.com/Schneegans/Burn-My-Windows/",
18 "BugReportUrl": "https://github.com/Schneegans/Burn-My-Windows/issues",
19 "ServiceTypes": [
20 "KWin/Effect"
21 ]
22 },
23 "X-KDE-ConfigModule": "kcm_kwin4_genericscripted",
24 "X-KDE-Ordering": "60",
25 "X-KDE-PluginKeyword": "kwin6_effect_marble",
26 "X-KWin-Config-TranslationDomain": "burn-my-windows",
27 "X-KWin-Exclusive-Category": "toplevel-open-close-animation",
28 "X-Plasma-API": "javascript",
29 "X-Plasma-MainScript": "code/main.js"
30}