1 / 42

Pre-Filter Antialiasing

Pre-Filter Antialiasing. Kurt Akeley CS248 Lecture 4 4 October 2007 http://graphics.stanford.edu/courses/cs248-07/. Review. Aliasing. Aliases are low frequencies in a rendered image that are due to higher frequencies in the original image. Jaggies. Original:. Rendered:.

gad
Télécharger la présentation

Pre-Filter Antialiasing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007 http://graphics.stanford.edu/courses/cs248-07/

  2. Review

  3. Aliasing Aliases are low frequencies in a rendered image that are due to higher frequencies in the original image.

  4. Jaggies Original: Rendered:

  5. Convolution theorem Let fand g be the transforms of f and g. Then Something difficult to do in one domain (e.g., convolution) may be easy to do in the other (e.g., multiplication)

  6. Aliased sampling of a point (or line) * x = = f(x) F(s)

  7. Aliased reconstruction of a point (or line) * x sinc(x) = = f(x) F(s)

  8. Reconstruction error (actually none!) Original Signal Phase matters! AliasedReconstruction

  9. Sampling theory Fourier theory explains jaggies as aliasing. For correct reconstruction: • Signal must be band-limited • Sampling must be at or above Nyquist rate • Reconstruction must be done with a sinc function All of these are difficult or impossible in the general case. Let’s see why …

  10. Why band-limiting is difficult Band-limiting primitives prior to rendering compromises image assembly in the framebuffer • Band-limiting changes (spreads) geometry • Finite spectrum  infinite spatial extent • Interferes with occlusion calculations • Leaves visible seams between adjacent triangles Can’t band-limit the final (framebuffer) image • There is no final image, there are only samples • If the sampling is aliased, there is no recovery Nyquist-rate sampling requires band-limiting

  11. Why ideal reconstruction is difficult In theory: • Required sinc function has • Negative lobes (displays can’t produce negative light) • Infinite extent (cannot be implemented) In practice: • Reconstruction is done by a combination of • Physical display characteristics (CRT, LCD, …) • The optics of the human eye • Mathematical reconstruction (as is done, for example, in high-end audio equipment) is not practical at video rates.

  12. Two antialiasing approaches are practiced Pre-filtering (this lecture) • Band-limit primitives prior to sampling • OpenGL ‘smooth’ antialiasing Increased sample rate (future lecture) • Multisampling, super-sampling • OpenGL ‘multisample’ antialiasing

  13. Pre-Filter Antialiasing

  14. * x = = f(x) F(s) Ideal point (or line cross section) sinc(x) sinc(x)

  15. * x = = f(x) F(s) Band-limited unit disk sinc(x) sinc(x)

  16. * x = = f(x) F(s) Almost-band-limited unit disk sinc(x) sinc2(x) sinc3(x) Finite extent!

  17. Equivalences These are equivalent: • Low-pass filtering • Band-limiting • (Ideal) reconstruction These are equivalent: • Point sampling of band-limited geometry • Weighted area sampling (FvD 3.17.3) of full-spectrum geometry

  18. Pre-filter pros and cons Pros • Almost eliminates aliasing due to undersampling • Allows pre-computation of expensive filters • Great image quality (with important caveats!) Cons • Can’t handle interactions of primitives with area • Reconstruction is still a problem

  19. Pre-filtering in the vertex pipeline Application struct { float x,y,z,w; float r,g,b,a;} vertex; Vertex assembly Vertex operations struct { vertex v0,v1,v2 } triangle; Primitive assembly Primitive operations Point sampling of pre-filtered primitives sets fragment alpha value struct { short int x,y; float depth; float r,g,b,a;} fragment; Rasterization Fragment operations Fragments are blended into the frame buffer struct { int depth; byte r,g,b,a;} pixel; Framebuffer Display

  20. Pre-filter point rasterization point being sampled at the center of this pixel alpha

  21. Pre-filter line rasterization line being sampled at the center of this pixel alpha

  22. Point size Xscreen frac bits Yscreen frac bits Pixel index 3 4 4 4 Pre-filtered primitive stored in table Supports pre-computation Simplifies distance calculation (square root in table) Can compensate for reconstruction errors • Sampling and reconstruction go hand-in-hand Fragment Alpha 32K x 8 8

  23. Line slope Xscreen frac bits Yscreen frac bits Pixel index Line width 5 4 4 4 3 Line tables get big! Fragment Alpha 1M x 8 8

  24. Triangle pre-filtering is difficult Three arbitrary vertex locations define a huge parameter space • Resulting table is too large to implement Edges can be treated independently • But this is a poor approximation near vertexes, where two or three edges affect the filtering • And triangles can be arbitrarily small

  25. Pre-filtering in the vertex pipeline Application struct { float x,y,z,w; float r,g,b,a;} vertex; Vertex assembly Vertex operations struct { vertex v0,v1,v2 } triangle; Primitive assembly Primitive operations Point sampling of pre-filtered primitives sets fragment alpha value struct { short int x,y; float depth; float r,g,b,a;} fragment; Rasterization Fragment operations Fragments are blended into the frame buffer struct { int depth; byte r,g,b,a;} pixel; Framebuffer Display

  26. Ideal pre-filtered image assembly Impulse-defined points and lines have no area So they don’t occlude each other So fragments should be summed into pixels C’pixel = Cpixel + Afrag Cfrag

  27. Practical pre-filtered image assembly Frame buffers have limited numeric range So summation causes overflow or clamping ‘Uncorrelated’ clamped blend yields good results • But clamping R, G, and B independently causes color shift ‘Anti-correlated’ clamped blend is an alternative • Best for rendering pre-filtered triangles • sorted front-to-back • But requires frame buffer to store alpha values C’pixel = (1-Afrag)Cpixel + Afrag Cfrag

  28. Anti-correlated blend function i = min(Afrag, (1-Apixel)) A’pixel = Apixel + I C’pixel = Cpixel + i Cfrag

  29. Demo

  30. OpenGL API glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); // sum glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // blend glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE); // saturate

  31. Filtering and Human Perception

  32. Resolution of the human eye Eye’s resolution is not evenly distributed Foveal resolution is ~20x peripheral Systems can track direction of view, draw high-resolution inset Flicker sensitivity is higher in periphery One eye can compensate for the other Research at NASA suggests high-resolution dominant display Human visual system is well engineered …

  33. Imperfect optics - linespread Ideal Actual

  34. Linespread function

  35. * x = = f(x) F(s) Filtering

  36. * * = = f(x) f(x) Frequencies are selectively attenuated

  37. Selective attenuation (cont.) * * = = f(x) f(x)

  38. Modulation transfer function (MTF)

  39. Optical “imperfections” improve acuity Image is pre-filtered Cutoff is approximately 60 cpd Cutoff is gradual – no ringing Aliasing is avoided Foveal cone density is 120 / degree Cutoff matches retinal Nyquist limit Vernier acuity is improved Foveal resolution is 30 arcsec Vernier acuity is 5-10 arcsec Linespread blur includes more sensors

  40. Summary Two approaches to antialiasing are practiced • Pre-filtering (this lecture) • Increased sample rate Pre-filter antialiasing • Works well for non-area primitives (points, lines) • Works poorly for area primitives (triangles, especially in 3-D) The human eye is well adapted • Sampling theory helps us here too

  41. Assignments Before Thursday’s class, read • FvD 3.1 through 3.14, Rasterization Project 1: • Continue work • Demos Wednesday 10 October

  42. End

More Related