![]() ![]() One last thing we need are the fancy shiny highlights. Which makes sense considering the real world scenario above. And when it’s somewhere in between we get a proportionate amount of light reflected back. That finally tells us that when the light source L is shining directly on the surface (collinear with N) we get the most reflected light and when it’s perpendicular to it we get zero reflected light. And when the vectors are collinear (Θ equals 0) the cosine value is 1 and when they are perpendicular (Θ equals π / 2) their cosine is 0. In our case a and b are normalized (their length is 1) so the dot product is basically just the cosine of the angle between the two vectors (since a = 1 and b = 1 so 1 times 1 is 1). L)? Well, a really cool thing arises in euclidean geometry which states:.If we’re in a room we’ll still be able to see the object because of other light reflections (ambient light). If we move the torch so that it’s pointing perpendicular to the surface of the object we won’t be able to see any light reflect off it (or just a teeny tiny bit). That’s because most of the light is reflecting back at us. If we’re holding a torch and point it directly at an object we’ll see the object very well lit. Now what does that mean? Well it’s a really nice trick. The first part is fairly similar to how ambient light is calculated but then we have ( N The diffuse component is the most “aha” component once you get it how it works. ![]() The bigger the k a the more ambient light we get. This shouldn’t be too difficult to understand. Transforming that into an equation we have: In order to calculate ambient lighting we need two things: the ambient coefficient which is just a constant value of how much ambient light would we like to apply and the ambient light color. Instead we always apply a minimum amount of light. Phong reflection model simplifies this by not calculating exactly how much light we get indirectly (by bouncing from other objects). That’s mostly due to light reflection from other objects in the room etc. If we look at a real world scenario where we have a light in a room we’ll never see an object completely black. Like mentioned above the ambient component provides base illumination for an object in case we’re getting zero direct light. How all three components add up is perfectly visible from another Wikipedia image: H, which is used for optimizing Phong shading using an approximation called Blinn-Phong shading.V, the view vector which is pointing towards the camera.R, the vector of a perfectly reflected ray of light.L, the light vector which is pointing towards the light source.Wikipedia provides a nice image that does most of the explanation for us: Now we just need to explain what all those vectors are. One more thing to mention is when we’re working with RGB we basically apply the equation for each color component. The third one is the specular component which can be seen as shiny bright spots. The second component is called diffuse light which is the light that bounces from the object in all directions. Now let’s look at the other two components. If we have only one light we can simplify the upper equation to: For the sake of explanation we’ll assume that we have only one light and then build up to multiple lights from there. We calculate the other two for every light we have in the scene. It basically provides a base illumination so that no part of an object that is being illuminated appears completely unlit. Every surface point I p is a sum of three different illumination components. All the vectors we’ll be using have to be normalized. The Phong Reflection Modelīefore we dive in let’s look at the Phong reflection model equation which is below. Yielding very good results and being pretty comprehensible makes it an excellent go to shader for someone just getting into the shader land. The evergreen Phong reflection model (also known as Phong Shader or Phong Illumination) is probably the most used shader ever. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |