Fighting with the projectionMatrix again…
In short I’m working on some billboard impostors. I’ve managed to create the desired frustum I want for my billboard rendering camera but translating it to a matrix is not working out so well.
See attached image for reference → The cyan-colored lines show the frustum, the numbers 0-7 are the positions for each of those corners. They’re stored in billboardVerts (Vector3[8]). My main camera and billboard rendering camera have the same position and rotation. A is the result of my projectionMatrix attempt (code below).
I’ve looked at the function PerspectiveOffCenter from the examples in the docs, and also glFrustum which looks like the exact same function.
First attempts were way off but I got close with this: (check image for position indexes)
PerspectiveOffCenter(billboardVerts[0].x,billboardVerts[1].x,billboardVerts[0].y,billboardVerts[3].y,(BBCenter[0] - mainCam.transform.position).magnitude,(BBCenter[1] - mainCam.transform.position).magnitude);
BBcenter[0] is the center of the near frustum plane (white in image), and BBcenter[0] the center of the far one.
Can’t seem to get my head around it so any help is greatly appreciated.
thanks,
Patrik