Download presentation

Presentation is loading. Please wait.

Published byMegan Wheeler Modified over 3 years ago

1
13.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 13 An Introduction to Ray Tracing

2
13.2 si31_2001 Ray Tracing n Ray tracing is an alternative rendering approach to the polygon projection, shading and z-buffer way of working n It is capable of high quality images through taking account of global illumination

3
13.3 si31_2001 Ray Tracing Example

4
13.4 si31_2001 Firing Rays pixel positions on view plane camera The view plane is marked with a grid corresponding to pixel positions on screen. A ray is traced from the camera through each pixel in turn. light

5
13.5 si31_2001 Finding Intersections pixel positions on view plane camera We calculate the intersection of the ray with all objects in the scene. The nearest inter- section will be the visible surface for that ray light

6
13.6 si31_2001 Intensity Calculation pixel positions on view plane camera The intensity at this nearest intersection is found from the usual Phong reflection model. Stopping at this point gives us a very simple rendering method. Often called: ray casting light

7
13.7 si31_2001 Phong Reflection Model light source N L R V eye surface I( ) = K a ( )I a ( ) + ( K d ( )( L. N ) + K s ( R. V ) n ) I*( ) / dist Note: R.V calculation replaced by H.N for speed - H = (L+V)/2 dist = distance attenuation factor Here V is direction of incoming ray, N is normal, L is direction to light source, and R is direction of perfect spec. reflection.

8
13.8 si31_2001 Intensity Calculation pixel positions on view plane camera Thus Phong reflection model gives us intensity at point based on a local model: I = I local where I local = I ambient + I diffuse + I specular Intensity calculated separately for red, green, blue light

9
13.9 si31_2001 Shadows pixel positions on view plane camera To determine if the point is in shadow, we can fire a ray at the light source(s) - in direction L. If the ray intersects another object, then point is in shadow from that light. In this case, we just use ambient component: I local = I ambient Otherwise the point is fully lit. light shadow ray Note this has to be done for every light source in scene.

10
13.10 si31_2001 Reflected Ray pixel positions on view plane camera Ray tracing models reflections by looking for light coming in along a secondary ray, making a perfect specular reflection. R 1 = V - 2 (V.N) N R1R1 light

11
13.11 si31_2001 Reflected Ray- Intersection and Recursion We calculate the intersection of this reflected ray, with all objects in the scene. The intensity at the nearest intersection point is calculated, and added as a contribution attenuated by distance. This is done recursively. pixel positions on view plane camera light

12
13.12 si31_2001 Reflected Ray - Intensity Calculation pixel positions on view plane camera light The intensity calculation is now: I = I local + k r * I reflected Here I reflected is calculated recursively k r is a reflection coefficient (similar to k s )

13
13.13 si31_2001 Ray Termination pixel positions on view plane camera Rays terminate: - on hitting diffuse surface - on going to infinity - after several reflections - why?

14
13.14 si31_2001 Transmitted Ray If the object is semi- transparent, we also need to take into account refraction pixel positions on view plane camera light Thus we follow also transmitted rays, eg T 1. T1T1

15
13.15 si31_2001 Refraction N V T i r r i Change in direction is determined by the refractive indices of the materials, i and r Snells Law: sin r = ( i / r ) * sin i T = ( i / r ) V - ( cos r - ( i / r ) cos i ) N

16
13.16 si31_2001 Refraction Contribution n The contribution due to transmitted light is taken as: k t * I t ( ) – where k t is the transmission coefficient I t ( ) is the intensity of transmitted light, again calculated separately for red, green, blue

17
13.17 si31_2001 Intensity Calculation pixel positions on view plane camera The intensity calculation is now: I = I local + k r * I reflected + k t * I transmitted I reflected and I transmitted are calculated recursively

18
13.18 si31_2001 Binary Ray Tracing Tree S1 S2S3 S4 pixel positions on view plane camera S1 S2 S3 S4 R1R1 T1T1 T1T1 R1R1 The intensity is calculated by traversing the tree and accumulating intensities light

19
13.19 si31_2001 Calculating Ray Intersections n A major part of ray tracing calculation is the intersection of ray with objects n Two important cases are: – sphere – polygon

20
13.20 si31_2001 Ray - Sphere Intersection Let camera position be (x 1, y 1, z 1 ) Let pixel position be (x 2, y 2, z 2 ) Any point on ray is: x(t) = x 1 + t * (x 2 - x 1 )= x 1 + t * i y(t) = y 1 + t * (y 2 - y 1 )= y 1 + t * j z(t) = z 1 + t * (z 2 - z 1 )= z 1 + t * k As t increases from zero, x(t), y(t), z(t) traces out the line from (x 1, y 1, z 1 ) through (x 2, y 2, z 2 ). Equation of sphere, centre (l, m, n) and radius r: (x - l) 2 + (y - m) 2 + (z - n) 2 = r 2

21
13.21 si31_2001 Ray - Sphere Intersection Putting the parametric equations for x(t), y(t), z(t) in the sphere equation gives a quadratic in t: at 2 + bt + c = 0 Exercise: write down a, b, c in terms of i, j, k, l, m, n, x 1, y 1, z 1 Solving for t gives the intersection points: b 2 - 4ac < 0 no intersections b 2 - 4ac = 0ray is tangent b 2 - 4ac > 0two intersections, we want smallest positive

22
13.22 si31_2001 Ray - Polygon Intersection Equation of ray: x(t) = x 1 + t * i y(t) = y 1 + t * j z(t) = z 1 + t * k Equation of plane: ax + by + cz + d = 0 Intersection: t = - (ax 1 + by 1 + cz 1 + d) / (ai + bj + ck) Need to check intersection within the extent of the polygon.

23
13.23 si31_2001 Ray Tracing - Limitations n This basic form of ray tracing is often referred to as Whitted ray tracing after Turner Whitted who did much of the early work... n Ray tracing in its basic form is computationally intensive n Much research has gone into increasing the efficiency and this will be discussed in next lecture.

24
13.24 si31_2001 Ray Tracing Example

25
13.25 si31_2001 Depth 0

26
13.26 si31_2001 Depth 1

27
13.27 si31_2001 Depth 2

28
13.28 si31_2001 Depth 3

29
13.29 si31_2001 Depth 4

30
13.30 si31_2001 Depth 7

31
13.31 si31_2001 Acknowledgements n As ever, thanks to Alan Watt for the excellent images

Similar presentations

Presentation is loading. Please wait....

OK

RENDERING : Global Illumination

RENDERING : Global Illumination

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on email etiquettes and conventions Ppt on hotel management software Ppt on fair and lovely cream Ppt on time management training Ppt on metro rail in india Ppt on mars one candidates Ppt on ms access query Download ppt on software project management Download ppt on cloud computing technology Free ppt on balanced diet