I'm writing game similar to Don't Starve using Libgdx and Box2Dlights. I have a flat-surface world with some billboarded objects on this surface. So the perspective camera is used. The angle between the normal to the screen and the normal to the surface(ground) is 45°. Some of these objects emit light to all directions (campfires). So RayHandler class is used to deal with those. The method which sets the combined matrix of the RayHandler requires the viewport width and hight. When the viewport of the perspective camera is passed to this method the rendered light disappears once its center is off the screen. What should be done to achieve the light disappearing only when it's completely off the screen(not just the center) so that the user doesn't see the moment it disappears? Thank you.
UPDATE:
Method rayHandler.setCombinedMatrix(camera);
requires OrthographicCamera. The camera I use is perspective. That's why it's impossible for me to use rayHandler.setCombinedMatrix(camera)
. The only option left for me is using setCombinedMatrix(Matrix4 combined, float x, float y, float viewPortWidth, float viewPortHeight)
. I can pass the combined matrix of the PerspectiveCamera with its position and viewport here, however it doesn't give the desired result as it still gives an incorrect viewport (probably since it doesn't consider the fact that the camera is in 3D space and is inclined).