Skip to main content
GameDev.net gamedev.net
🔒 Locked

anti aliasing that doesn't blur the image

Started by kengob Sep 18, 2009 at 12:13 PM 15 replies 9.8k views
Original Post
kengob
kengob
I'm trying to figure out a technique that will smooth edges but that will not blur the rest of the textured surfaces. This doesn't necessarily have to be real-time but should be close. From what I can understand it seems like any full screen anti-aliasing technique would make a slight blur on the entire image. One way I have thought of is to render an anti-aliased image the render a non anti aliased image and somehow (details not yet worked out) composite these two images. Hopefully there is a much better way to go about this. Any thoughts?
ddyer
ddyer
Anti-aliasing is blurring. There is no way around this.

If your images are "too blurry" when antialiased, they need to be higher
resolution to start with.

---visit my game site http://www.boardspace.net - free online strategy games
kengob
kengob
Thanks for confirming that I'm not crazy... Maybe what I'm looking for isn't called anti-aliasing, but there really should be a way to have smooth edges and sharp textures. My result resolution is not larger nor smaller than my texture resolution. Therefore, I should be able to get the same quality in the final image as in the original texture.
Matt Aufderheide
Matt Aufderheide
There is a method to smooth only edges...to do this, you need to do an edge detection filter on your image; the best methods use a depth buffer. Then use this "edge" image to blend in a blurred image of the scene. This way only the edges are blurry and it looks pretty decent.
Moe
Moe
There used to be a technique back in the day that did just antialiasing on edges.

It sounds to me like you have some sort of other issue though. What exactly do you mean by blurring the entire image? It sounds to me like there's something else at play that is making things blurry, not just AA.
InvalidPointer
InvalidPointer
Quote:
Original post by ddyer
Anti-aliasing is blurring. There is no way around this.

If your images are "too blurry" when antialiased, they need to be higher
resolution to start with.

Wrong on very, very many levels. Antialiasing as a general technique in signal processing refers to any number of techniques designed to combat artifacts resulting from forcing/discretizing a high-frequency input signal into a lower-frequency output. In computer graphics, this crops up most frequently (no pun intended) in the context of triangle edges, though texture filtering is in essence the same thing in a slightly different application. It is *not* blurring in any sense, the two techniques are orthogonal.

The triangle aliasing problem is usually solved by rendering into a higher-resolution temporary buffer and then resolving it into another that will actually be displayed. There are a number of different variations on this involving how and where the extra samples are stored and what methods are used to resolve them, but the idea is pretty much the same.

tl;dr edition: Blurring is not antialiasing. AA is (technically) done at a higher frequency than the input image, where blurring starts off at the initial resolution and goes down.

Now, with all that being said, you don't give much of a context here. Is this for a game? movie processing? PR shots, etc.?

clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.
kengob
kengob
More info. This will be used in movie processing. I'm using openGL on a windows xp with a nvidia quadro card.

For an example of how the image is blurred think about using a super sample technique. First you start out with the original image then supersample it (magnify it), lets say 4x, then render geometry at the higher resolution. Finally, you minify the result.

Clearly there are two places here that blur (Minification and magnification), whenever pixel boundaries don't exactly line up.

eq - Thanks, this looks promising. Similar to what Matt was talking about.

[Edited by - kengob on September 18, 2009 1:54:39 PM]
kuroioranda
kuroioranda
Quote:
Original post by kengob
For an example of how the image is blurred think about using a super sample technique. First you start out with the original image then supersample it (magnify it), lets say 4x, then render geometry at the higher resolution. Finally, you minify the result.

Clearly there are two places here that blur (Minification and magnification), whenever pixel boundaries don't exactly line up.


Actually, no. Supersampled antialiasing has no maginification step, the image is rendered into the larger buffer originally. So if you are doing 4x supersampling at 800x600, the image is actually rendered into a 3200x2400 buffer, and then downsampled to 800x600 for presentation on the screen. You end up with a higher quality image because each pixel in the final 800x600 buffer has 16 times as much image data going into its final color. This is especially noticeable at edges because if the boundary between two edges lies within the pixel, you will get color data from both blended in, instead of going with all one or the other edge (which creates "jaggies").

I'm guessing if this is for movie processing, you are starting with some fixed image size that has already been rendered. If you are trying to post process that by blowing an image up to 4x and then scaling it back down, then yes, that will blur the image (assuming you aren't point filtering both steps), because you are destroying the color information in the original image.

"Smoothing" an image without scaling it down or blurring it is actually a very hard problem, because you are effectively making up image data out of thin air, and making it happen realtime is crazy hard. Maybe going halfway and using a Sobel filter (http://en.wikipedia.org/wiki/Sobel_operator) to detect the edges in the image and only blur those would be a good compromise? This could easily be done as a post process filter on a GPU in realtime.
InvalidPointer
InvalidPointer
Quote:
Original post by kengob
supersample it (magnify it), lets say 4x, then render geometry at the higher resolution.

You're linearly filtering, not supersampling. Supersampling in image processing means you're *generating* an intermediate input at a resolution n times greater than the output. For example, running at 4xFSAA means your video hardware is generating the final color of each individual pixel from four unique samples taken from the (theoretically) infinitely detailed scene, then combining them in some arbitrary fashion. As soon as you drop the 'input resolution greater than the output' bit, you aren't antialiasing in the pedantic sense any more.

I was also referring to the actual requirements/specifications of the application more than the target hardware, here. If you're looking for edge filtering methods for videos, you might have more luck looking for those-- it'd likely be quite different than working with some of the additional data that might be available to a game engine.

EDIT: Ninja'd.
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.
zedz
zedz
yes with MSAA things can sometimes look 'blurred' hilights duller

If its lines etc that youre doing Ild suggest doing your own AA in a shader, or u could do a shader where u render into a larger texture + then do the AA yourself but only for the edges by comparing adjacent fragment depths/normals.

also for opengl see GL_POLYGON_SMOOTH IIRC that operates on polygon edges only (though this may be wrong), but also IIRC GL_POLYGON_SMOOTH doesnt give better AA than the results used nowadays
kengob
kengob
InvalidPointer, kuroioranda - Thanks for your replies. Let me try to explain a little better.

I'm supersampling in that my intermediate image is generated by rendering geometry to a texture that is some factor larger than my final output. However, the textures used to texture the rendered geometry are not large enough to not be magnified. So unless I started with images that are as large or larger than my supersample factor a magnification filter is applied.

I agree with what you are saying otherwise. So it looks like I will have to do some kind of edge detection and blur specific areas to get the desired results.
Sik_the_hedgehog
Sik_the_hedgehog
Stupid question: can't you just use nearest filtering for magnification (basically that means no filtering) and adjust texture coordinates so that one texel matches one pixel on screen? That would do the trick without modifying the image in the texture.
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
mzeo77
mzeo77
You could roll your own antialiasing by rendering to a larger larger texture.

By disabling magnification filtering (using nearest point), and by being careful how you set the texture coordinates, you can make sure a single pixel in the video only contributes to a single pixel in the output.

Render like this:
+--+--+--+--+|  | e| 2| 2|+--+--+--+--+| e| 1| 2| 2|+--+--+--+--+| e| 3| 4| 4|+--+--+--+--+| 3| 3| 4| 4|+--+--+--+--+

e = edge, 1..4 = pixel from video

Downscale 2x2 -> 1x1
+--+--+| a| 2|+--+--+| a| 4|+--+--+

a = antialiased edge, 1..4 = pixel from video

OOps, to late
kengob
kengob
Sik_the_hedgehog - For even magnifications I believe you would be correct. However, nearest minification would leave you with jagged edges.
mattnewport
mattnewport
For your particular case MSAA might be better than SSAA. MSAA only runs the pixel shader / samples the texture once per output fragment but rasterizes the triangles at a higher resolution and stores multiple depth and colour samples per pixel. This way there is no magnification then minification of the textured pixels within a triangle, only the edges are affected. This is more often a disadvantage quality wise for MSAA since you can't really get pixel shader anti-aliasing within a triangle but for your specific case you would avoid magnification and then downsampling of your textures.

You might also want to try using a high level of anisotropic filtering for your textured surfaces. Anisotropic filtering reduces blurring on texture surfaces rendered at a steep angle to the camera and so should give you less blurred results on downsampling.
kengob
kengob
mattnewport - Thanks, great input. I had the same feeling about msaa, so I tried it. However, part of my requirements are to use float32 images and this format with msaa isn't supported by my graphics card. I could always try to implement it manually...

Edit: I still suspect that, when the extra data per pixel is combined into an end result, it would still cause blurring. Anybody else msaa would have better results than ssaa?

[Edited by - kengob on September 18, 2009 5:20:36 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.