Custom GLSL: fresnel glow based on view position not working

I’m trying to make a custom fresnel effect in GLSL. It works for the straight-on angle, but it doesn’t stick to the edge of the object when I rotate the view:

The GLSL uses the a dot product of the view position and the normal, basically:

void main() {
    vec3 normal = normalize(fNormal);
    vec3 eye = normalize(;
    float rim = smoothstep(start, end, 1.0 - dot(normal, eye));
    float amount = clamp(rim, 0.0, 1.0) * alpha;
    gl_FragColor = vec4( vec3(amount), 1.0 );

I can’t figure out why rotating the camera doesn’t update the effect. I’ve confirmed that both the view position varying and the normal varying are up to date in the fragment shader.

You can debug this issue and modify the code by:

You can also see the related vertex GLSL by selecting “Outline (vertex)”.

I can’t figure out if either my math is wrong, or if PlayCanvas is optimizing away something (like the view matrix in the vertex shader?) and not updating it every frame. The fact that the effect works “head on” but not rotates make me think some uniform isn’t getting updated, but I’m just guessing.