1) My understanding of COMBINE was insufficient ;)
2) As I discovered while posting the same problem to the
idevgames.com forum, NSImage premultiplies alpha values.
So I adapted some TGA loading code and now it works as
one would expect.
Thank you very much -- my testbed works correctly, so I'm ready to go
through the process of converting all my textures from PNG to TGA, and
adding this functionality to my terrain engine.
Thanks!
Shamyl Zakariya
"this is, after all, one of those movies where people spend a great
deal of time looking at things and pointing."
From a review of _Fantastic Voyage_
On Nov 4, 2004, at 6:33 PM, bsupnik wrote:
Hi Shamyl,
Wild stab: this looks bad to me:
//why doesn't this give me a constant alpha?
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,
GL_COMBINE_ALPHA_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_CONSTANT_ARB
);
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_ONE );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE );
I do not think that GL_ONE is a valid operand mode for the combine
extension! (I think that GL_ONE is only used for framebuffer blending
via GL_BLEND and the imaging extensions but don't quote me on that.)
At least the spec only lists these four operands for the RGB section:
and of the four only the second two are allowed as inputs to the alpha
section.
So it looks to me like your alpha is not getting zapped like you think
it should be, and so alpha blending is zonking out your whole texture
at the fragment->framebuffer blend phase.
If this is the problem, the fix is easy: use the constant color (which
is per texture unit I _think_) to get yourself alpha:
// Set up the constant color to have alpha as 1 so we can just
// set our texes alpha to 1.
// When setting up the alpha, use replace, constant color, src alpha.
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_CONSTANT_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA);
I'm amazed you saw anything in your test actually...in my experience
the combine extension is very picky, and most of the time when I screw
up I just get black, so I'm surprised that passing a strange token to
the extension gave you any output.
I have to assume I'm doing something boneheaded. But please, don't
just point me to the COMBINE documentation. I've read it a dozen
times. I just don't *get* it, I guess. Could somebody clear it up for
me? I'm so baffled, and heartbroken.
The combine output is pretty opaque...I've been thinking that when I
finish this release I should write some kind of intro to combine,
since there seems to be nothing out there that shows how to use
combine for anything more complex than emulating GL_MODULATE (and what
good is that :-). It only took a stinkin' year to figure out how it
worked via trial and error...
Anyway, hope this helps! Combine is a very cool extension in that you
can fake a lot of shader-like effects on really ancient hardware. Too
bad the Gf-MX chipset has only 2 TUs...
*Cheers*
Ben
Shamyl Zakariya
"this is, after all, one of those movies where people spend a great
deal of time looking at things and pointing."
From a review of _Fantastic Voyage_
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden