Photorealism Steve Ash, Rhodes College 2006
Planes Plane equation a*x + b*y + c*z + d = 0 The triple N(a,b,c) is a vector that is perpendicular to the plane If N is also a unit vector, then for any point P(x p ,y p ,z p ) a*x p + b*y p + c*z p + d = distance from P to the plane N(a,b,c)
Planes Plane equation a*x + b*y + c*z + d = 0 N(a,b,c) POV specification plane { <a, b, c> d [ pigment (texture or color) ] [ material properties ] [ bump map (optional) ] }
Ray-Plane Intersection Plane equation a*x + b*y + c*z + d = 0 Ray equation p = source + t*direction p x = s x + t*d x p y = s y + t*d y p z = s z + t*d z Common point a*x + b*y + c*y + d = 0 a*(s x + t*d x ) + b*(s y + t*d y ) + c*(s z + t*d z ) = 0 could have 0 or 1 solutions (ray may be parallel to the plane) t = ?
Plane Texture Mapping Find any two vectors U, V such that N, U, V are mutually perpendicular Find a point Q that is on the plane N V P(x,y,z) Q U
Plane Texture Mapping Find any two vectors U, V such that N, U, V are mutually perpendicular Find a point Q that is on the plane Compute Q = -d * N u = QP * U v = QP * V Note – Q is indeed on the plane a*Q x + b*Q y + c*Q z + d = ??? N N*Q + d = V N*(-d*N) + d = -d*(N*N) + d = P(x,y,z) -d*1 + d = 0 Q U However, u and v are not in the range [0..1] , so in the image i = u*width % width j = v*height % height
Plane Bump Mapping Use (i, j) and U, V that were computed for Texture Mapping
Triangle Meshes
Triangle Meshes POV specification mesh { source { filename.pov } scale <sx, sy, sz> // multiply component-wise translate <tx, ty, tz> // add component wise [ pigment (texture or color) ] [ material properties ] [ bump map (optional) ] }
Triangle Meshes POV specification mesh { source { filename.pov } scale <sx, sy, sz> // multiply component-wise source specification: (flat) triangle translate <tx, ty, tz> // add component wise [ pigment (texture or color) ] v1 v2 v3 color triangle { <0, 0, 0>, <0, 10, 0>, <10, 0, 0> pigment {color rgb<1, 0, 0>} } [ material properties ] triangle { <0, 10, 0>, <10, 10, 0>, <10, 0, 0> pigment {color rgb<1, 0, 0>} } [ bump map (optional) ] triangle { <0, 0, 10>, <10, 0, 10>, <0, 10, 10> pigment {color rgb<0, 1, 0>} } triangle { <0, 10, 10>, <10, 0, 10>, <10, 10, 10> pigment {color rgb<0, 1, 0>} } } triangle { <10, 10, 10>, <10, 0, 10>, <10, 0, 0> pigment {color rgb<0, 0, 1>} } triangle { <10, 10, 10>, <10, 0, 0>, <10, 10, 0> pigment {color rgb<0, 0, 1>} } triangle { <0, 10, 10>, <0, 0, 0>, <0, 0, 10> pigment {color rgb<1, 1, 1>} } triangle { <0, 10, 10>, <0, 10, 0>, <0, 0, 0> pigment {color rgb<1, 1, 1>} } triangle { <0, 10, 0>, <10, 10, 10>, <10, 10, 0> pigment {color rgb<1, 0, 1>} } triangle { <0, 10, 0>, <0, 10, 10>, <10, 10, 10> pigment {color rgb<1, 0, 1>} } y triangle { <0, 0, 0>, <10, 0, 0>, <10, 0, 10> pigment {color rgb<1, 1, 0>} } triangle { <0, 0, 0>, <10, 0, 10>, <0, 0, 10> pigment {color rgb<1, 1, 0>} } 10 x 10 10 z
Triangle Meshes POV specification mesh { source { filename.pov } [ pigment (texture or color) ] source specification: smooth_triangle [ material properties ] [ bump map (optional) ] smooth_triangle { <91, -1, 0>, <0.862, -0.506, -0.000>, V1, N1 } <92, 0, 0>, <1, 0, 0>, V2, N2 <91, 0, 0>, <0.867, -0.440, 0.234> V3, N3 pigment { color rgb<1, 1, 1>} } color smooth_triangle { <91, 0, 0>, <0.867, -0.440, 0.234>, <92, 0, 0>, <1, 0, 0>, <91, 0, 0>, <0.853, -0.340, 0.396> pigment {color rgb<1, 1, 1>} } … y x z
Ray-Mesh Intersection Go through all triangles and pick the closest one that is intersected For ray-triangle intersection, see the paper Fast , minimum storage ray - triangle intersectjon . 1997. Tomas Möller, Ben Trumbore. Journal of Graphics Tools, 2(1):21—28. The paper shows how to compute three parameters (t, u, v) u, v – barycentric coordinates in the range [0..1] t – the t value for closeness V 2 V 0 P(x,y,z) P = (1 – u – v)*V 0 + u*V 1 + v*V 2 V 1
Ray-Mesh Intersection Use bounding box or bounding sphere to ignore rays quickly might intersect shape need to go through tris cannot intersect shape no need to go through tris
Mesh Texture Mapping 1. Use the barycentric coordinates u, v from the Ray-Triangle intersection test 2. Spherical or Cylindrical Map 3. Establish correspondence with texture For non-textured interpolate the color at the vertices: C = (1 – u – v)*C 0 + u*C 1 + v*C 2
Mesh Bump Mapping The POV models with smooth triangles specify the surface normal at the vertices N 2 use u, v to compute the normal N V 2 N 0 N = (1 – u – v)*N 0 + u*N 1 + v*N 2 V 0 V 1 N 1
Animation (Spherical Spiral) Compute points along the surface of the sphere so that the camera moves gradually along , θ, φ at the same time For camera location P use spherical coordinates x = R sinθ sinφ R – the radius of the dome on which the camera moves y = R cosφ θ – varies in the range [0 up to 2π] by step Δθ > 0 z = R cosθ sinφ φ – varies in the range [π/2=90 ◦ down to π/3=60 ◦ ] by step Δφ < 0 R will depend on the scene setup Δθ and Δφ will depend on the number of frames – divide each range by the number of frames [ θ and φ must update at the same time, so that the camera climbs up towards the pole (φ) as it revolves around the vertical axis (θ ) ] U W For camera’s coordinate system use the opposite directions of the ones used in bump mapping: P V V = (x, y, z) = (-sinθ sinφ, -cos φ, -cosθ sinφ ) W = ∂V/ ∂θ = ( -cosθ, 0, sinθ ) U = ∂V/ ∂φ = (-sinθ cosφ, sinφ, -cosθ cosφ )
Animation Camera/eye is specified by its location ( E ) , up vector ( U ) , and point to look at ( C ) . Compute the camera coordinate system V x U x W (make sure to normalize) and then compute the target point ( P ) through which to shoot the ray This will make it possible to move the camera and create an animation. U U (sky) Points along the horiz. line through C and directjon W : P P h = C + W ∙ h V W = V x U For each P h we need to move some E P h (locaton) units up along dir. U : C (look_at) W P = P h + U ∙ v So P = C + W ∙ h + U ∙ v h,v range: [-size/2, size/2] h,v step: size / density
Light Intensity Attenuation To model the fact that light intensity decreases by distance consider the length of the ray from the hit point to the light design a coefficient that gets smaller with longer distances I = Ambient + Diffuse + Specular I = Ambient + f attj * [ Diffuse + Specular ] I λ = k s *I aλ *O λ + ∑S j * f attj * [k s *I pjλ * O λ *(N*L) + k s *I pjλ *O λ *(R*V) n ] S j = 1 if point light I pj illuminates intersection point 0 if point light I pj does not illuminate
Recommend
More recommend