Video with Alpha Channel in Sofdec

Sofdec provides high-quality, high-compression video encoding and supports many features useful for your games, like alpha channel. In this post, we will see how to produce a video file with alpha channel using the Sofdec encoder.

Video with Alpha channel

It is possible to encode video materials that include an alpha channel to create movies with transparency. These videos can be useful in many ways, from the creation of seamless transitions between gameplay and pre-rendered cinematics to the integration of animated effects and layers that blend perfectly with the game.

In order to be able to create an alpha video with the Sofdec encoder, the source material must be rendered with a color depth of 32 bits (ARGB8888). It will include 8 bits for the alpha channel information. The format must be AVI for a video file, or BMP or TGA if the input consists in a sequence of images.

With the source material in the good format, it is now possible to encode the video with the Sofdec encoder:

  • Run the Sofdec Encoding Wizard.
  • Select the target platform.

01 SofdecWizard

  • On the Video Source page, select a video file with an alpha channel (or the first image from a sequence).
  • Confirm that the color depth of the data is indeed 32-bit.
  • Then tick the Alpha Movie checkbox. If the option is not available, your source material is not in the correct format.
  • After setting the output destination and the other encoding parameters, launch the encoding process to create the usm file.

You can use the Sofdec Viewer tool to preview the alpha video you just created. In the View menu, change the Background to Checkered Pattern to confirm that the video has transparency.

02 Softdec viewer

Alpha Plus Movies

With conventional alpha blending, the edges of a semi-transparent object can become black. For this type of material, it is better to use additive blending instead. However, this means that two videos must be rendered, in order to use both alpha and additive blending.

Sofdec can create Alpha Plus Movies, which combine the two videos into one unique usm file. One video should contain the alpha composition and the other the additive composition. Since a unique usm file is required, the decoding load and memory consumption will be greatly reduced.

03 AlphaPlus Comparison

To create an Alpha Plus Movie, first export two separate videos from your original source:

  • A first video containing the color information that includes the additive composition.
    Format: AVI, Color depth: 32 bits, Color channels: RGB
  • A second video containing the alpha composition only.
    Format: AVI, Color depth: 32 bits, Color channels: RGB+Alpha, Alpha color: Pre-multiplied (Matted).

The two videos can then be combined and encoded by using the command line version of the Sofdec Encoder.

Here is the command to do that:

sofdecenc.exe -video00=".\Video_RGB.avi" -alpha00=".\Video_Alpha.avi" -scale=1280,720 -framerate=60 -bitrate=2000000 -output=".\AlphaPlus.usm" -work_dir="." -preview=OFF -gop_closed=on -gop_i=1 -gop_p=4 -gop_b=2

The main sub-commands are:

-video00: path of the file containing the color information and additive composition.
-alpha00: path of the file containing the alpha composition only.
-scale: resolution after encoding.
-bitrate: image quality after encoding.
-framerate: frame rate specification.
-alpha quality (optional):  compression ratio of the alpha channel (40% by default).

Running this command, a unique usm file containing both compositions is generated.

Alpha Plus Movies can also be previewed using the Sofdec Viewer tool. In the View menu, simply change the Blend Mode to Additive.

Playing Alpha videos in Unreal or Unity

Alpha videos are handled in the same way than regular videos in both Unreal and Unity. In Unreal, playback is initiated via the ManaComponent containing the Material Texture created when the usm file was imported. In Unity, the usm file can be played directly via a CriManaMovieController.

For Alpha Plus Movies, Alpha Plus support must be set to Yes when creating the Material Texture in Unreal. In Unity, simply activate the Additive Mode in the CriManaMovieController.

Unity and Unreal

Leave a Reply

Your email address will not be published. Required fields are marked *