Sign in to follow this  

Outer glow shader?

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

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

This topic is 2551 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this