[Bf-blender-cvs] CVS commit: blender/source/blender/makesdna DNA_node_types.h blender/source/blender/render/intern/source zbuf.c blender/source/blender/src drawnode.c
Ton Roosendaal
ton at blender.org
Sat Feb 11 14:23:08 CET 2006
ton (Ton Roosendaal) 2006/02/11 14:23:08 CET
Modified files:
blender/source/blender/makesdna DNA_node_types.h
blender/source/blender/render/intern/source zbuf.c
blender/source/blender/src drawnode.c
Log:
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).
Revision Changes Path
1.6 +3 -2 blender/source/blender/makesdna/DNA_node_types.h
<http://projects.blender.org/viewcvs/viewcvs.cgi/blender/source/blender/makesdna/DNA_node_types.h.diff?r1=1.5&r2=1.6&cvsroot=bf-blender>
1.50 +112 -81 blender/source/blender/render/intern/source/zbuf.c
<http://projects.blender.org/viewcvs/viewcvs.cgi/blender/source/blender/render/intern/source/zbuf.c.diff?r1=1.49&r2=1.50&cvsroot=bf-blender>
1.13 +5 -2 blender/source/blender/src/drawnode.c
<http://projects.blender.org/viewcvs/viewcvs.cgi/blender/source/blender/src/drawnode.c.diff?r1=1.12&r2=1.13&cvsroot=bf-blender>
More information about the Bf-blender-cvs
mailing list