Advertisement

Interesting motion blur artifact

Started by February 19, 2006 01:29 PM
3 comments, last by lc_overlord 18 years, 6 months ago
I've been working on a full screen motion blur algorithm directed at older hardware. The algorithm basically takes a screen shot of the frame buffer from the previous frame and overlays it on the current frame with reduced alpha. For higher levels of blur, it then proceeds to do a guasian blur by overlaying the old frame at slightly different positions. This part of the algorithm works fine. When you introduce lighting, there is too much constant white and the screen eventually becomes white, as expected. I use a variable called region to determine the blur level of the algorithm. The algorithm works in the range for region > 0. However, i accidently included the region == 0. Oddly enough the algorithm began to work with lighting and blending. The code doesnt make sense. When region == 0, it shouldnt do anything; it should actually seg fault because of division by zero. Thus i've posted the code hoping one of you may be able to make anything of it: www.eng.uwaterloo.ca/~rramraj/blur.zip I used make and g++ to compile it but you should be able to use anything; its cross platform. Heres a list of things I would like to know: - Does this run on your machine? - How well does it run on your machine? - Can you explain why it works? Operation instructions: Spin cube: left, right, up, down Translate cube: pg up, pg down Lighting: l Blending: b Motion blur: m Blur level: less: home, more: end Other blurs included: Gaussian blur 1: r Gaussian blur 2: t To reproduce artifact: - run app - spin cube - press m - press l - press home Thanks for your time, - llvllatrix
-It runs, it was a bit of a bother to get it working, but it works.
-ok i guess, but the blur effect is sort of microscopic and only noticable if you turn the motion blur to max and hit the r key so the whole thing pauses for a second or so.
-it doesn't, setting Region to 0 effectivly should turn the blur off, witch it does, but it allso bugs the effect out until you enable lighting that makes the blurpolys black, and thus no whiteout.


I did some tinkering with the code to get a better effect.
i set the blend func to GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
and inserted code to insure that lighting is of while rendering the blur polys
GLboolean isLIGHTING = glIsEnabled(GL_LIGHTING);
if(isLIGHTING == GL_TRUE)
{
glDisable( GL_LIGHTING );
}
+ one at the other end that re enables it if needed

and finaly changed
motion_blur_alpha = 0.01f/region;
to
motion_blur_alpha = 0.1f/region;
Advertisement
I forgot to mention, the easiest way to see the effect is to move your mouse off the window.
Thanks lc_overlord,

I spent a bit more time with the code; It seems that when region is 0, only one untranslated frame is drawn. I'm not exactly sure what the alpha is on the frame but it is very high. I noticed on your implementation of the blur, we get a blackout whith lighting on, because the darker areas of the scene dominate. A high alpha in the artifact would explain why the blur preservers the image (ie no blackout).

I think there is something missing; something that controls blackout or whiteout artifacts. Perhpas it has something to do with the constants that we are dividing:

motion_blur_alpha = 0.01f/region;
motion_blur_alpha = 0.1f/region;

I think we need to calculate this constant based on frame rates and intensities. I'll look into how our eyes process images to see if I can get an appropriate value for the alpha.

Cheers,
- llvllatrix
Funny i didn't get any whiteout or blackout in my modified code.
What i found was that the white out was caused by the blend func, it just kept adding stuff together.
and the blackouts where caused by the lighting, the blur polys where not properly lit, when they shouldn't even be lit, and if they are black then you get a blackout.
allso if you increase region enough with motion_blur_alpha set to high it will sort of bug out and swipe everything to one corner , there is a fix for it but that only creates a diferent problem.


motion_blur_alpha: that value only dictates how long the motion blur will stay after the initial draw, set it to 0.3 and you get a pretty intense blur effect.
like this

allso, keeping region at 1 (or possibly at most 2) works the best in my oppinion, i don't know exactly why(yet) but motion_blur_alpha seems to have a better impact on the blur effect than region (better not greater).

[Edited by - lc_overlord on February 20, 2006 8:38:30 AM]

This topic is closed to new replies.

Advertisement