Monday, 17 December 2007

Understanding Blending in the Visual Effects Editor plugin

Many things in the VEE plugin, and other things in NWN2 is about blending. The first thing I understood was that I didn't know enough about alpha blending (and still don't). When looking around I came to the conclusion that I'm not the only one left in the dark. So here's some small notes that may be helpful if you play the the VEE.

About this thing called Alpha Channel
Alpha compositing is the process of combining an image with a background to create the appearance of partial transparency. It is often useful to render image elements in separate passes, and then combine the resulting multiple 2D images into a single, final image in a process called compositing. For example, compositing is used extensively when combining computer rendered image elements with live footage. Read more about it here.

Alpha Blending
With AB you can blend textures on a surface with transparacy on another surface. It also works with colours. The blending is determined by something called Source Blend and Destination Blend. Read more about it here.

Some of the Blends used in the VEE
  • Both blends use Inverse Source Alpha
    Each component of the source color is multiplied by the inverse of the alpha of the source color, and each component of the destination color is multiplied by the alpha of the source color. This can be represented as (1 − As, 1 − As, 1 − As, 1 − As), with a destination blend factor of (As, As, As, As); the destination blend selection is overridden.

  • Constant Blend Factor
    Each component of the color is multiplied by a constant.

  • Destination Alpha
    Each component of the color is multiplied by the alpha value of the destination. This can be represented as (Ad, Ad, Ad, Ad), where Ad is the destination alpha value.

  • Destination Color
    Each component color is multiplied by the destination color. This can be represented as (Rd, Gd, Bd, Ad), where R, G, B, and A respectively stand for red, green, blue, and alpha destination values.

  • Inverse Destination Alpha
    Each component of the color is multiplied by the inverse of the alpha value of the destination. This can be represented as (1 − Ad, 1 − Ad, 1 − Ad, 1 − Ad), where Ad is the alpha destination value.

  • Inverse Destination Color
    Each component of the color is multiplied by the inverse of the destination color. This can be represented as (1 − Rd, 1 − Gd, 1 − Bd, 1 − Ad), where Rd, Gd, Bd, and Ad respectively stand for the red, green, blue, and alpha destination values.

  • Inverse Source Alpha
    Each component of the color is multiplied by the inverse of the alpha value of the source. This can be represented as (1 − As, 1 − As, 1 − As, 1 − As), where As is the alpha destination value.

  • Inverse Source Color
    Each component of the color is multiplied by the inverse of the source color. This can be represented as (1 − Rs, 1 − Gs, 1 − Bs, 1 − As) where R, G, B, and A respectively stand for the red, green, blue, and alpha destination values.

  • Inverted Constant Blend Factor
    Each component of the color is multiplied by the inverse of a constant set in BlendFactor.

  • One
    Each component of the color is multiplied by (1, 1, 1, 1).

  • S0urce Alpha
    Each component of the color is multiplied by the alpha value of the source. This can be represented as (As, As, As, As), where As is the alpha source value.

  • Source Color
    Each component of the color is multiplied by the source color. This can be represented as (Rs, Gs, Bs, As), where R, G, B, and A respectively stand for the red, green, blue, and alpha source values.

  • Zero
    Each component of the color is multiplied by (0, 0, 0, 0).
This helped me a lot and I hope someone else will find it helpful.

/A

5 comments:

Anonymous said...

Thanks a lot! I asked for some information like this from Obsidian a long time age and didn't get anywhere. Much appreciated.

Ernie Noa said...

I failed my saving throw. I think that post just cast the equivalent of a feeblemind on me.

Amraphael said...

@jason:
Yes OE is a bit tight (or too busy) on sharing information on the tools they release. Maybe it's part of their recruiting policy. If they find out how it works - hire them :)

Amraphael said...

@ernie:
You gives up too easy, man! :D
It's not as hard as is look.

Ernie Noa said...

Yeah but if I start and figure it out, then I'd have an even bigger set of toys to play with (and be addicted too).

If I can figure out ASP.NET and MS SQL, and Photoshop (which I have handle on) I bet you are right. But it looks like a pandoras box I had best leave closed.