grphics05 - rendering (2)

23
RENDERING PART TWO THIS TIME, IT’S PERSONAL Michael heron

Upload: michael-heron

Post on 02-Nov-2014

61 views

Category:

Technology


1 download

DESCRIPTION

This is a course on the theoretical underpinnings of 3D Graphics in computing, suitable for students with a suitable grounding in technical computing.

TRANSCRIPT

Page 1: GRPHICS05 - Rendering (2)

RENDERING PART TWOTHIS TIME, IT’S PERSONAL

Michael heron

Page 2: GRPHICS05 - Rendering (2)

INTRODUCTION In the previous lecture we talked about the

nature of light reflection in rendering. Complex and governed by physics Approximations only

In this lecture we are going to talk about some of the other things that are involved in the rendering process. Rasterisation Hidden surface removal

Page 3: GRPHICS05 - Rendering (2)

RASTERISATION Rasterisation is the process of turning a

rendered 3D model into a two dimensional pixelized image. Most usual technique for creating real-time 3D

images. Directly competes with other techniques such as

ray tracing Rasterisation is comparatively fast.

But limited by the number of polygons to be drawn.

Page 4: GRPHICS05 - Rendering (2)

RASTERISATION Three processes for rasterisation:

Determine which squares of the 2D display are occupied by the polygon.

Determine the depth of each square. More on this later

Determine the colour of squares. Process can introduce complications.

Adjacent polygons should fit together without gaps. Can be complicated by nature of resolution.

Page 5: GRPHICS05 - Rendering (2)

RASTERISATION

http://uk.gamespot.com/pages/unions/forums/show_msgs.php?topic_id=25824342&union_id=7600

Graphical representation of 3D scene held ‘off screen’ in the frame buffer before being drawn.

It contains the colour and intensity of each pixel to be drawn on the screen.

When all polygons rasterised, the buffer is drawn to the screen.

Page 6: GRPHICS05 - Rendering (2)

HIDDEN SURFACE REMOVAL

Because processing cost is dependent on the number of polygons to be rendered, useful to restrict the number of polygons to draw.Polygons are sometimes partially or

completely hidden by other polygons. Occluded Determined by rasterisation.

A process by which we can reduce the number of polygons we draw is important.Handled in two separate ways

Page 7: GRPHICS05 - Rendering (2)

HIDDEN SURFACE REMOVAL

Object modelWhat the viewer would see

Entire polygons hidden from view point

Some polygons closer to viewer (overlapping)

Page 8: GRPHICS05 - Rendering (2)

HIDDEN SURFACE REMOVAL

Surfaces that are completely occluded are simply culled. They never get drawn.

Partially occluded polygons get dealt with using a Hidden Surface Removal algorithm. Most well known of these is the z-buffer

algorithm.

Page 9: GRPHICS05 - Rendering (2)

HIDDEN SURFACE REMOVAL

1. 2.

Stage one deals with culling backface polygons

Stage two deals with partial occlusion.

Page 10: GRPHICS05 - Rendering (2)

CULLING

Culling done relative to viewing angle. If difference between the viewing angle and the

surface normal is greater than 90 degrees, the surface is invisible.

Also known as back-face culling Remove those triangles not facing the camera

from the rendering queue. Deals with complete occluded polugons.

Page 11: GRPHICS05 - Rendering (2)

CULLING

If the difference is greater than 90 degrees,then we remove the polygon from the list Of objects to be rendered.

Page 12: GRPHICS05 - Rendering (2)

AFTER CULLING Having removed the hidden polygons, we

need to decide upon overlapping polygons. All polygons drawn as separate entities. No

knowledge of relationship in the scene. Need an algorithm to decide on how partially

occluded polygons are to be drawn. Such as the z-buffer algorithm.

Page 13: GRPHICS05 - Rendering (2)

THE PAINTER’S ALGORITHM Deals with hidden visibility by drawing things

farthest to nearest. Like a painter on a canvas.

Requires some pixels to be redrawn several times. And has some problems with overlapping

shapes. Compensation for this complicated and

expensive. Splitting polygons.

Page 14: GRPHICS05 - Rendering (2)

THE PAINTER’S ALGORITHM

Page 15: GRPHICS05 - Rendering (2)

Z-BUFFERING

For each pixel, we could sort each polygon by depth.Draw only the one nearest.Sorting a costly process

And done for each pixel to be rendered. Z-Buffering achieves the same effect

without sorting.Dramatic performance improvement in

terms of CPU.Quite costly in terms of memory

representation.Many hardware architectures have

dedicated z-buffer chips.

Page 16: GRPHICS05 - Rendering (2)

Z-BUFFER

The Z-Buffer is a 2D array that maps onto the same dimensions as the image.As we encounter polygons, we make a note

of their depth (z) value. We assume our viewport is on the

positive z-axisAnd we are looking down that z-axis towards

the scene. Done during rasterisation.

We keep a track of the depth of each image we are to draw.

We store the colour and the intensity as we do this.

Page 17: GRPHICS05 - Rendering (2)

Z-BUFFER

While doing the rasterisation, we can compare the z value against our current ‘nearest’ shape. If it’s farther away, we don’t render it.

Skip it, move on to the next If it’s closer than our previous closest, it

becomes the new closest match. It replaces the colour and intensity as it does so.

The end result is that the frame buffer contains only the information relating to the nearest polygon for any pixel.

Page 18: GRPHICS05 - Rendering (2)

Z-BUFFER

Page 19: GRPHICS05 - Rendering (2)

PROCESS 3D Scene leads to definition of

relationship of objects.Scene gets broken down into polygons to

represent 3D shapes. Back-face culling used to eliminate

polygons that are invisible. Rasterisation goes over each non-

culled polygon to determine where it falls on the viewing screen.Colour and intensity of each pixel

determinedZ-buffering used to ensure proper handling

of partial occlusion.

Page 20: GRPHICS05 - Rendering (2)

Z-BUFFERING AND TRANSPARENCY The Z-Buffer algorithm doesn’t work

for transparent polygons.Alas!

The z-buffer occludes things behind other things.With transparency, we should be able to

see the things we are in front of. A quick fix:

Draw opaque polygons firstThen draw translucent polygons

Can be combined with alpha blending.

Page 21: GRPHICS05 - Rendering (2)

OTHER KINDS OF HSR

Contribution culling If objects are too small to contribute to a

scene, then we simply discard them. Viewport culling

If objects are outside our viewing projection, we don’t process them.

Other visibility algorithms existsBinary tree partitioningWarnock algorithmRay Casting

Page 22: GRPHICS05 - Rendering (2)

IMPORTANCE OF HSR

Despite huge improvements in GPU hardware, efficiency still important.Hardware has gotten more powerfulModels have gotten more complex.

A certain frame-rate is required in order for ‘realistic’ motion to be experienced.Trade-off between polygon count and frame-

rate. Easiest way to reduce polygon count

without compromising graphical quality.

Page 23: GRPHICS05 - Rendering (2)

SUMMARY

Important to be able to cull hidden polygons and pixels. Reduces rendering cost.

Two related processes. Culling Visibility

Z-Buffering one of the most common processes in use today.