Re: FxPlug / OpenGL Smooth Line Artifact
site_archiver@lists.apple.com Delivered-To: pro-apps-dev@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=arboreality.net; h=Received:Cc:Message-Id:From:To:In-Reply-To:Content-Type:Mime-Version:Subject:Date:References:X-Mailer:X-Identified-User; b=ZRq5Ti5sR6D3MUb3H369F6rGqOYl9TQpgep8fe7X/dAerF+4Rzw2KvsSsRu92i1iESV0oY20D3vt4aI7++lHIqK4/L/u43Qb9dZ3xJfEiDnVVU+L6jgDmtYFhYXPYHsj; On Oct 17, 2008, at 5:12 PM, Darrin Cardani wrote: On Oct 17, 2008, at 5:10 PM, George King wrote: Thanks, George King glClearColor(1,1,1,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); Darrin -- Darrin Cardani dcardani@apple.com Hi Darrin, Thanks, _______________________________________________ Do not post admin requests to the list. They will be ignored. Pro-apps-dev mailing list (Pro-apps-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/pro-apps-dev/site_archiver%40lists.ap... This email sent to site_archiver@lists.apple.com I am seeing an odd artifact in my FxPlug OpenGL context when I draw a white line on a white background using GL_LINE_SMOOTH. In my test app that uses an NSOpenGL context (with no multisampling), i get pure white. However, when I run the same code in my FxPlug, I get dark artifacts where the line is blending. It looks as though the smooth line rasterizer is fading the color to black as the alpha fades to zero. As an example, take a white line with a small positive slope (almost horizontal). If I disable GL_BLEND, then I see two series of horizontal gradients in a staircase pattern, fading white to black and black to white. If I enable GL_BLEND, then the alpha for each gradient goes to zero as the color goes to black, leaving semi-transparent dark spots for every pixel of vertical rise. I hope that makes some sense! Attached are a few screen shots which should make the problem apparent. Note that this is not affected by glBlendColor, or the GL_TEXTURE_ENV_COLOR; changing either of those does not alter the black coloring. The problem occurs with and without texturing. Below is example code that can be pasted directly into the default FxFilter Xcode project. Insert it just before the glPopAttrib() call. You should also change *canRenderSoftware to NO to force OpenGL use. I'm hoping that I'm just missing some gl state call, but I've been scouring the red book all day to no avail. Let me know if I should post this to the OpenGL list too; I thought I'd ask here first since it works in regular contexts. I think the above is your problem. Since colors in OpenGL are already premultiplied, I think you want to use: Otherwise, you're applying the source alpha twice to the line color. I've always found this really confusing, too, fwiw. That fixes my test case, but unfortunately it introduces a similar problem elsewhere. Now my lines are getting white 'feathers' instead of black. Below is a screenshot from my project; I'll have to work at a better test case. Remember that using (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) works fine in a fresh NSOpenGLContext. I'm not sure what you mean about premultiplication. My limited understanding of that term is that when a function requires premultiplied color data, the color must multiply each color component by the alpha component ahead of time. So the quadruple for 100% red at 50% transparency is (.5, 0, 0, .5). When I want that color in OpenGL I call glColor4f(1, 0, 0, .5). Please let me know if I am misunderstanding the concept. George
participants (1)
-
George King