Computer Graphics Viewing, Rendering, Antialiasing گرد آوري و تاليف: دكتر احمد...

Post on 16-Dec-2015

225 views 8 download

Tags:

transcript

Computer Graphics Viewing, Rendering,

Antialiasing

Computer Graphics Viewing, Rendering,

Antialiasing

:گرد آوري و تاليف

دكتر احمد رضا نقش نيل چي

دانشگاه اصفهان

گروه مهندسي كامپيوتر

Right Handed Coordinate System

+X

+Y

+Z

+X

+Y

+Z

Viewing a 3D world

We have a model in this world and would like to view it from a new position.

We’ll call this new position the camera or eyepoint. Our job is to figure out what the model looks like on the display plane.

+X

+Y

+Z

Parallel Projection

+X

+Y

+Z

Perspective Projection

+X

+Y

+Z

Major Tasks of a Renderer Modelling:

Produce sets of vertices that define geometric objects Geometric Processing:

Determine which objects should appear and in what colour Normalization Clipping Hidden Surface Removal Shading Vertex-based: floating point processing in 3-D

Rasterization: Generate frame buffer pixels by Scan Conversion Pixel-based: integer processing in 2-D

Display: Pixels are read from the frame buffer onto the CRT Must overcome display artefacts through Antialiasing

A Note about Hidden-Surface Removal

Hidden Surface Removal (Visible Surface Determination) seeks to discover which objects are visible or obscured from the viewpoint

Object Space Approach: Consider polygons A and B pair-wise and determine if: (a) B

partially obscures A, (b) A partially obscures B, (c) A and B are completely visible, (d) B obscures A (or vice versa)

Image Space Approach: Follows ray-casting approach

Aliasing

Occurs when the sampling inherent in rendering does not contain enough information for an accurate image.

Original Scene

Scanline Luminosity

Sampling Pixel Centres

Sampled Signal Luminosity Signal

Rendered Image

Antialiasing

What is antialiasing? How do we see the affects of antialiasing? What can we do about it? Math behind antialiasing Antialiasing in modern day graphics cards Advanced stuff on AA

Let’s Revisit a pixel

A pixel is which of these things (theoretically)? point circle/disk square/rectangle has area has a location sample

Samples

Continuous - function with values at any input. Most things in the world. Ex. sine and cosine

Discrete - function with values only at specific inputs. Computers are discrete.

What is a 2D example? To convert from a continuous function to a discrete one, we discretize or sample

To convert form a continuous variable to a discrete one, we quantize When we render an image (which is a continuous function), we sample and

quantize

A New Thought about Images

Images are really a 2D function

Here’s an image plotted as a height field

Now we store this image as an “array” of points. What does that mean?

We Sample the Image Function

Here is the sampling function. It is called the delta function

Thus we are “sampling” a continuous image function

We call these samples at this regular grid of points, pixels.

Pixels are a sampling of the function that describes the image.

We store these pixels into memory as an array of colors.

How densely should we sample?

What would govern this?

A quick footnote into frequency analysis

A way to understand the sampling question is to convert the function into a different “space” or domain.

We use the Fourier Transform to convert the function (in our case the image) into the frequency domain.

What does sampling mean?

What happens if we don’t sample enough?

Aliasing in General

If we sample at too low a rate, the high frequencies in the image appear as lower frequencies.

How do we fix it? Increase sampling Remove high frequencies

Aliasing in Image

Aliasing manifests itself as “jaggies” in graphics. Thus we don’t have enough pixels to accurately represent the underlying function. Check out what happens when we increase our sampling.

Effects of Aliasing in Image

Common aliasing errors (called artefacts) are: jagged profiles, disappearing or improper fine detail, and disintegrating textures.

Jagged Profiles

Loss of Detail

Fixing Aliasing

Increase Resolution What’s wrong with this approach? Filtering is another possibility

We want to remove the high frequency areas How would we do that?

Let’s re-examine what a pixel is in reality.

Prefiltering

No Antialiasing Prefiltering

Postfiltering

Sampling: take jittered, regular or random samples.

Averaging: use an filter to assign weights to each sample. Sum all the weighted samples to obtain a pixel.

Jittered Regular

nn

nn

161

81

161

81

41

81

161

81

161

Filtering Example

(0,0)

(4,2)

(4,0)

2

2

1

10

0

3 4

Let’s recall

Filter Sampling

This reduces the high frequencies (which cause aliasing)

Interpolate between samples.

Filter Sampling Result (Example)

What are we doing?

(0,0)

(4,2)

(4,0)

2

2

1

10

0

3 4

Two ways to Antialias

Increase resolution (increase sampling) or

Supersampling

Increase Rendering Resolution

Render the image at a higher resolution and downsample. Really, you are letting your eye do some filtering for you.

Supersampling

For each pixel, we would like to figure out what “percentage” is covered.

(0,0)

(4,0)

2

1

10

0

3 4

Line Antialiasing

Full Screen Antialiasing

Another way to do the supersampling is to do full screen antialiasing

We want to draw the image with several camera jitter positions and average the answers

Full Screen Antialiasing Example (Exaggerated)

Anti-aliasing in Summary Developed to combat aliasing Super-sampling (Post-filtering):

Compute pixel color by averaging multiple samples.

Sample the scene at n times the display resolution. For example, suppose the display resolution is 512x512. Sampling at three times the width and three times the height of the display resolution would yield 1536x1536 samples

A filter provides the weights used to compute the average

Antialiasing Examples

پايانپايان