Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Aliasing confusion

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 vladic2000x   Members   


Posted 22 May 2013 - 12:51 PM



I am a bit confused on the aliasing problem in computer graphics(OpenGL), specifically:


1. In the picture below, the checkerboard texture is laid on a rectangle consisting of 2 triangles. Please note at the bottom of the image the jagged  edges of black and white blocks of the texture:




Is that problem called aliasing?


2. In the picture below, the same jagged effect can be seen on the edges of the right-most two triangles:




Is that the same aliasing problem?


I'm asking this because in first case, texture sampling is involved but in the second case there is no texture. 



3. If in the first example the issue is called aliasing, can we say that using linear filtering as magnification/minification filters in sampling the texture represent an anti-aliasing technique? I have searched the web for OpenGL anti-aliasing and I mostly read about "multisampling", so I'm wondering if linear and mipmap filtering can be considered anti-aliasing techniques?

Edited by vladic2000x, 22 May 2013 - 12:53 PM.

#2 Zaoshi Kaba   Members   


Posted 22 May 2013 - 04:10 PM

  1. yes
  2. yes
  3. no and no

Linear filtering is texture filter. If you attempt to take color between 2 pixels linear filter will interpolate them.

Aliasing is... Like in your 2nd picture. You draw white line on black background, so pixels are completely white or completely black. It doesn't look like a line since you can see pixels, it's more like bunch of rectangles. Anti-aliasing is supposed to smooth out these pixels, to make it look like an actual line. Here's some example: http://international.download.nvidia.com/webassets/en_US/shared/images/articles/introducing-the-geforce-gtx-680-gpu/TXAA.png

#3 MJP   Moderators   


Posted 22 May 2013 - 06:15 PM

1. Yes, that's aliasing. Essentially you have some signal that's stored in a texture, and the fragment shader samples that signal. If the fragment shader doesn't sample at an adequate rate relative to the rate at which the signal changes (the frequency of the signal), then you get aliasing. A black and white checkerboard is basically a series of step functions, and sampling step functions will always result in aliasing because they have an infinite rate of change.


2. Yes, that's a similar case of aliasing. In this case the aliasing stems from the rasterizer, which samples some signal (in this case a triangle) at a fixed set of sample positions (usually aligned to the center of pixels). A triangle edge is also a step function, so you get the same aliasing problem.

3. Yes, texture filtering is a very important means of anti-aliasing. Filtering reduces aliasing by attenuating high-frequency components of a signal, but can also remove detail that's present in those higher frequencies. However if you oversample by sampling at a higher rate than your screen resolution and then filter the result when downsampling, you can reduce aliasing while still preserving details. This is the basic premise behind both texture filtering and MSAA. The former works with texture sampling, and the later works with the rasterizer. With texture sampling you typically take 4 texture samples in a 2x2 grid and perform linear filtering, which allows you to avoid aliasing as long as your sampling rate is no less than 1/2 the resolution of your texture. So if you had a 512x512 texture, bilinear filtering won't alias as long as the texture is mapped to an area of the screen that's >= 256x256 pixels. If you need to go lower, you need to use pre-filter by creating a chain of mip maps. This "no less than 1/2 the texture resolution" rule is why you create each mip level to be 1/2 the size of the previous level.

If you're interested in this sort of thing, I have a rather lengthy series of articles on my blog regarding sampling and aliasing. It may put you to sleep, but there's a lot of (hopefully useful) info in there.

Edited by MJP, 13 June 2013 - 04:21 PM.

#4 vladic2000x   Members   


Posted 22 May 2013 - 11:46 PM

Thanks MJP, I'll defintely have a look at the articles.

#5 LorenzoGatti   Members   


Posted 23 May 2013 - 03:17 AM

Regarding the apparent disagreement in previous answers, filtering and mipmapping reduce aliasing in texture lookups (approximate sampling from wrong texture coordinates) which is separate from aliasing in rendering (approximate drawing to wrong frame buffer positions) but conceptually similar. They are addressed in different ways for technological reasons; for example, filtering texture lookups has been a cheap commoditized basic feature since the period of fixed function pipelines, while the same kind of filtering applied to rendering is a luxury because it would need expensive additional fragments as input.

Edited by LorenzoGatti, 19 June 2013 - 08:45 AM.

Omae Wa Mou Shindeiru

#6 marcClintDion   Members   


Posted 13 June 2013 - 02:32 PM

Chapter 17 of this book shows how to write anti-aliasing shaders http://wiki.labomedia.org/images/1/10/Orange_Book_-_OpenGL_Shading_Language_2nd_Edition.pdf

Consider it pure joy, my brothers and sisters, whenever you face trials of many kinds, because you know that the testing of your faith produces perseverance. Let perseverance finish its work so that you may be mature and complete, not lacking anything.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.