Monday, July 18, 2011

Animation and more

I was planning on adding the soft edge feature but even the most stripped down blur implementation was simply too slow. So, I shifted my focus towards animation and useability for a while. Here's a quick overview of the changes:
  • Making changes to a mask now automatically adds/updates a keyframe for the current frame. This means that as you jump back and forth through the footage and make adjustments to the mask(s), you don't have to worry about adding keyframes, etc. Roto2D takes care of all that. Of course, you can also edit the animation using the Graph Editor or Dopesheet.
  • All masks are now correctly stored in the .blend file. So, you don't have to worry about saving them seperately. 
  • Added selecting a mask by clicking on the outline.
  • Adding a point to a mask by double-clicking on the outline.
  • Added removing all selected points by pressing 'x' or 'del' or using the 'Remove' button. When drawing a new mask this will remove the last added point (pressing it again removes the point before that, etc.).
  • Added smoothing all selected points by pressing 'Shift'+'s' or using the 'Smooth' button.
  • Mask names can now be changed.
  • Mask color and alpha can now be changed.
  • Visibility of the outlines can now be toggled.
  • The use of 'Ctrl' and 'Shift' when editing points now matches the Foundry's Nuke
  • Tested it in Windows for the first time and fixed some strange OpenGL issues. 
And a new screenshot:
Animated mask.

With all that taken care of, it's time to dive back into the pixel buffers. Updating the Image object is still a bit too slow (about 1 sec. for 1920x1080) so I need to find a more direct way to pass the bgl.Buffer data to the Image object's buffer. If only I could get Image.gl_load() to stop causing a segmentation fault, or get direct access to the buffer... I feel another patch coming up! (And this one will be seriously serious :)

Friday, July 1, 2011

Finally a fully functioning rasterizer

In my previous post I expressed my fondness for triangles. Well, the triangles are no more. For every problem I solved, two more appeared. So, I threw out some 350 lines of code, including all the triangulation stuff, and replaced it with a good old scan line bucket rasterizer. It is a modified version of the one described here. This one is so simple that it actually works with any kind of mask I throw at it!
Here is a little example of the rasterizer in action:
The new rasterizer showing 3 masks (including a self-intersecting one)
For every mask a bgl.Buffer is filled, converted into an OpenGL texture, mapped to a 2d quad and displayed on top of the image in the UV/Image editor. It still needs some optimization and the anti-aliasing needs some more work but it is already fast enough for panning, zooming, etc. because OpenGL handles most of the heavy lifting.

I will try to make a video this weekend and post it here.
Next up: gaussian blur madness!