

When the view direction is perfectly aligned with the (now imaginary) reflection vector, the halfway vector aligns perfectly with the normal vector. The closer this halfway vector aligns with the surface's normal vector, the higher the specular contribution. Instead of relying on a reflection vector we're using a so called halfway vector that is a unit vector exactly halfway between the view direction and the light direction. The Blinn-Phong model is largely similar, but approaches the specular model slightly different which as a result overcomes our problem. Blinn as an extension to the Phong shading we've used so far. In 1977 the Blinn-Phong shading model was introduced by James F. Since we're nullifying this contribution at angles larger than 90 degrees we get the artifact as seen in the first image. This generally isn't a problem since the view direction is far from the reflection direction, but if we use a low specular exponent the specular radius is large enough to have a contribution under these conditions. In the right image we can see that the angle \(\theta\) between the view and reflection vector is larger than 90 degrees which as a result nullifies the specular contribution. The left image shows Phong reflections as familiar, with \(\theta\) being less than 90 degrees. However, with specular lighting we're not measuring the angle between the light source and the normal, but between the view and reflection vector. Wrong, this only applies to the diffuse component where an angle higher than 90 degrees between the normal and light source means the light source is below the lighted surface and thus the light's diffuse contribution should equal 0.0. You're probably thinking this won't be a problem since we shouldn't get any light with angles higher than 90 degrees anyways, right? If the angle is larger than 90 degrees, the resulting dot product becomes negative and this results in a specular exponent of 0.0. The reason this happens is because the angle between the view and reflection vector doesn't go over 90 degrees. You can see at the edges that the specular area is immediately cut off.

The image below shows what happens when we use a specular shininess exponent of 1.0 on a flat textured plane: Phong lighting is a great and very efficient approximation of lighting, but its specular reflections break down in certain conditions, specifically when the shininess property is low resulting in a large (rough) specular area. The Phong model looks nice, but has a few nuances we'll focus on in this chapter. In the lighting chapters we briefly introduced the Phong lighting model to bring a basic amount of realism into our scenes.
#Reflection vector code code#
anyway, you should hopefully be able to plug in your own values to the code and use it you desire.Advanced Lighting Advanced-Lighting/Advanced-Lighting i did this ages ago and i've kinda forgotten the theory behind the formulas at this point. Sorry if my explanations are a bit dodgy. now i'm just making it longer so that the end point of the reflected line is off the screen use this formula to get the reflection vector Vec2 = vector.new(nx/(math.sqrt(num)),ny/(math.sqrt(num))) if the vector is not normalised already, then normalise it if vec2 is normalised, this will equal 1 create a vector for the reflection surface

get the difference vector between the starting point and intersection point Code: Select all -lx,ly = the starting point of the lineįunction findLaserReflectAngle(lx,ly,ix,iy, nx,ny)
