@andylomas wrote:
I’ve been looking at the template code for the phong shader in libs/openFrameworks/gl/shaders and think I might have found a couple of bugs in phong.frag.
The raw interpollated value for v_transformedNormal is handed to the light shaders. I think the normal should be re-normalized to make sure it is truly a normalized value. Adding a line to re-nomalize it before the light loop appears to significantly reduce shading artefacts, particularly in specular highlights, if you’ve got vertex normals that are at quite different angles to each other (e.g. with a low poly count sphere).
In the light calculations the calculation of the halfVector between the light ray and eye ray appear to use a normalized version of the light ray direction but the eye direction appears to be un-normalized. I think this may be causing some effects such as biasing the halfRay, and hence the position of specular highlight, towards the eye-ray direction if the eye is a long way from the surface.
I might be missing something, but changing the code seems to create what looks to me like better shading!
Posts: 1
Participants: 1