1 / 27

Image Synthesis

Image Synthesis. Ray- Tracing – A Quick review. Colored rays. Bouncing rays. Forward or backward. Tracing photons out from each light source would lead to an excellent picture of the scene But most photons will never hit the eye

wilton
Download Presentation

Image Synthesis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Image Synthesis Ray-Tracing – A Quick review

  2. Colored rays

  3. Bouncing rays

  4. Forward or backward Tracing photons out from each light source would lead to an excellent picture of the scene But most photons will never hit the eye We want to know what photons certainly contribute to the image If we consider a pixel on the image plane, we know where photons hitting that pixel must be coming from Therefore, we trace rays backwardsfrom the eye into the scene

  5. The ray tracing camera • Infinite viewing frustum

  6. Ray tracing • The basicray-tracingmethod • Recursivesearchforpathstothelightsource • Interaction with matter • Point-wiseevaluationof an illumination model • Shadows, reflection, transparency N: surface normals R: reflected rays L: shadow rays T: transmitted rays T2 R2 R3 T1 N2 R1 N3 L3 L2 L1 N1 Point light source Viewpoint

  7. Ray tracing • The basic ray-tracing method

  8. Ray tracing • Recursiveraytraversalresults in a tree-likecomputation order • Depthofrecursioncanbearbitrary • More work in branches but lesscontributiontothe final image due toabsorption • I = Idirect+ ksIreflected+ ktIrefracted • Idirect= Iambiant+ Idiffuse+ Ispecular Viewpoint L1 R1 T1 L2 R2 R3 T2

  9. Ray tracing • The basic ray-tracing program • Define the camera ( Cam(o,d,f,x,y,X,Y) ) • O: point of view • D: viewing direction • f: focal distance (distance to the view plane) • x,y: size of the image plane • Up vector U (orientation of the image plane) • Define the viewport • X,Y: resolution of the viewport (the pixel raster) • Sampling the image plane with at least one ray per pixel

  10. Ray tracing Sampling theimage plane For (eachpixel) { Definetherayfromtheviewpointthroughthatpixel Tracetheraythroughthescene [ computeray-objectintersections recursivelyaccumulateobjectcolorsalongtheray ] Set accumulatedcolorasthepixelcolor }

  11. Ray tracing • Sampling the image plane • A continuous sphere sampling at varying viewport resolution

  12. Ray-object intersections Implicitsurfaces • Implicitequationsimplicitelydefine a setofpoints on thesurfacebytheequation F([x,y,z]T) = 0 • For a possibleintersectionpointit must hold: f(o + td) = 0 • Example:ray-plane(Ax+By+Cz+D = 0) intersection A(ox+tdx)+B(oy+tdy)+C(oz+tdz)+D=0 • t = -(Pn o + D) / (Pn  d) Check thedenominatorforray || plane

  13. Ray-object intersections Forimplicitsurfacesthe normal attheintersectionpointisgivenby n = f(p) = ( f(p)/x, f(p)/y, f(p)/z ) Example: sphere (x-cx)2 +(y-cy)2 +(z-cz)2 - R2 = 0 f(p)/x = 2(x-cx) f(p)/y = 2(y-cy) f(p)/z = 2(z-cz) n = 2(p-c), thevectorfromthecentertothepoint

  14. Ray-object intersections Ray-sphere(c,R) intersection • Implicitequationofthesphere (x-cx)2 +(y-cy)2 +(z-cz)2 - R2 = 0, whichisequalto (p-c)(p-c) – R2 = 0 • Withtheparametricray: (o+t d – c) (o+t d – c) – R2 = 0 • (dd)t2 + 2d(o-c)t + (o-c)(o-c) – R2 = 0 • Quadraticequation in t • Discriminantdeterminesthenumberofsolutions

  15. Ray-object intersections Parametricsurfaces • A mappingfromR2(u,v)toR3(x,y,z) x = f(u,v), y = g(u,v), z = h(u,v) A parametricunitsphere: : [0:2pi] Azimuth : [0:pi] Zenith x = cos()*sin() y = sin()*sin() z = cos()

  16. Ray-object intersections Parametricsurfaces • Intersectingtheraywith a parametricsurface ox + t dx = f(u,v) oy + t dy = g(u,v) oz + t dz = h(u,v) -> Yields 3 equationsand 3 unknowns -> solveit -> Mightbecomplicatedfor non-simple f,gand h • The normal isgivenby N(u,v) = (f/u, g/u, h/u) X (f/v, g/v, h/v)

  17. Ray-object intersections Ray-triangleintersection • Given a triangledefinedbythethreepoints A, B and C • Anypointwithinthetrianglecanbedefinedbymeansofbarycentriccoordinatesu,v,w P = uA+vB+wC, withu+v+w=1 andu,v,w> 0 B (u,v,w) Aa Ac P Ab A C

  18. Given a Ray … • … R(t) by ist originoanddirectiondR(t)=o+td • Intersection: (1-u-v)V0+uV1+vV2=O+tD-tD+ uV1-uV0+vV2-vV0=O-V0 [-D,V1-V0, V2-V0][t,u,v]T=O-V0

  19. Geometric Interpretation [-D,V1-V0, V2-V0][t,u,v]T=O-V0

  20. Solving the System of Equations

  21. Implementation boolIntersectTriangle( const VECTOR3& orig, const VECTOR3& dir, VECTOR3& v0, VECTOR3& v1, VECTOR3& v2, float* t, float* u, float* v ) { // Find vectors for two edges sharing vert0 VECTOR3 edge1 = v1 - v0; VECTOR3 edge2 = v2 - v0; // Begin calculating determinant - also used to calculate U parameter VECTOR3 pvec; Cross( &pvec, &dir, &edge2 );  // If determinant is near zero, ray lies in plane of triangle float det = Dot( &edge1, &pvec ); VECTOR3 tvec; if( det > 0 ) tvec = orig - v0; else { tvec = v0 - orig; det = -det; } if( det < 0.0001f ) return false; // Calculate U parameter and test bounds *u = Dot( &tvec, &pvec ); if( *u < 0.0f || *u > det ) return false; // Prepare to test V parameter VECTOR3 qvec; Cross( &qvec, &tvec, &edge1 );  // Calculate V parameter and test bounds *v = Dot( &dir, &qvec ); if( *v < 0.0f || *u + *v > det ) return false; // Calculate t, scale parameters, ray intersects triangle *t = Dot( &edge2, &qvec ); float fInvDet = 1.0f / det; *t *= fInvDet; *u *= fInvDet; *v *= fInvDet; returntrue; }

  22. Ray-tracing shadows • Shadow rays • For each ray-object intersection cast a ray toward the light sources • Check for intersections in-between object and light source • Take care of finite-precision arithmetic • Shadow ray might intersect object it originates from at t =  • Acceleration by means of pre-computed shadow maps or shadow volumes (to be discussed later)

  23. Ray-tracing shadows • Soft-shadows (Penumbras) • Occur where an area light source is partially occluded

  24. Ray-tracing shadows • Soft-shadows (Penumbras) • Reflectedintensityis proportional tothe solid angle ofthevisibleportionofthelight • Complexcomputation • Distribute multiple shadowraysacrosstheregion • Weightshadowcontributions

  25. Object representation Polygonal approximationofcontinuousobjects

  26. Object representation Polygonal approximationofcontinuousobjects • Approximation ofshapeby polygonal patches • Modellingbyhand, scanning, surfaceevaluation

  27. Object representation

More Related