Page MenuHome

ALPHA OVER: Node incorrectly does associated alpha over
Closed, ResolvedPublic

Description

The alpha over node functions incorrectly currently.

It should be possible to have an RGB value with zero alpha and result in an addition as the over operation should be:

Over.RGB + (Background.RGB * ( 1 - Over.Alpha) )

Currently, the code does a check for a less than or equal and does a direct copy at line 50:

static void do_alphaover_premul(bNode *UNUSED(node), float *out, float *src, float *over, float *fac)
{

if(over[3]<=0.0f) {
copy_v4_v4(out, src);
}

[...]

This is incorrect behavior and results in a broken composite if alpha is zero whereby a copy happens. The correct solution would be to change the sign to less than, or do away with it altogether and clamp the alpha to a zero value and permit the add of the values as opposed to copy:

if(over[3]<0.0f) {
copy_v4_v4(out, src);
}

NOTE: I've added a Color Ramp to clamp the output from the renderer as it is delivering negative alpha values and confusing the issue.

Event Timeline

Added a patch to fix this at http://projects.blender.org/tracker/index.php?func=detail&aid=29676&group_id=9&atid=127

patch applied on rev. 42814

Dalai Felinto (dfelinto) changed the task status from Unknown Status to Resolved.Dec 22 2011, 1:01 AM