Jump to content
  • Advertisement

Archived

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

Codejoy

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

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!