3
\$\begingroup\$

In most 3D renderings, a view frustum is used.
This has the problem, that things get stretched out towards the edges.
At "normal" fov (field of view) of about 60 degrees, the effect is not very noticeable, unless compared side by side (example) but at a higher fov of something like 120 degrees it's really noticeable by making things near the edge look way larger/closer (example).
A fov of anything near or over 180 degrees breaks the rendering completely.

So far, I couldn't find anything on how to render in such a way that fixes this or even how it's called.

The ultimate goal would be to be able to render up to 360 degrees (ignoring the hardware needed, to display it) without any distortion, relative to other parts of the image.

So, how would I approach rendering that? Is there already some open source software, I can take a look at?

\$\endgroup\$
  • 2
    \$\begingroup\$ This is usually done by rendering one or more views with conventional linear perspective, then applying an image effect to re-project the image(s) into an alternative form. See for example Unreal's implementation of the Panini Projection \$\endgroup\$ – DMGregory Jun 20 at 16:04
  • 1
    \$\begingroup\$ Regarding "without any distortion" - we can't quite meet that goal while "ignoring the hardware needed to display it". The effects you describe as distortion in the linear perspective case are actually the image correctly adapting to the surface on which it's displayed: the enlarging of features near the edges of the screen exactly corrects for the foreshortening we see when looking at a flat screen obliquely, from the intended viewpoint of the projection - like an anamorphic drawing. So eliminating distortion means considering the hardware. \$\endgroup\$ – DMGregory Jun 20 at 16:08
  • \$\begingroup\$ @DMGregory I don't think we tend to render games at anywhere near the correct FOV for this explanation to work. I reckon my screen right now is taking up about 45 degrees horizontally and 25 degrees vertically. Imagine playing a game at that FOV! You couldn't see anything! Since it's not going to be physically accurate anyway, we may as well choose something that looks good. \$\endgroup\$ – user253751 Jun 23 at 20:29
  • \$\begingroup\$ In reality, you would probably implement this by rendering a frustum like normal - perhaps multiple frustums - and then distorting it with a postprocessing shader. \$\endgroup\$ – user253751 Jun 23 at 20:31
1
\$\begingroup\$

There are many ways to project sphere to rectangle, as you can see in this video. Basic idea is simple:

  1. Build screen-sized lookup texture that maps screen coordinates to cube map coordinates, according to selected projection function (and it's parameters). Needs to be done once.
  2. Render scene to a cube map.
  3. Using a fragment shader, combine the two to project a cube map on a screen.

Problem is, this approach is going to cause massive performance toll and quality degradation, because pixel density is not going to match 1:1 between projection source and destination. (Unless you are willing to render cube map at higher resolutions to guarantee at least 1:1 density, which will cause even bigger performance impact.)

I don't see a way to do this transform at earlier stages of rendering, because GPU hardware depends on straight lines being straight, but all "interesting" projections break this guarantee. Essentially GPU can't render triangle with bent edges.

If alternate projections seem too fancy and you'd rather stick with perspective, then straight cube map method (as mentioned in other answer) should work, I just wanted to elaborate on it a little: all you need to do is to render scene to cube map (except 1 face that is never visible), then render it as unlit cube around camera. It's still susceptible to quality issues I mentioned earlier.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

This is actually a solved problem from shadowmapping point lights; you do multiple renderings instead of just a single rendering. So you can think of a render-to-cubemap as rendering with both horizontal and vertical FOV of 360 degrees, for example.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.