hokwang Posted August 24, 2022 Share Posted August 24, 2022 Hi, I hope it's a correct place to ask questions. I am experimenting setProjection() and setFov() methods of Player/Camera to see the changes. I found the following behavior and I am a bit confused how I can use the methods correctly. - setFov() changes FoV and the camera projection matrix <= expected. - setProjection() changes only the camera projection matrix but not FoV <= unexpected. Below is my code and output prints. Code: // setFov method Unigine::Log::message("\nPrevious fov: %f", player->getFov()); Unigine::Log::message("\nPrevious proj [0, 0]: %f", player->getProjection().get(0, 0)); Unigine::Log::message("\nPrevious proj [1, 1]: %f", player->getProjection().get(1, 1)); player->setFov(64.2604); Unigine::Log::message("\nCurrent fov: %f", player->getFov()); Unigine::Log::message("\nCurrent proj [0, 0]: %f", player->getProjection().get(0, 0)); Unigine::Log::message("\nCurrent proj [1, 1]: %f", player->getProjection().get(1, 1)); player->setFov(60); // setProjection method Unigine::Log::message("\nPrevious fov: %f", player->getFov()); Unigine::Math::mat4 prevProj = player->getProjection(); Unigine::Log::message("\nPrevious proj [0, 0]: %f", prevProj.get(0, 0)); Unigine::Log::message("\nPrevious proj [1, 1]: %f", prevProj.get(1, 1)); prevProj.get(0, 0) = 1.592272; prevProj.get(1, 1) = 1.592272; player->setProjection(prevProj); Unigine::Log::message("\nCurrent fov: %f", player->getFov()); Unigine::Log::message("\nCurrent proj [0, 0]: %f", player->getProjection().get(0, 0)); Unigine::Log::message("\nCurrent proj [1, 1]: %f", player->getProjection().get(1, 1)); Prints: Previous fov: 60.000000 Previous proj [0, 0]: 1.732051 Previous proj [1, 1]: 1.732051 Current fov: 64.260399 Current proj [0, 0]: 1.592272 Current proj [1, 1]: 1.592272 Previous fov: 60.000000 Previous proj [0, 0]: 1.732051 Previous proj [1, 1]: 1.732051 Current fov: 60.000000 Current proj [0, 0]: 1.592272 Current proj [1, 1]: 1.592272 Thanks! Link to comment
cash-metall Posted August 25, 2022 Share Posted August 25, 2022 Yes you are right. It can be confusing, but it makes sense: Changing fov/znear/zfar modificate projection matrix. But if you set your own projection matrix - getFov method is useless, because you can configurate matrix without fov (orthografic for example or some more specific) the same sitation if you use physical-base fov mode with film_gate and focal_lenght - getFov will return another previous value. Notice: if you do setFov it will force the projection matrix to be recalculated. Perhaps it requires refactoring to avoid such misunderstandings... but for now, only the getFov setFov methods can be completely removed from the proposals, which will complicate the work and understanding of the camera. 1 Link to comment
hokwang Posted August 25, 2022 Author Share Posted August 25, 2022 Right, thank you for the explanation. I understood that there must be cases that you cannot get the FOV out of projection matrix. Then, here is my following question. How does the rendering change with the updated camera projection matrix? Same as examples above, Changing the Fov with setFov() - do change the rendered image given resolution. Changing the projection matrix with setProjection() - does not change the rendered image (it stays the same fov which is not updated by projection matrix as you explained). My intent is to change the rendered image by setting projection matrix. Simply put, I want to render only the Region of Interest to save rendering time instead of rendering the full image and crop it. Link to comment
Recommended Posts