Hello 2021!

Match Tint  [SUBMITTED]

Moderator: SecondMan

User avatar
Shem Namo
Fusionista
Posts: 650
Joined: Sun Oct 06, 2019 9:15 pm
Answers: 1
Location: North Israel
Real name: David Kohen
Been thanked: 2 times

Re: Match Tint

#16

Post by Shem Namo »

Sorry about that @SecondMan, here's the updated Atom.

Thanks again,
David
com.LearnNowFX.MatchTint.zip
You do not have the required permissions to view the files attached to this post.

User avatar
SecondMan
Site Admin
Posts: 4781
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 30
Location: Vancouver, Canada
Been thanked: 18 times
Contact:

Re: Match Tint

#17

Post by SecondMan »

No need to apologise for sharing ;)

Update available in Reactor now, thanks and please check :cheer:

User avatar
Chad
Fusionator
Posts: 1555
Joined: Fri Aug 08, 2014 1:11 pm

Re: Match Tint

#18

Post by Chad »

Shem Namo wrote: Mon Aug 24, 2020 9:57 am Nice Suggestion @Millolab !!
I don't know what's the algorithm for that, do you happen to know it?
Fusion includes image functions for this:
inimg:AlphaMultiply(outimg)
inimg:AlphaDivide(outimg)

User avatar
Shem Namo
Fusionista
Posts: 650
Joined: Sun Oct 06, 2019 9:15 pm
Answers: 1
Location: North Israel
Real name: David Kohen
Been thanked: 2 times

Re: Match Tint

#19

Post by Shem Namo »

Thanks @SecondMan, it all works as expected now. :)

Thanks @Chad, I really like the built in Image functions,
but I did notice that when you have a fuse that uses a DCTL kernel, using any of the Image functions makes the fuse significantly slower.

So I added the code to the GPU code instead, it's only like 12 lines.
Here's the GPU code:

Did I implement the Alpha Divide/Multiply right?

Thanks again,
David
Code: [Select all] [Expand/Collapse] [Download] (Match Tint.dctl)
  1. TintParams = [[
  2.   float colorW[3];
  3.   float colorB[3];
  4.   float amount;
  5.   float saturation;
  6.   int prePost;
  7.   int srcCompOrder;
  8. ]]
  9.  
  10. TintKernel = [[
  11. __KERNEL__ void TintKernel(__CONSTANTREF__ TintParams *params, __TEXTURE2D__ src,  __TEXTURE2D_WRITE__ dst) {
  12.     DEFINE_KERNEL_ITERATORS_XY(x, y);
  13.     float4 image = _tex2DVecN(src, x, y, params->srcCompOrder);
  14.     float3 white = to_float3_v(params->colorW);
  15.     float3 black = to_float3_v(params->colorB);
  16.     float amount = params->amount/100.0f;
  17.  
  18. if(params->prePost == 1){
  19.   if(image.w != 0.0f){ 
  20.     image.x /= image.w;
  21.     image.y /= image.w;
  22.     image.z /= image.w;
  23.   }
  24. }      
  25.       float saturation = params->saturation;
  26.       float luma = (image.x * 0.299f) + (image.y * 0.587f) + (image.z * 0.114f);
  27.       image.x = saturation * image.x + (1.0f - saturation) * luma;
  28.       image.y = saturation * image.y + (1.0f - saturation) * luma;
  29.       image.z = saturation * image.z + (1.0f - saturation) * luma;
  30.        
  31.       float3 color = to_float3(image.x, image.y, image.z);
  32.       float3 map = color;
  33.       map.x = _mix(black.x, white.x, color.x);
  34.       map.y = _mix(black.y, white.y, color.y);
  35.       map.z = _mix(black.z, white.z, color.z);
  36.  
  37.  
  38.       color.x = _mix(color.x, map.x, amount);
  39.       color.y = _mix(color.y, map.y, amount);
  40.       color.z = _mix(color.z, map.z, amount);
  41.  
  42.  
  43.        
  44.       image.x = color.x;
  45.       image.y = color.y;
  46.       image.z = color.z;
  47.  
  48. if(params->prePost == 1){
  49.     image.x *= image.w;
  50.     image.y *= image.w;
  51.     image.z *= image.w;
  52. }        
  53.        
  54.         _tex2DVec4Write(dst, x, y, image);
  55.     }
  56. ]]

User avatar
Shem Namo
Fusionista
Posts: 650
Joined: Sun Oct 06, 2019 9:15 pm
Answers: 1
Location: North Israel
Real name: David Kohen
Been thanked: 2 times

Re: Match Tint  [SUBMITTED]

#20

Post by Shem Namo »

Hi everyone,

When I was first making this fuse, I saw that in the After Effects "Tint" effect there is a convenient little button that allows you to automatically swap the 2 colors from the 2 color pickers.

I didn't know how to do this back then, but I finally figured it out.
Here is a little update with the button added.

Thanks again,
David
com.LearnNowFX.MatchTint.zip
You do not have the required permissions to view the files attached to this post.

User avatar
SecondMan
Site Admin
Posts: 4781
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 30
Location: Vancouver, Canada
Been thanked: 18 times
Contact:

Re: Match Tint

#21

Post by SecondMan »

Submitted, thanks! :cheer:

User avatar
Shem Namo
Fusionista
Posts: 650
Joined: Sun Oct 06, 2019 9:15 pm
Answers: 1
Location: North Israel
Real name: David Kohen
Been thanked: 2 times

Re: Match Tint

#22

Post by Shem Namo »

Thanks @SecondMan!!