Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

klubbkid

OpenGL Color-keying in OpenGL

This topic is 6457 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I''m making an engine similiar to that of final fantasy tactics, what I need to be able to do is remove the hot-pink from my billboarded quads, see image. How can I do this? Thanks, - Derek

Share this post


Link to post
Share on other sites
Advertisement
Load them as 32-bit textures that have all of the hot pink parts set to transparent in the alpha map. Then you can use alpha blending or testing to make the transpart alpha parts not shown on output.

Or, you can create a mask while the texture is loading, with all hot pink parts made while, and all others black, so that you can use masking.



http://www.gdarchive.net/druidgames/

Share this post


Link to post
Share on other sites
First of all, good work on the background.
To get rid of the hotpink, try using an OpenGL mask. You can go to http://nehe.gamedev.net/tutorials/lesson20.asp for NeHe''s masking tutorial for OpenGL.
You might also try using blending, if you haven''t already.

Good luck with the rest of your engine.

-Brian

"Humans need a higher system than god."
~ Trieze Khushrenada

Share this post


Link to post
Share on other sites
Hyren,

Thanks for the compliments The engine is only a couple days old actually so it''s in rough shape right now, but I''m working on it

How can I make the mask dynamically at load time?

Thanks,
- Derek

Share this post


Link to post
Share on other sites
When you load a texture, create two of the same size instead of one. Send this loading function a color you want to be used as the color key. For every pixel that matches that color in the loaded texture, set the color of the other texture to black. If the pixel doesn''t match, set the color of the other texture to while.

Use the second one as a mask, and you''ve got instand color keying .



http://www.gdarchive.net/druidgames/

Share this post


Link to post
Share on other sites
Null and Void,

Thats what I figured would work....and I got the game working off the nehe recomendation of manually making the sprite and mask. See here. But I wanna use your method since it'll be easier to modify sprites and not need to worry about redoing the mask. I know I'm gonna need to use glReadPixels and glDrawPixels, but have never used these before....can I get some sample code? :D

Thanks,
- Derek

Edited by - Klubbkid on February 14, 2001 5:09:42 PM

Share this post


Link to post
Share on other sites
why use 2 images?

just use one quasi code follows

for (x=0;xfor (y=0;yimage[x*width+y]r =getchar;
image[x*width+y]g =getchar;
image[x*width+y]b =getchar;
if (image[x*width+y]r==255 && image[x*width+y]g==192 && image[x*width+y]b==64 ) a=0 // hotpink?
else a=255;
}//x
}//y
glTexImage2D(..... image )

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!