i total k a i ambient i i compute phong lighting at the
play

I total = k a I ambient + I i ( compute Phong lighting at the - PowerPoint PPT Presentation

Clarify: OpenGL Example University of British Columbia News Clarify: Projective Rendering Pipeline CPSC 314 Computer Graphics coordinate system point of view! coordinate system point of view! midterm is Monday, be on time! object world


  1. Clarify: OpenGL Example University of British Columbia News Clarify: Projective Rendering Pipeline CPSC 314 Computer Graphics coordinate system point of view! coordinate system point of view! • midterm is Monday, be on time! object world Jan-Apr 2010 viewing clipping glVertex3f(x,y,z) glVertex3f(x,y,z) O2W W2V V2C O2W W2V V2C VCS CCS CCS object world OCS OCS WCS WCS VCS viewing • HW2 solutions out projection projection O2W O2W W2V W2V V2C V2C alter w alter w modeling viewing modeling viewing WCS VCS VCS OCS WCS OCS glFrustum(...) glFrustum (...) Tamara Munzner transformation transformation transformation transformation transformation transformation projection projection modeling viewing modeling viewing transformation transformation transformation transformation CCS CCS transformation transformation clipping glMatrixMode( GL_PROJECTION ); Lighting/Shading IV, glTranslatef(x,y,z) glTranslatef (x,y,z) gluLookAt gluLookAt(...) (...) C2N C2N glLoadIdentity(); / w / w CCS CCS glRotatef glRotatef(a,x,y,z) (a,x,y,z) gluPerspective( 45, 1.0, 0.1, 200.0 ); Advanced Rendering I perspective perspective .... .... VCS VCS glMatrixMode( GL_MODELVIEW ); normalized division division OCS - object coordinate system glLoadIdentity(); device glutInitWindowSize(w,h) glutInitWindowSize (w,h) N2D N2D V2W V2W glTranslatef( 0.0, 0.0, -5.0 ); WCS - world coordinate system glViewport(x,y,a,b) glViewport (x,y,a,b) NDCS NDCS Week 7, Fri Mar 5 WCS WCS glPushMatrix() viewport viewport • transformations that VCS - viewing coordinate system W2O W2O glTranslate( 4, 4, 0 ); transformation transformation OCS1 OCS1 glutSolidTeapot(1); are applied to object CCS - clipping coordinate system device http://www.ugrad.cs.ubc.ca/~cs314/Vjan2010 glPopMatrix(); first are specified DCS DCS NDCS - normalized device coordinate system W2O W2O glTranslate( 2, 2, 0); last 2 3 OCS2 glutSolidTeapot(1); 4 OCS2 DCS - device coordinate system Coordinate Systems: Frame vs Point Coordinate Systems: Frame vs Point Homework Review: Reflection Equations read down: transforming read up: transforming points, • is gluLookAt V2W or W2V? depends on • most of my lecture slides use coordinate frame between coordinate frames, up from frame B coords to l n I diffuse = k d I light (n • l) reading ("reading down") from frame A to frame B frame A coords which way you read! θ • same with my post to discussion group: said to use DCS DCS display • coordinate frames: V2W D2N N2D N2D W2V, V2N, N2D D2N • takes you from view to world coordinate frame NDCS NDCS normalized device I specular = k s I light ( v • r ) n shiny • homework questions asked you to compute for N2V N2V V2N V2N • points/objects: W2V object/point coords ("reading up") VCS viewing VCS • transforms point from world to view coords V2W V2W W2V W2V WCS • correct matrix for question 1 is gluLookat WCS world W2O O2W W2O O2W • enough confusion that we will not deduct marks if 2 ( N ( N · L )) – L = R OCS OCS object you used inverse of gluLookAt instead of gluLookAt! • same for Q2, Q3: no deduction if you used inverses of correct matices 5 6 7 8 Review: Phong Lighting Model Review: Blinn-Phong Model Review: Lighting Review: Shading Models Summary • variation with better physical interpretation • lighting models • flat shading • combine ambient, diffuse, specular components • compute Phong lighting once for entire polygon • Jim Blinn, 1977 • ambient I out ( x ) = k s ( h • n ) n shiny • I in ( x );with h = ( l + v )/2 • Gouraud shading # lights • normals don’t matter k d ( n • l i ) + k s ( v • r i ) n shiny ) � I total = k a I ambient + I i ( • compute Phong lighting at the vertices • h : halfway vector • Lambert/diffuse • at each pixel across polygon, interpolate lighting i = 1 • angle between surface normal and light • h must also be explicitly normalized: h / |h| • commonly called Phong lighting values • Phong/specular • highlight occurs when h near n • Phong shading • once per light n n • surface normal, light, and viewpoint h • once per color component h • compute averaged vertex normals at the vertices v v • at each pixel across polygon, interpolate normals l l and compute Phong lighting • reminder: normalize your vectors when calculating! • normalize all vectors: n,l,r,v 9 10 11 12 Non-Photorealistic Shading Non-Photorealistic Shading Computing Normals Computing Normals k w = 1 + n � l • cool-to-warm shading • draw silhouettes: if , e =edge-eye vector • per-vertex normals by interpolating per-facet • per-vertex normals by interpolating per-facet , c = k w c w + (1 � k w ) c c ( e � n 0 )(e � n 1 ) � 0 2 normals normals • draw creases: if ( n 0 � n 1 ) � threshold • OpenGL supports both • OpenGL supports both • computing normal for a polygon • computing normal for a polygon • three points form two vectors b b c-b c c a-b a a http://www.cs.utah.edu/~gooch/SIG98/paper/drawing.html http://www.cs.utah.edu/~gooch/SIG98/paper/drawing.html 13 14 15 16

  2. Computing Normals Specifying Normals Global Illumination Models • per-vertex normals by interpolating per-facet normals • OpenGL state machine • simple lighting/shading methods simulate • OpenGL supports both local illumination models • uses last normal specified • computing normal for a polygon • if no normals specified, assumes all identical • no object-object interaction • three points form two vectors • per-vertex normals • global illumination models • cross: normal of plane glNormal3f(1,1,1); gives direction Advanced Rendering • more realism, more computation b glVertex3f(3,4,5); • normalize to unit length! (a-b) x (c-b) glNormal3f(1,1,0); • leaving the pipeline for these two lectures! glVertex3f(10,5,2); • which side is up? • per-face normals • approaches c-b c • convention: points in glNormal3f(1,1,1); counterclockwise • ray tracing a-b order glVertex3f(3,4,5); • radiosity glVertex3f(10,5,2); • normal interpreted as direction from vertex location a • photon mapping • can automatically normalize (computational cost) • subsurface scattering 17 18 19 20 glEnable(GL_NORMALIZE); Ray Tracing Simple Ray Tracing Reflection Refraction n d n • simple basic algorithm • view dependent method • mirror effects • happens at interface between transparent object • perfect specular reflection • well-suited for software rendering • cast a ray from viewer’s and surrounding medium eye through each pixel • flexible, easy to incorporate new effects • e.g. glass/air boundary • compute intersection of t • Turner Whitted, 1990 ray with first object in • Snell’s Law scene • pixel positions • cast ray from on projection • light ray bends based on projection intersection point on plane reference refractive indices c 1 , c 2 point object to light sources 21 22 23 24 Recursive Ray Tracing Basic Algorithm Basic Ray Tracing Algorithm Algorithm Termination Criteria • ray tracing can handle • termination criteria RayTrace (r,scene) • reflection (chrome/mirror) for every pixel p i { obj := FirstIntersection (r,scene) • no intersection • refraction (glass) generate ray r from camera position through pixel p i if (no obj) return BackgroundColor; • reach maximal depth • shadows else begin for every object o in scene { • spawn secondary rays if ( Reflect (obj) ) then • number of bounces if ( r intersects o ) reflect_color := RayTrace ( ReflectRay (r,obj)); • reflection, refraction compute lighting at intersection point, using local • contribution of secondary ray attenuated else • if another object is hit, normal and material properties; store result in p i below threshold reflect_color := Black; recurse to find its color pixel positions else if ( Transparent (obj) ) then on projection • each reflection/refraction attenuates ray • shadow projection p i = background color refract_color := RayTrace ( RefractRay (r,obj)); plane reference • cast ray from intersection else } point point to light source, check refract_color := Black; if intersects another object } return Shade (reflect_color,refract_color,obj); end; 25 26 27 28 Ray Tracing Algorithm Ray-Tracing Terminology Ray Trees Ray Tracing • all rays directly or indirectly spawned off by a single • terminology: • issues: primary ray Light Eye Image Plane • primary ray: ray starting at camera • generation of rays Source • shadow ray • intersection of rays with geometric primitives • reflected/refracted ray • geometric transformations Shadow Reflected Rays Ray • ray tree: all rays directly or indirectly spawned • lighting and shading off by a single primary ray • efficient data structures so we don’t have to • note: test intersection with every object • need to limit maximum depth of ray tree to ensure termination of ray-tracing process! Refracted Ray 29 30 www.cs.virginia.edu/~gfx/Courses/2003/Intro.fall.03/slides/lighting_web/lighting.pdf 31 32

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

Recommend


More recommend