Skip to main content
gamedev.net
🔒 Locked

Simple for u all ?, 2d blurring effect...

Started by Codejoy May 30, 2002 at 10:58 AM 3 replies 350+ views
Original Post
Codejoy
Codejoy
I was curious about how one would go about getting a cool 2d blurring/trailing effect. I thought perhaps about drawing my sprite, then drawing several copies of it closely following the sprite...each copy being alpha blended more and more behind the sprite. Would this effect be a good one? or are there actuall proven algorithms to achieve such an effect? Thanks, Shane
jjmontes
jjmontes
That''s right but i''ve read that, for a better effect, a smooth increasing blur should be applied to each sprite (the far the sprite, more blur and more transparency). But this is expensive to calculate in real time so if you really want it you must blur (not soften) them in design time.
-=[ J ]=-I always forget to change the tagline.
koji187
koji187
nothing beats the real algorithim man


#define trim(a,b,c,d) if (a>=c) d=c; else \
if (a<=b) d=b; else d=a



void filter_splitblur(unsigned long **scanlines,int w,int h)
{
register unsigned long r,g,b;
unsigned long *lin1;
unsigned long *lin2;
register int x,y;
register int n;

for (y=0;y {
trim(y+1,0,h-1,n);
lin1=scanlines[n];
trim(y-1,0,h-1,n);
lin2=scanlines[n];
for (x=0;x {
trim(x+1,0,w-1,n);
r=(unsigned char)lin1[n];
g=(unsigned char)(lin1[n]>>8);
b=(unsigned char)(lin1[n]>>16);
r+=(unsigned char)lin2[n]>>1;
g+=(unsigned char)(lin2[n]>>8)>>1;
b+=(unsigned char)(lin2[n]>>16)>>1;
trim(x-1,0,w-1,n);
r+=(unsigned char)lin1[n];
g+=(unsigned char)(lin1[n]>>8);
b+=(unsigned char)(lin1[n]>>16);
r+=(unsigned char)lin2[n];
g+=(unsigned char)(lin2[n]>>8);
b+=(unsigned char)(lin2[n]>>16);
scanlines[y][x]=RGB(r>>2,g>>2,b>>2);
}

}
}


play with this one abit
Codejoy
Codejoy
K few questions about that algorithm, whats n initalized to and what is x,y goto in the loop? w and H respectively?

and scanlines is that just a pointer to my video memory?

-Shane
a person
a person
its highly suggest using [ source ] and [ /source ] tages (without spaces) when showing code.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.