According to my understanding, the fragment shader takes the result from rasterization. However, according to Computer Graphics: Principles and Practice (3rd Edition), the rasterization will calculate the fragment color based on lighting in various directions:

```
for each pixel position (x, y):
closest[x, y] = ∞
for each triangle T:
   for each pixel position (x, y):
   let R be the ray through (x, y) from the eye
   let P be the intersection of R and T
   if P exists:
      sum = 0
      for each direction:
          sum += . . .
          if the distance to P is less than closest[x, y]:
             pixel[x, y] = sum
             closest[x, y] = |P − O|

```

so the fragment color pixel[x, y] is calculated base on lightings in the scene. So, after this, the fragment shader will apply colors, textures etc. to each fragement. How the colors in fragment shader or from the texture mix with the color calculated from rasterization?