Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Textures: Converting black to alpha channel, Help Please!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 kamal7   Members   -  Reputation: 107

Like
0Likes
Like

Posted 31 August 2012 - 10:27 AM

Hello I want to know how I can remove all the black shades of the following sprites in the provided spritesheet. I have alpha blending (color keying method) enabled which renders as it shows in the image below; however, I wish to achieve the end result shown at the bottom of the image. How can I achieve/approach this? I have done hours of research but I am still unsure how to approach this problem. I know this is possible but I don't know if it is possible to easily achieve this end result. Thanks to anyone who can guide me in the correct path.

I know it is recommended to use an alpha channel for this but I am working on an old game with thousands of sprites using .bmp files and I just want to convert the game to DirectX 9 as it uses DirectDraw7 to achieve this. I am unsure how to do this in DirectX 9 without using an alpha channel. It is impossible for me to use an alpha channel, rather converting the black to alpha channel is the way to go given the circumstances.

Posted Image

I use color keying method in alpha blending to remove any pixel with opaque black ( D3DCOLOR_ARGB(255,0,0,0) ). Is there a way to somehow remove any black shades but keep the other color in that pixel like it shows in the image? In other words remove any black contained in a single pixel that has an alpha range of 1~255 without altering any other color within that pixel ...and the more black removed, the more transparent the color contained within that pixel becomes.

Edited by kamal7, 31 August 2012 - 11:03 AM.


Ad:

#2 Seabolt   Members   -  Reputation: 451

Like
0Likes
Like

Posted 31 August 2012 - 12:48 PM

Unfortunately not that I know of. Now without processing the texture after you've loaded it with your own algorithm. If you want your final result you need a texture that already has alpha in it, then alpha blending will get you what you want.
Perception is when one imagination clashes with another

#3 MJP   Moderators   -  Reputation: 5416

Like
0Likes
Like

Posted 31 August 2012 - 03:58 PM

Yeah I don't think you're going to be able to effectively reconstruct the alpha channel from an image like that. A simpler solution might be to just render the sprite with additive blending, or some other blending mode that doesn't rely on alpha.

#4 JohnnyCode   Members   -  Reputation: 37

Like
0Likes
Like

Posted 03 September 2012 - 04:32 PM

if you want partialy transparent textures by a color key, based on darkness of a pixel you could try this :
compute the alpha from the "darkness" of a pixel, meaning you take the color vector on pixel and compute its length. Length 1.0 would result for (255,255,255) vector, length 0.0 would be for (0,0,0) color vector. In fact, brightness of a color is actualy the length of its vector.

But in general you should avoid computing alpha by color key, and have alpha explicitly written to the texture resource and just readit.
Ther are many 2d software that will do this computation technique I have described and generate you volatile alpha based on the grayscale of your source picture and so on. (there are many techniques for defining alpha from color part)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS