Fill Alpha channel with any ( image or video )

fan-boy wrote on 3/25/2019, 1:42 PM

Vegas needs Recipes . It has the ingredients , We just need to know how to put it all together .


this project uses Chroma Key to cut a mask . Then the mask is stuffed into the alpha channel.

Chroma key technique with Vegas :

on the Green Screen source image , open FX Chroma Key and FX  Mask Generator .
In the  FX  Chain list , Chroma Key comes First , in the chain .

In Mask Generator , click the Invert button , because Mask Generator's only
purpose here is to invert the mask and nothing else .
In chroma key , click the "Show Mask" button .
With both ( Chroma Key and Mask Generator ) OFF , pick a color with eye dropper .

Now , turn chroma key ON . we are viewing the NON-inverted Mask because  chroma key
"Show Mask" is ON and  Mask Generator is OFF .
Adjust High Threshold slider to make the foreground Solid White .
Now turn ON Mask Generator to view Mask as  Inverted .
Adjust Low Threshold slider to make the screen area full White .
Screen area being ( Green or Blue ) background .
That should be a good mask .  Toggle Mask Generator ON\OFF to inspect both views .
Turn Mask Generator OFF , and un-check  "Show Mask" in chroma key . We are now viewing the cut as a final inspection .

Stuff the  Mask in the alpha channel :

Duplicate the above Track ( For use as  Track 1 and Track 3 )

For  Track 3 , in Chroma Key , check the box "Show Mask" , because we want to stuff the Mask into the alpha channel .

add new track into the middle of those 2 tracks , and use Generated Media  Solid Black on this new track 2 .

on Track 1 ( the duplicated track ) , Chroma key is OFF( Mask Generator is also OFF ) and
set it's alpha channel to full Black by using FX "Channel Blend" .Set all 4 of the bottom row "Alpha" digit boxes to -10.000
Enable  blend mode  ADD , to  track 1 .

Track 2  has Solid Black RGB Generated Media , with Solid White alpha channel .
Set track 2's blend mode to  Multiply . Track 2 is a Parent of track 3 .

Track 3 ( the original chroma key cut ) , is a child of track 2 . Because  "Show Mask" is ON
in Chroma Key ,  all 4 channels hold the same Mask image , thus the alpha channel has the Mask .
When track 2 multiplies with track 3 , the resultant RGB image goes to Solid Black , while the
alpha channel of this composite will be that of track 3's alpha channel( the Mask ) .

At this point we have 2  RGBA items :
Tack 1 is the original RGB image with an  all Black alpha channel .
the composite of tracks ( 2  3 )  is an all Black RGB image with the Mask in the alpha channel .

When those 2 entities are  added ( Track 1 uses "ADD" blend mode ) , the result is :
RGB of track 1 , with the alpha channel of track ( 2  3 ) composite , is the new entity image result .

Use Vegas Viewer icon Top right of viewer , "Save to file" , and choose  .png .
that will save a 32 bit image  with  RGBA  channels .

The Mask in the alpha channel might not line up perfectly with the original source image foreground ,
because of the external  "cut" that occurs , when the alpha gets used , upon  import .

Render video with  video for windows  .avi  uncompressed , check the box to include alpha .
Makes a 32 bit .avi uncompressed video with  RGBA  channels .
Some .mov formats render with alpha channel .

updated : included picture number 8 , which shows how to stuff the alpha channel with any RGB source , this requires the use of FX Channel Blend , on track 3 ( No chroma key this time ) . Track 3 remains a child of track 2 . Everything else in the project remains the same . We now realize , Any RGB content can be placed into the alpha channel .


karma17 wrote on 3/29/2019, 5:36 PM

Very informative. I really like these more advanced tutorials. Vegas is so underrated in terms of its compositing capabilities. Without tutorials like this, it can be virtually impossible to piece it all together. But it can be done! I've really got to study what you've put out here.

fan-boy wrote on 4/2/2019, 7:03 PM

I was just commenting : the easiest way to make an alpha channel in Vegas and Photoshop is to :

Ensure the image\outline shape does NOT paint on every pixel of the Project Settings size . The unpainted areas will be Black in the alpha channel , while the painted portions will be White . Transparency will be gray Tones in the alpha channel . Then save as 32 bit .png , or 32 vit .avi Video for Windows , or possibly 32 bit .mov .

No special compositing needed .


Update , April 4 , 2019 This project "Fill Alpha Channel with any ( image or Video )" is only possible when using GPU 32 bit . This project will NOT work when using 8 bit . Track 1 will NOT work as shown , when using 8 bit File-->Properties-->bit depth-->8 bit .

as far as i know , 8 bit mode does have proper functionality . The project only worked because there are issues with GPU 32 bit , when using Mask Generator , and when working with a Solid Black alpha channel ( Track 1 ) .

the 6th image , the Green image( Track 1 ) , is NOT possible when using 8 bit . The Solid Black alpha channel with "Source Alpha" blend mode will Self multiply to make the RGB turn black ( This is Normal ) . However , when GPU 32 bit was used , the RGB channels remained intact , as seen in image number 6 .

fan-boy wrote on 4/5/2019, 2:03 PM


The project has been fixed , to work with  8 bit color .
And , since this project avoids using Solid Black alpha channel ,
this Fixed project should also work with  GPU 32 bit .

Requires only  2  Tracks .
Track 2 uses  Chroma key to cut the Mask , with  "Show Mask" On ( same as before )
"Show Mask" puts the Mask in  all 4  channels ( same as before )

Next ,
include  FX "Channel Blend" on track 2 , after  Chroma Key , in the FX chain .
Set the 3  far right column boxes to  10.000  10.000  10.000 , of the  RGB  rows .
What this just did makes the  RGB  channels  Full White .
( Vegas Viewer does NOT show full white RGB , because the alpha channel holds the Black-White  Mask ,
  and "Source Alpha" blend mode continues to do it's inherent internal  multiply )
( that is the  "Twist" , don't always believe what the Vegas Viewer displays , even when Vegas is correct )
That "Twist" could be named one of those "Trap and Pitfalls" , to be aware of .

Next ,
make a new track 1  on Top , to hold the original source ( image or video ) ,
Use  Multiply blend mode on track 1 .  Track 2 is a child of track 1 .

What we have are 2 media :
Track 1  is  source RGB with  Solid White alpha channel
Track 2  is  Solid White RGB with  Mask in the alpha channel .
Multiplying  track 1 to track 2 causes the  source RGB of track 1
to be placed into the RGB , while the  Mask  remains the same , in the alpha channel .

The  result composite is :
source RGB image with Mask in  alpha channel .

Math side note :
Solid White( 1 ) * "anything" is equal to "anything" . That is why
RGB of track 1 is  preserved , and Mask in alpha channel is preserved .

This revised project does not excuse the fact that 32 bit and 8 bit project settings operate differently .

END fix  update April 5 , 2019

fan-boy wrote on 4/6/2019, 12:57 PM

Third time round . Finally , the expected perfect result . Never thought it would be so simple . I made a mess of it , but finally got there .No color fringe . The rendered media looks the same as the live chroma cut on the Time Line

Chroma key automatically places the un-seen mask , directly into the alpha channel . The RGB channels retain their values( except for the Green ) . The Green background will not be visible in the exported image because of the inherent internal "Source Alpha" blend mode is now using that new mask ( alpha channel is No longer Solid White ) . But that's ok , cause the Stuffed alpha channel works , The new exported source media has a perfect Mask cut . Done .

Be sure to test the import , with Straight , Pre-Multiplied , Pre-Multiplied Dirty , to see which one works best . Above , is using Pre-Multiplied , on Track 2 import .


The original goal was to be able to place Any content into the RGB channels , with Any content into the Alpha Channel , but , I guess that ain't gonna happen .