Hi. This question is about calculating the normal of a vertex in GLSL (after I have moved the given vertex). For reference, I am posting the sample code from the OpenGL Shading Language 2nd Edition book, from Ch 16.6, Listing: 16.3.
My questions are:

I need to recalculate the normal after modifying the vertex position, right? (Assume that I have a cube and the vertices get moved +noise.xyz. Then I believe that the given normals for each vertex will be incorrect and need to be recalculated.) If I’m wrong, please tell me why. If I’m correct, can someone please point to a simple example, calculation, or GLSL function to calculate the new normal? (Note: assume I can calculate the position of neighboring vertices.)

If I need to recalculate the vertexnormal (question 1 above), then should I store the normal in gl_Normal or somewhere else? I thought the vertexnormal was to be used in some fixedfunction pipeline calculations for interpolation… (but I might be confused with bump map/texture normal interpolations in the fixedfunction pipeline).
Code from book:
uniform vec3 LightPosition;
uniform vec3 SurfaceColor;
uniform vec3 Offset;
uniform float ScaleIn;
uniform float ScaleOut;
varying vec4 Color;
void main()
{
vec3 normal = gl_Normal;
vec3 vertex = gl_Vertex.xyz +
noise3(Offset + gl_Vertex.xyz * ScaleIn) * ScaleOut;
// Posting question 1: this normal I think is wrong, dont we need to recalculate first?
normal = normalize(gl_NormalMatrix * normal);
vec3 position = vec3(gl_ModelViewMatrix * vec4(vertex,1.0));
vec3 lightVec = normalize(LightPosition  position);
float diffuse = max(dot(lightVec, normal), 0.0);
if (diffuse < 0.125)
diffuse = 0.125;
Color = vec4(SurfaceColor * diffuse, 1.0);
// Posting question 2: dont we need to save the new vertex normal for future calculations
gl_Position = gl_ModelViewProjectionMatrix * vec4(vertex,1.0);
}
Thanks.