Sign in to follow this  
chillypacman

Transparency With a Specific Colour?

Recommended Posts

The technique you describe is called "color-key transparency" and it isn't actually directly supported by your graphics card (AFAIK). To achieve this technique, you'll have to use regular GL blending functionality that you describe, and algorithmically create the appropriate alpha channel in your texture.

If you want to use this technique in your OpenGL application, you will have to modify your texture loading code to look for that colour and fill in the alpha channel appropriately:

for each pixel in bitmap
if pixel.rgb == (0,0,255) then
pixel.rgb = (0,0,0)
pixel.a = 0;
else
pixel.a = 1;
endif
endfor

Share this post


Link to post
Share on other sites
Quote:
Original post by Hodgman
The technique you describe is called "color-key transparency" and it isn't actually directly supported by your graphics card (AFAIK). To achieve this technique, you'll have to use regular GL blending functionality that you describe, and algorithmically create the appropriate alpha channel in your texture.

If you want to use this technique in your OpenGL application, you will have to modify your texture loading code to look for that colour and fill in the alpha channel appropriately:

for each pixel in bitmap
if pixel.rgb == (0,0,255) then
pixel.rgb = (0,0,0)
pixel.a = 0;
else
pixel.a = 1;
endif
endfor


oh righty then, it's a lot easier in directx but ok.

Share this post


Link to post
Share on other sites
Quote:
Original post by chillypacman
oh righty then, it's a lot easier in directx but ok.


Incidently enough, DirectX does pretty much the same thing under the hood of the D3DX functions. But yes, it is easier in the sense it's done for you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this