The normal is the same as the vertex position, but without the scale factor of r.
Texture coordinates can be defined however you like. It’s not uncommon to just use phi and theta (each mapped to the 0…1 range) as texture coordinates (that results in an equidistant cylindrical aka Plate Carée projection). The main problem is that any such mapping won’t be affine, meaning that you get some amount of distortion when approximating a sphere by a triangle mesh unless you use shaders to create a non-linear mapping.
Thank you so much again. But I still have question. For 2D texture, coordinate will range from (0,0) to (1,1), Why is it not the same for 3D texture, i.e. (0,0,0) to (1,1,1).
2D texture maps have the origin (0,0) at one corner of the image. Cube maps have the origin at the centre of the cube (the calculations are simpler that way).
Given (x,y,z) texture coordinates, a cube map lookup first determines which of the three components (x, y or z) has the largest absolute value, and its sign (positive or negative). The results determine which of the six faces are used.
Each of the two smaller components are divided by the absolute value of the larger component to generate s and t coordinates. Because the numerators are no larger than the denominator, the resulting s and t coordinates will always be between -1 and +1. These are then offset and scaled (s’=(s+1)/2, t’=(t+1)/2) to map them from -1…+1 to 0…1, producing 2D texture coordinates within the selected face.
E.g. if the z component is the largest, and is positive, then the +Z face would be selected and the texture coordinates are s’=(x/|z|+1)/2 and t’=(-y/|z|+1)/2.
(The choice of which component is used for s and which is used for t is somewhat arbitrary, as are their signs. For the +Z face, s=+x, t=-y. Table 8.19 in the 4.5 specification has the details).