Some Theory

Hey everyone,
One thing I’ve noticed about the compositing sub-forum is that there are tonnes of problems that could be easily solved with some simple knowledge of pixel mathematics, and knowing how the compositor actually works instead of how to use it.

So I’m going to outline what I think are the most important fundamental concepts in this post, and you guys can correct me if I’m wrong or unclear. I’m leaving out multi-pass compositing as it’s a big topic. Feel free to link people here, in fact please do!

1. Workings of an image file

In an RGBA image file there are 4 channels, a red, a green, a blue and an alpha channel. The red, green and blue channels affect the colour (or the amount of red, R, green, G, or blue, B) in that image. The alpha channel usually affect the transparency of an image, but is sometimes ignored in situations where transparency does not apply (e.g. a desktop wallpaper).

In blender you can see this with the ‘split RGBA’ node.


2. Pixel Values

Each pixel in each channel has a value between 0 and 1, with 0 being zero brightness (black) and 1 being full brightness.

Black would be R0, G0, B0, and white would be R1, G1, B1. The colour red would be R1, G0, B0.

Blender handles pixel values that are greater than 1 for compositing purposes, but generally you should try to stay away from pixel values >1, as when you save to a format that only supports 0 to 1 pixel brightness any value >1 will be clipped and set to 1. Applying a normalise node will bring the brightest pixel down/up to 1 and scale the other values accordingly.

You can see this when selecting a colour with blender’s colour selector.

3. Pixel Maths

When blending one image over the other, e.g. with the mix node, an operation combines the pixel above with the pixel below. With, for example, two pixels, where the top pixel has a value of 0.25 and the bottom pixel has a value of 0.5, using the mix node in addition will result in a pixel of value 0.75 (that is, 0.5 + 0.25) generally creating a brighter image. The same node set to multiply will multiply 0.5 by 0.25 resulting in a pixel of 0.125. Multiply generally results in darker images. The trick is to remember that we are generally dealing with values between 0 and 1.

4. The Alpha Channel

In this sub-forum, the alpha channel seems to throw up a lot of issues. It is often used to overlay one image onto another with an alpha over node, but can sometimes produce strange results. A big problem is often pre-multiplied alpha:

Pre-multiplied alpha is an attempt to give your computer less work to do when it comes to processing. When your computer draws one image over another, it has lots of calculations to do, one being to work out how intense the pixel is. For example, if there was a green pixel (G=1) that was 50% opaque (or had an alpha value of 0.5), to blend it properly you need to multiply the image by the alpha value, so the pixel would have a green value of 0.5. An image with pre-multiplied alpha has already had this calculation performed on it, so the original pixel would have a green value of 0.5.
So, in a nutshell, if you experience artefacts when overlaying images (or anything to do with alpha) it is a good idea to try toggling the premul button or using a ‘premul to key’ node.

5. HSV

This doesn’t seem to throw up loads of issues, but it’s useful to know. HSV is an alternative to RGB, instead of each pixel having a red, green and blue value, it has hue, saturation and value. Imagine a colour wheel, the hue is the rotation around the wheel, essentially the colour. The saturation is how intense the colour is, with 0 being white / grey and 1 being a bright colour. And the value is the overall intensity of the pixel.
This can make working with colour easier. For example, to create a grey scale image we can simply de-saturate the image.

6. VSE issues

I don’t know much about the vse, but here is a quick (and very short) FAQ courtesy of 3pointEdit:

VSE: Common Question number 1
Why is my video clip out of sync with the audio, they seem to be different lengths?

Answer: Make sure that the scene framerate and the video clip framerate matches. If not, you must remove the offending slips and change the scene settings.

VSE: Common Question number 2
Can I use the compositor for color correction or effects on my edited shots?

Answer: Not directly, the VSE output doesn’t go to the compositor nor can the same scene’s comp nodes go to the VSE. BUT another scenes comp nodes can.

VSE: Common Question number 3
Can I edit from a source window into my timeline with edit points?

Answer: Nope :frowning:

This is a nice short summation of re-occurring issues. Thanks Casio 23. Let’s hope it doesn’t disappear to quickly :wink: