esger.abbink_ Posted April 23, 2017 Share Posted April 23, 2017 Hi, we've ran into some issues around FoV: size is 2560x1440, specified horizontal view angle is 110 degrees, calculated unigine vertical view angle (vfov = hfov * height / width) is 61.875 degrees If I now change the size to 2560x720, but keep our horizontal view angle at 110 degrees I would expect this picture as result: However, the actual result is this: Note that the calculated unigine vertical view angle is now 30.9375 degrees (or exactly half of 61.875 as expected), but that the horizontal view angle is not in fact 110 degrees. It is less than that as the posts to the left are outside the view. I can modify the view angle to include the posts and have more or less the correct picture: However, this needs a vertical view angle of 33.46875 degrees, or 119 degrees horizontally (!). What is happening here?? We need accurate view frustum/fov results as we are using a multi-instance multiscreen setup including slightly modified blending/warping. (7 beamers to rear project all four sides of a tractor cabin) on a related side issue, it seems that setting the projection matrix directly does not update the internal unigine fov value? this means the result of getFov is invalid.. Link to comment
esger.abbink_ Posted April 23, 2017 Author Share Posted April 23, 2017 did some more digging, and I did not see that much wrong with the perspective matrix calculation so I was wondering if the frustum/viewport scaling has anything to do with it. I have disabled aspect correction in Viewport and calculate the perspective matrix as: double aspect_ratio = ((double)gui->getWidth ()) / ((double)gui->getHeight ()) ; double w = tan (deg2rad (viewPoint->fov / 2.0)) ; double h = w / aspect_ratio ; Unigine::Math::mat4 projection = Unigine::Math::frustum (-w, w, -h, h, 1.0, 1000.0) ; m_playerDummy->setProjection (projection) ; with viewPoint->fov being 110 degrees. Now the horizontal view angle is consistent among both sizes / aspect ratios: Note however that the horizontal angle is consistent for these two images, but differs from the original one(!): So seems like this one is not displaying 110 degrees either.. Link to comment
silent Posted April 24, 2017 Share Posted April 24, 2017 Hi Esger, Window aspect ratio is the part of the FOV calculations. You can either disable it via setAspectCorrection or multiply projection matrix additionally by current screen aspect ratio. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
esger.abbink_ Posted April 24, 2017 Author Share Posted April 24, 2017 Hi Silent, yes, I am aware. Which is why I disabled it. After disabling I indeed get correct and predictable results (see my second post). For us, disabling aspect correction is perfectly acceptable (I never understood the rationale behind the scaling anyway). However, the results with aspect ratio correction on do seem to be inconsistent and wrong (see first post). Unless I am wrong somewhere in my results, it is perhaps something that needs fixing that you should take a look at. Side question: we are still at 2.3 so the Render class does not yet have the getViewport call. How do I get access to the viewport (from C++)? For testing purposes I have disabled aspect correction in the engine completely, but this is of course not ideal. I would prefer to do it using the setAspectCorrection call. Link to comment
silent Posted April 24, 2017 Share Posted April 24, 2017 Hi Esger, setFOV() method initially sets the vertical FOV for the player / camera and so on, not horizontal. Maybe that will make sense? Horizontal FOV you can calculate that way: float aspect = float(engine.app.getWidth()) / engine.app.getHeight(); float hfov = vfov * aspect; Right now we don't see any issues with FOV calculations inside engine. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
esger.abbink_ Posted April 24, 2017 Author Share Posted April 24, 2017 Hi Silent, yes, I know unigine expects the fov to be the vertical one, we calculate the vertical fov from the horizontal fov. However, there does seem to be something amiss here. image size 2560x1440, vertical fov set to 61.875: image size 2560x720, vertical fov set to 30.9375 (or exactly half of 61.875): Notice that the horizontal angle should remain identical for these two cases. However, it is not, as is clearly visible by the missing fences in the second picture. Unless I am missing something, this is wrong. The second picture should look like this: And as already mentioned in an earlier post, disabling aspect ratio correction produces yet another horizontal angle for the same values: I believe this one to actually be the correct one. Meaning that both aspect ratio corrected ones are wrong. Any way to get access to the Viewport in C++ API in 2.3 version? Link to comment
silent Posted April 24, 2017 Share Posted April 24, 2017 Hi Esger, Sure, just use UnigineViewport.h and you will get access to it via C++: https://developer.unigine.com/en/docs/2.3/api/library/rendering/class.viewport How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
esger.abbink_ Posted April 25, 2017 Author Share Posted April 25, 2017 Hi Silent, the Viewport class does not provide a ::get () or something similar, the Render class has ::getViewport in 2.3.1, but we're still on 2.3. How do I get hold of a ViewportPtr in 2.3? Link to comment
silent Posted April 26, 2017 Share Posted April 26, 2017 Hi Esger, I'm afraid you will have to upgrade you project to 2.3.1 or modify that parameters via UnigineScript. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
esger.abbink_ Posted April 27, 2017 Author Share Posted April 27, 2017 Hi Silent, that was what I suspected. At the moment it is not feasible to upgrade to unigine 2.3.1 in this stage of the project. Will do so later this year. Then we'll leave the aspect correction completely disabled for now. Link to comment
silent Posted April 27, 2017 Share Posted April 27, 2017 Hi Esger, There is nothing wrong with keeping the aspect correction disabled if it fit your needs and you get the desired results :) How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts