Hello to all.

I think I've found at least a part of the reason for the spherical
mirror distortion issues, but I need the help of someone who knows
OpenGL to continue.

I've been reading through the changes introduced by Fabien when he
reworked the SMD feature. I'm working with checkouts of revisions 4190
(hereafter: "old code") and 4192 ("new code").

The re-work moves the distortion painting code from
StelViewportDistorter.hpp/.cpp to StelViewportEffect.hpp/.cpp, and
changes the point in which it is applied from global (the
StelMainGraphicsView class) to just the sky view
(StelAppGraphicsWidget). The code that calculates the distortion
itself remains unchanged.

What I noticed yesterday: the old code used a dedicated OpenGL texture
to paint the distortion
(StelViewportDistorterFisheyeToSphericMirror::mirror_texture). The new
code tries to use for the same purpose the texture of a
QGLFramebufferObject, which is a part of a swappable
foreground/background buffer mechanism. At least a part of the problem
is that the old mirror texture was a square, while the new buffers are
the same size/aspect ratio as the screen.

If you look at the old code, mirror_texture was a square with a side
determined by the texture_wh member, which is also used in the
computations in the constructor of the distorter class. It's equal to
the screen width, so I decided to try a small code change to make the
framebuffer objects square. (It's in the first attached patch.)

This had a result - the distortion seemed correct, but the distorted
image was much smaller than usual, huddling like a mushroom at the
bottom of the screen. :) After that, I tried to determine how
mirror_texture was used in the old code, and here's where I need
OpenGL expertise.

In the old ::paintViewportBuffer(), there's a call to
glCopyTexSubImage() which uses viewport size/position parameters and
viewport_texture_offset. It is omitted in the new code, presumable
because it's not needed, but I think that it's significant, because it
uses viewport_texture_offset - in the new code, that value is computed
and used in the texture coordinate transformations, but it's not used
in the distortion drawing code. Perhaps this function call is the
missing step to make the distorted image fill the screen properly?

Attached are two diffs, one for the temporary framebuffer solution,
the other the difference between the old and the new contents of the
StelViewportDistorter class (for a full diff between 4190 and 4192,
see the link above). I think that in the second diff, you can safely
assume that flag_use_ext_framebuffer_object is always false.

Regards,
Bogdan Marinov

Attachment: distorter code 4190-4192.diff
Description: Binary data

Attachment: framebuffer_change.diff
Description: Binary data

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Stellarium-pubdevel mailing list
Stellarium-pubdevel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stellarium-pubdevel

Reply via email to