Not tested but give it a shot :
in vertex shader add :
out vec3 eye;
Find :
vec4 modelvertexposition = entitymatrix_ * vec4(vertex_position,1.0);
After add :
eye = normalize( modelvertexposition.xyz - cameraposition );
In fragment shader :
Add :
in vec3 eye;
after all normal calculations add :
//calculate rim
float NormalToCam = 1.0 - abs(dot(eye*cameranormalmatrix,normal));
float rim = smoothstep(0.0, 1.0, NormalToCam); //adjust here for rim thickness
Find :
fragData0 = ...
After add :
fragData0+=vec4(rim,rim,rim,0);