
I tried my hand at a largely-framerate-independent motion blur, and figured I'd put it out there for some feedback/bashing/improvement. This basically renders a camera view to a bitmap on a transparent panel, then changes that panel's alpha based on the framerate and desired blurring. First, we define the panel:
Code:
// Load in a blank 1024x768 bitmap to render to:
bmap bitmap_motion_blur="bitmap_motion_blur.tga";
// This is the panel that contains that bitmap:
panel panel_motion_blur {
bmap = bitmap_motion_blur;
layer = -1;
flags = transparent;
}
(See
www.dejobaan.com/misc/bitmap_motion_blur.tga for the bitmap_motion_blur I'm using.) Next, we create the function that we use to set the blur amount:
Code:
var motion_blur;
// This essentially sets the transparency (alpha value) of our view at 100fps. Call with values of 0..100:
function set_motion_blur(newval) {
motion_blur=newval;
if(newval==0) {
// No blur; shut off the panel:
panel_motion_blur.visible=0;
camera.bmap = 0;
} else {
// Blur is positive:
panel_motion_blur.visible=1;
camera.bmap = bitmap_motion_blur;
}
}
We then change the panel's alpha value (call this once per frame) to account for framerate:
Code:
if(motion_blur) {
panel_motion_blur.alpha = 100 - pow( ((100-motion_blur)/100), (time/0.16) )*100 ;
}
Changing the amount of motion blur is, then, a simple call to motion_blur(<blur alpha 0..100>).
There are a number of problems with this approach; for example, any semi-transparent panels will appear slightly less transparent. (This is most noticable when motion_blur() is called with low values.) Also, it requires A6 Pro, since it uses the pelican rendering option.
However, it (somewhat) mitigates my largest concern, which is that without the constant re-evaluation of the panel's alpha value, the blurring varies wildly with framerate.
Any thoughts?