Repetition of TDA361. Ulf Assarsson

Size: px
Start display at page:

Download "Repetition of TDA361. Ulf Assarsson"

Transcription

1 Repetition of TDA361 Ulf Assarsson

2 Misc Eng translation: All your answers on exam must be written in English Till alla lärare på masternivån, Undervisningen på Chalmers masterprogram sker på engelska. Vicerektor Sven Engström klarlägger att all examination också sker på engelska dvs tentamenssvaren skall vara på engelska. Syftet är att studenten skall träna i att kommunicera på engelska såväl muntligt som skriftligt i olika situationer. För skriftliga tentamina gäller t ex att annat språk än engelska inte skall beaktas vid rättningen. Som tidigare är ordböcker tillåtna hjälpmedel vid tentamina förutom vid tentamen i språk. Var vänlig meddela detta till studenterna på Dina kurser inför tentamensperioden i oktober. Tomas Akenine-Mőller 2002

3 Lecture 1: Real-time Rendering The Graphics Rendering Pipeline Chapter 2 in the book The pipeline is the engine that creates images from 3D scenes Three conceptual stages of the pipeline: Application (executed on the CPU) Geometry Rasterizer Application Geometry Rasterizer Image input 3D scene + how to locate the bottleneck, RTR: ch 10.1 Ulf Assarsson 2004 output

4 GEOMETRY Summary Application Geometry Rasterizer model space world space world space camera space compute lighting projection image space clip map to screen ModelViewMtx = Model to View Matrix Ulf Assarsson 2004

5 Lecture 2: Transforms Homogeneous notation Quaternions Know what they are good for. Not knowing all mathematical rules. Projections Ulf Assarsson 2004

6 Tomas Akenine-Mőller 2002 Homogeneous notation A point: Translation becomes: A vector (direction): Translation of vector: Also allows for projections (later) 1 1 ) ( z z y y x x z y x z y x t p t p t p p p p t t t t T T z y x p p p 1 p T z y x d d d 0 d Td d Translationsdelen rotationsdelen 03. Vectors and Transforms

7 Change of Frames M model-to-world : M world model-toz z z z y y y y x x x x o c b a o c b a o c b a (0,5,0) E.g.: p world = M mw p model = M mw (0,5,0) T = 5 b (+ o) b x y z a c o world space model space 03. Vectors and Transforms

8 03. Vectors and Transforms Projections Orthogonal (parallel) and Perspective Tomas Akenine-Mőller 2002

9 Tomas Akenine-Mőller 2002 Orthogonal projection Simple, just skip one coordinate Say, we re looking along the z-axis Then drop z, and render y x z y x ortho ortho p p p p p M M z z 03. Vectors and Transforms

10 06. Rasterization, Depth Sorting and Culling: DDA Algorithm Digital Differential Analyzer DDA was a mechanical device for numerical solution of differential equations Line y=kx+ m satisfies differential equation dy/dx = k = Dy/Dx = y 2 -y 1 /x 2 -x 1 Along scan line Dx = 1 y=y1; For(x=x1; x<=x2,ix++) { write_pixel(x, round(y), line_color) y+=k; }

11 06. Rasterization, Depth Sorting and Culling: Using Symmetry Use for 1 k 0 For k > 1, swap role of x and y For each y, plot closest x

12 06. Rasterization, Depth Sorting and Culling: Very Important! The problem with DDA is that it uses floats which was slow in the old days Bresenhams algorithm only uses integers You do not need to know Bresenham s algorithm by heart. It is enough to understand the following 2 slides.

13 Bresenham s line drawing algorithm The line is drawn between two points (x 0, y 0 ) and (x 1, y 1 ) k ( y ( x Slope 1 0 (y = kx + m) 1 y x 0 ) ) This is the reason that DDA needs floats. So Bresenham s solution is to multiply all corresponding numbers with (x 1 -x 0 ) to get integers. Each time we step 1 in x-direction, we should increment y with k. Otherwise the error in y increases with k. If the error surpasses 0.5, the line has become closer to the next y- value, so we add 1 to y simultaneously decreasing the error by 1 function line(x0, x1, y0, y1) int deltax := abs(x1 - x0) int deltay := abs(y1 - y0) real error := 0 real deltaerr := deltay / deltax int y := y0 for x from x0 to x1 plot(x,y) error := error + deltaerr if error 0.5 y := y + 1 error := error See also Ulf Assarsson 2006

14 Bresenham s line drawing algorithm Now, convert algorithm to only using integer computations The trick we use is to multiply all the fractional numbers above by (x 1, x 0 ), which enables us to express them as integers. The only problem remaining is the constant 0.5 to deal with this, we multiply both sides of the inequality by 2 Old float version: function line(x0, x1, y0, y1) int deltax := abs(x1 - x0) int deltay := abs(y1 - y0) real error := 0 real deltaerr := deltay / deltax int y := y0 for x from x0 to x1 plot(x,y) error := error + deltaerr if error 0.5 y := y + 1 error := error New integer version: function line(x0, x1, y0, y1) int deltax := abs(x1 - x0) int deltay := abs(y1 - y0) real error := 0 real deltaerr := deltay int y := y0 for x from x0 to x1 plot(x,y) error := error + deltaerr if 2*error deltax y := y + 1 error := error - deltax Bresenhams alg. Ulf Assarsson 2006

15 06. Rasterization, Depth Sorting and Culling: Painter s Algorithm Render polygons a back to front order so that polygons behind others are simply painted over B behind A as seen by viewer Requires ordering of polygons first O(n log n) calculation for ordering Not every polygon is either in front or behind all other polygons Fill B then A I.e., : Sort all triangles and render them back-to-front.

16 06. Rasterization, Depth Sorting and Culling: z-buffer Algorithm Use a buffer called the z or depth buffer to store the depth of the closest object at each pixel found so far As we render each polygon, compare the depth of each pixel to depth in z buffer If less, place shade of pixel in color buffer and update z buffer

17 Lektion 3: OpenGL Uses OpenGL (or DirectX) Will not ask about syntax. Know how to use. E.g. how to achieve Transparency Fog(start, stop, linear/exp/exp-squared) Specify a material, a triangle Ulf Assarsson 2004

18 03. OpenGL: Specifying vertices and polygons OpenGL is a state machine. Commands typically change the current state Multiple calling formats for the commands: void glvertex{234}{sifd}( T coords ); glbegin()/glend(). (Slow) glbegin(gl_triangle) glvertex3f(0,0,0) glvertex3f(0,1,0); glvertex3f(1,1,0); glend(); Optional: Can specify for instance glcolor3f(r,g,b), gltexcoord2f(s,t), glnormal3f(x,y,z) - typically per vertex or per primitive. Display lists are created with surrounding glnewlist() and glendlist(). (Fast) int dlist=glgenlists(1); glnewlist(dlist,gl_compile); glutsolidsphere(radius, 20, 20); glendlist(); Display lists are then drawn with: glcalllist(dlist); Vertex Arrays (Fast): // generate one display list number // indicates start of display list // or any object specification // indicates end of display list Idea: Objects are stored internally in the most efficient format void gltexcoordpointer( int size, enum type, sizei stride, void *pointer ); //Defines an array of texture coordinates void glcolorpointer( int size, enum type, sizei stride,void *pointer ); //Defines an array of colors (void glindexpointer( enum type, sizei stride, void *pointer ); //Defines an array of color indices) void glnormalpointer( enum type, sizei stride,void *pointer ); //Defines an array of normals void glvertexpointer( int size, enum type, sizei stride,void *pointer ); //Defines an array of vertices void glenableclientstate( enum array ); void gldisableclientstate( enum array ); with array set to TEXTURE_COORD_ARRAY, COLOR_ARRAY, INDEX_ARRAY, NORMAL_ARRAY, or VERTEX_ARRAY, void glarrayelement(int i ); // Transfers the ith element of every enabled array to OpenGL void gldrawarrays(mode; first; count); // Renders multiple primitives from the enabled arrays void gldrawelements(mode, count, type,*indices ); // Same as gldrawarrays, but takes array elements pointed to by indices. void glinterleavedarrays(format; stride; pointer); // One array with vertices, normals, textures and/colors interleaved Ulf Assarsson 2003

19 03. OpenGL: Matrix and Stack Operations Matrix Operations: glrotate(),gltranslate(), glscale(), GLU Helper functions: gluperspective(), glulookat, Ulf Assarsson 2003

20 03. OpenGL: Lighting and Colors glcolor4f(r,g,b,a), glcolor3f(r,g,b) Used when lighting is disabled: Disable with gldisable( GL_LIGHTING ); Could be changed for instance per vertex or per object. Can also be specified with glcolorpointer() as described previously glmaterialfv() Used when lighting is enabled. Enable with glenable( GL_LIGHTING ); Must also enable lights: glenable( GL_LIGHTn ); Example: glmaterialfv(gl_front_and_back, GL_AMBIENT, float rgba[4]) glmaterialfv(gl_front_and_back, GL_DIFFUSE, float rgba[4]) glmaterialfv(gl_front_and_back, GL_SPECULAR, float rgba[4]) glmaterialfv(gl_front_and_back, GL_EMISSION, float rgba[4]) glmaterialf(gl_front_and_back, GL_SHININESS, 30) Ulf Assarsson 2003

21 03. OpenGL: Buffers Frame buffer Back/front/left/right gldrawbuffers() Alpha channel: glalphafunc() Depth buffer (z-buffer) For correct depth sorting Instead of BSP-algorithm, painters algorithm Stencil buffer E.g. Shadow volumes and masking rendering to non-rectangular regions, Accumulation buffer Ulf Assarsson 2003

22 Lecture 4.1: Shading Lighting i=iamb+idiff+ispec+iemission + + = Know how to compute components. Also, Blinns and Phongs highlight model Ulf Assarsson 2004

23 05. Shading: Lighting Light: Ambient (r,g,b,a) Diffuse (r,g,b,a) Specular (r,g,b,a) Material: Ambient (r,g,b,a) Diffuse (r,g,b,a) Specular (r,g,b,a) Emission (r,g,b,a) = självlysande färg Tomas Added Akenine-Mőller by Ulf Assarsson,

24 04. Shading: Lighting i=iamb+idiff+ispec+iemission I.e.: i=iamb+idiff+ispec+iemission i amb m amb s amb i diff ( nl) m Phong s reflection model: diff i s spec diff mshi max(0,( r v) ) m spec s spec Blinn s reflection model: i spec mshi max(0,( hn) ) m spec s spec iemission m emission Tomas Akenine-Mőller 2002

25 04. Shading: Ambient component: iamb Ad-hoc tries to account for light coming from other surfaces Just add a constant color: i amb m amb s amb i.e., (i r, i g, i b, i a ) = (m r, m g, m b, m a ) (l r, l g, l b, l a ) gllightmodelfv(gl_light_model_ambient, global_ambient) Modified Tomas Akenine-Mőller by Ulf Assarsson,

26 04. Shading: Diffuse component : idiff i=iamb+idiff+ispec+iemission Diffuse is Lambert s law: i diff nl Photons are scattered equally in all directions i diff ( nl) m diff s diff cos Tomas Akenine-Mőller 2002

27 04. Shading: Lighting Specular component : ispec Diffuse is dull (left) Specular: simulates a highlight Tomas Akenine-Mőller 2002

28 04. Shading: Specular component: Phong Phong specular highlight model Reflect l around n: r r l 2(n l)n i ( r v) (cos ) spec m shi m shi ( n l) n -l n l nl i spec mshi max(0,( r v) ) m spec s spec Next: Blinns highlight formula: (n. h) m Tomas Akenine-Mőller 2002

29 04. Shading: Halfway Vector Blinn proposed replacing v r by n h where h = (l+v)/ l + v (l+v)/2 is halfway between l and v If n, l, and v are coplanar: y /2 Must then adjust exponent so that (n h) e (r v) e i spec (e 4e) mshi max(0,( hn) ) m spec s spec

30 04. Shading: Shading Three common types of shading: Flat, Goraud, and Phong In standard Gouraud shading the lighting is computed per triangle vertex and for each pixel, the color is interpolated from the colors at the vertices. In Phong Shading the lighting is not per vertex. Instead the normal is interpolated per pixel from the normals defined at the vertices and full lighting is computed per pixel using this normal. This is of course more expensive but looks better. Flat Gouraud Phong Tomas Akenine-Mőller 2002

31 04. Shading: Transparency and alpha Transparency Very simple in real-time contexts The tool: alpha blending (mix two colors) Alpha (a) is another component in the frame buffer, or on triangle Represents the opacity 1.0 is totally opaque 0.0 is totally transparent The over operator: c ac ( 1a) c o s d Rendered object Tomas Akenine-Mőller 2002

32 04. Shading: Transparency Need to sort the transparent objects First, render all non-transparent triangles as usual. Then, sort all transparent triangles and render back-to-front with blending enabled. (and using standard depth test) Partly to avoid problems with the depth test and partly because the blending operation is order dependent. Tomas Akenine-Mőller 2002

33 Leture 4.2: Sampling, filtrering, and AA Why care? When does it occur? In pixels, time, texture, etc Nyquist Filters Supersampling schemes Jittered sampling Adaptive sampling in ray tracing Ulf Assarsson 2004

34 Filtering FILTERING: For magnification: Nearest or Linear (box vs Tent filter) For minification: Bilinear using mipmapping Trilinear using mipmapping Anisotropic some mipmap lookups along line Ulf of Assarsson anisotropy 2004

35 Interpolation Magnification Minification Ulf Assarsson 2004

36 Bilinear filtering using Mipmapping Ulf Assarsson 2004

37 07. Texturing: Mipmapping Image pyramid Half width and height when going upwards Average over 4 parent texels to form child texel Depending on amount of minification, determine which image to fetch from Compute d first, gives two images Bilinear interpolation in each v d u Tomas Akenine-Mőller 2002

38 07. Texturing: (u 0,v 0,d 0 ) Mipmapping Interpolate between those bilinear values Gives trilinear interpolation Level n+1 d v u Level n Constant time filtering: 8 texel accesses Tomas Akenine-Mőller 2002

39 Anisotropic texture filtering Ulf Assarsson 2004

40 07. Texturing: 05. Texturing Most important: Texturing, environment mapping Bump mapping 3D-textures, Particle systems Sprites and billboards

41 07. Texturing: Environment mapping Assumes the environment is infinitely far away Sphere mapping For details, see OH Cube mapping is the norm nowadays Advantages: no singularities as in sphere map Much less distortion Gives better result Not dependent on a view position Modified by Ulf Assarsson 2004 Tomas Akenine-Mőller 2002

42 07. Texturing: Cube mapping eye n y z x Simple math: compute reflection vector, r Largest abs-value of component, determines which cube face. Example: r=(5,-1,2) gives POS_X face Divide r by abs(5) gives (u,v)=(-1/5,2/5) If your hardware has this feature, then it does all the work Tomas Akenine-Mőller 2002

43 07. Texturing: Bump mapping by Blinn in 1978 Inexpensive way of simulating wrinkles and bumps on geometry Too expensive to model these geometrically Instead let a texture modify the normal at each pixel, and then use this normal to compute lighting per pixel geometry + = Bump map Bump mapped geometry Stores heights: can derive normals Tomas Akenine-Mőller 2002

44 07. Texturing: 3D Textures 3D textures: Feasible on modern hardware as well Texture filtering is no longer trilinear Rather quadlinear (linear interpolation 4 times) Enables new possibilities Can store light in a room, for example Tomas Akenine-Mőller 2002

45 07. Texturing: GLbyte M[64]= { 127,0,0,127, 127,0,0,127, 127,0,0,127, 127,0,0,127, 0,127,0,0, 0,127,0,127, 0,127,0,127, 0,127,0,0, 0,0,127,0, 0,0,127,127, 0,0,127,127, 0,0,127,0, 127,127,0,0, 127,127,0,127, 127,127,0,127, 127,127,0,0}; Sprites Sprites (=älvor) was a technique on older home computers, e.g. VIC64. As opposed to billboards sprites does not use the frame buffer. They are rasterized directly to the screen using a special chip. A special bitregister also marked colliding sprites. void display(void) { glclearcolor(0.0,1.0,1.0,1.0); glclear(gl_color_buffer_bit); glenable (GL_BLEND); glblendfunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glrasterpos2d(xpos1,ypos1); glpixelzoom(8.0,8.0); gldrawpixels(width,height, GL_RGBA, GL_BYTE, M); } glpixelzoom(1.0,1.0); glutswapbuffers();

46 07. Texturing: Billboards 2D images used in 3D environments Common for trees, explosions, clouds, lens flares

47 07. Texturing: Billboards Rotate them towards viewer Either by rotation matrix or by orthographic projection

48 07. Texturing: Billboards Fix correct transparency by blending AND using alphatest glenable(gl_alpha_test); glalphafunc(gl_greater, 0.1); Color Buffer Depth Buffer With blending Threshold > 0. If alpha value in texture is lower than this threshold value, the pixel is not rendered to. I.e., neither frame buffer nor z-buffer is updated. Which is what we want to achieve. E.g. here: With alpha test

49 07. Texturing: n axial billboarding The rotation axis is fixed and disregarding the view position (Also called Impostors)

50 Lecture 6.1: Intersection Tests 4 techniques: Analythic Geometric e.g. ray vs box (3 slabs) SAT Test: 1. axes ortho to side of A, 2. axes ortho to side of B 3. crossprod of edges Dynamic tests Know how they work E.g., describe an algorithm for intersection between a ray and a polygon. Know equations for ray, sphere, cylinder, plane Ulf Assarsson 2004

51 Analytical: Ray/plane intersection Ray: r(t)=o+td Plane formula: n p + d = 0 o d n Replace p by r(t) and solve for t: n (o+td) + d = 0 n o+tn d + d = 0 t = (-d -n o) / (n d) Tomas Akenine-Mőller 2003

52 Tomas Akenine-Mőller 2003 Analytical: Ray/sphere test Sphere center: c, and radius r Ray: r(t)=o+td Sphere formula: p-c =r Replace p by r(t): r(t)-c =r 0 ) ) ( ( ) ) ( ( 2 r t t c r c r 1 0 ) ( ) ( ) ) 2(( 2 2 d c ο c ο d c ο r t t 0 ) ( ) ( 2 r t t c d o c d o 0 ) ( ) ( ) ) 2(( ) ( 2 2 r t t c ο c ο d c ο d d o d c r This is a standard quadratic equation. Solve for t.

53 Lecture 6.2: Spatial Data Structures and Speed-Up Techniques Speed-up techniques Culling Backface View frustum (hierarchical) Portal Occlusion Culling Detail Levels-of-detail How to construct and use the spatial data structures BVH, BSP-trees (polygon aligned + axis aligned) Ulf Assarsson 2004

54 Lecture 6.2: Spatial data structures BVH, Grids (recursive/hierarchical), octrees/quadtree, BVH spherical / OBB / AABB, BSP (polygon / axis aligned, kdtrees) How to use, what they look like, how to construct (if mentioned in the course) Ulf Assarsson 2004

55 Ray Tracing Summary of the Ray tracingalgorithm: Image plane light trace() Point is in shadow shade() trace() trace() shade() main()-calls trace() for each pixel trace(): should return color of closest hit point along ray. 1. calls findclosestintersection() 2. If any object intersected call shade(). Shade(): should compute color at hit point 1. For each light source, shoot shadow ray to determine if light source is visible If not in shadow, compute diffuse + specular contribution. 2. Compute ambient contribution 3. Call trace() recursively for the reflection- and refraction ray. Tomas Akenine-Mőller 2002

56 Lecture 7-8: Ray tracing Adaptive Super Sampling Jittering How to stop recursion? (Transmission) Speedup techniques Spatial data structures Optimizations for BVHs skippointer tree BVH-traversal (You do not need to learn the ray traversal algorithms for Grids nor AA-BSP trees) Shadow cache Material (Fresnel: metall, dielectrics) Constructive Solid Geometry Ulf Assarsson 2004

57 09. Curves and Surfaces: Objectives p 1 Introduce the types of curves Interpolating Blending polynomials for interpolation of 4 control points (fit curve to 4 control points) Hermite fit curve to 2 control points + 2 derivatives (tangents) Bezier 2 interpolating control points + 2 intermediate points to define the tangents B-spline To get C 2 continuity NURBS Different weights of the control points and The control points can be at non-uniform intervalls p 0 p 2 p 3

58 09. Curves and Surfaces: Splines and Basis If we examine the cubic B-spline from the perspective of each control (data) point, each interior point contributes (through the blending functions) to four segments We can rewrite p(u) in terms of the data points as p( u) B ( u) i defining the basis functions {B i (u)} p i

59 u 09. Curves and Surfaces: B-Splines These are our control points, p 0 - p 8, to which we want to approximate a curve p 0 p 1 p 2 p 3 p 4 p5 p 6 p 7 p 8 100% u= Illustration of how the control points are evenly (uniformly) distributed along the parameterisation u of the curve p(u). In each point p(u) of the curve, for a given u, the point is defined as a weighted sum of the closest 4 surrounding points. Below are shown the weights for each point along u=01 p 0 p 1 p 2 p 3 p 4 p 5 p 6 p 7 p 8 u

60 SUMMARY B-Splines 100% In each point p(u) of the curve, for a given u, the point is defined as a weighted sum of the closest 4 surrounding points. Below are shown the weights for each point along u=01 Blendfunction B 1 (u) for point p 1 p 0 p 1 p 2 p 3 p 4 p 5 p 6 p 7 p 8 The weight function (blend function) B pi (u) for a point p i can thus be written as a translation of a basis function B(t). B pi (u) = B(u-i) u B(t): 100% t Our complete B-spline curve p(u) can thus be written as: p( u) B ( u) i p i

61 09. Curves and Surfaces: NURBS NURBS is similar to B-Splines except that: 1. The control points can have different weights, w i, (heigher weight makes the curve go closer to that control point) 2. The control points do not have to be at uniform distances (u=0,1,2,3...) along the parameterisation u. E.g.: u=0, 0.5, 0.9, 4, 14, NURBS = Non-Uniform Rational B-Splines The NURBS-curve is thus defined as: Division with the sum of the weights, to make the combined weights sum up to 1, at each position along the curve. Otherwise, a translation of the curve is introduced (which can be fun but normally not desired)

62 09. Curves and Surfaces: NURBS Allowing control points at non-uniform distances means that the basis functions B pi () are being streched and non-uniformly located. E.g.: Each curve B pi () should of course look smooth and C 2 continuous. But it is not so easy to draw smoothly by hand... u

63 Lecture 10.1: Collision Detection 3 types of algorithms: With rays Fast but not exact With BVH Pseudo code is simple to derive Slower but exact For lots of objects. why? Course pruning of obviously non-colliding objects Sweep-and-prune Ulf Assarsson 2004

64 10.2 Vertex and Fragment Shaders: Vertex- and Fragment shaders Understand the following shaders Especially the first two

65 10. Vertex and Fragment Shaders: Wave Motion Vertex Shader uniform float time; uniform float xs, zs; void main() { float s; s = *sin(xs*time)*sin(zs*time); gl_vertex.y = s*gl_vertex.y; gl_position = gl_modelviewprojectionmatrix*gl_vertex; }

66 10. Vertex and Fragment Shaders: Particle System uniform vec3 init_vel; uniform float g, m, t; void main() { vec3 object_pos; object_pos.x = gl_vertex.x + vel.x*t; object_pos.y = gl_vertex.y + vel.y*t - g/(2.0*m)*t*t; object_pos.z = gl_vertex.z + vel.z*t; gl_position = gl_modelviewprojectionmatrix* vec4(object_pos,1); }

67 10. Vertex and Fragment Shaders: Vertex Shader for per Fragment Lighting /* vertex shader for per-fragment Phong shading */ varying vec3 normale; varying vec4 positione; void main() { normale = gl_normalmatrixmatrix*gl_normal; positione = gl_modelviewmatrix*gl_vertex; gl_position = gl_modelviewprojectionmatrix*gl_vertex; }

68 10. Vertex and Fragment Shaders: Fragment Shader for per Fragment Lighting varying vec3 normale; varying vec4 positione; void main() { vec3 norm = normalize(normale); vec3 lightv = normalize(gl_lightsource[0].position-positione.xyz); vec3 viewv = normalize(positione); vec3 halfv = normalize(lightv + viewv); vec4 diffuse = max(0, dot(lightv, viewv)) *gl_frontmaterial.diffuse*gl_lightsource[0].diffuse; vec4 ambient = gl_frontmaterial.ambient*gl_lightsource[0].ambient;

69 10. Vertex and Fragment Shaders: Fragment Shader for per Fragment Lighting int f; if(dot(lightv, viewv)> 0.0) f =1.0); else f = 0.0; vec3 specular = f*pow(max(0, dot(norm, halfv), gl_frontmaterial.shininess) *gl_frontmaterial.specular*gl_lightsource[0].specular); vec3 color = vec3(ambient + diffuse + specular); gl_fragcolor = vec4(color, 1.0); }

70 Lecture 11: Shadows + Reflection Point light / Area light Three ways of thinking about shadows The basis for different algorithms. Shadow mapping Be able to describe the algorithm Shadow volumes Be able to describe the algorithm Stencil buffer, 4-pass algorithm, Z-pass, Z-fail, Creating quads from the silhouette edges as seen from the light source, etc Pros and cons of shadow volumes vs shadow maps Planar reflections how to do. Why not using environment mapping? Ulf Assarsson 2004

71 Ways of thinking about shadows As separate objects (like Peter Pan's shadow) This corresponds to planar shadows As volumes of space that are dark This corresponds to shadow volumes As places not seen from a light source looking at the scene. This corresponds to shadow maps Note that we already "have shadows" for objects facing away from light Tomas Akenine-Mőller 2002

72 Using the Shadow Map When scene is viewed, check viewed location in light's shadow buffer If point's depth is (epsilon) greater than shadow depth, object is in shadow. shadow depth map For each pixel, compare distance to light with the depth stored in the shadow map 1. Render a shadow depth map from light source. 2. Render from eye. For each generated pixel, transform (warp) the x,y,z-coordinate to light space and compare depth with the stored depth value in the shadow map. If greater point is in shadow Else point is in light Problem: bias / offset neededtomas Akenine-Mőller 2002

73 Tomas Akenine-Mőller 2002

74 Shadow volumes Shadow volume concept Create volumes of space in shadow from each polygon in light. Each triangle creates 3 projecting quads Tomas Akenine-Mőller 2002

75 Using the Volume To test a point, count the number of polygons between it and the eye. If we look through more frontfacing than backfacing polygons, then in shadow. backfacing frontfacing Tomas Akenine-Mőller 2002

76 How to implement shadow volumes with stencil buffer (Z-pass) A four pass process [Heidmann91]: 1st Pass: render the scene with just ambient lighting. Turn off updating Z-buffer and writing to color buffer (i.e. Z-compare, draw to stencil only). 2nd pass: render front facing shadow volume polygons to stencil buffer, incrementing count. 3rd pass: render backfacing shadow volume polygons to stencil, decrementing. 4th pass: render diffuse and specular where stencil buffer is 0. Tomas Akenine-Mőller 2002

77 a=#shadow volumes a point is located within. a is independent of in which direction we count. Choose point at infinity. That point is always outside shadow, due to the caping of the shadow volumes Tomas Akenine-Mőller 2002

78 Compared to Z-pass: Invert z-test Invert stencil inc/dec I.e., count to infinity instead of from eye. Tomas Akenine-Mőller 2002

79 Shadow maps vs shadow volumes Shadow Volumes Good: Anything can shadow anything, including selfshadowing, and the shadows are sharp. Bad: 3 or 4 passes, shadow polygons must be generated and rendered lots of polygons & fill, Shadow Maps Good: Anything to anything, constant cost regardless of complexity, map can sometimes be reused. Bad: Frustum limited. Jagged shadows if res too low, biasing headaches. Tomas Akenine-Mőller 2002

80 Merging Volumes Edge shared by two polygons facing the light creates front and backfacing quad. This interior edge makes two quads, which cancel out Tomas Akenine-Mőller 2002

81 Silhouette Edges From the light s view, caster interior edges do not contribute to the shadow volume. Finding the silhouette edge gets rid of many useless shadow volume polygons. Tomas Akenine-Mőller 2002

82 Planar reflections Assume plane is z=0 Then apply glscalef(1,1,-1); Effect: z Tomas Akenine-Mőller 2002

83 Planar reflections Backfacing becomes front facing! Lights should be reflected as well Need to clip (using stencil buffer) See example on clipping: Tomas Akenine-Mőller 2002

84 Planar reflections How should you render? 1) the ground plan polygon into the stencil buffer 2) the scaled (1,1,-1) model, but mask with stencil buffer Reflect light pos as well Use front face culling 3) the ground plane (semi-transparent) 4) the unscaled model Tomas Akenine-Mőller 2002

85 Lektion 11 Global Illumination Global belysning: Why is not standard ray tracing enough? Light transport notation, rendering eq., BRDFs Monte Carlo Ray Tracing Path tracing Photon mapping L o L e f r ( x,, ') L ( x, ')( ' n) d' i Ray tracing Global Illumination Ulf Assarsson 2004

86 Lektion 12: Perspective correct texturing Taxonomy: Sort first sort middle sort last fragment sort last image Bandwidth Why it is a problem How to solve it Be able to sketch the architecture of a moder graphics card Ulf Assarsson 2004

87 Department of Computer Engineering Application PCI-E x16 Vertex shader Vertex shader Vertex shader Primitive assembly Geo shader Geo shader Clipping Fragment Generation Geo shader On NVIDIA 8000-series: Vertex-, Geometryand Fragment shaders allocated from a pool of 128 processors Fragment shader Fragment shader Fragment shader Fragment Merge Fragment Merge Fragment Merge

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology Ulf Assarsson Department of Computer Engineering Chalmers University of Technology Lecture 1: Real-time Rendering The Graphics Rendering Pipeline Three conceptual stages of the pipeline: Application (executed

More information

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students) TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students) Saturday, January 13 th, 2018, 08:30-12:30 Examiner Ulf Assarsson, tel. 031-772 1775 Permitted Technical Aids None, except

More information

An introduction to Global Illumination. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

An introduction to Global Illumination. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology An introduction to Global Illumination Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Misc Till alla lärare på masternivån, Undervisningen på Chalmers masterprogram

More information

Lecture 1. Application-, geometry-, rasterization stage Real-time Graphics pipeline. Z-buffer Double buffering Screen tearing

Lecture 1. Application-, geometry-, rasterization stage Real-time Graphics pipeline. Z-buffer Double buffering Screen tearing Full-time wrapup Lecture 1 Application-, geometry-, rasterization stage Real-time Graphics pipeline Modelspace, worldspace, viewspace, clip space, screen space Z-buffer Double buffering Screen tearing

More information

TDA361/DIT220 Computer Graphics, January 15 th 2016

TDA361/DIT220 Computer Graphics, January 15 th 2016 TDA361/DIT220 Computer Graphics, January 15 th 2016 EXAM (Same exam for both CTH- and GU students) Friday January 15 th, 2016, 8.30 12.30 Examiner Ulf Assarsson, tel. 0701-738535 Permitted Technical Aids

More information

Texturing. Slides done by Tomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Texturing. Slides done by Tomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology Texturing Slides done by Tomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology 1 Texturing: Glue n-dimensional images onto geometrical objects l Purpose:

More information

Texturing. Slides done bytomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Texturing. Slides done bytomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology Texturing Slides done bytomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology 1 Texturing: Glue n-dimensional images onto geometrical objects l Purpose:

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

Shading. Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Shading. Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Shading Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Overview of today s lecture l A simple most basic real-time lighting model

More information

GLSL II. Objectives. Coupling GLSL to Applications Example applications

GLSL II. Objectives. Coupling GLSL to Applications Example applications GLSL II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico Objectives Coupling GLSL to Applications Example

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

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

Shadow Rendering EDA101 Advanced Shading and Rendering

Shadow Rendering EDA101 Advanced Shading and Rendering Shadow Rendering EDA101 Advanced Shading and Rendering 2006 Tomas Akenine-Möller 1 Why, oh why? (1) Shadows provide cues about spatial relationships among objects 2006 Tomas Akenine-Möller 2 Why, oh why?

More information

Shading. Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Shading. Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Shading Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Overview of today s lecture l A simple most basic real-time lighting model

More information

Objectives. Coupling GLSL to Applications Example applications

Objectives. Coupling GLSL to Applications Example applications GLSL II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico Objectives Coupling GLSL to Applications Example

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

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

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

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

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

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing EECE 478 Rasterization & Scenes Rasterization Learning Objectives Be able to describe the complete graphics pipeline. Describe the process of rasterization for triangles and lines. Compositing Manipulate

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

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

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

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

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

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

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Spatial Data Structures and Speed-Up Techniques Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Spatial data structures What is it? Data structure that organizes

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

Computer Graphics 10 - Shadows

Computer Graphics 10 - Shadows Computer Graphics 10 - Shadows Tom Thorne Slides courtesy of Taku Komura www.inf.ed.ac.uk/teaching/courses/cg Overview Shadows Overview Projective shadows Shadow textures Shadow volume Shadow map Soft

More information

Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology A tool needed for the graphics people all the time Very important components: Need to make them fast! Finding if

More information

Spatial Data Structures and Speed-Up Techniques. Ulf Assarsson Department of Computer Science and Engineering Chalmers University of Technology

Spatial Data Structures and Speed-Up Techniques. Ulf Assarsson Department of Computer Science and Engineering Chalmers University of Technology Spatial Data Structures and Speed-Up Techniques Ulf Assarsson Department of Computer Science and Engineering Chalmers University of Technology Exercises l Create a function (by writing code on paper) that

More information

RASTERISED RENDERING

RASTERISED RENDERING DH2323 DGI16 INTRODUCTION TO COMPUTER GRAPHICS AND INTERACTION RASTERISED RENDERING Christopher Peters HPCViz, KTH Royal Institute of Technology, Sweden chpeters@kth.se http://kth.academia.edu/christopheredwardpeters

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

Deferred Rendering Due: Wednesday November 15 at 10pm

Deferred Rendering Due: Wednesday November 15 at 10pm CMSC 23700 Autumn 2017 Introduction to Computer Graphics Project 4 November 2, 2017 Deferred Rendering Due: Wednesday November 15 at 10pm 1 Summary This assignment uses the same application architecture

More information

Computer Graphics. Shadows

Computer Graphics. Shadows Computer Graphics Lecture 10 Shadows Taku Komura Today Shadows Overview Projective shadows Shadow texture Shadow volume Shadow map Soft shadows Why Shadows? Shadows tell us about the relative locations

More information

+ = Texturing: Glue n-dimensional images onto geometrical objects. Texturing. Texture magnification. Texture coordinates. Bilinear interpolation

+ = Texturing: Glue n-dimensional images onto geometrical objects. Texturing. Texture magnification. Texture coordinates. Bilinear interpolation Texturing Slides done bytomas Akenine-Möller and Ulf Assarsson Chalmers University of Technology Texturing: Glue n-dimensional images onto geometrical objects Purpose: more realism, and this is a cheap

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

Models and Architectures

Models and Architectures Models and Architectures Objectives Learn the basic design of a graphics system Introduce graphics pipeline architecture Examine software components for an interactive graphics system 1 Image Formation

More information

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU FROM VERTICES TO FRAGMENTS Lecture 5 Comp3080 Computer Graphics HKBU OBJECTIVES Introduce basic implementation strategies Clipping Scan conversion OCTOBER 9, 2011 2 OVERVIEW At end of the geometric pipeline,

More information

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL International Edition Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL Sixth Edition Edward Angel Dave Shreiner Interactive Computer Graphics: A Top-Down Approach with Shader-Based

More information

Realtime 3D Computer Graphics Virtual Reality

Realtime 3D Computer Graphics Virtual Reality Realtime 3D Computer Graphics Virtual Reality From Vertices to Fragments Overview Overall goal recapitulation: Input: World description, e.g., set of vertices and states for objects, attributes, camera,

More information

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1 UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series PG Examination 2013-14 COMPUTER GAMES DEVELOPMENT CMPSME27 Time allowed: 2 hours Answer any THREE questions. (40 marks each) Notes are

More information

Rasterization Computer Graphics I Lecture 14. Scan Conversion Antialiasing Compositing [Angel, Ch , ]

Rasterization Computer Graphics I Lecture 14. Scan Conversion Antialiasing Compositing [Angel, Ch , ] 15-462 Computer Graphics I Lecture 14 Rasterization March 13, 2003 Frank Pfenning Carnegie Mellon University http://www.cs.cmu.edu/~fp/courses/graphics/ Scan Conversion Antialiasing Compositing [Angel,

More information

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today! Last Time? Real-Time Shadows Perspective-Correct Interpolation Texture Coordinates Procedural Solid Textures Other Mapping Bump Displacement Environment Lighting Textures can Alias Aliasing is the under-sampling

More information

Overview. Shading. Shading. Why we need shading. Shading Light-material interactions Phong model Shading polygons Shading in OpenGL

Overview. Shading. Shading. Why we need shading. Shading Light-material interactions Phong model Shading polygons Shading in OpenGL Overview Shading Shading Light-material interactions Phong model Shading polygons Shading in OpenGL Why we need shading Suppose we build a model of a sphere using many polygons and color it with glcolor.

More information

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY 1(84) Information Coding / Computer Graphics, ISY, LiTH TSBK 07 Computer Graphics Ingemar Ragnemalm, ISY 1(84) Lecture 5 3D graphics part 3 Illumination Illumination applied: Shading Surface detail: Mappings

More information

Discrete Techniques. 11 th Week, Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of

Discrete Techniques. 11 th Week, Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of Discrete Techniques 11 th Week, 2010 Buffer Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of bits/pixel Pixel OpenGL Frame Buffer OpenGL Buffers Color buffers

More information

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1 Today s class Simple shadows Shading Lighting in OpenGL Wednesday, November 21, 27 Computer Graphics - Class 1 1 Simple shadows Simple shadows can be gotten by using projection matrices Consider a light

More information

Rasterization, Depth Sorting and Culling

Rasterization, Depth Sorting and Culling Rasterization, Depth Sorting and Culling Rastrerzation How can we determine which pixels to fill? Reading Material These slides OH 17-26, OH 65-79 and OH 281-282, by Magnus Bondesson You may also read

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

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology Ulf Assarsson Department of Computer Engineering Chalmers University of Technology Tracing Photons One way to form an image is to follow rays of light from a point source finding which rays enter the lens

More information

COMP3421. Particle Systems, Rasterisation

COMP3421. Particle Systems, Rasterisation COMP3421 Particle Systems, Rasterisation Particle systems Some visual phenomena are best modelled as collections of small particles. Examples: rain, snow, fire, smoke, dust Particle systems Particles are

More information

Mattan Erez. The University of Texas at Austin

Mattan Erez. The University of Texas at Austin EE382V: Principles in Computer Architecture Parallelism and Locality Fall 2008 Lecture 10 The Graphics Processing Unit Mattan Erez The University of Texas at Austin Outline What is a GPU? Why should we

More information

The Rasterizer Stage. Texturing, Lighting, Testing and Blending

The Rasterizer Stage. Texturing, Lighting, Testing and Blending 1 The Rasterizer Stage Texturing, Lighting, Testing and Blending 2 Triangle Setup, Triangle Traversal and Back Face Culling From Primitives To Fragments Post Clipping 3 In the last stages of the geometry

More information

Computer Graphics. Curves and Surfaces. Hermite/Bezier Curves, (B-)Splines, and NURBS. By Ulf Assarsson

Computer Graphics. Curves and Surfaces. Hermite/Bezier Curves, (B-)Splines, and NURBS. By Ulf Assarsson Computer Graphics Curves and Surfaces Hermite/Bezier Curves, (B-)Splines, and NURBS By Ulf Assarsson Most of the material is originally made by Edward Angel and is adapted to this course by Ulf Assarsson.

More information

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE UGRAD.CS.UBC.C A/~CS314 Mikhail Bessmeltsev 1 WHAT IS RENDERING? Generating image from a 3D scene 2 WHAT IS RENDERING? Generating image

More information

The Rasterization Pipeline

The Rasterization Pipeline Lecture 5: The Rasterization Pipeline Computer Graphics and Imaging UC Berkeley CS184/284A, Spring 2016 What We ve Covered So Far z x y z x y (0, 0) (w, h) Position objects and the camera in the world

More information

Real-Time Rendering. Tomas Möller Eric Haines. A K Peters Natick, Massachusetts

Real-Time Rendering. Tomas Möller Eric Haines. A K Peters Natick, Massachusetts Real-Time Rendering Tomas Möller Eric Haines n A K Peters Natick, Massachusetts Contents Preface 1 Introduction 1 1.1 Contents Overview 2 1.2 Notation and Definitions 3 1.2.1 Mathematical Notation 3 1.2.2

More information

Fondamenti di Grafica 3D The Rasterization Pipeline.

Fondamenti di Grafica 3D The Rasterization Pipeline. Fondamenti di Grafica 3D The Rasterization Pipeline paolo.cignoni@isti.cnr.it http://vcg.isti.cnr.it/~cignoni Ray Casting vs. GPUs for Triangles Ray Casting For each pixel (ray) For each triangle Does

More information

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Shadow Buffer Theory Observation:

More information

Homework #2. Hidden Surfaces, Projections, Shading and Texture, Ray Tracing, and Parametric Curves

Homework #2. Hidden Surfaces, Projections, Shading and Texture, Ray Tracing, and Parametric Curves Computer Graphics Instructor: Brian Curless CSE 457 Spring 2013 Homework #2 Hidden Surfaces, Projections, Shading and Texture, Ray Tracing, and Parametric Curves Assigned: Sunday, May 12 th Due: Thursday,

More information

6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm

6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm 6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm In this assignment, you will add an interactive preview of the scene and solid

More information

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored. From Vertices to Fragments: Rasterization Reading Assignment: Chapter 7 Frame Buffer Special memory where pixel colors are stored. System Bus CPU Main Memory Graphics Card -- Graphics Processing Unit (GPU)

More information

Sign up for crits! Announcments

Sign up for crits! Announcments Sign up for crits! Announcments Reading for Next Week FvD 16.1-16.3 local lighting models GL 5 lighting GL 9 (skim) texture mapping Modern Game Techniques CS248 Lecture Nov 13 Andrew Adams Overview The

More information

CSCI 420 Computer Graphics Lecture 14. Rasterization. Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California

CSCI 420 Computer Graphics Lecture 14. Rasterization. Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California CSCI 420 Computer Graphics Lecture 14 Rasterization Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California 1 Rasterization (scan conversion) Final step in pipeline:

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

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Three-Dimensional Graphics V. Guoying Zhao 1 / 55 Computer Graphics Three-Dimensional Graphics V Guoying Zhao 1 / 55 Shading Guoying Zhao 2 / 55 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material

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

Introduction to Computer Graphics with WebGL

Introduction to Computer Graphics with WebGL Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science Laboratory University of New Mexico Models and Architectures

More information

CS GAME PROGRAMMING Question bank

CS GAME PROGRAMMING Question bank CS6006 - GAME PROGRAMMING Question bank Part A Unit I 1. List the different types of coordinate systems. 2. What is ray tracing? Mention some applications of ray tracing. 3. Discuss the stages involved

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

Adaptive Point Cloud Rendering

Adaptive Point Cloud Rendering 1 Adaptive Point Cloud Rendering Project Plan Final Group: May13-11 Christopher Jeffers Eric Jensen Joel Rausch Client: Siemens PLM Software Client Contact: Michael Carter Adviser: Simanta Mitra 4/29/13

More information

INF3320 Computer Graphics and Discrete Geometry

INF3320 Computer Graphics and Discrete Geometry INF3320 Computer Graphics and Discrete Geometry Texturing Christopher Dyken Martin Reimers 06.10.2010 Page 1 Texturing Linear interpolation Real Time Rendering: Chapter 5: Visual Appearance Chapter 6:

More information

Shading, lighting, & BRDF Theory. Cliff Lindsay, PHD

Shading, lighting, & BRDF Theory. Cliff Lindsay, PHD Shading, lighting, & BRDF Theory Cliff Lindsay, PHD Overview of today s lecture BRDF Characteristics Lights in terms of BRDFs Classes of BRDFs Ambient light & Shadows in terms of BRDFs Decomposing Reflection

More information

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important?

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important? Last Time Modeling Transformations Illumination (Shading) Real-Time Shadows Viewing Transformation (Perspective / Orthographic) Clipping Projection (to Screen Space) Graphics Pipeline Clipping Rasterization

More information

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li.

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li. Fall 2015 CSCI 420: Computer Graphics 7.1 Rasterization Hao Li http://cs420.hao-li.com 1 Rendering Pipeline 2 Outline Scan Conversion for Lines Scan Conversion for Polygons Antialiasing 3 Rasterization

More information

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012 CSE 167: Introduction to Computer Graphics Lecture #8: GLSL Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012 Announcements Homework project #4 due Friday, November 2 nd Introduction:

More information

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA)

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA) CSCI 420 Computer Graphics Lecture 14 Rasterization Jernej Barbic University of Southern California Scan Conversion Antialiasing [Angel Ch. 6] Rasterization (scan conversion) Final step in pipeline: rasterization

More information

For Intuition about Scene Lighting. Today. Limitations of Planar Shadows. Cast Shadows on Planar Surfaces. Shadow/View Duality.

For Intuition about Scene Lighting. Today. Limitations of Planar Shadows. Cast Shadows on Planar Surfaces. Shadow/View Duality. Last Time Modeling Transformations Illumination (Shading) Real-Time Shadows Viewing Transformation (Perspective / Orthographic) Clipping Projection (to Screen Space) Graphics Pipeline Clipping Rasterization

More information

CS452/552; EE465/505. Clipping & Scan Conversion

CS452/552; EE465/505. Clipping & Scan Conversion CS452/552; EE465/505 Clipping & Scan Conversion 3-31 15 Outline! From Geometry to Pixels: Overview Clipping (continued) Scan conversion Read: Angel, Chapter 8, 8.1-8.9 Project#1 due: this week Lab4 due:

More information

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

Shadow Algorithms. CSE 781 Winter Han-Wei Shen Shadow Algorithms CSE 781 Winter 2010 Han-Wei Shen Why Shadows? Makes 3D Graphics more believable Provides additional cues for the shapes and relative positions of objects in 3D What is shadow? Shadow:

More information

Recall: Indexing into Cube Map

Recall: Indexing into Cube Map Recall: Indexing into Cube Map Compute R = 2(N V)N-V Object at origin Use largest magnitude component of R to determine face of cube Other 2 components give texture coordinates V R Cube Map Layout Example

More information

lecture 18 - ray tracing - environment mapping - refraction

lecture 18 - ray tracing - environment mapping - refraction lecture 18 - ray tracing - environment mapping - refraction Recall Ray Casting (lectures 7, 8) for each pixel (x,y) { cast a ray through that pixel into the scene, and find the closest surface along the

More information

Texture Mapping II. Light maps Environment Maps Projective Textures Bump Maps Displacement Maps Solid Textures Mipmaps Shadows 1. 7.

Texture Mapping II. Light maps Environment Maps Projective Textures Bump Maps Displacement Maps Solid Textures Mipmaps Shadows 1. 7. Texture Mapping II Light maps Environment Maps Projective Textures Bump Maps Displacement Maps Solid Textures Mipmaps Shadows 1 Light Maps Simulates the effect of a local light source + = Can be pre-computed

More information

CEng 477 Introduction to Computer Graphics Fall 2007

CEng 477 Introduction to Computer Graphics Fall 2007 Visible Surface Detection CEng 477 Introduction to Computer Graphics Fall 2007 Visible Surface Detection Visible surface detection or hidden surface removal. Realistic scenes: closer objects occludes the

More information

Homework #2. Shading, Ray Tracing, and Texture Mapping

Homework #2. Shading, Ray Tracing, and Texture Mapping Computer Graphics Prof. Brian Curless CSE 457 Spring 2000 Homework #2 Shading, Ray Tracing, and Texture Mapping Prepared by: Doug Johnson, Maya Widyasari, and Brian Curless Assigned: Monday, May 8, 2000

More information

CS 354R: Computer Game Technology

CS 354R: Computer Game Technology CS 354R: Computer Game Technology Texture and Environment Maps Fall 2018 Texture Mapping Problem: colors, normals, etc. are only specified at vertices How do we add detail between vertices without incurring

More information

CS 130 Exam I. Fall 2015

CS 130 Exam I. Fall 2015 CS 130 Exam I 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

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

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer Real-Time Rendering (Echtzeitgraphik) Michael Wimmer wimmer@cg.tuwien.ac.at Walking down the graphics pipeline Application Geometry Rasterizer What for? Understanding the rendering pipeline is the key

More information

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into 2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into the viewport of the current application window. A pixel

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

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines COMP30019 Graphics and Interaction Scan Converting Polygons and Lines Department of Computer Science and Software Engineering The Lecture outline Introduction Scan conversion Scan-line algorithm Edge coherence

More information

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015 Orthogonal Projection Matrices 1 Objectives Derive the projection matrices used for standard orthogonal projections Introduce oblique projections Introduce projection normalization 2 Normalization Rather

More information

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting Last Time? Real-Time Shadows Today Why are Shadows Important? Shadows & Soft Shadows in Ray Tracing Planar Shadows Projective Texture Shadows Shadow Maps Shadow Volumes Why are Shadows Important? Depth

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

COMP371 COMPUTER GRAPHICS

COMP371 COMPUTER GRAPHICS COMP371 COMPUTER GRAPHICS LECTURE 14 RASTERIZATION 1 Lecture Overview Review of last class Line Scan conversion Polygon Scan conversion Antialiasing 2 Rasterization The raster display is a matrix of picture

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

E.Order of Operations

E.Order of Operations Appendix E E.Order of Operations This book describes all the performed between initial specification of vertices and final writing of fragments into the framebuffer. The chapters of this book are arranged

More information