|
From: James W. <ja...@fr...> - 2007-05-11 01:09:22
|
jo...@st... wrote: > On May 10, 2007, at 23:08 UTC, James Walker wrote: > >> Back in 2004, there was some discussion here about the fact that the >> Interactive Renderer essentially assumes that ARGB textures use >> premultiplied alpha, and questioning whether it ought to be an >> option. Yesterday I changed the OpenGL renderer to assume non >> -premultiplied alpha, but now I'm wondering if that was too rash. > > I'd say so. :) First, you don't want to break existing software; and > second, premultiplied alpha can be very useful in making (for example) > "glow" effects. > >> The QD3D manual doesn't seem to give any hint whether alpha should be >> premultiplied or not. I believe there was a claim in 2004 that >> QuickDraw 3D did use premultiplied alpha, but I can't confirm that >> today. When I loaded an ARGB texture test in Classic Geom Test, the >> result doesn't agree with either of our renderers. > > Hmm. That's surprising. It's been a while, of course, but I was sure > that textures have worked the same way in Quesa as in QD3D from the > beginning. Certainly neither I nor my artist partner (Jeff Quan) have > ever noticed the difference -- and he's even written a tutorial on the > proper use of premultiplied alpha. That was for Meshwork users, and > was years ago, so I'd think he/we would have tested it under QD3D. OK... >> Anyway, in the previous discussion, it was suggested that the >> premultipled flag could be set with an object property on the >> renderer, or a new style object. It occurs to me now that it might >> make sense to set it at the level of individual textures... maybe a >> new pixel type constant like kQ3PixelTypeARGB32Premultiplied, maybe >> an object property or custom element. > > That'd be OK, but for the sort of thing I've done, it would be > overkill. An object property on the renderer would be fine, and a > style object would be even finer. I don't see a need to be more > granular than that. Most objects either need to glow, or they don't -- > and it's certainly not hard to premultiply some of the textures if > needed. Maybe even that's overkill. Maybe I should just document that premultiplied alpha is expected, say next to kQ3PixelTypeARGB32 in the header docs. As for the OpenGL renderer, I didn't like the switching back and forth between glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA), but I could go the other way: use premultiplied alpha even for vertex colors, and always use glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA). -- James W. Walker, Innoventive Software LLC <http://www.frameforge3d.com/> |