grphics05 - rendering (2)
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
RENDERING PART TWOTHIS TIME, IT’S PERSONAL
Michael heron
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
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.
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.
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.
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
HIDDEN SURFACE REMOVAL
Object modelWhat the viewer would see
Entire polygons hidden from view point
Some polygons closer to viewer (overlapping)
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.
HIDDEN SURFACE REMOVAL
1. 2.
Stage one deals with culling backface polygons
Stage two deals with partial occlusion.
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.
CULLING
If the difference is greater than 90 degrees,then we remove the polygon from the list Of objects to be rendered.
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.
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.
THE PAINTER’S ALGORITHM
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.
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.
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.
Z-BUFFER
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.
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.
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
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.
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.