diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-11 11:46:36 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-11 11:46:36 +0400 |
commit | 4e213765ecd2d05251ead548b01a55b9f00d0ec0 (patch) | |
tree | c91eb916f3d71f0b63349dcc0b44866527eab2c7 /source/blender | |
parent | 315698543bfc675a0432b006a2fb94b4ed27b576 (diff) |
Fixes for keying screen:
- Fixed issue with black areas appearing when too many sites
are defined.
Currently tweak epsilon value for this, but probably actual
issue is somewhere else, can't see it yet.
- Fixed issue with bright pixels appearing in the sites, was
caused by accumulating color for pixels, which isn't needed.
Once color for pixel was set stop iterating via triangles.
Could give some speedup too.
- Ignore markers which are outside of frame bounds, they were
giving bad triangulation and they can't affect on gradient
due to color fir such sites is not known.
- Sites used to be created at position without track offset
taken into account.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/voronoi.c | 2 | ||||
-rw-r--r-- | source/blender/compositor/operations/COM_KeyingScreenOperation.cpp | 35 |
2 files changed, 29 insertions, 8 deletions
diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index eeb0187b74c..dc76fb1493d 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -39,7 +39,7 @@ #include "BLI_voronoi.h" #include "BLI_utildefines.h" -#define VORONOI_EPS 1e-3 +#define VORONOI_EPS 1e-2 enum { voronoiEventType_Site = 0, diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp index 53572162b9e..cf20712cfeb 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp @@ -104,10 +104,20 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri /* count sites */ for (track = (MovieTrackingTrack *) tracksbase->first, sites_total = 0; track; track = track->next) { MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame); + float pos[2]; - if ((marker->flag & MARKER_DISABLED) == 0) { - sites_total++; + if (marker->flag & MARKER_DISABLED) + continue; + + add_v2_v2v2(pos, marker->pos, track->offset); + + if (!IN_RANGE_INCL(pos[0], 0.0f, 1.0f) || + !IN_RANGE_INCL(pos[1], 0.0f, 1.0f)) + { + continue; } + + sites_total++; } if (!sites_total) @@ -128,10 +138,19 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri VoronoiSite *site; ImBuf *pattern_ibuf; int j; + float pos[2]; if (marker->flag & MARKER_DISABLED) continue; + add_v2_v2v2(pos, marker->pos, track->offset); + + if (!IN_RANGE_INCL(pos[0], 0.0f, 1.0f) || + !IN_RANGE_INCL(pos[1], 0.0f, 1.0f)) + { + continue; + } + site = &sites[i]; pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE); @@ -153,8 +172,8 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y)); IMB_freeImBuf(pattern_ibuf); - site->co[0] = marker->pos[0] * width; - site->co[1] = marker->pos[1] * height; + site->co[0] = pos[0] * width; + site->co[1] = pos[1] * height; } IMB_freeImBuf(ibuf); @@ -308,9 +327,11 @@ void KeyingScreenOperation::executePixel(float *color, int x, int y, MemoryBuffe if (barycentric_coords_v2(a->co, b->co, c->co, co, w)) { if (barycentric_inside_triangle_v2(w)) { - color[0] += a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2]; - color[1] += a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2]; - color[2] += a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2]; + color[0] = a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2]; + color[1] = a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2]; + color[2] = a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2]; + + break; } } } |