diff --git a/Cool b/Cool index 4795b6a1..0014dbf7 160000 --- a/Cool +++ b/Cool @@ -1 +1 @@ -Subproject commit 4795b6a1315c416be0b03e1a7c58b13aff1eb820 +Subproject commit 0014dbf77d41fa1e26a8c51a1521a0ef37a5b290 diff --git a/Nodes/12 Image Blend/Mix (Light).clbnode b/Nodes/12 Image Blend/Mix (Light).clbnode new file mode 100644 index 00000000..17568166 --- /dev/null +++ b/Nodes/12 Image Blend/Mix (Light).clbnode @@ -0,0 +1,9 @@ +// To learn how to write nodes, see https://coollab-art.com/Tutorials/Writing%20Nodes/Intro + +INPUT Oklab 'Color2'; +INPUT float 'Percent'; + +Oklab main(Oklab Color1) +{ + return mix(Color1, 'Color2', 'Percent'); +} \ No newline at end of file diff --git a/Nodes/12 Image Blend/Mix (Light).clbnode.presets.json b/Nodes/12 Image Blend/Mix (Light).clbnode.presets.json new file mode 100644 index 00000000..25becc0b --- /dev/null +++ b/Nodes/12 Image Blend/Mix (Light).clbnode.presets.json @@ -0,0 +1,68 @@ +{ + "Presets": { + "Underlying container": [ + { + "first": "92f7e19a-fc1c-49b8-8135-130c88229e1c", + "second": { + "Name": "Default", + "Values": [ + { + "index": 7, + "data": { + "Name": "Color2", + "Value": { + "sRGB": { + "x": 1.0, + "y": 0.9998999834060669, + "z": 0.9998999834060669 + } + }, + "Metadata": { + "Is HDR": false + }, + "Default Value": { + "sRGB": { + "x": 1.0, + "y": 0.9998999834060669, + "z": 0.9998999834060669 + } + }, + "Default Metadata": { + "Is HDR": false + } + } + }, + { + "index": 2, + "data": { + "Name": "Percent", + "Value": 0.5, + "Metadata": { + "Bounds": { + "Has min bound": false, + "Min": 0.0, + "Has max bound": false, + "Max": 1.0, + "Drag speed": 0.009999999776482582, + "Use slider": true + } + }, + "Default Value": 0.5, + "Default Metadata": { + "Bounds": { + "Has min bound": false, + "Min": 0.0, + "Has max bound": false, + "Max": 1.0, + "Drag speed": 0.009999999776482582, + "Use slider": false + } + } + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/Nodes/12 Image Blend/Mix (Paint).clbnode b/Nodes/12 Image Blend/Mix (Paint).clbnode new file mode 100644 index 00000000..99a420b2 --- /dev/null +++ b/Nodes/12 Image Blend/Mix (Paint).clbnode @@ -0,0 +1,9 @@ +// To learn how to write nodes, see https://coollab-art.com/Tutorials/Writing%20Nodes/Intro + +INPUT sRGB 'Color2'; +INPUT float 'Percent'; + +sRGB main(sRGB Color1) +{ + return mixbox_lerp(Color1, 'Color2', 'Percent'); +} \ No newline at end of file diff --git a/Nodes/12 Image Blend/Mix (Paint).clbnode.presets.json b/Nodes/12 Image Blend/Mix (Paint).clbnode.presets.json new file mode 100644 index 00000000..1236b81d --- /dev/null +++ b/Nodes/12 Image Blend/Mix (Paint).clbnode.presets.json @@ -0,0 +1,68 @@ +{ + "Presets": { + "Underlying container": [ + { + "first": "49fbfa3e-7018-44e3-847c-ea57da42f4f0", + "second": { + "Name": "Default", + "Values": [ + { + "index": 7, + "data": { + "Name": "Color2", + "Value": { + "sRGB": { + "x": 1.0, + "y": 0.9998999834060669, + "z": 0.9998999834060669 + } + }, + "Metadata": { + "Is HDR": false + }, + "Default Value": { + "sRGB": { + "x": 1.0, + "y": 0.9998999834060669, + "z": 0.9998999834060669 + } + }, + "Default Metadata": { + "Is HDR": false + } + } + }, + { + "index": 2, + "data": { + "Name": "Percent", + "Value": 0.5, + "Metadata": { + "Bounds": { + "Has min bound": true, + "Min": 0.0, + "Has max bound": true, + "Max": 1.0, + "Drag speed": 0.009999999776482582, + "Use slider": true + } + }, + "Default Value": 0.5, + "Default Metadata": { + "Bounds": { + "Has min bound": false, + "Min": 0.0, + "Has max bound": false, + "Max": 1.0, + "Drag speed": 0.009999999776482582, + "Use slider": false + } + } + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/Nodes/12 Image Blend/Mix.clbnode b/Nodes/12 Image Blend/Mix.clbnode deleted file mode 100644 index 3efc386a..00000000 --- a/Nodes/12 Image Blend/Mix.clbnode +++ /dev/null @@ -1,7 +0,0 @@ - -INPUT float 'percent'; - -sRGB_PremultipliedA main(sRGB_PremultipliedA Over, sRGB_PremultipliedA Under) -{ - return 'percent' * Over + (1.0 - 'percent') * Under; -} \ No newline at end of file diff --git a/Nodes/12 Image Blend/Opacity.clbnode.presets.json b/Nodes/12 Image Blend/Opacity.clbnode.presets.json deleted file mode 100644 index 69d89d5a..00000000 --- a/Nodes/12 Image Blend/Opacity.clbnode.presets.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "PresetManager": { - "Presets": { - "Underlying container": [ - { - "first": "cbcf2ddb-51d4-4fff-bac2-de8d2350f06f", - "second": { - "Name": "Default", - "Values": [ - { - "index": 2, - "data": { - "Name": "percent", - "Value": 0.5, - "Metadata": { - "Bounds": { - "Has min bound": false, - "Min": 0.0, - "Has max bound": false, - "Max": 1.0, - "Drag speed": 0.10000000149011612, - "Use slider": true - } - }, - "Default Value": 0.5, - "Default Metadata": { - "Bounds": { - "Has min bound": false, - "Min": 0.0, - "Has max bound": false, - "Max": 1.0, - "Drag speed": 0.009999999776482582, - "Use slider": false - } - } - } - } - ] - } - } - ] - } - } -} \ No newline at end of file diff --git a/Nodes/12 Image Blend/Over.clbnode b/Nodes/12 Image Blend/Over (Light).clbnode similarity index 100% rename from Nodes/12 Image Blend/Over.clbnode rename to Nodes/12 Image Blend/Over (Light).clbnode diff --git a/Nodes/12 Image Blend/Over.clbnode.presets.json b/Nodes/12 Image Blend/Over (Light).clbnode.presets.json similarity index 95% rename from Nodes/12 Image Blend/Over.clbnode.presets.json rename to Nodes/12 Image Blend/Over (Light).clbnode.presets.json index 71a8d983..1d2c43af 100644 --- a/Nodes/12 Image Blend/Over.clbnode.presets.json +++ b/Nodes/12 Image Blend/Over (Light).clbnode.presets.json @@ -2,7 +2,7 @@ "Presets": { "Underlying container": [ { - "first": "ef366185-eeb3-4c86-92e6-a139302c3864", + "first": "2dc66228-4356-4c03-b1a4-1b956c1351e8", "second": { "Name": "Default", "Values": [ diff --git a/Nodes/12 Image Blend/Over (Paint).clbnode b/Nodes/12 Image Blend/Over (Paint).clbnode new file mode 100644 index 00000000..fe71f6bf --- /dev/null +++ b/Nodes/12 Image Blend/Over (Paint).clbnode @@ -0,0 +1,19 @@ +// To learn how to write nodes, see https://coollab-art.com/Tutorials/Writing%20Nodes/Intro + +INPUT sRGB_PremultipliedA 'Background'; + +sRGB_PremultipliedA main(sRGB_PremultipliedA Foreground) +{ + float new_alpha = Foreground.a + (1. - Foreground.a) * 'Background'.a; + return vec4( + premultiply( + mixbox_lerp( + unpremultiply('Background'.rgb, 'Background'.a), + unpremultiply(Foreground.rgb, Foreground.a), + Foreground.a + ), + new_alpha + ), + new_alpha + ); +} \ No newline at end of file diff --git a/Nodes/12 Image Blend/Over (Paint).clbnode.presets.json b/Nodes/12 Image Blend/Over (Paint).clbnode.presets.json new file mode 100644 index 00000000..ca058249 --- /dev/null +++ b/Nodes/12 Image Blend/Over (Paint).clbnode.presets.json @@ -0,0 +1,42 @@ +{ + "Presets": { + "Underlying container": [ + { + "first": "2fec6af0-2106-498f-930e-94811d87bdbe", + "second": { + "Name": "Default", + "Values": [ + { + "index": 8, + "data": { + "Name": "Background", + "Value": { + "sRGB, Straight alpha": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 1.0 + } + }, + "Metadata": { + "Is HDR": false + }, + "Default Value": { + "sRGB, Straight alpha": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 1.0 + } + }, + "Default Metadata": { + "Is HDR": false + } + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/changelog.md b/changelog.md index c68a6ed7..b1ea2116 100644 --- a/changelog.md +++ b/changelog.md @@ -14,6 +14,7 @@ ## 🐣beta-9 WIP - ✨ Added Midi support! +- ✨ Added the "Paint" blend mode. - ✨ Added an Output window that you can project during live shows, while still having your View window on your screen to move the camera and the widgets. To open this window, go in the `Commands` menu and select `Open output window`. - ✨ Added "Load Backup" in case you accidentally refused to save your unsaved changes. - 🐛 Fix: the transparency information was sometimes getting lost between nodes. diff --git a/res/mixbox/LICENSE b/res/mixbox/LICENSE new file mode 100644 index 00000000..21decaa0 --- /dev/null +++ b/res/mixbox/LICENSE @@ -0,0 +1,337 @@ +Mixbox is licensed for non-commercial use under the CC BY-NC 4.0 license below. + +If you want to obtain commercial license, please contact: mixbox@scrtwpns.com + +=============================================================================== + +Creative Commons Attribution-NonCommercial 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution-NonCommercial 4.0 International Public License ("Public +License"). To the extent this Public License may be interpreted as a +contract, You are granted the Licensed Rights in consideration of Your +acceptance of these terms and conditions, and the Licensor grants You +such rights in consideration of benefits the Licensor receives from +making the Licensed Material available under these terms and +conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + d. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + g. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + i. NonCommercial means not primarily intended for or directed towards + commercial advantage or monetary compensation. For purposes of + this Public License, the exchange of the Licensed Material for + other material subject to Copyright and Similar Rights by digital + file-sharing or similar means is NonCommercial provided there is + no payment of monetary compensation in connection with the + exchange. + + j. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + k. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + l. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part, for NonCommercial purposes only; and + + b. produce, reproduce, and Share Adapted Material for + NonCommercial purposes only. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties, including when + the Licensed Material is used other than for NonCommercial + purposes. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's + License You apply must not prevent recipients of the Adapted + Material from complying with this Public License. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database for NonCommercial purposes + only; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + +=============================================================================== diff --git a/res/mixbox/README-SHADERS.md b/res/mixbox/README-SHADERS.md new file mode 100644 index 00000000..8cdce9e4 --- /dev/null +++ b/res/mixbox/README-SHADERS.md @@ -0,0 +1,170 @@ +## GLSL Shader +```glsl +#ifdef GL_ES +precision highp float; +#endif + +// uncomment the following line if you work in linear space +// #define MIXBOX_COLORSPACE_LINEAR + +uniform sampler2D mixbox_lut; // bind the "mixbox_lut.png" texture here + +#include "mixbox.glsl" // paste the contents of mixbox.glsl here + +void main(void) +{ + vec3 rgb1 = vec3(0, 0.129, 0.522); // blue + vec3 rgb2 = vec3(0.988, 0.827, 0); // yellow + float t = 0.5; // mixing ratio + + vec3 rgb = mixbox_lerp(rgb1, rgb2, t); + + gl_FragColor = vec4(rgb, 1.0); +} +``` +```glsl +vec3 mix_three(vec3 rgb1, vec3 rgb2, vec3 rgb3) +{ + mixbox_latent z1 = mixbox_rgb_to_latent(rgb1); + mixbox_latent z2 = mixbox_rgb_to_latent(rgb2); + mixbox_latent z3 = mixbox_rgb_to_latent(rgb3); + + // mix together 30% of rgb1, 60% of rgb2, and 10% of rgb3 + mixbox_latent z_mix = 0.3*z1 + 0.6*z2 + 0.1*z3; + + vec3 rgb_mix = mixbox_latent_to_rgb(z_mix); + + return rgb_mix; +} +``` + +## HLSL Shader +```hlsl +// uncomment the following line if you work in linear space +// #define MIXBOX_COLORSPACE_LINEAR + +Texture2D MixboxLUT; // bind the "mixbox_lut.png" texture here +SamplerState MixboxSampler; // FILTER_MIN_MAG_LINEAR_MIP_POINT + +#define MIXBOX_LUT(UV) MixboxLUT.SampleLevel(MixboxSampler, UV, 0) + +#include "mixbox.hlsl" + +float4 PSMain() : SV_Target +{ + float3 rgb1 = float3(0, 0.129, 0.522); // blue + float3 rgb2 = float3(0.988, 0.827, 0); // yellow + float t = 0.5; // mixing ratio + + float3 rgb_mix = MixboxLerp(rgb1, rgb2, t); + + return float4(rgb_mix, 1.0); +} +``` +```hlsl +float3 MixThree(float3 rgb1, float3 rgb2, float3 rgb3) +{ + MixboxLatent z1 = MixboxRGBToLatent(rgb1); + MixboxLatent z2 = MixboxRGBToLatent(rgb2); + MixboxLatent z3 = MixboxRGBToLatent(rgb3); + + // mix together 30% of rgb1, 60% of rgb2, and 10% of rgb3 + MixboxLatent zMix = 0.3*z1 + 0.6*z2 + 0.1*z3; + + float3 rgbMix = MixboxLatentToRGB(zMix); + + return rgbMix; +} +``` + +## Metal Shader +```metal +#include +using namespace metal; + +// uncomment the following line if you work in linear space +// #define MIXBOX_COLORSPACE_LINEAR + +#include "mixbox.metal" + +fragment float4 // load "mixbox_lut.png" into texture 0 +fragment_main(texture2d mixbox_lut [[texture(0)]]) +{ + float3 rgb1 = float3(0, 0.129, 0.522); // blue + float3 rgb2 = float3(0.988, 0.827, 0); // yellow + + float t = 0.5; // mixing ratio + + float3 rgb_mix = mixbox_lerp(mixbox_lut, rgb1, rgb2, t); + + return float4(rgb_mix, 1.0); +} +``` +```metal +float3 mix_three(texture2d mixbox_lut, + float3 rgb1, float3 rgb2, float3 rgb3) +{ + mixbox_latent z1 = mixbox_rgb_to_latent(mixbox_lut, rgb1); + mixbox_latent z2 = mixbox_rgb_to_latent(mixbox_lut, rgb2); + mixbox_latent z3 = mixbox_rgb_to_latent(mixbox_lut, rgb3); + + // mix together 30% of rgb1, 60% of rgb2, and 10% of rgb3 + mixbox_latent z_mix = 0.3*z1 + 0.6*z2 + 0.1*z3; + + float3 rgb_mix = mixbox_latent_to_rgb(z_mix); + + return rgb_mix; +} +``` + +## OSL Shader +```c +#include "mixbox.osl" + +shader mix( + color rgb1 = color(0.0, 0.015, 0.235), // blue + color rgb2 = color(0.973, 0.651, 0.0), // yellow + float t = 0.5, // mixing ratio + output color rgb_mix = 0 + ) +{ + rgb_mix = mixbox_lerp(rgb1, rgb2, t); +} +``` +```c +color mix_three(color rgb1, color rgb2, color rgb3) +{ + mixbox_latent z1 = mixbox_rgb_to_latent(rgb1); + mixbox_latent z2 = mixbox_rgb_to_latent(rgb2); + mixbox_latent z3 = mixbox_rgb_to_latent(rgb3); + + // mix together 30% of rgb1, 60% of rgb2, and 10% of rgb3 + mixbox_latent z_mix = 0.3*z1 + 0.6*z2 + 0.1*z3; + + color rgb_mix = mixbox_latent_to_rgb(z_mix); + + return rgb_mix; +} +``` + +## Pigment Colors +| Pigment | | RGB | Float RGB | Linear RGB | +| --- | --- |:----:|:----:|:----:| +| Cadmium Yellow | | 254, 236, 0 | 0.996, 0.925, 0.0 | 0.991, 0.839, 0.0 | +| Hansa Yellow | | 252, 211, 0 | 0.988, 0.827, 0.0 | 0.973, 0.651, 0.0 | +| Cadmium Orange | | 255, 105, 0 | 1.0, 0.412, 0.0 | 1.0, 0.141, 0.0 | +| Cadmium Red | | 255, 39, 2 | 1.0, 0.153, 0.008 | 1.0, 0.02, 0.001 | +| Quinacridone Magenta | | 128, 2, 46 | 0.502, 0.008, 0.18 | 0.216, 0.001, 0.027 | +| Cobalt Violet | | 78, 0, 66 | 0.306, 0.0, 0.259 | 0.076, 0.0, 0.054 | +| Ultramarine Blue | | 25, 0, 89 | 0.098, 0.0, 0.349 | 0.01, 0.0, 0.1 | +| Cobalt Blue | | 0, 33, 133 | 0.0, 0.129, 0.522 | 0.0, 0.015, 0.235 | +| Phthalo Blue | | 13, 27, 68 | 0.051, 0.106, 0.267 | 0.004, 0.011, 0.058 | +| Phthalo Green | | 0, 60, 50 | 0.0, 0.235, 0.196 | 0.0, 0.045, 0.032 | +| Permanent Green | | 7, 109, 22 | 0.027, 0.427, 0.086 | 0.002, 0.153, 0.008 | +| Sap Green | | 107, 148, 4 | 0.42, 0.58, 0.016 | 0.147, 0.296, 0.001 | +| Burnt Sienna | | 123, 72, 0 | 0.482, 0.282, 0.0 | 0.198, 0.065, 0.0 | + +## License +Copyright (c) 2022, Secret Weapons. All rights reserved.
+Mixbox is provided under the CC BY-NC 4.0 license for non-commercial use only.
+If you want to obtain commercial license, please contact: mixbox@scrtwpns.com diff --git a/res/mixbox/README.md b/res/mixbox/README.md new file mode 100644 index 00000000..0f1acc57 --- /dev/null +++ b/res/mixbox/README.md @@ -0,0 +1,370 @@ +# Mixbox: Pigment-Based Color Mixing + +

+ +

+ +Mixbox is a new blending method for natural color mixing. It produces saturated gradients with hue shifts and natural secondary colors during blending. Yellow and blue make green. The interface is simple - RGB in, RGB out. Internally, Mixbox treats colors as real-life pigments using the Kubelka & Munk theory to predict realistic color behavior. That way, colors act like actual paints and bring more vibrance and intuition into digital painting. + +* Paper: https://scrtwpns.com/mixbox.pdf
+* Video: https://youtu.be/ATzVPVNp1qA
+* Talk: https://youtu.be/_qa5iWdfNKg
+* Demo: https://scrtwpns.com/mixbox/painter
+ +Mixbox is shipping in Rebelle 5 Pro as the [Rebelle Pigments](https://www.escapemotions.com/products/rebelle/about) feature and in the [Flip Fluids](https://flipfluids.com/) addon for Blender. + +## Usage +- [C / C++](cpp): `#include "mixbox.h"` and build `mixbox.cpp` together with your project +- [C#](csharp): use Mixbox package from NuGet `https://www.nuget.org/packages/Mixbox/2.0.0` +- [Java](java): add `implementation 'com.scrtwpns:mixbox:2.0.0'` to your Gradle +- [JavaScript](javascript): ` + + + +``` +## Node +```javascript +import mixbox from 'mixbox'; + +let rgb1 = "rgb(0, 33, 133)"; // blue +let rgb2 = "rgb(252, 211, 0)"; // yellow +let t = 0.5; // mixing ratio + +let mixed = mixbox.lerp(rgb1, rgb2, t); + +console.log(mixed); +``` + +## Java +```java +import java.awt.Color; +import com.scrtwpns.Mixbox; + +class HelloMixbox { + public static void main(String[] args) { + Color color1 = new Color(0, 33, 133); // blue + Color color2 = new Color(252, 211, 0); // yellow + float t = 0.5f; // mixing ratio + + Color colorMix = new Color(Mixbox.lerp(color1.getRGB(), color2.getRGB(), t)); + + System.out.print(colorMix); + } +} +``` + +## Android +```java +package com.example.hellomixbox; + +import android.app.Activity; +import android.os.Bundle; +import android.view.View; +import android.graphics.Color; + +import com.scrtwpns.Mixbox; + +public class MainActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + int color1 = Color.rgb(0, 33, 133); // blue + int color2 = Color.rgb(252, 211, 0); // yellow + float t = 0.5f; // mixing ratio + + int colorMix = Mixbox.lerp(color1, color2, t); + + View view = new View(this); + view.setBackgroundColor(colorMix); + setContentView(view); + } +} +``` + +## C# +```csharp +using System.Drawing; +using Scrtwpns.Mixbox; + +public class HelloMixbox +{ + public static void Main(string[] args) + { + Color color1 = Color.FromArgb(0, 33, 133); // blue + Color color2 = Color.FromArgb(252, 211, 0); // yellow + float t = 0.5f; // mixing ratio + + Color colorMix = Color.FromArgb(Mixbox.Lerp(color1.ToArgb(), color2.ToArgb(), t)); + + System.Console.WriteLine(colorMix); + } +} +``` + +## Unity +```csharp +using UnityEngine; +using Scrtwpns.Mixbox; + +public class NewBehaviourScript : MonoBehaviour +{ + void Start() + { + Color color1 = new Color(0.0f, 0.129f, 0.522f); // blue + Color color2 = new Color(0.988f, 0.827f, 0.0f); // yellow + float t = 0.5f; // mixing ratio + + Color colorMix = Mixbox.Lerp(color1, color2, t); + + Debug.Log(colorMix); + } +} +``` + +## Unity Shader +```ShaderLab +Shader "MixboxHelloShader" +{ + Properties + { + _MixboxLUT ("Mixbox LUT", 2D) = "white" {} // assign "Packages/Mixbox/Textures/MixboxLUT.png" + + _Color1 ("Color 1", Color) = (0, 0.129, 0.522, 1) // blue + _Color2 ("Color 2", Color) = (0.988, 0.827, 0, 1) // yellow + } + SubShader + { + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + + sampler2D _MixboxLUT; + #include "Packages/com.scrtwpns.mixbox/ShaderLibrary/Mixbox.cginc" + + fixed4 _Color1; + fixed4 _Color2; + + struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; + struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = v.uv; + return o; + } + + fixed4 frag (v2f i) : SV_Target + { + fixed4 mixedColor = MixboxLerp(_Color1, _Color2, i.uv.x); + return mixedColor; + } + ENDCG + } + } +} +``` + +## Unity Shader Graph +

+ +

+ +## Godot +```gdscript +var Mixbox = preload("res://addons/mixbox/mixbox.gd") + +var color1 = Color(0.0, 0.129, 0.522) # blue +var color2 = Color(0.988, 0.827, 0.0) # yellow +var t = 0.5 # mixing ratio + +var color_mix = Mixbox.lerp(color1, color2, t) + +print(color_mix) +``` + +## Godot Shader +```glsl +shader_type canvas_item; + +uniform sampler2D mixbox_lut; // attach "addons/mixbox/mixbox_lut.png" here + +uniform vec4 color1 : hint_color = vec4(0.0, 0.129, 0.522, 1.0); // blue +uniform vec4 color2 : hint_color = vec4(0.988, 0.827, 0.0, 1.0); // yellow + +#include "addons/mixbox/mixbox.gdshaderinc" + +void fragment() { + COLOR = mixbox_lerp(color1, color2, UV.x); +} +``` + +## Godot VisualShader +

+ +

+ +## WebGL +```html + +``` +```javascript +var shader = ` + precision highp float; + + uniform sampler2D mixbox_lut; // bind mixbox.lutTexture(gl) here + + #include "mixbox.glsl" + + void main(void) { + vec3 rgb1 = vec3(0, 0.129, 0.522); // blue + vec3 rgb2 = vec3(0.988, 0.827, 0); // yellow + float t = 0.5; // mixing ratio + + vec3 rgb = mixbox_lerp(rgb1, rgb2, t); + + gl_FragColor = vec4(rgb, 1.0); + } +`; + +shader = shader.replace('#include "mixbox.glsl"', mixbox.glsl()); +``` +```javascript +gl.useProgram(shaderProgram); +gl.activeTexture(gl.TEXTURE0); +gl.bindTexture(gl.TEXTURE_2D, mixbox.lutTexture(gl)); +gl.uniform1i(gl.getUniformLocation(shaderProgram, "mixbox_lut"), 0); +``` + +## Examples + +| Gradients | Mountains | Palette Snakes | +|:---:|:---:|:---:| +| | | | +| [source code](javascript/examples/gradients.js) | [source code](javascript/examples/mountains.js) | [source code](javascript/examples/palette.js) | + +| Splash Art | Paint Mixer | Pigment Fluids | +|:---:|:---:|:---:| +| | | | +| [source code](javascript/examples/splash.html) | [source code](javascript/examples/mixer.js) | [source code](https://scrtwpns.com/mixbox/fluids/script.js) | + +## Painter +

+ +

+This painting app runs two color mixing implementations in parallel: one based on Mixbox and the other that performs ordinary RGB mixing. The app allows switching between them on the fly, showing the differences between pigment-based mixing and the normal RGB mixing. To launch the painter in your browser, please click here. + +## License +Copyright (c) 2022, Secret Weapons. All rights reserved.
+Mixbox is provided under the CC BY-NC 4.0 license for non-commercial use only.
+If you want to obtain commercial license, please contact: mixbox@scrtwpns.com diff --git a/res/mixbox/mixbox.glsl b/res/mixbox/mixbox.glsl new file mode 100644 index 00000000..5ce29572 --- /dev/null +++ b/res/mixbox/mixbox.glsl @@ -0,0 +1,173 @@ +// ========================================================== +// MIXBOX 2.0 (c) 2022 Secret Weapons. All rights reserved. +// License: Creative Commons Attribution-NonCommercial 4.0 +// Authors: Sarka Sochorova and Ondrej Jamriska +// ========================================================== +// +// BASIC USAGE +// +// vec3 rgb = mixbox_lerp(rgb1, rgb2, t); +// +// MULTI-COLOR MIXING +// +// mixbox_latent z1 = mixbox_rgb_to_latent(rgb1); +// mixbox_latent z2 = mixbox_rgb_to_latent(rgb2); +// mixbox_latent z3 = mixbox_rgb_to_latent(rgb3); +// +// // mix 30% of rgb1, 60% of rgb2, and 10% of rgb3 +// mixbox_latent z_mix = 0.3*z1 + 0.6*z2 + 0.1*z3; +// +// vec3 rgb_mix = mixbox_latent_to_rgb(z_mix); +// +// PIGMENT COLORS +// +// Cadmium Yellow 0.996, 0.925, 0.000 +// Hansa Yellow 0.988, 0.827, 0.000 +// Cadmium Orange 1.000, 0.412, 0.000 +// Cadmium Red 1.000, 0.153, 0.008 +// Quinacridone Magenta 0.502, 0.008, 0.180 +// Cobalt Violet 0.306, 0.000, 0.259 +// Ultramarine Blue 0.098, 0.000, 0.349 +// Cobalt Blue 0.000, 0.129, 0.522 +// Phthalo Blue 0.051, 0.106, 0.267 +// Phthalo Green 0.000, 0.235, 0.196 +// Permanent Green 0.027, 0.427, 0.086 +// Sap Green 0.420, 0.580, 0.016 +// Burnt Sienna 0.482, 0.282, 0.000 +// +// LICENSING +// +// If you want to obtain commercial license, please +// contact us at: mixbox@scrtwpns.com +// + +#ifndef MIXBOX_INCLUDED +#define MIXBOX_INCLUDED + +#ifndef MIXBOX_LUT + #if __VERSION__ <= 120 + #define MIXBOX_LUT(UV) texture2D(mixbox_lut, UV) + #else + #define MIXBOX_LUT(UV) textureLod(mixbox_lut, UV, 0.0) + #endif +#endif + +#define mixbox_latent mat3 + +vec3 mixbox_eval_polynomial(vec3 c) +{ + float c0 = c[0]; + float c1 = c[1]; + float c2 = c[2]; + float c3 = 1.0 - (c0 + c1 + c2); + + float c00 = c0 * c0; + float c11 = c1 * c1; + float c22 = c2 * c2; + float c01 = c0 * c1; + float c02 = c0 * c2; + float c12 = c1 * c2; + float c33 = c3 * c3; + + return (c0*c00) * vec3(+0.07717053, +0.02826978, +0.24832992) + + (c1*c11) * vec3(+0.95912302, +0.80256528, +0.03561839) + + (c2*c22) * vec3(+0.74683774, +0.04868586, +0.00000000) + + (c3*c33) * vec3(+0.99518138, +0.99978149, +0.99704802) + + (c00*c1) * vec3(+0.04819146, +0.83363781, +0.32515377) + + (c01*c1) * vec3(-0.68146950, +1.46107803, +1.06980936) + + (c00*c2) * vec3(+0.27058419, -0.15324870, +1.98735057) + + (c02*c2) * vec3(+0.80478189, +0.67093710, +0.18424500) + + (c00*c3) * vec3(-0.35031003, +1.37855826, +3.68865000) + + (c0*c33) * vec3(+1.05128046, +1.97815239, +2.82989073) + + (c11*c2) * vec3(+3.21607125, +0.81270228, +1.03384539) + + (c1*c22) * vec3(+2.78893374, +0.41565549, -0.04487295) + + (c11*c3) * vec3(+3.02162577, +2.55374103, +0.32766114) + + (c1*c33) * vec3(+2.95124691, +2.81201112, +1.17578442) + + (c22*c3) * vec3(+2.82677043, +0.79933038, +1.81715262) + + (c2*c33) * vec3(+2.99691099, +1.22593053, +1.80653661) + + (c01*c2) * vec3(+1.87394106, +2.05027182, -0.29835996) + + (c01*c3) * vec3(+2.56609566, +7.03428198, +0.62575374) + + (c02*c3) * vec3(+4.08329484, -1.40408358, +2.14995522) + + (c12*c3) * vec3(+6.00078678, +2.55552042, +1.90739502); +} + +float mixbox_srgb_to_linear(float x) +{ + return (x >= 0.04045) ? pow((x + 0.055) / 1.055, 2.4) : x/12.92; +} + +float mixbox_linear_to_srgb(float x) +{ + return (x >= 0.0031308) ? 1.055*pow(x, 1.0/2.4) - 0.055 : 12.92*x; +} + +vec3 mixbox_srgb_to_linear(vec3 rgb) +{ + return vec3(mixbox_srgb_to_linear(rgb.r), + mixbox_srgb_to_linear(rgb.g), + mixbox_srgb_to_linear(rgb.b)); +} + +vec3 mixbox_linear_to_srgb(vec3 rgb) +{ + return vec3(mixbox_linear_to_srgb(rgb.r), + mixbox_linear_to_srgb(rgb.g), + mixbox_linear_to_srgb(rgb.b)); +} + +mixbox_latent mixbox_rgb_to_latent(vec3 rgb) +{ +#ifdef MIXBOX_COLORSPACE_LINEAR + rgb = mixbox_linear_to_srgb(clamp(rgb, 0.0, 1.0)); +#else + rgb = clamp(rgb, 0.0, 1.0); +#endif + + float x = rgb.r * 63.0; + float y = rgb.g * 63.0; + float z = rgb.b * 63.0; + + float iz = floor(z); + + float x0 = mod(iz, 8.0) * 64.0; + float y0 = floor(iz / 8.0) * 64.0; + + float x1 = mod(iz + 1.0, 8.0) * 64.0; + float y1 = floor((iz + 1.0) / 8.0) * 64.0; + + vec2 uv0 = vec2(x0 + x + 0.5, y0 + y + 0.5) / 512.0; + vec2 uv1 = vec2(x1 + x + 0.5, y1 + y + 0.5) / 512.0; + + if (MIXBOX_LUT(vec2(0.5, 0.5) / 512.0).b < 0.1) + { + uv0.y = 1.0 - uv0.y; + uv1.y = 1.0 - uv1.y; + } + + vec3 c = mix(MIXBOX_LUT(uv0).rgb, MIXBOX_LUT(uv1).rgb, z - iz); + + return mixbox_latent(c, rgb - mixbox_eval_polynomial(c), vec3(0.0)); +} + +vec3 mixbox_latent_to_rgb(mixbox_latent latent) +{ + vec3 rgb = clamp(mixbox_eval_polynomial(latent[0]) + latent[1], 0.0, 1.0); + +#ifdef MIXBOX_COLORSPACE_LINEAR + return mixbox_srgb_to_linear(rgb); +#else + return rgb; +#endif +} + +vec3 mixbox_lerp(vec3 color1, vec3 color2, float t) +{ + return mixbox_latent_to_rgb((1.0-t)*mixbox_rgb_to_latent(color1) + t*mixbox_rgb_to_latent(color2)); +} + +vec4 mixbox_lerp(vec4 color1, vec4 color2, float t) +{ + return vec4(mixbox_lerp(color1.rgb, color2.rgb, t), mix(color1.a, color2.a, t)); +} + +#endif diff --git a/res/mixbox/mixbox_lut.png b/res/mixbox/mixbox_lut.png new file mode 100644 index 00000000..af21715b Binary files /dev/null and b/res/mixbox/mixbox_lut.png differ diff --git a/src/Module_Nodes/Module_Nodes.cpp b/src/Module_Nodes/Module_Nodes.cpp index 6733d16d..a790994c 100644 --- a/src/Module_Nodes/Module_Nodes.cpp +++ b/src/Module_Nodes/Module_Nodes.cpp @@ -300,6 +300,7 @@ void Module_Nodes::render_impl(RenderParams in, UpdateContext_Ref update_ctx) shader.set_uniform("_camera2D_inverse", glm::inverse(in.provider(Cool::Input_Camera2D{}))); shader.set_uniform("_height", in.provider(Cool::Input_Height{})); shader.set_uniform("_aspect_ratio", in.provider(Cool::Input_AspectRatio{})); + shader.set_uniform_texture("mixbox_lut", Cool::TextureLibrary_FromFile::instance().get(Cool::Path::root() / "res/mixbox/mixbox_lut.png")->id()); shader.set_uniform_texture( "_previous_frame_texture", diff --git a/src/Module_Nodes/gen_primitive_types.py b/src/Module_Nodes/gen_primitive_types.py index 0c0a2eeb..9a62b7c3 100644 --- a/src/Module_Nodes/gen_primitive_types.py +++ b/src/Module_Nodes/gen_primitive_types.py @@ -434,7 +434,7 @@ def gen_code(in_vec: str, out_vec: str, implementation: str): in_vec=vec_type(dimension(color1) + 1), out_vec=vec_type(dimension(color2)), implementation=f""" - {vec_type(dimension(color2))} to = {color_conversion}(from.{color_components} / saturate(from.{alpha_component})); + {vec_type(dimension(color2))} to = {color_conversion}(unpremultiply(from.{color_components}, from.{alpha_component})); return to; """, ) @@ -471,8 +471,8 @@ def gen_code(in_vec: str, out_vec: str, implementation: str): out_vec=vec_type(dimension(color2) + 1), implementation=f""" // We need to unpremultiply for the color conversion, and re-premultiply afterwards - {vec_type(dimension(color2))} to = {color_conversion}(from.{color_components} / saturate(from.{alpha_component})); - return {vec_type(dimension(color2)+1)}(to * saturate(from.{alpha_component}), from.{alpha_component}); + {vec_type(dimension(color2))} to = {color_conversion}(unpremultiply(from.{color_components}, from.{alpha_component})); + return {vec_type(dimension(color2)+1)}(premultiply(to, from.{alpha_component}), from.{alpha_component}); """, ) case "_PremultipliedA", "_StraightA": @@ -480,7 +480,7 @@ def gen_code(in_vec: str, out_vec: str, implementation: str): in_vec=vec_type(dimension(color1) + 1), out_vec=vec_type(dimension(color2) + 1), implementation=f""" - {vec_type(dimension(color2))} to = {color_conversion}(from.{color_components} / saturate(from.{alpha_component})); + {vec_type(dimension(color2))} to = {color_conversion}(unpremultiply(from.{color_components}, from.{alpha_component})); return {vec_type(dimension(color2)+1)}(to, from.{alpha_component}); """, ) @@ -490,7 +490,7 @@ def gen_code(in_vec: str, out_vec: str, implementation: str): out_vec=vec_type(dimension(color2) + 1), implementation=f""" {vec_type(dimension(color2))} to = {color_conversion}(from.{color_components}); - return {vec_type(dimension(color2)+1)}(to * saturate(from.{alpha_component}), from.{alpha_component}); + return {vec_type(dimension(color2)+1)}(premultiply(to, from.{alpha_component}), from.{alpha_component}); """, ) return res diff --git a/src/Module_Nodes/generate_shader_code.cpp b/src/Module_Nodes/generate_shader_code.cpp index ec241f7c..97b566c7 100644 --- a/src/Module_Nodes/generate_shader_code.cpp +++ b/src/Module_Nodes/generate_shader_code.cpp @@ -75,6 +75,8 @@ out vec4 out_Color; // TODO(JF) Move this to the 3D Renderer node #include "_ROOT_FOLDER_/res/3D-renderer.glsl" +uniform sampler2D mixbox_lut; // The uniform must have this exact name that mixbox.glsl expects. +#include "_ROOT_FOLDER_/res/mixbox/mixbox.glsl" vec2 to_view_space(vec2 uv) {{ diff --git a/src/Module_Nodes/generated/implicit_color_conversions.inl b/src/Module_Nodes/generated/implicit_color_conversions.inl index 7d9cc7e7..6ca48ad2 100644 --- a/src/Module_Nodes/generated/implicit_color_conversions.inl +++ b/src/Module_Nodes/generated/implicit_color_conversions.inl @@ -62,7 +62,7 @@ if (from == PrimitiveType::Oklab_StraightA && to == PrimitiveType::Oklab_Premult { vec3 to = (from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -77,7 +77,7 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::Oklab) vec3 Coollab_Oklab_from_Oklab_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = (from.xyz / saturate(from.a)); + vec3 to = (unpremultiply(from.xyz, from.a)); return to; } @@ -93,7 +93,7 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::Oklab_St vec4 Coollab_Oklab_StraightA_from_Oklab_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = (from.xyz / saturate(from.a)); + vec3 to = (unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -190,7 +190,7 @@ if (from == PrimitiveType::Oklab_StraightA && to == PrimitiveType::LinearRGB_Pre { vec3 to = Cool_LinearRGB_from_Oklab(from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -205,7 +205,7 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::LinearRG vec3 Coollab_LinearRGB_from_Oklab_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_LinearRGB_from_Oklab(from.xyz / saturate(from.a)); + vec3 to = Cool_LinearRGB_from_Oklab(unpremultiply(from.xyz, from.a)); return to; } @@ -221,7 +221,7 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::LinearRG vec4 Coollab_LinearRGB_StraightA_from_Oklab_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_LinearRGB_from_Oklab(from.xyz / saturate(from.a)); + vec3 to = Cool_LinearRGB_from_Oklab(unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -238,8 +238,8 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::LinearRG { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_LinearRGB_from_Oklab(from.xyz / saturate(from.a)); - return vec4(to * saturate(from.a), from.a); + vec3 to = Cool_LinearRGB_from_Oklab(unpremultiply(from.xyz, from.a)); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -335,7 +335,7 @@ if (from == PrimitiveType::Oklab_StraightA && to == PrimitiveType::sRGB_Premulti { vec3 to = Cool_sRGB_from_Oklab(from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -350,7 +350,7 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::sRGB) vec3 Coollab_sRGB_from_Oklab_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_sRGB_from_Oklab(from.xyz / saturate(from.a)); + vec3 to = Cool_sRGB_from_Oklab(unpremultiply(from.xyz, from.a)); return to; } @@ -366,7 +366,7 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::sRGB_Str vec4 Coollab_sRGB_StraightA_from_Oklab_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_sRGB_from_Oklab(from.xyz / saturate(from.a)); + vec3 to = Cool_sRGB_from_Oklab(unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -383,8 +383,8 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::sRGB_Pre { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_sRGB_from_Oklab(from.xyz / saturate(from.a)); - return vec4(to * saturate(from.a), from.a); + vec3 to = Cool_sRGB_from_Oklab(unpremultiply(from.xyz, from.a)); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -480,7 +480,7 @@ if (from == PrimitiveType::Oklab_StraightA && to == PrimitiveType::Okhsl_Premult { vec3 to = Cool_Okhsl_from_Oklab(from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -495,7 +495,7 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::Okhsl) vec3 Coollab_Okhsl_from_Oklab_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_Okhsl_from_Oklab(from.xyz / saturate(from.a)); + vec3 to = Cool_Okhsl_from_Oklab(unpremultiply(from.xyz, from.a)); return to; } @@ -511,7 +511,7 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::Okhsl_St vec4 Coollab_Okhsl_StraightA_from_Oklab_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_Okhsl_from_Oklab(from.xyz / saturate(from.a)); + vec3 to = Cool_Okhsl_from_Oklab(unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -528,8 +528,8 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::Okhsl_Pr { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_Okhsl_from_Oklab(from.xyz / saturate(from.a)); - return vec4(to * saturate(from.a), from.a); + vec3 to = Cool_Okhsl_from_Oklab(unpremultiply(from.xyz, from.a)); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -625,7 +625,7 @@ if (from == PrimitiveType::Oklab_StraightA && to == PrimitiveType::Float_Premult { float to = Cool_Float_from_Oklab(from.xyz); - return vec2(to * saturate(from.a), from.a); + return vec2(premultiply(to, from.a), from.a); } )STR", @@ -640,7 +640,7 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::Float) float Coollab_Float_from_Oklab_PremultipliedA/*coollabdef*/(vec4 from) { - float to = Cool_Float_from_Oklab(from.xyz / saturate(from.a)); + float to = Cool_Float_from_Oklab(unpremultiply(from.xyz, from.a)); return to; } @@ -656,7 +656,7 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::Float_St vec2 Coollab_Float_StraightA_from_Oklab_PremultipliedA/*coollabdef*/(vec4 from) { - float to = Cool_Float_from_Oklab(from.xyz / saturate(from.a)); + float to = Cool_Float_from_Oklab(unpremultiply(from.xyz, from.a)); return vec2(to, from.a); } @@ -673,8 +673,8 @@ if (from == PrimitiveType::Oklab_PremultipliedA && to == PrimitiveType::Float_Pr { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - float to = Cool_Float_from_Oklab(from.xyz / saturate(from.a)); - return vec2(to * saturate(from.a), from.a); + float to = Cool_Float_from_Oklab(unpremultiply(from.xyz, from.a)); + return vec2(premultiply(to, from.a), from.a); } )STR", @@ -770,7 +770,7 @@ if (from == PrimitiveType::LinearRGB_StraightA && to == PrimitiveType::Oklab_Pre { vec3 to = Cool_Oklab_from_LinearRGB(from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -785,7 +785,7 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::Okla vec3 Coollab_Oklab_from_LinearRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_Oklab_from_LinearRGB(from.xyz / saturate(from.a)); + vec3 to = Cool_Oklab_from_LinearRGB(unpremultiply(from.xyz, from.a)); return to; } @@ -801,7 +801,7 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::Okla vec4 Coollab_Oklab_StraightA_from_LinearRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_Oklab_from_LinearRGB(from.xyz / saturate(from.a)); + vec3 to = Cool_Oklab_from_LinearRGB(unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -818,8 +818,8 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::Okla { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_Oklab_from_LinearRGB(from.xyz / saturate(from.a)); - return vec4(to * saturate(from.a), from.a); + vec3 to = Cool_Oklab_from_LinearRGB(unpremultiply(from.xyz, from.a)); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -883,7 +883,7 @@ if (from == PrimitiveType::LinearRGB_StraightA && to == PrimitiveType::LinearRGB { vec3 to = (from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -898,7 +898,7 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::Line vec3 Coollab_LinearRGB_from_LinearRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = (from.xyz / saturate(from.a)); + vec3 to = (unpremultiply(from.xyz, from.a)); return to; } @@ -914,7 +914,7 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::Line vec4 Coollab_LinearRGB_StraightA_from_LinearRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = (from.xyz / saturate(from.a)); + vec3 to = (unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -1011,7 +1011,7 @@ if (from == PrimitiveType::LinearRGB_StraightA && to == PrimitiveType::sRGB_Prem { vec3 to = Cool_sRGB_from_LinearRGB(from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -1026,7 +1026,7 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::sRGB vec3 Coollab_sRGB_from_LinearRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_sRGB_from_LinearRGB(from.xyz / saturate(from.a)); + vec3 to = Cool_sRGB_from_LinearRGB(unpremultiply(from.xyz, from.a)); return to; } @@ -1042,7 +1042,7 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::sRGB vec4 Coollab_sRGB_StraightA_from_LinearRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_sRGB_from_LinearRGB(from.xyz / saturate(from.a)); + vec3 to = Cool_sRGB_from_LinearRGB(unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -1059,8 +1059,8 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::sRGB { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_sRGB_from_LinearRGB(from.xyz / saturate(from.a)); - return vec4(to * saturate(from.a), from.a); + vec3 to = Cool_sRGB_from_LinearRGB(unpremultiply(from.xyz, from.a)); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -1156,7 +1156,7 @@ if (from == PrimitiveType::LinearRGB_StraightA && to == PrimitiveType::Okhsl_Pre { vec3 to = Cool_Okhsl_from_LinearRGB(from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -1171,7 +1171,7 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::Okhs vec3 Coollab_Okhsl_from_LinearRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_Okhsl_from_LinearRGB(from.xyz / saturate(from.a)); + vec3 to = Cool_Okhsl_from_LinearRGB(unpremultiply(from.xyz, from.a)); return to; } @@ -1187,7 +1187,7 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::Okhs vec4 Coollab_Okhsl_StraightA_from_LinearRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_Okhsl_from_LinearRGB(from.xyz / saturate(from.a)); + vec3 to = Cool_Okhsl_from_LinearRGB(unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -1204,8 +1204,8 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::Okhs { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_Okhsl_from_LinearRGB(from.xyz / saturate(from.a)); - return vec4(to * saturate(from.a), from.a); + vec3 to = Cool_Okhsl_from_LinearRGB(unpremultiply(from.xyz, from.a)); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -1301,7 +1301,7 @@ if (from == PrimitiveType::LinearRGB_StraightA && to == PrimitiveType::Float_Pre { float to = Cool_Float_from_LinearRGB(from.xyz); - return vec2(to * saturate(from.a), from.a); + return vec2(premultiply(to, from.a), from.a); } )STR", @@ -1316,7 +1316,7 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::Floa float Coollab_Float_from_LinearRGB_PremultipliedA/*coollabdef*/(vec4 from) { - float to = Cool_Float_from_LinearRGB(from.xyz / saturate(from.a)); + float to = Cool_Float_from_LinearRGB(unpremultiply(from.xyz, from.a)); return to; } @@ -1332,7 +1332,7 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::Floa vec2 Coollab_Float_StraightA_from_LinearRGB_PremultipliedA/*coollabdef*/(vec4 from) { - float to = Cool_Float_from_LinearRGB(from.xyz / saturate(from.a)); + float to = Cool_Float_from_LinearRGB(unpremultiply(from.xyz, from.a)); return vec2(to, from.a); } @@ -1349,8 +1349,8 @@ if (from == PrimitiveType::LinearRGB_PremultipliedA && to == PrimitiveType::Floa { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - float to = Cool_Float_from_LinearRGB(from.xyz / saturate(from.a)); - return vec2(to * saturate(from.a), from.a); + float to = Cool_Float_from_LinearRGB(unpremultiply(from.xyz, from.a)); + return vec2(premultiply(to, from.a), from.a); } )STR", @@ -1446,7 +1446,7 @@ if (from == PrimitiveType::sRGB_StraightA && to == PrimitiveType::Oklab_Premulti { vec3 to = Cool_Oklab_from_sRGB(from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -1461,7 +1461,7 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::Oklab) vec3 Coollab_Oklab_from_sRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_Oklab_from_sRGB(from.xyz / saturate(from.a)); + vec3 to = Cool_Oklab_from_sRGB(unpremultiply(from.xyz, from.a)); return to; } @@ -1477,7 +1477,7 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::Oklab_Str vec4 Coollab_Oklab_StraightA_from_sRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_Oklab_from_sRGB(from.xyz / saturate(from.a)); + vec3 to = Cool_Oklab_from_sRGB(unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -1494,8 +1494,8 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::Oklab_Pre { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_Oklab_from_sRGB(from.xyz / saturate(from.a)); - return vec4(to * saturate(from.a), from.a); + vec3 to = Cool_Oklab_from_sRGB(unpremultiply(from.xyz, from.a)); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -1591,7 +1591,7 @@ if (from == PrimitiveType::sRGB_StraightA && to == PrimitiveType::LinearRGB_Prem { vec3 to = Cool_LinearRGB_from_sRGB(from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -1606,7 +1606,7 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::LinearRGB vec3 Coollab_LinearRGB_from_sRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_LinearRGB_from_sRGB(from.xyz / saturate(from.a)); + vec3 to = Cool_LinearRGB_from_sRGB(unpremultiply(from.xyz, from.a)); return to; } @@ -1622,7 +1622,7 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::LinearRGB vec4 Coollab_LinearRGB_StraightA_from_sRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_LinearRGB_from_sRGB(from.xyz / saturate(from.a)); + vec3 to = Cool_LinearRGB_from_sRGB(unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -1639,8 +1639,8 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::LinearRGB { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_LinearRGB_from_sRGB(from.xyz / saturate(from.a)); - return vec4(to * saturate(from.a), from.a); + vec3 to = Cool_LinearRGB_from_sRGB(unpremultiply(from.xyz, from.a)); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -1704,7 +1704,7 @@ if (from == PrimitiveType::sRGB_StraightA && to == PrimitiveType::sRGB_Premultip { vec3 to = (from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -1719,7 +1719,7 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::sRGB) vec3 Coollab_sRGB_from_sRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = (from.xyz / saturate(from.a)); + vec3 to = (unpremultiply(from.xyz, from.a)); return to; } @@ -1735,7 +1735,7 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::sRGB_Stra vec4 Coollab_sRGB_StraightA_from_sRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = (from.xyz / saturate(from.a)); + vec3 to = (unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -1832,7 +1832,7 @@ if (from == PrimitiveType::sRGB_StraightA && to == PrimitiveType::Okhsl_Premulti { vec3 to = Cool_Okhsl_from_sRGB(from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -1847,7 +1847,7 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::Okhsl) vec3 Coollab_Okhsl_from_sRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_Okhsl_from_sRGB(from.xyz / saturate(from.a)); + vec3 to = Cool_Okhsl_from_sRGB(unpremultiply(from.xyz, from.a)); return to; } @@ -1863,7 +1863,7 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::Okhsl_Str vec4 Coollab_Okhsl_StraightA_from_sRGB_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_Okhsl_from_sRGB(from.xyz / saturate(from.a)); + vec3 to = Cool_Okhsl_from_sRGB(unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -1880,8 +1880,8 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::Okhsl_Pre { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_Okhsl_from_sRGB(from.xyz / saturate(from.a)); - return vec4(to * saturate(from.a), from.a); + vec3 to = Cool_Okhsl_from_sRGB(unpremultiply(from.xyz, from.a)); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -1977,7 +1977,7 @@ if (from == PrimitiveType::sRGB_StraightA && to == PrimitiveType::Float_Premulti { float to = Cool_Float_from_sRGB(from.xyz); - return vec2(to * saturate(from.a), from.a); + return vec2(premultiply(to, from.a), from.a); } )STR", @@ -1992,7 +1992,7 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::Float) float Coollab_Float_from_sRGB_PremultipliedA/*coollabdef*/(vec4 from) { - float to = Cool_Float_from_sRGB(from.xyz / saturate(from.a)); + float to = Cool_Float_from_sRGB(unpremultiply(from.xyz, from.a)); return to; } @@ -2008,7 +2008,7 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::Float_Str vec2 Coollab_Float_StraightA_from_sRGB_PremultipliedA/*coollabdef*/(vec4 from) { - float to = Cool_Float_from_sRGB(from.xyz / saturate(from.a)); + float to = Cool_Float_from_sRGB(unpremultiply(from.xyz, from.a)); return vec2(to, from.a); } @@ -2025,8 +2025,8 @@ if (from == PrimitiveType::sRGB_PremultipliedA && to == PrimitiveType::Float_Pre { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - float to = Cool_Float_from_sRGB(from.xyz / saturate(from.a)); - return vec2(to * saturate(from.a), from.a); + float to = Cool_Float_from_sRGB(unpremultiply(from.xyz, from.a)); + return vec2(premultiply(to, from.a), from.a); } )STR", @@ -2122,7 +2122,7 @@ if (from == PrimitiveType::Okhsl_StraightA && to == PrimitiveType::Oklab_Premult { vec3 to = Cool_Oklab_from_Okhsl(from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -2137,7 +2137,7 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::Oklab) vec3 Coollab_Oklab_from_Okhsl_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_Oklab_from_Okhsl(from.xyz / saturate(from.a)); + vec3 to = Cool_Oklab_from_Okhsl(unpremultiply(from.xyz, from.a)); return to; } @@ -2153,7 +2153,7 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::Oklab_St vec4 Coollab_Oklab_StraightA_from_Okhsl_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_Oklab_from_Okhsl(from.xyz / saturate(from.a)); + vec3 to = Cool_Oklab_from_Okhsl(unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -2170,8 +2170,8 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::Oklab_Pr { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_Oklab_from_Okhsl(from.xyz / saturate(from.a)); - return vec4(to * saturate(from.a), from.a); + vec3 to = Cool_Oklab_from_Okhsl(unpremultiply(from.xyz, from.a)); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -2267,7 +2267,7 @@ if (from == PrimitiveType::Okhsl_StraightA && to == PrimitiveType::LinearRGB_Pre { vec3 to = Cool_LinearRGB_from_Okhsl(from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -2282,7 +2282,7 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::LinearRG vec3 Coollab_LinearRGB_from_Okhsl_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_LinearRGB_from_Okhsl(from.xyz / saturate(from.a)); + vec3 to = Cool_LinearRGB_from_Okhsl(unpremultiply(from.xyz, from.a)); return to; } @@ -2298,7 +2298,7 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::LinearRG vec4 Coollab_LinearRGB_StraightA_from_Okhsl_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_LinearRGB_from_Okhsl(from.xyz / saturate(from.a)); + vec3 to = Cool_LinearRGB_from_Okhsl(unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -2315,8 +2315,8 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::LinearRG { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_LinearRGB_from_Okhsl(from.xyz / saturate(from.a)); - return vec4(to * saturate(from.a), from.a); + vec3 to = Cool_LinearRGB_from_Okhsl(unpremultiply(from.xyz, from.a)); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -2412,7 +2412,7 @@ if (from == PrimitiveType::Okhsl_StraightA && to == PrimitiveType::sRGB_Premulti { vec3 to = Cool_sRGB_from_Okhsl(from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -2427,7 +2427,7 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::sRGB) vec3 Coollab_sRGB_from_Okhsl_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_sRGB_from_Okhsl(from.xyz / saturate(from.a)); + vec3 to = Cool_sRGB_from_Okhsl(unpremultiply(from.xyz, from.a)); return to; } @@ -2443,7 +2443,7 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::sRGB_Str vec4 Coollab_sRGB_StraightA_from_Okhsl_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = Cool_sRGB_from_Okhsl(from.xyz / saturate(from.a)); + vec3 to = Cool_sRGB_from_Okhsl(unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -2460,8 +2460,8 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::sRGB_Pre { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_sRGB_from_Okhsl(from.xyz / saturate(from.a)); - return vec4(to * saturate(from.a), from.a); + vec3 to = Cool_sRGB_from_Okhsl(unpremultiply(from.xyz, from.a)); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -2525,7 +2525,7 @@ if (from == PrimitiveType::Okhsl_StraightA && to == PrimitiveType::Okhsl_Premult { vec3 to = (from.xyz); - return vec4(to * saturate(from.a), from.a); + return vec4(premultiply(to, from.a), from.a); } )STR", @@ -2540,7 +2540,7 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::Okhsl) vec3 Coollab_Okhsl_from_Okhsl_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = (from.xyz / saturate(from.a)); + vec3 to = (unpremultiply(from.xyz, from.a)); return to; } @@ -2556,7 +2556,7 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::Okhsl_St vec4 Coollab_Okhsl_StraightA_from_Okhsl_PremultipliedA/*coollabdef*/(vec4 from) { - vec3 to = (from.xyz / saturate(from.a)); + vec3 to = (unpremultiply(from.xyz, from.a)); return vec4(to, from.a); } @@ -2653,7 +2653,7 @@ if (from == PrimitiveType::Okhsl_StraightA && to == PrimitiveType::Float_Premult { float to = Cool_Float_from_Okhsl(from.xyz); - return vec2(to * saturate(from.a), from.a); + return vec2(premultiply(to, from.a), from.a); } )STR", @@ -2668,7 +2668,7 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::Float) float Coollab_Float_from_Okhsl_PremultipliedA/*coollabdef*/(vec4 from) { - float to = Cool_Float_from_Okhsl(from.xyz / saturate(from.a)); + float to = Cool_Float_from_Okhsl(unpremultiply(from.xyz, from.a)); return to; } @@ -2684,7 +2684,7 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::Float_St vec2 Coollab_Float_StraightA_from_Okhsl_PremultipliedA/*coollabdef*/(vec4 from) { - float to = Cool_Float_from_Okhsl(from.xyz / saturate(from.a)); + float to = Cool_Float_from_Okhsl(unpremultiply(from.xyz, from.a)); return vec2(to, from.a); } @@ -2701,8 +2701,8 @@ if (from == PrimitiveType::Okhsl_PremultipliedA && to == PrimitiveType::Float_Pr { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - float to = Cool_Float_from_Okhsl(from.xyz / saturate(from.a)); - return vec2(to * saturate(from.a), from.a); + float to = Cool_Float_from_Okhsl(unpremultiply(from.xyz, from.a)); + return vec2(premultiply(to, from.a), from.a); } )STR", @@ -2798,7 +2798,7 @@ if (from == PrimitiveType::Float_StraightA && to == PrimitiveType::Oklab_Premult { vec3 to = Cool_Oklab_from_Float(from.x); - return vec4(to * saturate(from.y), from.y); + return vec4(premultiply(to, from.y), from.y); } )STR", @@ -2813,7 +2813,7 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::Oklab) vec3 Coollab_Oklab_from_Float_PremultipliedA/*coollabdef*/(vec2 from) { - vec3 to = Cool_Oklab_from_Float(from.x / saturate(from.y)); + vec3 to = Cool_Oklab_from_Float(unpremultiply(from.x, from.y)); return to; } @@ -2829,7 +2829,7 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::Oklab_St vec4 Coollab_Oklab_StraightA_from_Float_PremultipliedA/*coollabdef*/(vec2 from) { - vec3 to = Cool_Oklab_from_Float(from.x / saturate(from.y)); + vec3 to = Cool_Oklab_from_Float(unpremultiply(from.x, from.y)); return vec4(to, from.y); } @@ -2846,8 +2846,8 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::Oklab_Pr { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_Oklab_from_Float(from.x / saturate(from.y)); - return vec4(to * saturate(from.y), from.y); + vec3 to = Cool_Oklab_from_Float(unpremultiply(from.x, from.y)); + return vec4(premultiply(to, from.y), from.y); } )STR", @@ -2943,7 +2943,7 @@ if (from == PrimitiveType::Float_StraightA && to == PrimitiveType::LinearRGB_Pre { vec3 to = Cool_LinearRGB_from_Float(from.x); - return vec4(to * saturate(from.y), from.y); + return vec4(premultiply(to, from.y), from.y); } )STR", @@ -2958,7 +2958,7 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::LinearRG vec3 Coollab_LinearRGB_from_Float_PremultipliedA/*coollabdef*/(vec2 from) { - vec3 to = Cool_LinearRGB_from_Float(from.x / saturate(from.y)); + vec3 to = Cool_LinearRGB_from_Float(unpremultiply(from.x, from.y)); return to; } @@ -2974,7 +2974,7 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::LinearRG vec4 Coollab_LinearRGB_StraightA_from_Float_PremultipliedA/*coollabdef*/(vec2 from) { - vec3 to = Cool_LinearRGB_from_Float(from.x / saturate(from.y)); + vec3 to = Cool_LinearRGB_from_Float(unpremultiply(from.x, from.y)); return vec4(to, from.y); } @@ -2991,8 +2991,8 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::LinearRG { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_LinearRGB_from_Float(from.x / saturate(from.y)); - return vec4(to * saturate(from.y), from.y); + vec3 to = Cool_LinearRGB_from_Float(unpremultiply(from.x, from.y)); + return vec4(premultiply(to, from.y), from.y); } )STR", @@ -3088,7 +3088,7 @@ if (from == PrimitiveType::Float_StraightA && to == PrimitiveType::sRGB_Premulti { vec3 to = Cool_sRGB_from_Float(from.x); - return vec4(to * saturate(from.y), from.y); + return vec4(premultiply(to, from.y), from.y); } )STR", @@ -3103,7 +3103,7 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::sRGB) vec3 Coollab_sRGB_from_Float_PremultipliedA/*coollabdef*/(vec2 from) { - vec3 to = Cool_sRGB_from_Float(from.x / saturate(from.y)); + vec3 to = Cool_sRGB_from_Float(unpremultiply(from.x, from.y)); return to; } @@ -3119,7 +3119,7 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::sRGB_Str vec4 Coollab_sRGB_StraightA_from_Float_PremultipliedA/*coollabdef*/(vec2 from) { - vec3 to = Cool_sRGB_from_Float(from.x / saturate(from.y)); + vec3 to = Cool_sRGB_from_Float(unpremultiply(from.x, from.y)); return vec4(to, from.y); } @@ -3136,8 +3136,8 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::sRGB_Pre { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_sRGB_from_Float(from.x / saturate(from.y)); - return vec4(to * saturate(from.y), from.y); + vec3 to = Cool_sRGB_from_Float(unpremultiply(from.x, from.y)); + return vec4(premultiply(to, from.y), from.y); } )STR", @@ -3233,7 +3233,7 @@ if (from == PrimitiveType::Float_StraightA && to == PrimitiveType::Okhsl_Premult { vec3 to = Cool_Okhsl_from_Float(from.x); - return vec4(to * saturate(from.y), from.y); + return vec4(premultiply(to, from.y), from.y); } )STR", @@ -3248,7 +3248,7 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::Okhsl) vec3 Coollab_Okhsl_from_Float_PremultipliedA/*coollabdef*/(vec2 from) { - vec3 to = Cool_Okhsl_from_Float(from.x / saturate(from.y)); + vec3 to = Cool_Okhsl_from_Float(unpremultiply(from.x, from.y)); return to; } @@ -3264,7 +3264,7 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::Okhsl_St vec4 Coollab_Okhsl_StraightA_from_Float_PremultipliedA/*coollabdef*/(vec2 from) { - vec3 to = Cool_Okhsl_from_Float(from.x / saturate(from.y)); + vec3 to = Cool_Okhsl_from_Float(unpremultiply(from.x, from.y)); return vec4(to, from.y); } @@ -3281,8 +3281,8 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::Okhsl_Pr { // We need to unpremultiply for the color conversion, and re-premultiply afterwards - vec3 to = Cool_Okhsl_from_Float(from.x / saturate(from.y)); - return vec4(to * saturate(from.y), from.y); + vec3 to = Cool_Okhsl_from_Float(unpremultiply(from.x, from.y)); + return vec4(premultiply(to, from.y), from.y); } )STR", @@ -3346,7 +3346,7 @@ if (from == PrimitiveType::Float_StraightA && to == PrimitiveType::Float_Premult { float to = (from.x); - return vec2(to * saturate(from.y), from.y); + return vec2(premultiply(to, from.y), from.y); } )STR", @@ -3361,7 +3361,7 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::Float) float Coollab_Float_from_Float_PremultipliedA/*coollabdef*/(vec2 from) { - float to = (from.x / saturate(from.y)); + float to = (unpremultiply(from.x, from.y)); return to; } @@ -3377,7 +3377,7 @@ if (from == PrimitiveType::Float_PremultipliedA && to == PrimitiveType::Float_St vec2 Coollab_Float_StraightA_from_Float_PremultipliedA/*coollabdef*/(vec2 from) { - float to = (from.x / saturate(from.y)); + float to = (unpremultiply(from.x, from.y)); return vec2(to, from.y); }