Blender Git Loki
Git Commits -> Revision fbbe592
Revision fbbe592 by Ton Roosendaal (master) February 11, 2006, 13:23 (GMT) |
Two significant improvements in vectorblur: 1) Accumulation buffer alpha handling Accumulating colors in an accumulation is simple; a weighting factor can make sure colors don't over- or undersaturate. For alpha this is a bit more complex... especially because the masks for vectorblur are anti-aliased themselves with alpha values. Up to now I just premultiplied the mask-alpha with the actual color alpha, which worked OK for solid masks, but not for transparent ones. I thought that would be an acceptable situation, since 'ztra' faces only get blurred with alpha==1. However, it gives bad results when using 'mist' in Blender, which just gives pixels an alpha value based on camera distance. In these cases the alpha became oversaturated, accumulating into too high values. The solution is to store the mask-alpha separately, only premultiply this alpha with the weighting factor to define the accumulation amount. This is the math: blendfactor: the accumulation factor for a vectorblur pass passRGBA: color and alpha value of the current to be accumulated pass accRGBA: color and alpha value of accumulation buffer (initialized with original picture values) maskA: the mask's alpha itself accRGBA = (1 - maskA*blendfactor)*accRGBA + (maskA*blendfactor)*passRGBA This formula accumulates alpha values equally to colors, only using the mask-alpha as 'alpha-over' operation. It all sounds very logical, I just write this extensive log because I couldn't find any technical doc about this case. :) 2) Creating efficient masks with camera-shake Vector blur can only work well when there's a clear distinction between what moves, and what doesn't move. This you can solve for example by rendering complex scenes in multiple layers. This isn't always easy, or just a lot of work. Especially when the camera itself moves, the mask created by the vectorblur code becomes the entire image. A very simple solution is to introduce a small threshold for moving pixels, which can efficiently separate the hardly-moving pixels from the moving ones, and thus create nice looking masks. You can find this new option in the VectorBlur node, as 'min speed'. This mimimum speed is in pixel units. A value of just 3 will already clearly separate the background from foreground. Note; to make this work OK, all vectors in an image are scaled 3 pixels smaller, to ensure everything keeps looking coherent. Test renders; 'Elephants Dream' scene with lotsof moving parts; rendered without OSA, image textures, shadow or color correction. No vectorblur: http://www.blender.org/bf/vblur.jpg With vectorblur, showing the alpha-saturation for mist: http://www.blender.org/bf/vblur1.jpg New accumulation formula: http://www.blender.org/bf/vblur2.jpg Same image, but now with a 3 pixel minimum speed threshold: http://www.blender.org/bf/vblur3.jpg Next frame, without minimum speed http://www.blender.org/bf/vblur4.jpg Same frame with speed threshold: http://www.blender.org/bf/vblur5.jpg (Only 20 steps of vectorblur were applied for clarity). |
Commit Details:
Full Hash: fbbe5925ffc3e24289bc747557483d4fcdabb33f
SVN Revision: 6787
Parent Commit: a056904
Lines Changed: +118, -83