Jump to content
  • Advertisement
Sign in to follow this  
joe1d83

Outer glow shader?

This topic is 2764 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

Hi,

I'm looking for a shader or some code snippet,
that would do a outer glow effect similar to WPF's DropShadowEffect.

Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Generally speaking, the drop shadow is basically a blurred version of the alpha channel of the original image. After you have a blurred alpha value, you interpolate between the desired shadow color and the original background color (may be transparent) by that value. And of course you offset the blur sampling x and y coordinates in order to move the shadow as needed. Finally, it is common that the original image is alpha-composited over the shadow in order to establish the visual effect of the object actually casting the shadow onto the view plane.

It is common in public drop shadow implementations that the quality of the blur can be specified by the user. A true two-pass (x-y separable) Gaussian filtering is the best quality, but it is also heavy to compute - whereas two-pass rolling box filter is very performant. Smaller filter kernels (like 2x2 or 3x3) are also feasible to do in single pass, but if the blur radius is large, it is more efficient to separate the blurring to x and y passes in order to reduce the total computation complexity.

Finding code for several types of blur is easy. The basic principle is to take source samples not only from the current position but also from around the current pixel, and taking their weighted average (this is where the algorithm varies) as the destination value. In effect, this simulates the light leaking from neighboring pixels, thus blurring the image.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!