Download presentation
Presentation is loading. Please wait.
1
Simple Texture Mapping
and Simple Ray-Tracing
2
Texture Map Each pixel in a texture map is called a Texel
Each Texel is associated with a (s,t) 2D texture coordinate The range of s, t is [0.0,1.0] due to normalization
3
Simple Mapping Texture Coordinates Projection Coordinates
4
Simple Mapping Texture Coordinates Projection Coordinates
5
Simple Mapping
6
Basic File Structure Add texture coordinates v1 x1 y1 z1 u1 v1
7
Texture Filtering Get an interpolated value from near four neighbors
8
Bilinear Interpolation
9
Perspective Correction
Linear Interpolation of Texture Coordinate Corrected Interpolation
10
Perspective Correction
Let’s assume that the viewport is located 1 unit away from the projection center
11
Perspective Correction
Compare linear interpolation in screen space
12
Perspective Correction
13
Perspective Correction
We can interpolate arbitrary parameters of a surface on the screen coordinates in the linear fashion Use s instead t ! (ex) Gouraud shading, Phong normal . . etc
14
Perspective Correction
Further reading (Perspective correction with Z-buffering)
15
Ray Tracing Concept eye view plane Binary Tree
16
Ray Tracing Procedure For each ray r from eye to pixel, color the pixel the value returned by the function: ray_cast(r) ray_cast(r) { s nearest_intersected_surface(r); p point_of_intersection(r, s); u reflect(r, s, p); v refract(r, s, p); c phong(p, s, r) + s.kreflect ray_cast(u) + s.krefract ray_cast(v); return(c); }
17
Ray Tracing Procedure s nearest_intersected_surface(r);
Use geometric searching to find the nearest surface s intersected by the ray r p point_of_intersection(r, s); Compute p, the point of intersection of ray r with surface s u reflect(r, s, p); v refract(r, s, p); Compute the reflected ray u and the refracted ray v using Snell’s Laws
18
Ray Tracing Procedure phong(p, s, r) s.kreflect ray_cast(u)
Evaluate the Phong reflection model for the ray r at point p on surface s, taking shadowing into account s.kreflect ray_cast(u) Multiply the contribution from the reflected ray u by the specular-reflection coefficient kreflect for surface s s.krefract ray_cast(v) Multiply the contribution from the refracted ray v by the specular-refraction coefficient krefract for surface s
19
Reflection and Refraction
Reflected and refracted rays are computed using Snell’s Law surface normal reflected ray incident ray surface refracted ray
20
Shadowing If any object intersects the shadow ray between the surface and the point light source, the surface is in shadow w.r.t. that light source blocked ! u L N r
21
Surface Intersection Ray equation ray path
22
Surface Intersection For sphere,
If the discriminant is negative, the ray does not intersect the sphere. Otherwise, intersection coordinates are obtained using smaller s.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.