Talk:Cg Programming/Unity/Specular Highlights

In the code calculating specularReflection, there's no need in if-else statement. Negative values are already clamped using max.

Even more: current if-else causes wrong clamping. I.e. there could easily be the case where normal is pointing to the opposite side than light, but it should still produce specular highlight. E.g., for the point on the ball's edge (where normal is almost perpendicular to the viewing vector) and the "rim" light source (located behind the ball and aimed towards the camera). —Preceding unsigned comment added by 46.147.184.35 (discuss) 09:49, 21 November 2013‎


 * The if-condition is different from the max function. If the light is on the opposite side of the normal, the light will usually be blocked by the object such that it cannot reach the point and therefore cannot be reflected and therefore there shouldn't be a specular highlight. Of course, if one assumes a rough surface things can be different. --Martin Kraus (discuss • contribs) 09:42, 26 November 2013 (UTC)