Compute light frustum


I need to compute a frustum for light that contains the viewing frustum of the camera.
I try to do this :

  • compute the ndc coord to the world : points[0] = invMVP*glm::vec4(-1 ,1 , 1,1) ; for each corner of my NDC cube
  • compute an aligned axis bounding box of the corners and the light in world space
  • compute a frustum over my bounding box : glm::mat4 Lmat = glm::frustum(minX,maxX,minY,maxY,minZ,maxZ);

Is this the good way ?

I try to use it to keep triangles that can project a shadow in view frustum.