#### Archived

This topic is now archived and is closed to further replies.

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

This topic is 5989 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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.

##### Share on other sites
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

##### Share on other sites
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

##### Share on other sites
its highly suggest using [ source ] and [ /source ] tages (without spaces) when showing code.

1. 1
Rutin
45
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632985
• Total Posts
3009724
• ### Who's Online (See full list)

There are no registered users currently online

×