   float pointSpecularFactor = pow(max(0.0, dot(fragmentToCamera, pointLightReflect)), materialSpecularFactor);
   vec4 pointSpecularColor = pointLight.specularIntensity * vec4(pointLight.color, 1) * materialSpecularIntensity * pointSpecularFactor / pointLightDistance2;
 
-  vec4 pointColor = pointAmbientColor + pointDiffuseColor + pointSpecularColor;
+  return pointAmbientColor + pointDiffuseColor + pointSpecularColor;
+}
 
-  // spot light TODO: make procedure
-
+vec4 calcSpotLight(vec3 normal, vec3 fragmentToCamera) {
   vec3 spotLightDirection = normalize(fragmentPos - spotLight.position);
   float spotAngleCos = dot(spotLightDirection, spotLight.direction);
   float spotFactor = float(spotAngleCos > spotLight.cutoff) *(1.0 - 1.0*(1.0 - spotAngleCos) / (1.0 - spotLight.cutoff));

  float spotSpecularFactor = pow(max(0.0, dot(fragmentToCamera, spotLightReflect)), materialSpecularFactor);
  vec4 spotSpecularColor = spotLight.specularIntensity * vec4(spotLight.color, 1) * materialSpecularIntensity * spotSpecularFactor / spotLightDistance2;

  vec4 spotColor = spotFactor*(spotAmbientColor + spotDiffuseColor + spotSpecularColor);

  vec4 temp = texture(textureSampler, fragmentUV) * (directColor + pointColor + spotColor);
  color = pow(temp, gamma);
}

out vec4 color;

vec4 calcDirectionalLight(vec3 normal, vec3 fragmentToCamera) {
  vec4 directAmbientColor = vec4(directionalLight.color, 1) * directionalLight.ambientIntensity;

  float directDiffuseFactor = max(0.0, dot(normal, -directionalLight.direction));
