Photoshop Layer Transparency From Darkness

Soldato
Joined
6 Sep 2006
Posts
6,302
Location
London
Hey guys, this is something I've thought could be useful many times but I've yet to find out how to do it if it's possible at all.

Basically at the moment I'm creating a texture for a terrain where each of the channels corresponds to what texture will be used. So I have a base texture for my terrain then 4 other textures given by the R, G, B and A components of the image. The base texture is determined by the leftover, ie the black parts of the image.

So in the shader it'll look something like this.

colour += texture1 * image.R;
colour += texture2 * image.G;
colour += texture3 * image.B;
colour += texture4 * image.A;
colour += baseTexture * (255 - image.R + image.G + image.B + image.A);

That's not really important for my issue but it's the background to the problem. To achieve the image I want I split it into layers in photoshop for each of the different colours, I pick the areas where I want the different textures and colour them in with their respective colour. But to add a little noise around the mid-height of the terrain I took the greyscale heightmap, removed the low and high values so I'm left with the middle values then added some noise and did some other things to it so I'm left with some nice noisy white values on a black background. I colourised the white to green (the channel colour for that texture) but now I'm left with green on a black background.

What I need is the green on a transparent background. The green goes smoothly down from 255 to 0 so using the magic wand to select the black parts and delete them wouldn't work, I'd either still be left with a black halo around the green or lose the blurriness around the green parts.

My question is, is it possible to convert the darkness of that layer to its transparency.What I want is the same as if I took a completely transparent layer and painted each bit of green with the paintbrush so the green blurred into the transparency of the layer. Is it possible to get this from the darkness of the pixels?
 
Here you go, have a whack at it :)

ter1.jpg
 
When I open it in chrome it looks like what I need. I can't open the file in photoshop for some reason, it says the file format module can't parse the file. So long as the transparency is in the layer itself and not just as a separate alpha channel then it's what I need. Unless there's some way of assigning that separate alpha channel to the layer itself.
 
Have you tried renaming it to take the .html part off the end? It's just something RS adds on. It's a single layer file, the transparency is part of the layer :)
 
Last edited:
Trying to download it again, had to wait as I don't have a RS account. Can you describe how you managed to do it?

EDIT: realised what I was doing wrong, when I clicked the download link on RS after waiting it showed the image in chrome, however when I tried to save the image or save the page it would try to download it again off RS before saving it (don't ask me why). This caused the saved file just to be the html page saying I'd gone over my download limit. Another hour wait and then I'll try right clicking the download link and saving it directly before opening it in chrome.
 
Last edited:
I can't manage to download it properly off RS. I still need to know how you managed to do it anyway :)

Can you give a quick description?
 
Erm, I was fiddling for a bit, so I cant remember exactly, but I did this basically.

I used colour range to select some of the green and fiddled with the slider untill i had a fairly good cut-out. Colour range will select some of the blacks around the edge too making it look blended but unfortunately dark still. So i colour ranged the darker colour, with a fairly low fuzziness, and used the brightness and saturation (in hue/sat) to pump some green into it
Repeated that a few times and that came out.
Its not perfect, it has lost some bit and bobs.

By selecting the different shades of green, be it dark near the black or bright near the centres via colour range, you can seperate them into different layers, then adjust there brightness and saturation seperately.
 
Ah.. so no one-click method. Dang. I'm going to have to write my own plugin to set the layer transparency as the inverse brightness of the pixel! Thanks for explaining how you did it anyway :)
 
Try this..

Duplicate the background layer to give you a working layer. Or double click the background if you prefer.
CTRL/CMD click green channel thumbnail to load selection of that channel.
CTRL/CMD + I to inverse selection
Delete to clear selection - This should give you a rough but slightly innaccurate result.
Layer / Matting / Remove Black Matte

Put a blank black background underneath the new transparent green mist layer to give you a visual copy of the first image you started with. Then get a copy of the original image (with black) and place as the highest layer. You can then check the accuracy by hide/showing the top layer. If you did it properly there should be absolutely no change to the image.

To clarify,

Top layer - A copy of the original image you started with
Middle layer - The green mist with transparency
Bottom layer - Blank layer filled with black

Let me know if that works ok for you :) If you need anything clarifying let me know.
 
Last edited:
Back
Top Bottom