2000-01-16 - Part 2 Lecture 3: Computer graphics Introduction - - PowerPoint PPT Presentation

2000 01 16 part 2
SMART_READER_LITE
LIVE PREVIEW

2000-01-16 - Part 2 Lecture 3: Computer graphics Introduction - - PowerPoint PPT Presentation

Mats Nyl en January 16, 2001 Slide 1 of 21 2000-01-16 - Part 2 Lecture 3: Computer graphics Introduction Colour, Lights & Surface properties Cameras & Coordinate systems Lecture 4: Computer graphics contd


slide-1
SLIDE 1

Mats Nyl´ en January 16, 2001 Slide 1 of 21

2000-01-16 - Part 2

  • Lecture 3: Computer graphics

– Introduction – Colour, Lights & Surface properties – Cameras & Coordinate systems

  • Lecture 4: Computer graphics cont’d

– Coordinate transformations & Actor geometry – Graphics systems – A simple vtk example

  • Textbook: Chapter 3, except 3.10 which is covered in lecture 11.
  • Exercises: 3.1, 3.2, 3.7 and 3.8.

VIS01

slide-2
SLIDE 2

Mats Nyl´ en January 16, 2001 Slide 2 of 21

Physical description of rendering

VIS01

slide-3
SLIDE 3

Mats Nyl´ en January 16, 2001 Slide 3 of 21

Image-order and object-order

There are two types of rendering algorithms

  • Image order, e.g., ray-tracing (or ray-casting)
  • Object order, render one object at a time.

VIS01

slide-4
SLIDE 4

Mats Nyl´ en January 16, 2001 Slide 4 of 21

Surface versus volume rendering

When we think about rendering we often think about surface-rendering, however some things are very hard to do with that kind of technique, e.g., clouds, smoke or translucent surfaces. This leads to the idea of Volume rendering. Volume-rendering is naturally done with ray-tracing or ray-casting techniques, where rendering is done

  • ne ray at the time.

VIS01

slide-5
SLIDE 5

Mats Nyl´ en January 16, 2001 Slide 5 of 21

Colour

There are three types of cones in the human retina, with caraterstic re- sponse.

4000 ˚ A 5000 ˚ A 6000 ˚ A Relative response Wavelength

Red Green Blue

VIS01

slide-6
SLIDE 6

Mats Nyl´ en January 16, 2001 Slide 6 of 21

Colour models

There are various colour models in use

  • RGB specifies colours as an additive mix of Red, Green and Blue.
  • HSV Specfies Hue (colour), Saturation, and Value to specify a colour.
  • CMY specifies colours as a subtractive mix of Cyan, Magenta and Yel-

low, this colour model is mainly used for printing purposes. VIS01

slide-7
SLIDE 7

Mats Nyl´ en January 16, 2001 Slide 7 of 21

Lights

For the purpose of this lecture, we assume a simplified light model, where the light source is placed at infinity. VIS01

slide-8
SLIDE 8

Mats Nyl´ en January 16, 2001 Slide 8 of 21

Surface properties

Ambient lighting equation Rc = LcOc Diffuse lighting equation Rc = LcOc[ On · (− Ln)] and finally the specular part Rc = LcOc[ S · (− Cn)]Osp where S = 2[ On · (− Ln)] On +

  • Ln. The complete lighting equation is thus

Rc = OaiOacLc − OdiOdcLc( On · Ln) + OsiOscLc[ S · (− Cn)]Osp VIS01

slide-9
SLIDE 9

Mats Nyl´ en January 16, 2001 Slide 9 of 21

Effects of specular reflection

The following figure illustrates the effect of the specular component. The toprow has a specular intensity value of 0.5, and the bottom row 1.0. The specular exponent is 5, 10, 20 and 40 VIS01

slide-10
SLIDE 10

Mats Nyl´ en January 16, 2001 Slide 10 of 21

Cameras

The pictures below illustrates the terminology for cameras additionally we define a front and back clipping plane. VIS01

slide-11
SLIDE 11

Mats Nyl´ en January 16, 2001 Slide 11 of 21

Coordinate systems

There are four distinct coordinate systems commonly used in computer graphics: model, world, view and display.

  • the model coordinate system is where the model is defined, one for each

actor

  • the world coordinate system is the 3D system within which the actors

are placed

  • the view coordinate system is what is visible in the camera, each point

having a x and y value as well as a depth, or z value.

  • the display coordinate system is in actual pixels on the screen

VIS01

slide-12
SLIDE 12

Mats Nyl´ en January 16, 2001 Slide 12 of 21

Homgeneous coordinates

We use homogeneous coordinates, so each point is represented by four values: (xh, yh, zh, wh) the corresponding 3D location is: x = xh wh y = yh wh z = zh wh Note that this representation includes points at infinity (wh = 0). VIS01

slide-13
SLIDE 13

Mats Nyl´ en January 16, 2001 Slide 13 of 21

Translation

A translation transform is defined by a matrix TT =

    

1 tx 1 ty 1 tz 1

    

applying this to (x, y, z, 1)T gives x′ = x + tx y′ = y + ty z′ = z + tz VIS01

slide-14
SLIDE 14

Mats Nyl´ en January 16, 2001 Slide 14 of 21

Scaling

Likewise We can scale an object by the transform matrix TS =

    

sx sy sz 1

    

VIS01

slide-15
SLIDE 15

Mats Nyl´ en January 16, 2001 Slide 15 of 21

Rotation

Similary the rotation transform is given by TR =

     

cosθx′x cosθx′y cosθx′z cosθy′x cosθy′y cosθy′z cosθz′x cosθz′y cosθz′z 1

     

VIS01

slide-16
SLIDE 16

Mats Nyl´ en January 16, 2001 Slide 16 of 21

Complete transform

To transform the coordinates of an actor we would 1 scale the actor 2 rotate the actor 3 translate the actor If the actor is defined by a series of (homogeneous) coordinates {p1, p2, . . . , pn}, we would thus generate the actors coordinates in the world coordinate sys- tem as p′

i = TTTRTS pi

note that the order is very important! VIS01

slide-17
SLIDE 17

Mats Nyl´ en January 16, 2001 Slide 17 of 21

Graphics Systems

Typical graphics system will render a few simple graphics primitives in an efficient fashion

  • Polygon
  • Triangle strip
  • Line
  • Polyline
  • Point

On high end system all of these will be rendered in hardware. VIS01

slide-18
SLIDE 18

Mats Nyl´ en January 16, 2001 Slide 18 of 21

Shading alternatives

When rendering surfaces, smooth surfaces are replaced with polygonal ap- proximations, to regain the smooth appearance som sort of shading needs to be done

  • Flat shading: the normal used in the lighting calculation is the actual

normals of the polygons

  • Goroud shading: uses normals at each vertex, then interpolates during

scan-conversion

  • Phong shading: interpolates the vertex normals for each point within

the polygon. Hardware Phong shading will soon be a standard feature. VIS01

slide-19
SLIDE 19

Mats Nyl´ en January 16, 2001 Slide 19 of 21

A simple example

Let us the object-oriented graphics of vtk to create a simple scene consist- ing of a single cone. We will need these classes vtkRenderer vtkRenderWindow vtkConeSource vtkPolyDataMapper vtkActor VIS01

slide-20
SLIDE 20

Mats Nyl´ en January 16, 2001 Slide 20 of 21

Main part of program

// create a rendering window and renderer vtkRenderer *ren = vtkRenderer::New(); vtkRenderWindow *renWindow = vtkRenderWindow::New(); renWindow->AddRenderer(ren); renWindow->SetSize( 300, 300 ); // create an actor and give it cone geometry vtkConeSource *cone = vtkConeSource::New(); cone->SetResolution(8); vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New(); coneMapper->SetInput(cone->GetOutput()); vtkActor *coneActor = vtkActor::New(); coneActor->SetMapper(coneMapper); // assign our actor to the renderer ren->AddActor(coneActor); // draw the resulting scene renWindow->Render();

VIS01

slide-21
SLIDE 21

Mats Nyl´ en January 16, 2001 Slide 21 of 21

Summary and outlook

Graphics systems will take care of the basics for us. The next step is to consider the visualization pipeline. VIS01