Re: FxPlug / OpenGL Smooth Line Artifact
Re: FxPlug / OpenGL Smooth Line Artifact
- Subject: Re: FxPlug / OpenGL Smooth Line Artifact
- From: Darrin Cardani <email@hidden>
- Date: Fri, 17 Oct 2008 17:12:50 -0700
On Oct 17, 2008, at 5:10 PM, George King wrote:
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.
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);
I think the above is your problem. Since colors in OpenGL are already
premultiplied, I think you want to use:
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
Otherwise, you're applying the source alpha twice to the line color.
I've always found this really confusing, too, fwiw.
Darrin
--
Darrin Cardani
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden