21 float tanFovHalf = tan(fov / 2.0f);
23 float nearHeight = 2.0f * tanFovHalf * zNear;
24 float nearWidth = nearHeight * aspectRatio;
25 float farHeight = 2.0f * tanFovHalf * zFar;
26 float farWidth = farHeight * aspectRatio;
28 glm::vec3 nearCenter = position + front * zNear;
29 glm::vec3 farCenter = position + front * zFar;
31 const glm::vec3 nearTopLeft = nearCenter + up * (nearHeight * 0.5f) - right * (nearWidth * 0.5f);
32 const glm::vec3 nearTopRight = nearCenter + up * (nearHeight * 0.5f) + right * (nearWidth * 0.5f);
33 const glm::vec3 nearBottomLeft = nearCenter - up * (nearHeight * 0.5f) - right * (nearWidth * 0.5f);
34 const glm::vec3 nearBottomRight = nearCenter - up * (nearHeight * 0.5f) + right * (nearWidth * 0.5f);
36 const glm::vec3 farTopLeft = farCenter + up * (farHeight * 0.5f) - right * (farWidth * 0.5f);
37 const glm::vec3 farTopRight = farCenter + up * (farHeight * 0.5f) + right * (farWidth * 0.5f);
38 const glm::vec3 farBottomLeft = farCenter - up * (farHeight * 0.5f) - right * (farWidth * 0.5f);
39 const glm::vec3 farBottomRight = farCenter - up * (farHeight * 0.5f) + right * (farWidth * 0.5f);