Preventing one specific color to be written

Is it possible to prevent one specific color to be written to the z-buffer ? I know the colormasking function prevents r,g,b values to be written, but there’s not one function that prevents one combination of rgb values to be written, if there was such a function (like glDenyColor3f (r,g,b)), masking would be a lot easier to implement. You could do it single-pass.

Someone agrees with this function ?


This function already exists in one way, and it’s also done in a single pass. Add an alpha channel before uploading your texture. All pixels get alpha=1.0 except for the color you want to reject, these pixels should have alpha=0.0, and use glAlphaFunc to reject all pixels with alpha=0, or at least below a certain threshold. But I agree that it might be abit usefull though.

Yes, using glAlphaFunc is the way to go. The reason that there is not a color key available for doing this sort of thing is that there isn’t any way to define proper behavior once mipmapping, bilinear filtering, etc… start having there way with your colors.