Skip to main content
HandsomeHarvey
Participating Frequently
April 8, 2018
Question

How to Load Selection with ALL semi-transparent (semi-opaque) pixels

  • April 8, 2018
  • 3 replies
  • 2657 views

I have been researching this subject on the forums and experimenting on my own for quite some time without figuring out how to achieve this desired functionality.

My understanding is that load selection's functionality is to select all opaque pixels and pixels with a transparency value of 50% or higher. I have need of being able to select pixels with ANY transparency value greater than zero.

I am working on a 2D Unity project where all assets are required to be imported as they were designed within Photoshop. Some of the assets are created using blend modes and layer styles which are being blended with a base layer that will NOT be imported.

In order for the blend mode to take effect, I must flatten the blend layer with the base layer and then alpha out the base layer's contents (because it will not be imported).

Before merging, I have created a duplicate of the blend layer that is flattened with an empty layer that I can use to sample the alpha with Load Selection.

The issue I am experiencing, is that using Load Selection, inverting, then deleting... while correctly deleting the base layer, actually comes with the unintended consequence of also deleting part of the Outer Glow layer style. The outer glow creates a black outline that fades into full transparency, and I'm essentially omitting half of the effect because the selection will not register the 0<X<50% pixels.

I have tried Load Selection and adjusting the threshold of a quick mask to increase my selection, but this causes all pixels to become fully opaque which is also undesired behavior.

I have even tried something as simple as Load Selection on the flattened layer, inverted selection, and deleted just to see if the inverse of the selected area was accurate, and even doing this deletes part of the glow. I also tried this with Select All to no success.

Is there some way to select all pixel with a transparency greater than zero with Load Selection or some other selection method? I have thought about painting a mask on the flattened layer, but the shape of the art is so intricate I'd imaging it'd be near impossible to get it fading out accurately.

This topic has been closed for replies.

3 replies

rob day
Community Expert
Community Expert
April 8, 2018

My understanding is that load selection's functionality is to select all opaque pixels and pixels with a transparency value of 50% or higher. I have need of being able to select pixels with ANY transparency value greater than zero.

It's understandable why you might think that, because the warning displayed when loading less than 50% transparency as a selection is a bit ambiguous. Here there actually is a selection it just can't be represented with a marquee.

rob day
Community Expert
Community Expert
April 8, 2018

Sorry if I'm misunderstanding your question, but have you tried Command clicking the layer with transparency you want to select? That will load the layer's transparency as a selection, which can then be saved as a channel.

Pixels with less than 50% transparency do get selected, they just don't get represented by the selection marquee above. Here you can see the transparent selection gets represented by a corresponding gray value in the saved channel.

My understanding is that load selection's functionality is to select all opaque pixels and pixels with a transparency value of 50% or higher. I have need of being able to select pixels with ANY transparency value greater than zero.

If I want to select all of the pixels with any amount of transparency, I can use the Magic Wand set to 0 Tolerance and with Selecting Contiguous Pixels on a pixel that is fully transparent and then invert the selection.

Edit: If you have multiple layers turn on the Magic Wand's Sample Colors from composite image

HandsomeHarvey
Participating Frequently
April 8, 2018

Thanks for the reply, Rob!

As an example, I have tried to use Load Selection on an image with feathered alpha (going from fully opaque to fully transparent). And THEN used a Fill for white and I can very clearly see that the Fill extends beyond the perceived marquee selection.

So, I understand what you are saying. The selection is in fact including pixels lower than 50% transparency. I also tried the wand tool at 0 tolerance, but then my selection is simply fully opaque. :[ That is the part that boggles me about this whole thing. If I use Load Selection on that same graphic, Select Inverse, and Clear it will actually remove part of the graphic even though the inverse should be what it ISN'T and in theory have no effect.

Actually, I just realized in writing this reply this may very well be the intended functionality within Photoshop since these operations are likely happening on a per pixel basis. It is possibly that those outliers, being less than 50% when inverted would be treated as more than 50% in their selection and using Clear would understandably cull them.

Now, I'm not sure what to do. I have to delete via selection because I need my images exported as PNGs which do not support alpha channels. I am sure if I used a format that supported alpha channels, I could just save the selection as alpha, and let the image decide how to apply the transparency on the artwork. Hmm..

rob day
Community Expert
Community Expert
April 8, 2018

Can you share a sample file? Why PNG? Is this going to print or web?

Mylenium
Legend
April 8, 2018

Well, have you even ever looked at the channels palette and image calculations. all your answers are there.

Mylenium

HandsomeHarvey
Participating Frequently
April 8, 2018

Yes, and Yes. Not sure what you were attempting to get at. Could you elaborate?

HandsomeHarvey
Participating Frequently
April 9, 2018

Actually, I found this on the Unity forums:

"The problem with outer glow is it's a very expensive effect to reproduce in real time, and worse the way sprites work the glow can only extend as far as the sprite's mesh, which is usually fairly tight to the sprite, and can bleed glows from the surrounding sprites packed in the sprite atlas too close, hence why the outline effect that is common is usually only a pixel or two wide.

The easiest way to do a outer glow like Photoshop is going to be to an outer glow in Photoshop."

So a Unity shader solution doesn't seem like a good idea. Back to Photoshop it is.


Okay, I've got as good a solution as I will get on this subject.

Through sheer experimentation, I found that a really close approximation is simply to:

1) Set blend mode to normal and manual select a color that closely matches the blend result.

2) Duplicate the layer.

And that's it. Save out as PNG and drop it into Unity and looks near identical to Photoshop. You will have a flat luminence value across your glow, so this won't work with glows that are intended to have varying intensities. But you can probably solve that by inverting the selecting and taking a brush tool with a low opacity and alpha masking/deleting parts of the glow.

There is something about low transparency pixels get alpha'd that makes straight texture conversion to Unity not fully accurate, but this is a viable workaround.

Thanks for your earlier help, Rob.

-Harvey