Basic diffuse lighting giving artifacts with MSAA

Hey. I’ve had a bug with my lighting shader for a while now and I thought I’d ask if anyone knows anything about it. With multisampling enabled I get single-pixel artifacts where the lighting computation gives a much higher value than it should. The artifact happens on triangles that are almost 90 degrees aligned to the screen (almost invisible/very “thin”), around the outline of smooth objects. This is my shader line to calculate the light intensity from a point light (no distance attenuation).


float light = max(dot(normalize(normal), normalize(lightPosition - eyeSpacePosition.xyz)), 0.0);

Here’s a screenshot of the artifacts that keep on flickering when the camera moves. There’s no texturing or anything, I just output the above light value the RGB channels. This is with 2xMSAA but it’s more or less visible at any sample rate.

http://img546.imageshack.us/img546/5469/lightingartifacts.png

I have a hunch that this is due to the fact that the normal becomes extrapolated for those edge samples and somehow wrap around or something. If that’s the case, then the only solution I know of is to enable centroid interpolation, which is an OGL4 feature. -_-’

Uggh: Errr…try looking at this: http://mynameismjp.wordpress.com/2012/10/28/msaa-resolve-filters/

The resolve is done by OpenGL, I’m just requesting a pixel format with MSAA:


Display.create(new PixelFormat(24, 0, 24, 0, 2));

Just looking at your image it looks like aliasing…so the resolve might be the problem.

Nope, it was the interpolation. I accidentally spotted that centroid interpolation was in fact supported in OGL3 and tried it and that fixed it.

EDIT: More info: http://quest3d.com/forum/index.php?topic=69239.0

Is this real-time medical graphics programming by any chance? If so, how do you get into a field like that?

? Not at all, that’s just a 3D model without any textures.

Haha it looks a lot like a bone, which is why davedes thought that :wink:

OH! xD But it’s not a bone, it’s a butt! xDDDD

That’s an ugly flat ass ;D

Damn, that should have obvious…but I doubt I would have thought of it.

Errm…you accidentally a word :stuck_out_tongue: