Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

I want to create an image which I can use as a texture in OpenGL. The image is a jpg that comes in red.

In my OpenGL I want to be able to change the red color to any other color the user selects, for this i thought the best solution was just to discard the rgb channels from the original image and only use the alpha channel of the texture, and the rgb the user selected.

The problem is that even thought I have tried for quite some time, this only seems to work for the edges of the image, not the inner part of the image.

This is the example image:

enter image description here

As it can be seen, there are parts that are in pure red, others that are mixed with white, and complete white parts. I need to have "a png alpha image" in where white represents transparent. This means that complete red will have an alpha of 1.0, complete white an alpha of 0.0 and anything in between an alpha between 0.0-1.0.

In OpenGL I have access to the r,g,b,a channels of the texture. So if anyone has another solution that doesn't use alpha that would help too.

Thanks

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I guess you need something like this:

enter image description here

enter image description here

Where deepest red is 100% black. It is not hard to do. You can experiment a bit more with it by:

  1. Desaturate your image to grayscale

  2. Open Levels and tune it up as you need.

I also have done it as PNG with transparency https://dl.dropboxusercontent.com/u/1007168/Untitled-1.png Please check if this is what you need.

To do it as PNG with transparency and ready for recolor:

  1. Select your layer with image and copy to clipboard. Then create a new mask: enter image description here

  2. Paste your image from clipboard to the mask: enter image description here

  3. Turn off the mask and back to usual RGB channels: enter image description here

  4. Hold Ctrl (Cmd) key and click over little thumb of your mask at Channels palette: enter image description here

  5. Now you can delete the white. Press DEL: enter image description here

To check how it works you can try to recolor it by yourself:

  1. Switch on "Hold transparent pixel": enter image description here

  2. Fill it up with any color: enter image description here

Here is the sample how it looks recolored in different colors: enter image description here

share|improve this answer
    
Hello, thanks for the response. Yes this is exactly what I am looking for. I did what you told me there and converted to grayscale, then moved the levels. But im not sure what to do after... The thing is that I need to do this for around 16 different patterns (that will be used in a texture map) so i have to figure out the procedure. –  Chiquis Jun 4 at 9:01
    
@Chiquis, do you need your masks as PNGs with transparency (instead white)? –  Vnovak Jun 4 at 9:04
    
Yeah, what I need is to be able to create that image that you made. It is exactly what i need. I adjusted the "levels" to make it a bit more darker but I don't know how to go from that step to a png with transparency. –  Chiquis Jun 4 at 9:08
    
Ok, adding info to answer how to do a PNG with transparency (ready for recolor) next –  Vnovak Jun 4 at 9:10
    
Thank you very much for your help! –  Chiquis Jun 4 at 10:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.