Ren'Py panorama distortion

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,268
22,315
I stumbled over xpan and ypan today and tested a bit, it's a nice feature, but sadly most panoramas are spherical, or cylindrical, which means they are distorted. I did some test render in Daz and they are the same with no option to render without distortion.
So my question is basically: Is there a way to counter these distortions in renpy? I thought I've seen some spherical transform some time ago, but I can't find it. Is there such a thing, or am I mixing things up here?
How would one approach a spherical image in renpy, if even possible?

Just asking out of curiosity btw, so don't bang your head too hard over it^^
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,302
15,172
So my question is basically: Is there a way to counter these distortions in renpy? I thought I've seen some spherical transform some time ago, but I can't find it. Is there such a thing, or am I mixing things up here?
I don't think that there's a spherical transform, but even if there were, could it be really used to counter the distortions generated by DAZ ?
There's two problems here. Firstly you need to find the exact opposite of the distortion used by DAZ. Secondly you'll end with missing data here and there, not a big amount, but they'll exist and can't be really interpolated ; at least not goodly enough to not look weird.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,268
22,315
There's two problems here. Firstly you need to find the exact opposite of the distortion used by DAZ. Secondly you'll end with missing data here and there, not a big amount, but they'll exist and can't be really interpolated ; at least not goodly enough to not look weird.
I'm not a mathmatical genius, but I know these distortions in panoramas are all based on the same principle. A spherical distortion always uses the same "grid". Here is an example:
26363697850_53505495a2_o.png

The same ares get distorted/compressed/stretched, the only problem is that different images have different proportions, but the formula still applys:
360_test_ex.jpg
So basically all you need is the center point and one should be able to calculate, erm... something... and obviously a bigger brain than I have xD

The easier way would obviously be to find a way to render flat panormas in Daz^^
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,302
15,172
I'm not a mathmatical genius, but I know these distortions in panoramas are all based on the same principle. A spherical distortion always uses the same "grid".
My math are far behind me, but as far as I remember, curves don't go well with flat result.

Here it's just a question of perspective. The further you are from the center, the bigger the image will be, or the smaller, it depend if you curve to the outside or to the inside.
If it lead to a bigger image, extra pixels will be added in the middle, while the image will be cropped into a rectangle. And if it lead to a smaller image, pixels will be removed from the middle, while some will be added on the top and bottom, to fill the rectangle.

At creation time it's not a problem, the original model is here to help you know what color should have those pixels. But once you've the curved image it's to late, you've already lost those information and will have to guess them.

Either the curve lead to a bigger image on the side, and when you'll apply the opposite distortion, you'll have blank (well, black here) spaces on top and bottom sides :
less.png

Or it will lead to a smaller image on the sides, and it's in the middle that you'll have blank (still black) spaces :
more.png
Note: I used straight lines, but they are obviously curved since the original distortion use curves. It's just that I suck at drawing :D


The easier way would obviously be to find a way to render flat panormas in Daz^^
Easier and only effective possibility, alas.
 

Saki_Sliz

Well-Known Member
May 3, 2018
1,403
1,004
That is called equal rectangular projection mapping, the images of the room. If you zoom in close enough (such as narrow cone of vision we have), a scene can look like you are panning around (at least from my testing). You could also uv wrap the image to a sphere, and stick a camera inside, and it would work, but as for actually transforming the image in 2D in real time, I have found some example code and what not, but I can't understand it enough to translate it into something else (been coding nearly 15 years). the main issue is that the transformation can not be done to just the image alone with some systems, but I only really glanced at things.