|
Cheap, Faked Motion Blur (Pro Edition)
#78705
06/20/06 17:27
06/20/06 17:27
|
Joined: Aug 2002
Posts: 681 Massachusetts, USA
Ichiro
OP
User
|
OP
User
Joined: Aug 2002
Posts: 681
Massachusetts, USA
|
 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?
|
|
|
Re: Cheap, Faked Motion Blur (Pro Edition)
[Re: Ichiro]
#78706
06/20/06 20:05
06/20/06 20:05
|
Joined: Jun 2005
Posts: 656
Grafton
User
|
User
Joined: Jun 2005
Posts: 656
|
I just tried your approach and I think it works suprisingly well! I wouldnt think the re-evaluation of the panels alpha while the blur is enabled would be much of a problem, in fact it seems a good idea. I havent experimented with other panels that have transparency, but if it causes a noticable, bothersome problem on a prominent semi-transparent panel, perhaps the affected panels' alpha transparency could be adjusted while the blur is active? I changed the set_motion_blur function in mine to fade the blur out when you "turn it off" instead of it just ending abrubtly like this; Code:
function set_motion_blur(newval) { motion_blur=newval;
if(newval==0) { // No blur; shut off the panel: while(panel_motion_blur.alpha < 100) { panel_motion_blur.alpha += 3*time_step; wait(1); } panel_motion_blur.visible=0; camera.bmap = 0; } else { // Blur is positive: panel_motion_blur.visible=1; camera.bmap = bitmap_motion_blur; } }
You always come up with the most amazing stuff Ichiro! Thanks for sharing this.
Not two, not one.
|
|
|
Re: Cheap, Faked Motion Blur (Pro Edition)
[Re: Ichiro]
#78707
06/20/06 23:45
06/20/06 23:45
|
Joined: Sep 2002
Posts: 8,177 Netherlands
PHeMoX
Senior Expert
|
Senior Expert
Joined: Sep 2002
Posts: 8,177
Netherlands
|
Very cool indeed  !! Judging from your screenshots, the effect is pretty convincing  . So all you use as render target is a fully black tga as transparent panel? Nice, Cheers
|
|
|
Re: Cheap, Faked Motion Blur (Pro Edition)
[Re: EdMercer]
#78712
06/21/06 23:23
06/21/06 23:23
|
Joined: Aug 2002
Posts: 681 Massachusetts, USA
Ichiro
OP
User
|
OP
User
Joined: Aug 2002
Posts: 681
Massachusetts, USA
|
I've 'wired' the ammount of blur to the player speed and it gives a great illusion !That's a great idea; I gave that a try, and it's really neat to see everything blend together at high speeds. I stuck a vid up here (38MB, XviD), for anyone interested. The compressed video is a bit blurry, so it makes it tough to tell when the in-engine blur is taking place(!)
|
|
|
Re: Cheap, Faked Motion Blur (Pro Edition)
[Re: Ichiro]
#78713
06/22/06 15:34
06/22/06 15:34
|
Joined: Sep 2002
Posts: 8,177 Netherlands
PHeMoX
Senior Expert
|
Senior Expert
Joined: Sep 2002
Posts: 8,177
Netherlands
|
Hhaha! Very nice movie, I think that gameplay seemed pretty interesting too by the way. I don't know why, but the movement physics reminded me a bit of the good 'ol Battlezone, must be because of the cool gravity. Anyways, yeah the blur effect is hard to see in the movie, but when the player reaches the level's edge, you'll see it... When everything goes like it should, I'll be having pro within a week or so, and I can't wait already to experiment with this code!  Cheers
|
|
|
|