cancel
Showing results for 
Search instead for 
Did you mean: 

Distortion mesh triangle direction issues

jherico
Adventurer
So, when I was going through the code the other day I came across the section in LibOVR\Src\Util\Util_Render_Stereo.cpp that talks about how the mesh actually changes the direction in which the quads are bisected into triangles.


This way triangle edges don't span long distances over the distortion function, so linear interpolation works better & we can use fewer tris.


All well and good. As I read it, essentially the desire is to make the face the center of the distortion. However, while I was experimenting with the code today, looking to experiment with the performance differences of raw triangles vs strips, while still maintaining the space filling curve. Playing around with the code in order to understand the geometry, I decided to disable half the triangles for one of the two diagonal directions. The result was this image:



I had expected the inflection point of the triangles to be the point of intersection with the lens axis, i.e. the radial center of the distortion. Instead, the inflection point is geometric center of the mesh, counting by nodes. So nearly a third of the screen is filled with triangles that are facing the wrong way, at least for the stated goal of minimizing the distance over which the distortion value is interpolated rather than calculated.

Also, because of the way the triangles are used, the ones towards the edges end up approaching single pixel width. Wouldn't it make more sense to redistribute the vertices so that the distorted versions of the triangles all have roughly the same area in terms of pixels? I'm less clear on this point, since it would mean that towards the edge, you'd be interpolating over a larger area where the distortion scale is changing most quickly. My intuition starts to fail me when I start thinking about distortion gradients and pixels per arcsecond.
Brad Davis - Developer for High Fidelity Co-author of Oculus Rift in Action
3 REPLIES 3

tomf
Explorer
The simple answer is that the triangle grid is just a fixed-size grid positioned on the source of the distortion, rather than the screen. This is usually fine as long as the source covers roughly the same half-FOV left as it does right, and same FOV up and down. Normally this is the case (e.g. a typical DK1 half-FOV is 46 degrees inwards, 53 degrees outwards). So it's not completely centered, but it's usually close.

The puzzle in this case is why it's so far off-center. Clearly, it's because the half-FOV "outwards" is much larger than the half-FOV "inwards", but there's lots of possible reasons for that. One is that the application manually overrode it of course. Another possibility is that there's something odd going on in the automatic FOV code, because either the half-IPD or the eye-relief are wrong (or both).

In future SDKs we'd like to change the mesh so that it is centered on the destination rather than the source, and potentially also so the triangle density drops towards the edge to prevent rendering slivers.
Tom Forsyth - OculusVR coder

jherico
Adventurer
"tomf" wrote:
The puzzle in this case is why it's so far off-center.


I did notice that the undistorted versions of the images no longer place the center of the scene directly under the lens axis. I assumed that this was because was pushing more of the image to the outer edge in order to take better advantage of the resolution of the texture. It seemed like with the old mechanism, a disproportionate amount of the texture space for the inwards side of the image was being wasted because it's outside the visible area.

"tomf" wrote:
One is that the application manually overrode it of course. Another possibility is that there's something odd going on in the automatic FOV code, because either the half-IPD or the eye-relief are wrong (or both).


It's the OculusWorldDemo with only a few modifications to make it run in OpenGL on windows, so I think it's using the standard FOV (per this)

"tomf" wrote:
In future SDKs we'd like to change the mesh so that it is centered on the destination rather than the source, and potentially also so the triangle density drops towards the edge to prevent rendering slivers.


I'm not really a math guy, so forgive me if this is completely off the rails, but here's my thinking:

If you plot the distortion scaling factor as a curve, and consider the vertices to be points on that curve, then the error introduced by a given triangle doing linear interpolation instead of direct calculation is the area between the curve and the straight line drawn between the two points.

So, the calculation of the vertices should position them so that the normal to the hypotenuse of each triangle scales with the first derivative of the distortion scaling function. That way each triangle should introduce about the same amount of error over the area of the triangle, compared to doing per-pixel calculation.

The inflection vertex (the one that appears as close as possible to the lens axis, call it Vi ) should be chosen so that the derivative value is the same for both the upper left and upper right vertices (Vul & Vur): ∫ Vi->Vul == ∫ Vi->Vur

OK, I expressed that terribly. Oh well.
Brad Davis - Developer for High Fidelity Co-author of Oculus Rift in Action

brantlew
Adventurer
The C samples clamp the inner edge of the FOV to the middle of the screen to avoid large render targets. Because the lenses are quite a bit off-center on the DK1 it creates a fairly asymmetrical FOV as the outside edge extend towards the edge of the screen while the inner edge remains constant. The lens centers on the DK2 are better centered on the screen halfs and so the FOV expands symmetrically. It should reduce this effect a good bit on the DK2.
Get Help
Did this answer your question? If it didn’t, use our search to find other topics or create your own and other members of the community will help out.

Check out some popular posts here:
Getting Help from the Meta Quest Community
Tips and Tricks: Charging your Meta Quest Headset
Tips and Tricks: Help with Pairing your Meta Quest
Trouble With Facebook/Instagram Accounts?