Several small fixes to nodes:

- Code formation fix in keying node
- Fixed crash when creating keying screen for frame where there's no movie
- Attempt to improve keying node to handle alpha on hair better
This commit is contained in:
Sergey Sharybin
2012-05-30 14:39:20 +00:00
parent 39e6acfb08
commit 6fb53f7c42
2 changed files with 9 additions and 6 deletions

View File

@@ -47,7 +47,7 @@ static float get_pixel_saturation(float *pixel, float screen_balance)
float mid = pixel[0] + pixel[1] + pixel[2] - min - max;
float val = (1.0f - screen_balance) * min + screen_balance * mid;
return max - val;
return (max - val) * (1.0f - val) * (1.0f - val);
}
KeyingOperation::KeyingOperation(): NodeOperation()
@@ -92,7 +92,7 @@ void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler
if (primary_channel != screen_primary_channel) {
/* different main channel means pixel is on foreground */
color[0] = 1.0f;
}
}
else if (saturation >= screen_saturation) {
/* saturation of main channel is more than screen, definitely a background */
color[0] = 0.0f;
@@ -102,7 +102,7 @@ void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler
distance = 1.0f - saturation / screen_saturation;
color[0] = distance;
color[0] = distance * distance;
if (color[0] < this->clipBlack)
color[0] = 0.0f;
@@ -110,5 +110,5 @@ void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler
color[0] = 1.0f;
else
color[0] = (color[0] - this->clipBlack) / (this->clipWhite - this->clipBlack);
}
}
}

View File

@@ -102,11 +102,14 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
if (!sites_total)
return NULL;
triangulation = (TriangulationData *) MEM_callocN(sizeof(TriangulationData), "keying screen triangulation data");
BKE_movieclip_user_set_frame(&user, framenumber);
ibuf = BKE_movieclip_get_ibuf(movieClip, &user);
if (!ibuf)
return NULL;
triangulation = (TriangulationData *) MEM_callocN(sizeof(TriangulationData), "keying screen triangulation data");
sites = (VoronoiSite *) MEM_callocN(sizeof(VoronoiSite) * sites_total, "keyingscreen voronoi sites");
track = (MovieTrackingTrack *) tracksbase->first;
i = 0;