Archived

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

disabling a color in a texture

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

Recommended Posts

Hi! I''m making a 2d game in ogl. tilebased. Got the boys running around and colliding *proud* But how do I dissable a color from being rendered? The guys running around surrounded by a blue quad! *horrible* thanx :D "No lies of sugar can sweeten the sournes of reality" }+TITANIUM+{ A.K.A. DXnewbie[onMIRC]

Share on other sites
Use glColorMask to prevent a color from being written to the frame buffer. Or you can use the texture environment and modulate the fragment color with a mask color (the constant color for example, or the primary/secondary color if you need per-vertex masking). You can also use the blending stage and modulate with a constant color. But be aware that these modulation method replaces the masked color with black, glColorMask just don''t write the other components.

Share on other sites
You mean transparency, don''t you?

Im that case, look up alpha blending and alpha testing. Rundown: create your textures as TGA (RGBA). Enable blending or alpha test. Alpha values of 0 in the texture will not be rendered, while values 255 will be completely solid.

Share on other sites
Ah, maybe the OP wanted color keying; disable a single color, not disable a color channel. Well, then forget about my post and follow llyod advice.

Share on other sites
yeah, colorkeying.

I only have a .bmp loader, and no time to do any other. I could easily add a "color key" value into a file and read that (I have such a system right now, small "render shaders").

But say I have a color 100,100,50 or something that I don''t want to be visible. Do I really have to enable alpha blending for that? That glColorMask looked good until I noticed it completely disables a color (red,green or/and blue)?

"No lies of sugar can sweeten the sournes of reality"

}+TITANIUM+{ A.K.A. DXnewbie[onMIRC]

Share on other sites
opengl doesnt have colorkeying ( except if you do it yourself in a fragmentprogram)

so the best, and easiest thing to do is to do as proposed, create an alphalayer when you load the image.

Share on other sites
You don''t need alpha blending (unless you use it elsewhere), alpha testing will work just as well.
Basicly, you set the alpha of your normal pixels to 1 on load, and your color-key pixels to 0.
Then:
glEnable(GL_ALPHA_TEST);glAlphaFunc(GL_GREATER,0.0f);

Now all pixels with an alpha > 0 will be drawn, other pixels will be discarded.

1. 1
Rutin
24
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 46
• 41
• 23
• 13
• Forum Statistics

• Total Topics
631746
• Total Posts
3002022
×