Lecture 5 Basic Rendering

Size: px
Start display at page:

Download "Lecture 5 Basic Rendering"

Transcription

1 Lecture 5 Basic Rendering Dr. Shuang LIANG School of Software Engineering Tongji University Spring 2013

2 At the end of this lecture, you will have enough weapons to generate the above cool figures!

3 Let s start this amazing and thorny journey!

4 Today s Topics Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Surface rendering

5 Today s Topics Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Surface rendering

6 Realism in computer graphics Goal of many graphics algorithms is to create results that are as physically realistic as possible Realism in graphics can be subdivided into different categories: geometric modeling, rendering, behavior, and interaction Techniques and algorithms used to achieve realism in category are dependent on several factors application or content (movies, scientific visualization, etc.) user type (novice vs. expert) resources (time, money, processing power, etc.) Degree of realism that can be achieved usually depends on amount of resources when resources are short, use approximations

7 Realism and media Early computer graphics focused on still images typically meant photorealism goal was to accurately reconstruct a scene at a specific time emphasized good approximations of geometry and light reflection properties of surfaces

8 Realism and media Early computer graphics focused on still images With the increased production of animated graphics (commercials, movies, special effects, cartoons) comes new standard of realism character animation natural phenomena: cloth, fur, hair, skin, grass, trees, smoke, water, clouds, wind Newtonian physics: objects which collide, fall, scatter, bend, shatter, etc.

9 Realism and media Always a tradeoff between realism and rendering time Applications that require real-time input/output could handle severely limited amount of realism Applications which do not require real-time interaction (films, static imagery), have unlimited time to achieve realism Real-time interaction during modeling (3DS Max) Rendered image

10 Tradeoff Consider a movie vs. scientific visualizations and CAD models movie will want to achieve as many special effects as possible (motion blur, depth of field, etc.) CAD (engineering) models will skip these special effects for clarity scientific visualizations will display the geometric model and/or simulation data as is, without any approximations, curve smoothing, etc., to avoid hiding artifacts, approximations, or errors

11 Polygonalization Realism in geometry represent objects as sets of polygons finite level of detail if we zoom in it doesn t look good easily hardware accelerated often want simplest mesh possible while preserving as much detail as possible fewer vertices needed at flat, simple portions of mesh more vertices needed at complex varying regions of mesh

12 Realism in geometry Mesh simplification / decimation take detailed model, reduce number of polygons while keeping as much shape as possible various algorithms exist active area of research Meshes can also be smoothed, sharpened, manipulated, etc. same concepts learned in filtering can be applied to 3d models instead of 2d images E.g., smoothing a mesh requires removing high frequencies

13 Realism in geometry Subdivision surfaces two-step process to add more detail to mesh: Topology refinement (add new vertices) Geometry refinement several schemes for subdividing continuously subdivide triangles into more triangles for more details as needed allows for editing of multi-resolution models (editing at various levels of detail)

14 Dynamic LOD Realism in geometry objects far from the camera don t need as many polygons, while objects closer should have more replace farther objects with low resolution meshes multiple versions of model in scene graph (differing only in level of detail) Terrain and water rendered at different LODs

15 Bump mapping Realism in geometry Achieved by perturbing the surface normals of the object and using the perturbed normal during lighting calculations Does not modify the underlying geometry

16 Realism in geometry Displacement mapping Displace vertices in a mesh by values stored in a 2D texture Actually modifies the geometry

17 Realism in rendering Multiple light bounces add more lighting to the scene by calculating lighting coming directly from light sources, as well as light reflected off of other objects appears more photorealistic, but much more expensive to compute Often hacked by using a constant ambient term instead Left: single ray cast via nonrecursive ray tracing (3 sec. render time) Right: multiple light bounces via photon mapping (57 sec.)

18 Realism in rendering Polygonal rendering and Gouraud shading fast, easily implemented in hardware (default lighting in OpenGL) per vertex lighting interpolates color between vertices lighting is only calculated at vertices from direct light sources no global illumination does not look very realistic (hard shadows, no light reflecting off other objects)

19 Raytracing Realism in rendering shoot rays from the eye into the scene at each intersection calculate amount of light hitting the object if the surface is reflective or refractive, reflect /refract the ray and continue tracing good for shiny, reflective surfaces expensive for global illumination hard to compute multi-bounce lighting

20 Radiosity Realism in rendering subdivide scene into patches, iteratively compute how much light each patch contributes to each other patch good for diffuse global illumination view independent, once solved, can move camera around A virtual scene rendered by radiosity algorithm

21 Realism in rendering Other rendering techniques: spherical harmonics path tracing point based rendering image based lighting (IBL)

22 Realism in behavior Behavior realism is important we are very distracted by unrealistic behavior even if the rendering is realistic good behavior is very convincing even if the rendering is not realistic Keyframing most animations are created through keyframes animators spend hours specifying one key pose after another; in between frames interpolated based on the keyframes

23 Realism in behavior Motion capture (mocap) sample positions and orientations of real world markers over time once captured, apply these motions to a computer model usually better than keyframed animations extremely realistic

24 Physical simulation Realism in behavior can look extremely realistic usually very expensive to calculate (such as fluid dynamics) realism vs. time tradeoff Egg explosion simulation Simulating fracturing of stone

25 Today s Topics Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Surface rendering

26 Vector representation Vector operations a xi y j zk { x, y, z} Length (or norm) of a vector a x y z Normalized vector (unit vector) a { x, y, z } a a a a We say a 0, if and only if x 0, y 0, z 0

27 Vector operations if a ( x1, y1, z1), b x2 y2 z2 (,, ), then a b ( x x, y y, z z ), b Dot product (inner product) a a b a b cos x x y y z z Laws of dot product: Theorem a b b a, a ( b c)= a b+ a c a b 0 a b (why?)

28 Cross product Vector operations i j k ab x1 y1 z1 i j k x y z y z z x x y y z z x x y

29 Cross product c a b is also a vector, whose direction is determined by the right-hand law and c a, c b c a b sin c a b (easy to prove) represents the oriented area of the parallelogram taking and as two sides r1 r2 r2 r (why?) 1 Vector operations c b a

30 Vector operations Cross product Theorem Theorem same time, and they are not equal to zero at the (easy to understand) a b 0 (why?) Property r ( r r ) r r r r

31 Vector operations Mixed product (scalar triple product or box product) ( a, b, c) ( a b) c a a a b b Geometric Interpretation: it is the (signed) volume of the parallelepiped defined by the three vectors given b c c c

32 Mixed product (scalar triple product or box product) ( a, b, c) ( a b) c Vector operations a a a b b b c c c ( a b) c a b c cos a b sin c cos Base h c a

33 Mixed product (scalar triple product or box product) ( a, b, c) ( a b) c Property: Vector operations a a a b b b c c c ( a, b, c) ( b, c, a) ( c, a, b) ( a, b, c) ( b, a, c) ( a, c, b) why?

34 Vector operations Mixed product (scalar triple product or box product) Theorem a, b, c are coplanar ( a, b, c) 0 why? a, b, c are coplanar,, v, at the same time, and a b vc 0 they are not equal to zero

35 A question often met in applications Given two vectors v, v 1 2 v, making 3 v3 v1 Vector operations, how to construct another vector v 2 v 3 Solution: p v v cos normalized( v ) 2 1 v p v 1 v v v v v v v v1 v 2 v 1 v 1 then: v v v 3 2 p

36 Introduction to vector functions r( t) ( x( t), y( t), z( t)) where t is a variable, is a vector function Derivative of a vector function Properties (1) (2) dx dy dz r( t),, dt dt dt ( t) r( t) ( t) r( t) ( t) r ( t) r ( t) r ( t) r( t) r ( t) r ( t) r ( t) r ( t) r ( t) r( t) r ( t) r ( t) r ( t) (3)

37 Introduction to vector functions r( t) ( x( t), y( t), z( t)) where t is a variable, is a vector function Derivative of a vector function Properties (4) r ( t), r ( t), r ( t) dx dy dz r( t),, dt dt dt r 1 ( t), r2 ( t), r3 ( t) r1 ( t), r 2 ( t), r3 ( t) r1 ( t), r2 ( t), r 3 ( t)

38 Theorem Length of Proof: Introduction to vector functions r () t is const r( t) r( t) 0 r( t) const r( t) r( t) const r( t) r( t) r( t) r( t) 0 2 r( t) r( t) 0 r( t) r( t) 0 Geometric interpretation: sphere curve r() t is the trace of a (hyper) 2

39 Theorem Introduction to vector functions r( t) 0, and the direction of r() t is fixed r( t) r( t) 0 r() t Geometric interpretation: the trace of is a straight line passing the origin of the coordinate system

40 Theorem ( t) ( t), Introduction to vector functions r() t r r 0 and is parallel to a fixed plane r( t), r( t), r ( t) 0 Proof: Let n be the normal of that plane, then nr( t) 0, Then, nr( t) 0, nr( t) 0, Then, n is perpendicular to three vectors r( t), r( t), r ( t) Then, r( t), r( t), r ( t) should belong to same plane r( t), r( t), r ( t) 0 Then, Geometric interpretation: the origin r() t locates in a plane passing

41 Today s Topics Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Surface rendering

42 What is 3D rendering? Topics in computer graphics Imaging: representing 2D images Modeling: representing 3D objects Rendering: constructing 2D images from 3D models Animation: simulating changes over time

43 Interactive 3D rendering scenario I Images generated in fraction of a second (<1/10) as user controls rendering parameters (e.g., camera) Achieve highest quality possible in given time Useful for visualization, games, etc. Meshviewer

44 Batch 3D rendering scenario II One image generated with as much quality as possible for a particular set of rendering parameters Take as much time as is needed (minutes) Useful for photorealistism, movies, etc. Avatar

45 3D primitives 3D rendering pipeline Modeling transformation Lighting Viewing transformation Projection transformation Clipping Viewport transformation Scan conversion Transform into 3D world coordinate system Illuminate according to lighting and reflectance Transform into 3D camera coordinate system Transform into 2D camera coordinate system Clip primitives outside camera s view Transform into image coordinate system Draw pixels (includes texturing, hidden surface) 2D image

46 Ray-casting framework Ray-casting (a simple version of ray tracing) Generate an image by sending one ray per pixel It is a major rendering algorithm in CG

47 Ray-casting framework Image Raycast (Camera cam, Scene scene, int width, int height) { Image image = new Image (width, height) ; for (int i = 0 ; i < height ; i++) for (int j = 0 ; j < width ; j++) { Ray ray = RayThruPixel (cam, i, j) ; Intersection hit = Intersect (ray, scene) ; image[i][j] = FindColor (hit) ; } return image ; } We will focus on figuring out details of this framework!

48 Ray-casting framework illustration

49 Ray-casting framework illustration

50 Ray-casting framework illustration Image plane

51 Ray-casting framework illustration Image plane

52 Ray-casting framework illustration Each pixel corresponds to one ray. We need to figure out which scene point each ray hits.

53 Ray-casting framework illustration What s the color you put in each pixel?

54 Ray-casting framework illustration Pixel color determined by shading models

55 Ray-casting framework illustration Following terminologies are equivalent Eye = camera = viewpoint Eye coordinate system = camera coordinate system = viewpoint coordinate system View plane = virtual screen = image plane

56 Ray-casting framework Image Raycast (Camera cam, Scene scene, int width, int height) { Image image = new Image (width, height) ; for (int i = 0 ; i < height ; i++) for (int j = 0 ; j < width ; j++) { Ray ray = RayThruPixel (cam, i, j) ; Intersection hit = Intersect (ray, scene) ; image[i][j] = FindColor (hit) ; } return image ; } In what coordinate systems?

57 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Surface rendering Outline

58 Camera coordinate system The scene and the camera are described in WCS However, ray-casting can be more conveniently described in the camera coordinate system Camera position

59 Camera coordinate system The scene and the camera are described in WCS However, ray-casting can be more conveniently described in the camera coordinate system Here comes the question: How to get the coordinates of objects in the camera coordinate system? Answer: we need a transformation matrix to transform the objects defined in WCS to the camera coordinate system

60 Camera coordinate system We assume the camera is at the origin of WCS. To specify the camera coordinate system, two vectors are given, N and V. (N and V are not necessarily perpendicular) n N N ( n, n, n ) x y z y view v u v Vn Vn nu ( u, u, u ) x y z ( vx, vy, vz ) z view n u x view

61 Camera coordinate system Then, in the camera coordinate system, the coordinate of the point (x, y, z, 1) defined in the WCS is x 0 c ux uy uz x y vx vy vz 0 c y z c nx ny nz 0 z

62 Camera coordinate system One step further, if the camera s position is (x 0, y 0, z 0, 1) x 0 c ux uy uz x0 x y vx vy vz 0 c y 0 y z c n z x ny n z 0 z The final transformation matrix from WCS to camera system is xc ux uy uz uxx0 uy y0 uzz0 x y v c x vy vz vxx0 vy y0 vzz 0 y z c n z x ny nz nxx0 ny y0 nzz

63 Camera coordinate system summary (1) Ray-casting is more convenient expressed in camera coordinate system The scene should be transformed from WCS to the camera coordinate system To specify the camera system, you need to provide the camera position P 0, the reference point P ref, and the up vector (V) (Note that: P 0 - P ref determines N) The center of view-plane resides on the z view ; normally the view-plane is perpendicular to z view ; So, only parameter needs to be provided to determine the viewplane, that is what?

64 Camera coordinate system summary (2) The camera coordinate system mentioned in our lecture is a right-handed system However, in some existing systems, camera system is left-handed (e.g., OpenGL); For more details about the 3D pipeline, you can refer to Chapter 7 of the recommended textbook In OpenGL, the following three functions are most related glulookat (x0, y0, z0, xref, yref, zref, Vx, Vy, Vz) glortho (xwmin, xwmax, ywmin, ywmax, dnear, dfar) gluperspective (theta, aspect, dnear, dfar) Note: in OpenGL, the view-plane coincides with near clipping plane

65 Ray-casting framework Image Raycast (Camera cam, Scene scene, int width, int height) { Image image = new Image (width, height) ; for (int i = 0 ; i < height ; i++) for (int j = 0 ; j < width ; j++) { Ray ray = RayThruPixel (cam, i, j) ; Intersection hit = Intersect (ray, scene) ; image[i][j] = FindColor (hit) ; } return image ; How? }

66 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Surface rendering Outline

67 Ray representation Ray representation One point P 0 (if you select the camera position as P 0, in the camera coordinate system P 0 = (0, 0, 0)) Direction vector d (normalized is better) Parametric line equation: r P d 0 t d P 0

68 Ray representation Note in most cases, the ray is constructed by linking the eye and each pixel position in the view-plane. In this way, the projection of the scene to the view-plane is actually perspective projection (pinhole camera). If each ray takes z view as the direction, you get the orthographic (parallel) projection. Both of these two projection modes are supported in OpenGL

69 Ray representation Looking different?

70 Ray-casting framework Image Raycast (Camera cam, Scene scene, int width, int height) { Image image = new Image (width, height) ; for (int i = 0 ; i < height ; i++) for (int j = 0 ; j < width ; j++) { Ray ray = RayThruPixel (cam, i, j) ; Intersection hit = Intersect (ray, scene) ; image[i][j] = FindColor (hit) ; } return image ; How? }

71 Ray-plane intersection Actually, for each ray through, we need to find the closest intersection point Intersection Intersect (Ray ray, Scene scene) { min_t = infinity; min_primitive = NULL; foreach primitive in scene { t = intersect (ray, primitive) ; if (t>0 && t < min_t) { min_primitive = primitive; min_t = t; } } return Intersection(min_t, min_primitive) ; }

72 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Ray-polygon intersection Ray-sphere intersection Ray-cylinder intersection Ray-cone intersection CSG Shading models Surface rendering Outline

73 Ray-polygon intersection At first, check whether the plane is back-facing; if so, you do not need to calculate intersection since the eye cannot see such a face at all! Each planar polygon is enclosed by boundary edges in a counterclockwise manner; its normal points outward ray n d n The eye can see this face d ray The eye cannot see this face

74 Ray-polygon intersection At first, check whether the plane is back-facing; if so, you do not need to calculate intersection since the eye cannot see such a face at all! Each planar polygon is enclosed by boundary edges in a counterclockwise manner; its normal points outward nd 0 The eye can see this face Then, you can calculate the intersection point of the ray and the planar polygon

75 Ray-polygon intersection The equation of the infinite plane The plane passes the known point r 0, and its normal is n Its equation is Why? r n nr n 0 0 r 0 We let D nr 0 rn D, then 0

76 Ray-polygon intersection Intersection of the infinite plane with the ray Plane equation rn D 0 Ray equation r P0 dt n Ray r 0 Then, we have ( P dt) n D 0 0 D P0 n t dn The intersection point is D P0 n r P0 d dn

77 Ray-polygon intersection Intersection of the infinite plane with the ray Plane equation rn D 0 Ray equation r P0 dt D P0 n The intersection point is r P0 d E.g. dn z Plane: passing (1, 0, 0), (0, 1, 0), and (0, 0, 1) y Ray: the Z-axis Calculate their intersection point x Can I work it out?

78 Ray-polygon intersection Intersection of the infinite plane with the ray Plane equation rn D 0 Ray equation r P0 dt D P0 n The intersection point is r P0 d dn It is straightforward to get the distance between the camera (eye) and the intersection point How to decide whether the intersection point is within a planar polygon mesh?

79 Ray-polygon intersection In or out checking B A P C E D B A C E D P Check the direction of the following cross products for the two cases PAPB, PB PC, PC PD, PDPE, PE PA If P locates within the polygon, all the cross products have the same direction; otherwise, the directions would be different. Any limitations?

80 Special case: ray-triangle intersection Barycentric definition of a plane A (non-degenerate) triangle (a, b, c) defines a plane Any point P on this plane can be written as P(,, ) a b c, where 1 c a P b

81 Special case: ray-triangle intersection Barycentric definition of a plane Since 1, we have P(, ) (1 ) a b c a ( b a) ( c a) c a P b non-orthogonal coordinate system on the plane

82 Special case: ray-triangle intersection Barycentric definition of a plane Since 1, we have P(, ) (1 ) a b c a ( b a) ( c a) If we require that E.g., if 0,, 0, P must lines on the line c-a c, we get just the triangle! a P b

83 Special case: ray-triangle intersection Barycentric definition of a plane Given a, b, c, and P, how to compute,? P a ( b a) ( c a) e 1 e 2 a+ be 1 +ge 2 - P = 0 e 1 a e1 e2 P 0 e 2 a e1 e2 P 0 e1 e1 e1 e2 e1 ( P a) e e e e e ( P a) e1 e1 e1 e2 e1 ( P a) e1 e2 e2 e2 e2 ( P a)

84 Special case: ray-triangle intersection Intersection of a ray and barycentric triangle Ray equation r P0 dt Points on the barycentric triangle r a ( b a) ( c a) The ray intersects with the triangle if P0 dt a ( b a) ( c a) with 1, 0, 0 a c P d b P 0

85 Special case: ray-triangle intersection Intersection of a ray and barycentric triangle P0 dt a ( b a) ( c a) P0 x dxt ax ( bx ax) ( cx ax) P0 y d yt a y ( b y a y ) ( c y a y ) P0 z dzt az ( bz az ) ( cz az ) Re-group and write in the matrix form Ax=b ( a b ) ( a c ) d t a P ( a b ) ( a c ) d t a P ( a b ) ( a c ) d t a P x x x x x x 0x y y y y y y 0 y z z z z z z 0z

86 Special case: ray-triangle intersection Intersection of a ray and barycentric triangle a b a c d a P a b a c d a P a b a c d t a P A x x x x x x 0x y y y y y y 0 y z z z z z z 0z Can be easily solved by Cramer s rule, a P a c d a b a P d a b a c a P x 0x x x x x x x 0x x x x x x x 0x a P a c d a b a P d a b a c a P y 0 y y y y y y y 0 y y y y y y y 0 y a P a c d a b a P d a b a c a P,, t A A A z 0z z z z z z z 0z z z z z z z 0z Can be copied mechanically into code for implementation!

87 Special case: ray-triangle intersection Pros of barycentric represenation for intersection Efficient Stores no plane equation Get the barycentric coordinates for free Useful for interpolation, texture mapping, etc. c a P d b P 0

88 Special case: ray-triangle intersection Barycentric interpolation v, v, v a, b, c Values defined at They can be colors, normals, texture coordinates etc P(,, ) a b c v(,, ) v v v is the point Then, is the barycentric interpolation of v 1 ~v 3 at point P,, i.e., once you know, you can interpolate values using the same weights, very convenient a ( v ) 1 () v b c ( v ) 3 ( v2)

89 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Ray-polygon intersection Ray-sphere intersection Ray-cylinder intersection Ray-cone intersection CSG Shading models Surface rendering Outline

90 Ray-sphere intersection Can be used when the object in the scene is described in explicit analytical form of sphere Suppose that the center of the sphere is S 0 and its radius is R. Its equation is 2 r S0 r S0 R (1) The ray equation is r P0 d t (d is a unit vector) (2) Ray

91 Ray-sphere intersection Can be used when the object in the scene is described in explicit analytical form of sphere Suppose that the center of the sphere is S 0 and its radius is R. Its equation is 2 r S0 r S0 R (1) The ray equation is r P0 d t (d is a unit vector) Combine (1) and (2), we can get t 2( P0 S0) dt ( P0 S0) R 0 b c 2 If b 4c0, the ray does not intersect with the sphere 2 b b 4c otherwise t 2 (2)

92 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Ray-polygon intersection Ray-sphere intersection Ray-cylinder intersection Ray-cone intersection CSG Shading models Surface rendering Outline

93 Ray-cylinder intersection Can be used when the cylinder is analytically described Cylinder: the center of the bottom face is S 0, radius is R, height is h, the central symmetric axis is AXIS, Such a solid cylinder can be described as AXIS r S0 r S0 ( r S0) AXIS R r S0 AXIS 0 r S1 AXIS 0 Since S1 S0 h* AXIS 0 AXIS h (1) (2) rs (3)

94 Ray-cylinder intersection Can be used when the cylinder is analytically described Cylinder: r S0 r S0 ( r S0) AXIS r S0 AXIS 0 r S AXIS h 0 Ray: r P0 dt P dt S P dt S ( P dt S ) AXIS R Simplify it, we have: R (1) (2) (3)

95 Ray-cylinder intersection where, a 1 ( AXIS d) 2 at bt c b d( P d ) AXIS d AXIS ( P d ) c ( P d ) AXIS ( P d ) R Then, b b ac t1,2 a Then, you need to check whether the intersection points really reside on the cylindrical surface bounded by the bottom and top faces. That is, whether it satisfies (2) and (3) r S0 AXIS 0 (2) r S0 AXIS h 0 (3)

96 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Ray-polygon intersection Ray-sphere intersection Ray-cylinder intersection Ray-cone intersection CSG Shading models Surface rendering Outline

97 AXIS Ray-cone intersection Can be used when the cone is analytically described Cone: the apex of the cone is S 0, half apex angle is, height is h, the central symmetric axis is AXIS, Try to describe such a cone in a mathematical formula and compute its intersection with the ray r P d 0 t

98 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Ray-polygon intersection Ray-sphere intersection Ray-cylinder intersection Ray-cone intersection CSG Shading models Surface rendering Outline

99 CSG Constructive solid geometry Build a complex object based on a set of primitives Three basic boolean operations: union, intersection, and subtraction CSG can be naturally implemented in the ray-casting framework

100 Constructive solid geometry CSG implementation in ray-casting framework Step 1: compute the intersection points (actually ray parameters ts ) with left child node and right child node Step 2: sort the intersection points according to their corresponding parameters Step 3: classify the line segments in the final results as in or out Step 4: remove the redundant points for the in line segments; after this step, any two adjacent line segments belong to different categories ( in or out ) Above 4-steps procedure actually is a recursive process since each child node is also a CSG tree

101 Constructive solid geometry CSG implementation in ray-casting framework Rules for line segments classification Operator Left node Right node Result union intersection subtraction in in out out in in out out in in out out in out in out in out in out in out in out in in in out in out out out out in out out

102 Constructive solid geometry CSG implementation in ray-casting framework E.g., union of A and B B A t 4 t t 2 3 t 1 ray Step 1: intersections with A: t 1, t 2 ; intersections with B: t 3, t 4 Step 2: sort the points, t 1, t 3, t 2, t 4 Step 3: classify the line segments out in in in out Step 4: remove redundant points out in out

103 Constructive solid geometry CSG implementation in ray-casting framework E.g., intersection of A and B B A ray t 4 t t 2 3 t 1 Step 1: intersections with A: t 1, t 2 ; intersections with B: t 3, t 4 Step 2: sort the points, t 1, t 3, t 2, t 4 Step 3: classify the line segments out out in out out Step 4: remove redundant points out in out

104 Constructive solid geometry CSG implementation in ray-casting framework E.g., difference of A and B B A ray t 4 t t 2 3 t 1 Step 1: intersections with A: t 1, t 2 ; intersections with B: t 3, t 4 Step 2: sort the points, t 1, t 3, t 2, t 4 Step 3: classify the line segments out in out out out Step 4: remove redundant points out in out

105 Ray-casting framework Image Raycast (Camera cam, Scene scene, int width, int height) { Image image = new Image (width, height) ; for (int i = 0 ; i < height ; i++) for (int j = 0 ; j < width ; j++) { Ray ray = RayThruPixel (cam, i, j) ; Intersection hit = Intersect (ray, scene) ; image[i][j] = FindColor (hit) ; } return image ; }

106 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Light sources Phong shading model Shadow Transparency Surface rendering Outline

107 Shading model Shading model, or illumination model, or lighting model is used to mimic the physical world to decide the color of a point in the visual scene The object s color is decided by The light The attributes of the object

108 The most simple one It is omni-directional Point light source Attributes to specify a point light source Position (p x, p y, p z ) Intensity I (if it is a chromatic light, three values representing R, G, and B are needed) Coefficients (a 0, a 1, a 2 ) to specify its attenuation property with distance d I d I d

109 The most simple one It is omni-directional Point light source Attributes to specify a point light source Position (p x, p y, p z ) Intensity I (if it is a chromatic light, three values representing R, G, and B are needed) Coefficients (a 0, a 1, a 2 ) to specify its attenuation property with distance d In this lecture, except otherwise specified, the light source is considered as monochromatic. For a practical chromatic light, simply repeat the theories to R, G, and B respectively, and combine the results together.

110 Directional light source Besides position and color, the apex angle of the lighting cone needs to be specified l f V obj angatten 0.0, when Vobj Vlight cos l Vobj Vlight, otherwise where is a constant V light can be combined

111 Directional light source Besides position and color, the apex angle of the lighting cone needs to be specified l V obj V light

112 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Light sources Phong shading model Shadow Transparency Surface rendering Outline

113 Phong shading model (single light) Developed by Bui Tuong Phong ( 裴祥风 ) (Vietnamese, ) In 1973, he developed the Phong shading model He dies in 1975 for leukaemia By Phong model, the light energy emitted from a point on an object to the observer s eye comprises three components Ambient lighting Diffuse reflection Specular reflection

114 Phong shading model (single light) Ambient lighting Ambient lighting is a constant for a scene I a Different surface can have different ambient reflection coefficient k a (0<= k a <= 1) So, if only consider ambient lighting, the illumination at a point simply is I Iaka Rendering results when only ambient lighting is considered

115 Phong shading model (single light) Diffuse reflection Diffuse reflection is the reflection of light from a surface such that an incident ray is reflected at many angles rather than at just one angle as in the case of specular reflection (chalk, clay) An illuminated ideal diffuse reflecting surface will have equal luminance from all directions in the hemisphere surrounding the surface diffuse reflections specular reflection (big) surface reflected scatter distribution BRDF

116 Phong shading model (single light) Diffuse reflection Diffuse reflection is the reflection of light from a surface such that an incident ray is reflected at many angles rather than at just one angle as in the case of specular reflection (chalk, clay) An illuminated ideal diffuse reflecting surface will have equal luminance from all directions in the hemisphere surrounding the surface Lambert reflection law L N I diff Ik L d( NL), NL 0 0, NL 0 (Light is at the back of the surface) where, N is the normal of the surface at the examined position, L is the direction of the light, k d is the diffuse reflection coefficient of the surface, I L is the intensity of the incident light

117 Phong shading model (single light) Diffuse reflection Diffuse reflection is the reflection of light from a surface such that an incident ray is reflected at many angles rather than at just one angle as in the case of specular reflection (chalk, clay) An illuminated ideal diffuse reflecting surface will have equal luminance from all directions in the hemisphere surrounding the surface Lambert reflection law L N Or simply write as I I k diff L d max( NL,0)

118 Phong shading model (single light) When considering both the ambient lighting and the diffusion reflection, the observed intensity of a point can be described as I Iaka ILkd max( NL,0) Illuminated by ambient lighting and diffuse reflection Left: diffuse reflection only right: ambient + diffuse reflection

119 Phong shading model (single light) Specular reflection Specular reflection is the mirror-like reflection of light from a surface, in which light from a single incoming direction (a ray) is reflected into a single outgoing direction Used to model mirrors, metals, etc.

120 Phong shading model (single light) Specular reflection L Specular reflection is the mirror-like reflection of light from a surface, in which light from a single incoming direction (a ray) is reflected into a single outgoing direction Used to model mirrors, metals, etc. Surface normal Direction of reflection N R to viewpoint V The observed light is I spec L s Ik L s I k VR n cos ( ) R (2 NL) N L k s = specular reflection coefficient n = specular exponent n

121 Phong shading model (single light) L Specular reflection (a simplified version) Surface normal N Direction of reflection H R L V H L V to viewpoint V I I k spec L s I VR I k n Then, n spec L s More accurately, I HN approximated by I k spec L s max( HN,0) n NH (less computation)

122 Phong shading model (single light) When considering the ambient lighting, the diffusion reflection, and the specular reflection at the same time, the observed intensity of a point can be described as I I k I k max( NL,0) k max( NH,0) n a a L d s This is called as Phong shading model!!

123 Phong shading model (single light) When considering the ambient lighting, the diffusion reflection, and the specular reflection at the same time, the observed intensity of a point can be described as I I k I k max( NL,0) k max( NH,0) n a a L d s (two light sources) with increased n

124 Phong shading model (multi-lights) Multi-lights Single light case can be easily extended to multi-light case Suppose there are m lights in the scene, m N L N H I I k I k max(,0) k max(,0) a a Li d i s i i1 n

125 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Light sources Phong shading model Shadow Transparency Surface rendering Outline

126 Shadows In previous discussions, we always assume that the light source can see the object Shadow term tells if a light source is blocked Cast a ray towards the light source L i s i = 0, if the ray is blocked; s i = 1, otherwise viewpoint X The light cannot illuminate the sphere; the light ray is blocked by the triangle View plane

127 Shadows In previous discussions, we always assume that the light source can see the object Shadow term tells if a light source is blocked Cast a ray towards the light source L i s i = 0, if the ray is blocked; s i = 1, otherwise Then, the Phong shading model becomes m N L N H I I k I s k max(,0) k max(,0) a a Li i d i s i i1 n Scene rendering results when considering shadow terms

128 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Light sources Phong shading model Shadow Transparency Polygonal rendering Outline

129 Transparency If an object is transparent to some extent, the observer can see the objects behind it Accurate transparency modeling needs the raytracing algorithm, which is quite time-consuming

130 Transparency A simple transparency model I k I k I 1 t refl t trans Where I refl is the intensity of the examined point by using the Phong shading mode; I trans is the intensity of the intersection point (with the viewpoint-ray) behind the transparent object; 0<=k t <=1 is transparency factor. Transparent object viewpoint I refl Itrans View plane

131 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Polygon rendering Flat surface rendering Gouraud surface rendering Phong surface rendering Outline

132 Polygon rendering How do we choose a color for each filled pixel if the object is represented in a set of polygonal meshes? It is called as polygon shading problem Simplest shading approach is to perform independent lighting calculation for every pixel

133 Polygon rendering Actually, we can take advantage of spatial coherence Illumination calculations for pixels covered by the same primitive are related to each other Common used polygon algorithms, flat shading, Gouraud shading, and Phong shading

134 Flat surface rendering The most simplest one, also called as constant intensity surface rendering One illumination calculation per polygon Assign all pixels inside each polygon the same color No interpolation, pick a single representative intensity and propagate it over entire primitive loses almost all depth cues Objects look like they are composed of polygons OK for polyhedral objects Not so good for smooth surfaces

135 Flat surface rendering Some examples with flat surface rendering

136 Flat surface rendering Some examples with flat surface rendering

137 Flat surface rendering Some examples with flat surface rendering

138 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Polygon rendering Flat surface rendering Gouraud surface rendering Phong surface rendering Outline

139 Gouraud surface rendering Was proposed by Henri Gouraud in 1971 H. Gouraud, Computer Display of Curved Surfaces, Doctoral Thesis, University of Utah, USA, Properties produce continuous shading of surfaces represented by polygon meshes It is often used to achieve continuous lighting on triangle surfaces by computing the lighting at the corners of each triangle and linearly interpolating the resulting colors for each pixel covered by the triangle

140 Gouraud surface rendering Working principles Step 1: estimate the normal of each vertex by averaging the surface normals of the polygons that meet at each vertex N 4 N v n k 1 n k 1 N N k k N 1 N 2 N v N 3

141 Gouraud surface rendering Working principles Step 1: estimate the normal of each vertex by averaging the surface normals of the polygons that meet at each vertex Step 2: compute the color for each vertex based on a shading model (e.g., Phong model) Step 3: for each screen pixel that is covered by the polygonal mesh, color intensities can then be interpolated from the color values calculated at the vertices (more on next page)

142 Gouraud surface rendering Working principles Bilinear interpolation At first, interpolate illumination along polygon edges (I a, I b ) Then, interpolate illumination along scan lines (I p ) scan line I 1 I 2 I 3 a I b I I p y 1 y s y 2 y y y y y I y y y y I I s s a y y y y I y y y y I I s s b a b a p b a b p b a p x x x x I x x x x I I

143 Gouraud surface rendering Working principles For interpolation of triangle, we can use barycentric coordinates, still remember? Very convenient and straightforward!! (Previous page of this slide)

144 Cons Gouraud surface rendering Gouraud shading can miss specular highlights because it interpolates vertex colors instead of calculating intensity directly at each point, or interpolating vertex normals

145 Gouraud surface rendering Some examples with Gouraud surface rendering Flat (left) vs Gouraud (right)

146 Gouraud surface rendering Some examples with Gouraud surface rendering Flat (left) vs Gouraud (right)

147 Gouraud surface rendering Some examples with Gouraud surface rendering Flat (left) vs Gouraud (right)

148 Gouraud surface rendering Some examples with Gouraud surface rendering Flat (left) vs Gouraud (right)

149 Overview Vector operations Ray-casting framework Camera coordinate system Ray representation Ray-surface intersection Shading models Polygon rendering Flat surface rendering Gouraud surface rendering Phong surface rendering Outline

150 Phong surface rendering Phong surface rendering refers to an interpolation technique for surface rendering in 3D computer graphics It is also called Phong interpolation or normal-vector interpolation surface rendering Specifically, it interpolates surface normals across rasterized polygons and computes pixel colors based on the interpolated normals and a reflection model

151 Phong surface rendering Phong model: normal vector interpolation Similar interpolation process as Gouraud shading; however, it interpolates N rather than I Always captures specular highlights, but computationally expensive At each pixel, N is recomputed and normalized Then I is computed at each pixel (lighting model is more expensive than interpolation algorithms) This is now implemented in hardware, very fast

152 Phong surface rendering Some examples with Phong surface rendering Flat (left), Gouraud (middle) and Phong shading models

153 Phong surface rendering Some examples with Phong surface rendering Flat (left), Gouraud (middle) and Phong shading models

154 Phong surface rendering Some examples with Phong surface rendering Flat (left), Gouraud (middle) and Phong shading models

155 Thanks everybody!

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project To do Continue to work on ray programming assignment Start thinking about final project Lighting Course Outline 3D Graphics Pipeline Modeling (Creating 3D Geometry) Mesh; modeling; sampling; Interaction

More information

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows Recollection Models Pixels Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows Can be computed in different stages 1 So far we came to Geometry model 3 Surface

More information

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye Ray Tracing What was the rendering equation? Motivate & list the terms. Relate the rendering equation to forward ray tracing. Why is forward ray tracing not good for image formation? What is the difference

More information

Pipeline Operations. CS 4620 Lecture 10

Pipeline Operations. CS 4620 Lecture 10 Pipeline Operations CS 4620 Lecture 10 2008 Steve Marschner 1 Hidden surface elimination Goal is to figure out which color to make the pixels based on what s in front of what. Hidden surface elimination

More information

CS 325 Computer Graphics

CS 325 Computer Graphics CS 325 Computer Graphics 04 / 02 / 2012 Instructor: Michael Eckmann Today s Topics Questions? Comments? Illumination modelling Ambient, Diffuse, Specular Reflection Surface Rendering / Shading models Flat

More information

Shading, Advanced Rendering. Week 7, Wed Feb 28

Shading, Advanced Rendering. Week 7, Wed Feb 28 University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Shading, Advanced Rendering Week 7, Wed Feb 28 http://www.ugrad.cs.ubc.ca/~cs314/vjan2007 Reading for Today and Tomorrow

More information

So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources.

So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources. 11 11.1 Basics So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources. Global models include incident light that arrives

More information

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source Topic 9: Lighting & Reflection models Lighting & reflection The Phong reflection model diffuse component ambient component specular component Spot the differences Terminology Illumination The transport

More information

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component Topic 9: Lighting & Reflection models Lighting & reflection The Phong reflection model diffuse component ambient component specular component Spot the differences Terminology Illumination The transport

More information

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping Topic 12: Texture Mapping Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping Texture sources: Photographs Texture sources: Procedural Texture sources: Solid textures

More information

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized Topic 11: Texture Mapping Motivation Sources of texture Texture coordinates Bump mapping, mip mapping & env mapping Texture sources: Photographs Texture sources: Procedural Texture sources: Solid textures

More information

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11 Pipeline Operations CS 4620 Lecture 11 1 Pipeline you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX PROCESSING TRANSFORMED GEOMETRY conversion of primitives to pixels RASTERIZATION

More information

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural Topic 11: Texture Mapping Motivation Sources of texture Texture coordinates Bump mapping, mip mapping & env mapping Topic 11: Photographs Texture Mapping Motivation Sources of texture Texture coordinates

More information

Level of Details in Computer Rendering

Level of Details in Computer Rendering Level of Details in Computer Rendering Ariel Shamir Overview 1. Photo realism vs. Non photo realism (NPR) 2. Objects representations 3. Level of details Photo Realism Vs. Non Pixar Demonstrations Sketching,

More information

Reflection and Shading

Reflection and Shading Reflection and Shading R. J. Renka Department of Computer Science & Engineering University of North Texas 10/19/2015 Light Sources Realistic rendering requires that we model the interaction between light

More information

Pipeline Operations. CS 4620 Lecture 14

Pipeline Operations. CS 4620 Lecture 14 Pipeline Operations CS 4620 Lecture 14 2014 Steve Marschner 1 Pipeline you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX PROCESSING TRANSFORMED GEOMETRY conversion of primitives

More information

CHAPTER 1 Graphics Systems and Models 3

CHAPTER 1 Graphics Systems and Models 3 ?????? 1 CHAPTER 1 Graphics Systems and Models 3 1.1 Applications of Computer Graphics 4 1.1.1 Display of Information............. 4 1.1.2 Design.................... 5 1.1.3 Simulation and Animation...........

More information

CPSC GLOBAL ILLUMINATION

CPSC GLOBAL ILLUMINATION CPSC 314 21 GLOBAL ILLUMINATION Textbook: 20 UGRAD.CS.UBC.CA/~CS314 Mikhail Bessmeltsev ILLUMINATION MODELS/ALGORITHMS Local illumination - Fast Ignore real physics, approximate the look Interaction of

More information

Computer Graphics I Lecture 11

Computer Graphics I Lecture 11 15-462 Computer Graphics I Lecture 11 Midterm Review Assignment 3 Movie Midterm Review Midterm Preview February 26, 2002 Frank Pfenning Carnegie Mellon University http://www.cs.cmu.edu/~fp/courses/graphics/

More information

Graphics Pipeline. CS535 Fall Daniel G. Aliaga Department of Computer Science Purdue University

Graphics Pipeline. CS535 Fall Daniel G. Aliaga Department of Computer Science Purdue University Graphics Pipeline CS535 Fall 2016 Daniel G. Aliaga Department of Computer Science Purdue University Ray-tracing Inverse mapping for every pixel construct a ray from the eye for every object in the scene

More information

Computer Graphics. Illumination Models and Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

Computer Graphics. Illumination Models and Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL Computer Graphics Chapter 10 llumination Models and Surface-Rendering Methods Somsak Walairacht, Computer Engineering, KMTL Outline Light Sources Surface Lighting Effects Basic llumination Models Polygon

More information

Ray-Tracing. Misha Kazhdan

Ray-Tracing. Misha Kazhdan Ray-Tracing Misha Kazhdan Ray-Tracing In graphics, we often represent the surface of a 3D shape by a set of triangles. Goal: Ray-Tracing Take a collection of triangles representing a 3D scene and render

More information

CS 130 Final. Fall 2015

CS 130 Final. Fall 2015 CS 130 Final Fall 2015 Name Student ID Signature You may not ask any questions during the test. If you believe that there is something wrong with a question, write down what you think the question is trying

More information

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane Rendering Pipeline Rendering Converting a 3D scene to a 2D image Rendering Light Camera 3D Model View Plane Rendering Converting a 3D scene to a 2D image Basic rendering tasks: Modeling: creating the world

More information

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1 Ray tracing Computer Graphics COMP 770 (236) Spring 2007 Instructor: Brandon Lloyd 3/19/07 1 From last time Hidden surface removal Painter s algorithm Clipping algorithms Area subdivision BSP trees Z-Buffer

More information

CS5620 Intro to Computer Graphics

CS5620 Intro to Computer Graphics So Far wireframe hidden surfaces Next step 1 2 Light! Need to understand: How lighting works Types of lights Types of surfaces How shading works Shading algorithms What s Missing? Lighting vs. Shading

More information

Topics and things to know about them:

Topics and things to know about them: Practice Final CMSC 427 Distributed Tuesday, December 11, 2007 Review Session, Monday, December 17, 5:00pm, 4424 AV Williams Final: 10:30 AM Wednesday, December 19, 2007 General Guidelines: The final will

More information

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker CMSC427 Advanced shading getting global illumination by local methods Credit: slides Prof. Zwicker Topics Shadows Environment maps Reflection mapping Irradiance environment maps Ambient occlusion Reflection

More information

CPSC 314 LIGHTING AND SHADING

CPSC 314 LIGHTING AND SHADING CPSC 314 LIGHTING AND SHADING UGRAD.CS.UBC.CA/~CS314 slide credits: Mikhail Bessmeltsev et al 1 THE RENDERING PIPELINE Vertices and attributes Vertex Shader Modelview transform Per-vertex attributes Vertex

More information

Computer Graphics. Illumination and Shading

Computer Graphics. Illumination and Shading Rendering Pipeline modelling of geometry transformation into world coordinates placement of cameras and light sources transformation into camera coordinates backface culling projection clipping w.r.t.

More information

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura Computer Graphics Lecture 13 Global Illumination 1: Ray Tracing and Radiosity Taku Komura 1 Rendering techniques Can be classified as Local Illumination techniques Global Illumination techniques Local

More information

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models Computergrafik Matthias Zwicker Universität Bern Herbst 2009 Today Introduction Local shading models Light sources strategies Compute interaction of light with surfaces Requires simulation of physics Global

More information

Computer Graphics Ray Casting. Matthias Teschner

Computer Graphics Ray Casting. Matthias Teschner Computer Graphics Ray Casting Matthias Teschner Outline Context Implicit surfaces Parametric surfaces Combined objects Triangles Axis-aligned boxes Iso-surfaces in grids Summary University of Freiburg

More information

Introduction to Visualization and Computer Graphics

Introduction to Visualization and Computer Graphics Introduction to Visualization and Computer Graphics DH2320, Fall 2015 Prof. Dr. Tino Weinkauf Introduction to Visualization and Computer Graphics Visibility Shading 3D Rendering Geometric Model Color Perspective

More information

Rendering. Illumination Model. Wireframe rendering simple, ambiguous Color filling flat without any 3D information

Rendering. Illumination Model. Wireframe rendering simple, ambiguous Color filling flat without any 3D information llumination Model Wireframe rendering simple, ambiguous Color filling flat without any 3D information Requires modeling interaction of light with the object/surface to have a different color (shade in

More information

SEOUL NATIONAL UNIVERSITY

SEOUL NATIONAL UNIVERSITY Fashion Technology 5. 3D Garment CAD-1 Sungmin Kim SEOUL NATIONAL UNIVERSITY Overview Design Process Concept Design Scalable vector graphics Feature-based design Pattern Design 2D Parametric design 3D

More information

Chapter 10. Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

Chapter 10. Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL Computer Graphics Chapter 10 llumination Models and Surface-Rendering Methods Somsak Walairacht, Computer Engineering, KMTL 1 Outline Light Sources Surface Lighting Effects Basic llumination Models Polygon

More information

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL:

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL: CS580: Ray Tracing Sung-Eui Yoon ( 윤성의 ) Course URL: http://sglab.kaist.ac.kr/~sungeui/gcg/ Recursive Ray Casting Gained popularity in when Turner Whitted (1980) recognized that recursive ray casting could

More information

Chapter 7 - Light, Materials, Appearance

Chapter 7 - Light, Materials, Appearance Chapter 7 - Light, Materials, Appearance Types of light in nature and in CG Shadows Using lights in CG Illumination models Textures and maps Procedural surface descriptions Literature: E. Angel/D. Shreiner,

More information

Graphics and Interaction Rendering pipeline & object modelling

Graphics and Interaction Rendering pipeline & object modelling 433-324 Graphics and Interaction Rendering pipeline & object modelling Department of Computer Science and Software Engineering The Lecture outline Introduction to Modelling Polygonal geometry The rendering

More information

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline Sampling and Reconstruction of Visual Appearance CSE 274 [Fall 2018], Special Lecture Ray Tracing Ravi Ramamoorthi http://www.cs.ucsd.edu/~ravir Motivation Ray Tracing is a core aspect of both offline

More information

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models Computergrafik Thomas Buchberger, Matthias Zwicker Universität Bern Herbst 2008 Today Introduction Local shading models Light sources strategies Compute interaction of light with surfaces Requires simulation

More information

Graphics for VEs. Ruth Aylett

Graphics for VEs. Ruth Aylett Graphics for VEs Ruth Aylett Overview VE Software Graphics for VEs The graphics pipeline Projections Lighting Shading VR software Two main types of software used: off-line authoring or modelling packages

More information

CPSC / Illumination and Shading

CPSC / Illumination and Shading CPSC 599.64 / 601.64 Rendering Pipeline usually in one step modelling of geometry transformation into world coordinate system placement of cameras and light sources transformation into camera coordinate

More information

CEng 477 Introduction to Computer Graphics Fall

CEng 477 Introduction to Computer Graphics Fall Illumination Models and Surface-Rendering Methods CEng 477 Introduction to Computer Graphics Fall 2007 2008 Illumination Models and Surface Rendering Methods In order to achieve realism in computer generated

More information

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing Lecture 11 Ray tracing Introduction Projection vs. ray tracing Projection Ray tracing Rendering Projection vs. ray tracing Projection Ray tracing Basic methods for image generation Major areas of computer

More information

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline Last Time? The Traditional Graphics Pipeline Participating Media Measuring BRDFs 3D Digitizing & Scattering BSSRDFs Monte Carlo Simulation Dipole Approximation Today Ray Casting / Tracing Advantages? Ray

More information

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1) Computer Graphics Lecture 14 Bump-mapping, Global Illumination (1) Today - Bump mapping - Displacement mapping - Global Illumination Radiosity Bump Mapping - A method to increase the realism of 3D objects

More information

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CSE528 Computer Graphics: Theory, Algorithms, and Applications CSE528 Computer Graphics: Theory, Algorithms, and Applications Hong Qin State University of New York at Stony Brook (Stony Brook University) Stony Brook, New York 11794--4400 Tel: (631)632-8450; Fax: (631)632-8334

More information

Lighting and Shading

Lighting and Shading Lighting and Shading Today: Local Illumination Solving the rendering equation is too expensive First do local illumination Then hack in reflections and shadows Local Shading: Notation light intensity in,

More information

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches: Surface Graphics Objects are explicitely defined by a surface or boundary representation (explicit inside vs outside) This boundary representation can be given by: - a mesh of polygons: 200 polys 1,000

More information

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading) Lecture 9 Graphics pipeline (rasterization and shading) Graphics pipeline - part 1 (recap) Perspective projection by matrix multiplication: x pixel y pixel z canonical 1 x = M vpm per M cam y z 1 This

More information

Photorealism: Ray Tracing

Photorealism: Ray Tracing Photorealism: Ray Tracing Reading Assignment: Chapter 13 Local vs. Global Illumination Local Illumination depends on local object and light sources only Global Illumination at a point can depend on any

More information

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline Last Time? The Traditional Graphics Pipeline Reading for Today A Practical Model for Subsurface Light Transport, Jensen, Marschner, Levoy, & Hanrahan, SIGGRAPH 2001 Participating Media Measuring BRDFs

More information

Rendering Part I (Basics & Ray tracing) Lecture 25 December 1, 2015

Rendering Part I (Basics & Ray tracing) Lecture 25 December 1, 2015 Rendering Part I (Basics & Ray tracing) Lecture 25 December 1, 2015 What is rendering? Generating an image from a 3D scene model Ingredients Representation of 3D geometry Specification for camera & lights

More information

Simple Lighting/Illumination Models

Simple Lighting/Illumination Models Simple Lighting/Illumination Models Scene rendered using direct lighting only Photograph Scene rendered using a physically-based global illumination model with manual tuning of colors (Frederic Drago and

More information

Computer Graphics. Lecture 9 Environment mapping, Mirroring

Computer Graphics. Lecture 9 Environment mapping, Mirroring Computer Graphics Lecture 9 Environment mapping, Mirroring Today Environment Mapping Introduction Cubic mapping Sphere mapping refractive mapping Mirroring Introduction reflection first stencil buffer

More information

03 RENDERING PART TWO

03 RENDERING PART TWO 03 RENDERING PART TWO WHAT WE HAVE SO FAR: GEOMETRY AFTER TRANSFORMATION AND SOME BASIC CLIPPING / CULLING TEXTURES AND MAPPING MATERIAL VISUALLY DISTINGUISHES 2 OBJECTS WITH IDENTICAL GEOMETRY FOR NOW,

More information

Computer Graphics. Illumination and Shading

Computer Graphics. Illumination and Shading () Illumination and Shading Dr. Ayman Eldeib Lighting So given a 3-D triangle and a 3-D viewpoint, we can set the right pixels But what color should those pixels be? If we re attempting to create a realistic

More information

L1 - Introduction. Contents. Introduction of CAD/CAM system Components of CAD/CAM systems Basic concepts of graphics programming

L1 - Introduction. Contents. Introduction of CAD/CAM system Components of CAD/CAM systems Basic concepts of graphics programming L1 - Introduction Contents Introduction of CAD/CAM system Components of CAD/CAM systems Basic concepts of graphics programming 1 Definitions Computer-Aided Design (CAD) The technology concerned with the

More information

COMP371 COMPUTER GRAPHICS

COMP371 COMPUTER GRAPHICS COMP371 COMPUTER GRAPHICS SESSION 15 RAY TRACING 1 Announcements Programming Assignment 3 out today - overview @ end of the class Ray Tracing 2 Lecture Overview Review of last class Ray Tracing 3 Local

More information

Ray Tracer Due date: April 27, 2011

Ray Tracer Due date: April 27, 2011 Computer graphics Assignment 4 1 Overview Ray Tracer Due date: April 27, 2011 In this assignment you will implement the camera and several primitive objects for a ray tracer, and a basic ray tracing algorithm.

More information

Illumination and Shading

Illumination and Shading Illumination and Shading Computer Graphics COMP 770 (236) Spring 2007 Instructor: Brandon Lloyd 2/14/07 1 From last time Texture mapping overview notation wrapping Perspective-correct interpolation Texture

More information

Lecture 11. More Ray Casting/Tracing

Lecture 11. More Ray Casting/Tracing Lecture 11 More Ray Casting/Tracing Basic Algorithm For each pixel { } Shoot a ray from camera to pixel for all objects in scene Compute intersection with ray Find object with closest intersection Display

More information

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline Final Projects Proposals due Thursday 4/8 Proposed project summary At least 3 related papers (read & summarized) Description of series of test cases Timeline & initial task assignment The Traditional Graphics

More information

Graphics for VEs. Ruth Aylett

Graphics for VEs. Ruth Aylett Graphics for VEs Ruth Aylett Overview VE Software Graphics for VEs The graphics pipeline Projections Lighting Shading Runtime VR systems Two major parts: initialisation and update loop. Initialisation

More information

Ray Tracing. Outline. Ray Tracing: History

Ray Tracing. Outline. Ray Tracing: History Foundations of omputer Graphics Online Lecture 9: Ray Tracing 1 History and asic Ray asting Ravi Ramamoorthi Effects needed for Realism (Soft) Shadows Reflections (Mirrors and Glossy) Transparency (Water,

More information

Illumination Models & Shading

Illumination Models & Shading Illumination Models & Shading Lighting vs. Shading Lighting Interaction between materials and light sources Physics Shading Determining the color of a pixel Computer Graphics ZBuffer(Scene) PutColor(x,y,Col(P));

More information

Sung-Eui Yoon ( 윤성의 )

Sung-Eui Yoon ( 윤성의 ) CS380: Computer Graphics Ray Tracing Sung-Eui Yoon ( 윤성의 ) Course URL: http://sglab.kaist.ac.kr/~sungeui/cg/ Class Objectives Understand overall algorithm of recursive ray tracing Ray generations Intersection

More information

Global Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Global Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller Global Illumination CMPT 361 Introduction to Computer Graphics Torsten Möller Reading Foley, van Dam (better): Chapter 16.7-13 Angel: Chapter 5.11, 11.1-11.5 2 Limitation of local illumination A concrete

More information

CS 130 Exam I. Fall 2015

CS 130 Exam I. Fall 2015 S 3 Exam I Fall 25 Name Student ID Signature You may not ask any questions during the test. If you believe that there is something wrong with a question, write down what you think the question is trying

More information

Last week. Machiraju/Zhang/Möller

Last week. Machiraju/Zhang/Möller Last week Machiraju/Zhang/Möller 1 Overview of a graphics system Output device Input devices Image formed and stored in frame buffer Machiraju/Zhang/Möller 2 Introduction to CG Torsten Möller 3 Ray tracing:

More information

Global Rendering. Ingela Nyström 1. Effects needed for realism. The Rendering Equation. Local vs global rendering. Light-material interaction

Global Rendering. Ingela Nyström 1. Effects needed for realism. The Rendering Equation. Local vs global rendering. Light-material interaction Effects needed for realism Global Rendering Computer Graphics 1, Fall 2005 Lecture 7 4th ed.: Ch 6.10, 12.1-12.5 Shadows Reflections (Mirrors) Transparency Interreflections Detail (Textures etc.) Complex

More information

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department CSE 690: GPGPU Lecture 2: Understanding the Fabric - Intro to Graphics Klaus Mueller Stony Brook University Computer Science Department Klaus Mueller, Stony Brook 2005 1 Surface Graphics Objects are explicitely

More information

Computer Graphics. Lecture 10. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura 12/03/15

Computer Graphics. Lecture 10. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura 12/03/15 Computer Graphics Lecture 10 Global Illumination 1: Ray Tracing and Radiosity Taku Komura 1 Rendering techniques Can be classified as Local Illumination techniques Global Illumination techniques Local

More information

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects Basic Ray Tracing Rendering: Reality Eye acts as pinhole camera Photons from light hit objects Rendering: Reality Eye acts as pinhole camera Photons from light hit objects Rendering: Reality Eye acts as

More information

CS 488. More Shading and Illumination. Luc RENAMBOT

CS 488. More Shading and Illumination. Luc RENAMBOT CS 488 More Shading and Illumination Luc RENAMBOT 1 Illumination No Lighting Ambient model Light sources Diffuse reflection Specular reflection Model: ambient + specular + diffuse Shading: flat, gouraud,

More information

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading CENG 477 Introduction to Computer Graphics Ray Tracing: Shading Last Week Until now we learned: How to create the primary rays from the given camera and image plane parameters How to intersect these rays

More information

Ray Casting. Outline. Similar to glulookat derivation. Foundations of Computer Graphics

Ray Casting. Outline. Similar to glulookat derivation. Foundations of Computer Graphics Foundations of omputer Graphics Online Lecture 10: Ray Tracing 2 Nuts and olts amera Ray asting Outline amera Ray asting (choose ray directions) Ravi Ramamoorthi Outline in ode Image Raytrace (amera cam,

More information

Illumination & Shading: Part 1

Illumination & Shading: Part 1 Illumination & Shading: Part 1 Light Sources Empirical Illumination Shading Local vs Global Illumination Lecture 10 Comp 236 Spring 2005 Computer Graphics Jargon: Illumination Models Illumination - the

More information

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Lecture 15: Shading-I. CITS3003 Graphics & Animation Lecture 15: Shading-I CITS3003 Graphics & Animation E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 Objectives Learn that with appropriate shading so objects appear as threedimensional

More information

CSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

CSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016 CSE 167: Introduction to Computer Graphics Lecture #6: Lights Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016 Announcements Thursday in class: midterm #1 Closed book Material

More information

CS451Real-time Rendering Pipeline

CS451Real-time Rendering Pipeline 1 CS451Real-time Rendering Pipeline JYH-MING LIEN DEPARTMENT OF COMPUTER SCIENCE GEORGE MASON UNIVERSITY Based on Tomas Akenine-Möller s lecture note You say that you render a 3D 2 scene, but what does

More information

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing Ray Tracing Basics I Computer Graphics as Virtual Photography Photography: real scene camera (captures light) photo processing Photographic print processing Computer Graphics: 3D models camera model (focuses

More information

Homework #2. Shading, Projections, Texture Mapping, Ray Tracing, and Bezier Curves

Homework #2. Shading, Projections, Texture Mapping, Ray Tracing, and Bezier Curves Computer Graphics Instructor: Brian Curless CSEP 557 Autumn 2016 Homework #2 Shading, Projections, Texture Mapping, Ray Tracing, and Bezier Curves Assigned: Wednesday, Nov 16 th Due: Wednesday, Nov 30

More information

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting Ray Casting COMP 175: Computer Graphics April 26, 2018 1/41 Admin } Assignment 4 posted } Picking new partners today for rest of the assignments } Demo in the works } Mac demo may require a new dylib I

More information

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012) Foundations of omputer Graphics (Spring 202) S 84, Lecture 5: Ray Tracing http://inst.eecs.berkeley.edu/~cs84 Effects needed for Realism (Soft) Shadows Reflections (Mirrors and Glossy) Transparency (Water,

More information

COMP environment mapping Mar. 12, r = 2n(n v) v

COMP environment mapping Mar. 12, r = 2n(n v) v Rendering mirror surfaces The next texture mapping method assumes we have a mirror surface, or at least a reflectance function that contains a mirror component. Examples might be a car window or hood,

More information

Intro to Ray-Tracing & Ray-Surface Acceleration

Intro to Ray-Tracing & Ray-Surface Acceleration Lecture 12 & 13: Intro to Ray-Tracing & Ray-Surface Acceleration Computer Graphics and Imaging UC Berkeley Course Roadmap Rasterization Pipeline Core Concepts Sampling Antialiasing Transforms Geometric

More information

3D Rendering. Course Syllabus. Where Are We Now? Rendering. 3D Rendering Example. Overview. Rendering. I. Image processing II. Rendering III.

3D Rendering. Course Syllabus. Where Are We Now? Rendering. 3D Rendering Example. Overview. Rendering. I. Image processing II. Rendering III. Course Syllabus I. Image processing II. Rendering III. Modeling 3D Rendering Rendering I. Animation (Michael Bostock, CS426, Fall99) Image Processing Adam Finkelstein Princeton University COS 426, Spring

More information

Computer Graphics 1. Chapter 7 (June 17th, 2010, 2-4pm): Shading and rendering. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2010

Computer Graphics 1. Chapter 7 (June 17th, 2010, 2-4pm): Shading and rendering. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2010 Computer Graphics 1 Chapter 7 (June 17th, 2010, 2-4pm): Shading and rendering 1 The 3D rendering pipeline (our version for this class) 3D models in model coordinates 3D models in world coordinates 2D Polygons

More information

3D Rasterization II COS 426

3D Rasterization II COS 426 3D Rasterization II COS 426 3D Rendering Pipeline (for direct illumination) 3D Primitives Modeling Transformation Lighting Viewing Transformation Projection Transformation Clipping Viewport Transformation

More information

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker CMSC427 Shading Intro Credit: slides from Dr. Zwicker 2 Today Shading Introduction Radiometry & BRDFs Local shading models Light sources Shading strategies Shading Compute interaction of light with surfaces

More information

SUMMARY. CS380: Introduction to Computer Graphics Ray tracing Chapter 20. Min H. Kim KAIST School of Computing 18/05/29. Modeling

SUMMARY. CS380: Introduction to Computer Graphics Ray tracing Chapter 20. Min H. Kim KAIST School of Computing 18/05/29. Modeling CS380: Introduction to Computer Graphics Ray tracing Chapter 20 Min H. Kim KAIST School of Computing Modeling SUMMARY 2 1 Types of coordinate function Explicit function: Line example: Implicit function:

More information

Rendering Algorithms: Real-time indirect illumination. Spring 2010 Matthias Zwicker

Rendering Algorithms: Real-time indirect illumination. Spring 2010 Matthias Zwicker Rendering Algorithms: Real-time indirect illumination Spring 2010 Matthias Zwicker Today Real-time indirect illumination Ray tracing vs. Rasterization Screen space techniques Visibility & shadows Instant

More information

Computer Science 426 Midterm 3/11/04, 1:30PM-2:50PM

Computer Science 426 Midterm 3/11/04, 1:30PM-2:50PM NAME: Login name: Computer Science 46 Midterm 3//4, :3PM-:5PM This test is 5 questions, of equal weight. Do all of your work on these pages (use the back for scratch space), giving the answer in the space

More information

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic. Shading Models There are two main types of rendering that we cover, polygon rendering ray tracing Polygon rendering is used to apply illumination models to polygons, whereas ray tracing applies to arbitrary

More information

DH2323 DGI13. Lab 2 Raytracing

DH2323 DGI13. Lab 2 Raytracing DH2323 DGI13 Lab 2 Raytracing In this lab you will implement a Raytracer, which draws images of 3D scenes by tracing the light rays reaching the simulated camera. The lab is divided into several steps.

More information

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1 graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1 graphics pipeline sequence of operations to generate an image using object-order processing primitives processed one-at-a-time

More information

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1) Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1) Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Why do we need Lighting & shading? Sphere

More information