Mobile app version of vmapp.org
Login or Join
Shakeerah625

: How to make a distance-based gradient around a shape in Photoshop CC? I have an irregularly-shaped pixel image on a transparent background. I would like it to "cast a shadow" all around it

@Shakeerah625

Posted in: #AdobePhotoshop #Pixel #Shadows #Transparency

I have an irregularly-shaped pixel image on a transparent background. I would like it to "cast a shadow" all around it by creating semi-transparent pixels around the edge of the image. Specifically, I want the transparency of each pixel to be determined based on how close it is to the pixels of the image (i.e. transparency proportional to the Euclidean distance between the target pixel and the nearest image pixel).

Selecting the pixels I want to apply the gradient around is trivial, but I can't figure out how to make a gradient that will automatically recede based on the Euclidean distance from the rest of the image. Just to be clear, this is the end result I want:

000111000
002333200
024555420
135###531
135###531
024555420
002333200
000111000


...where ### stands for the original image pixels, and 0-5 stand for 0% through 50% transparency black pixels (the % chosen here is arbitrary).

Obviously this would be straightforward if it were a simple image like the above, because I could just create a circular gradient centered on the image. But I want this to work for an arbitrary irregular shape, with pixels getting more transparent the further they are from the shape's edge.

This is such a simple and obvious use case (it's commonly done with text, for one example) that there must be an easy way to do it, but I don't know what that is. The only solution I can come up with so far is to iteratively grow the selection outside of the image by one pixel at a time and decrease the transparency with multiple bucket fills, but it's hard to get that smooth and it's cumbersome. Is there a simpler way to do this?

EDIT

I think I understand now.

Photoshop's selection tools are more flexible than I realized. When you grow a border, it does so smoothly even though it looks like there are only specific pixels selected. I wasn't seeing the smoothness of the selection area until I entered Quick Mask mode.

So yeah, it's super easy to do this. Growing a selection automatically smooths the edges with partial transparency automatically. Just grow around the border of the shape on a separate mask layer, and fill the area, and the effect is exactly what I wanted.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Shakeerah625

1 Comments

Sorted by latest first Latest Oldest Best

 

@Frith110

Photoshop's selection tools are more flexible than I'd realized. A selection in photoshop isn't just a set of pixels: it's a mapping of pixels to transparency. In most modes it looks like the selection border is a hard border, but that border is actually the boundary of all pixels which are at least partially selected.

When you grow a selection border, the selection area automatically applies a transparency gradient to each pixel based on its distance from the original border, so the new selection area (or "mask" might be the right term) consists of "partially selected" pixels. The further from the original border, the more transparent the selection will be. Smoothing is the default behavior, which is exactly what I needed.

I was able to figure this as soon as I opened Quick Mask mode, because that mode directly shows you the transparency of each pixel in the mask.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme