2000 01 16 part 2
play

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


  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

  2. Mats Nyl´ en January 16, 2001 Slide 2 of 21 Physical description of rendering VIS01

  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

  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 one ray at the time. VIS01

  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. Green Red Blue Relative response 4000 ˚ A 5000 ˚ 6000 ˚ A A Wavelength VIS01

  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

  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

  8. Mats Nyl´ en January 16, 2001 Slide 8 of 21 Surface properties Ambient lighting equation R c = L c O c Diffuse lighting equation R c = L c O c [ � O n · ( − � L n )] and finally the specular part C n )] O sp R c = L c O c [ � S · ( − � where � S = 2[ � O n · ( − � L n )] � O n + � L n . The complete lighting equation is thus C n )] O sp R c = O ai O ac L c − O di O dc L c ( � O n · � L n ) + O si O sc L c [ � S · ( − � VIS01

  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

  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

  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

  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: ( x h , y h , z h , w h ) the corresponding 3D location is: x = x h y = y h z = z h w h w h w h Note that this representation includes points at infinity ( w h = 0). VIS01

  13. Mats Nyl´ en January 16, 2001 Slide 13 of 21 Translation A translation transform is defined by a matrix   1 0 0 t x 0 1 0 t y   T T =   0 0 1 t z     0 0 0 1 applying this to ( x, y, z, 1) T gives x ′ = x + t x y ′ = y + t y z ′ = z + t z VIS01

  14. Mats Nyl´ en January 16, 2001 Slide 14 of 21 Scaling Likewise We can scale an object by the transform matrix  0 0 0  s x 0 0 0 s y   T S =   0 0 0 s z     0 0 0 1 VIS01

  15. Mats Nyl´ en January 16, 2001 Slide 15 of 21 Rotation Similary the rotation transform is given by   0 cosθ x ′ x cosθ x ′ y cosθ x ′ z 0 cosθ y ′ x cosθ y ′ y cosθ y ′ z     T R =   0 cosθ z ′ x cosθ z ′ y cosθ z ′ z     0 0 0 1 VIS01

  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 { p 1 , p 2 , . . . , p n } , we would thus generate the actors coordinates in the world coordinate sys- tem as p ′ i = T T T R T S p i note that the order is very important! VIS01

  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

  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

  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

  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

  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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend