 Okay, welcome back. Today we're mainly going to be talking about the visual rendering part of virtual reality. I'll be covering what are standard computer graphics techniques but at the same time highlighting what some of the challenges and differences are with respect to rendering to head mounted displays and what the troubles are that are presented in that context that are I think somewhat unique and unusual in comparison to graphical rendering on a screen that's fixed with respect to the observer. So, you may remember that last time we covered tracking systems. So, we finished up by covering both orientation and position tracking and so remember that the view point that you have when you're rendering the scene the virtual world or perhaps it's some recorded version of the real world. Whenever you're rendering that for the eye your eye's perspective is attached to a tracker. So, that perspective is changing frequently and that's one of the challenges that comes into play here when we get into the rendering part. So, when I got into rendering I started to give a brief overview I'll put visual in front of it because we'll also cover audio rendering and so you can imagine rendering onto a display for other senses of the body. And as I mentioned there were two main approaches to visual rendering there is image order versus object order which in image order it goes pixel by pixel and an object order it goes object by object which in our case is triangle by triangle. So, that's where I left off last time let me just go through what happens in image order rendering first. So, we'll cover this case, but the particular methods inside are related to both. So, some of the things I'll cover end up applying as well to object order rendering. So, we will come back to those. So, generally the most common method for image order rendering is referred to as ray tracing which involves three stages. One ray generation, two I will write them here quickly and then I will go into details on each of them. Ray intersection and three shading. So, if we take a look at ray generation. So, it's pixel by pixel as I said last time the outer loop in the image order rendering is to go across each pixel and figure out what should the RGB values be at that pixel. So, the first step is to figure out what is the visibility ray that goes through that pixel to the focal point of this kind of a virtual camera that we're constructing with perspective transformation. So, I will just draw it so that it looks like a one dimensional image here. So, I have the image plane here and I focus on one particular pixel. So, it just has one location like that. There's the focal point of the perspective projection transform and then I have this ray that I need to define the equations of. I'm not going to work through the algebra in this lecture. So, it should be a straight line and it goes out indefinitely. So, that's the ray generation part is to figure out based on the pixel based on the focal point what is the equation for this line well ray let's say which you start with a line equation and then you just take half of the line in a particular direction going out. And now the next problem is to figure out what is the first one of your objects which in our case is triangles to be hit by this ray going outward. And so, out in the scene there are some triangles around some of them are not hit by the ray oops let me make sure I only draw triangles perhaps this one here is the first one struck and then there are some other ones further away. So, for step number 2 we need to do intersection tests with triangles and then figure out the closest triangle that struck that is going to be the part of the scene that this image this pixel in the image is effectively looking at right. So, that is what we have to figure out we need to figure out what should the amount of intensity and color be corresponding to this particular triangle that is hit first this other triangle that is hit later would be occluded or completely behind just drawing where the intersection points might be. So, you can look in the book if you like or try to derive yourself some simple equations or piece of code for testing the intersection between a triangle and three-dimensional space and a line segment in three-dimensional space. So, it is not too complex it is some sort of maybe high school geometry and algebra exercise. Now of course, if you are seen has millions of triangles in there then it is not very efficient to go and loop through each and every one of these triangles for each and every one of these pixels and. So, you may want to develop a data structure that cleverly arranges the triangles. So, that you can eliminate large fractions of them from having to test them based on what zones or what regions these rays appear in. So, I do not recommend doing the absolute simplest case where you just loop through a million triangles in each and every one of these pixel by pixel operations right. So, after we do that we figure out ok this is the part that I am going to care about here let us say this is the nearest intersection point. So, this is what is showing up right there in the image again I am just imagining the image runs this way as well coming out of the board. So, we need to figure out at this exact location what should we draw what should the RGB values be for this pixel based on the fact that this visibility ray hits this triangle first. Well one thing we assume is that in this virtual world that has been constructed we want to play some light sources and then the light is going to hit our objects our triangles in this case and then based on the reflectance properties of the triangles we are going to determine what the RGB value should be. So, that gets to the shading part which is part 3 here. So, let me now go into shading.