-
Notifications
You must be signed in to change notification settings - Fork 1
/
2d360.cal
37 lines (29 loc) · 1.03 KB
/
2d360.cal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{
2d360.cal
Definitions for full 360 equirectangular projection
Originally based on 3d360.cal (c)2014 Mark J. Stock
Modified 2018 Dion Moult for a mono instead of a stereo image
Use it like this:
X=2048; Y=1024; cnt $Y $X | rcalc -f 2d360.cal -e "XD=$X;YD=$Y;X=0;Y=0;Z=0" | rtrace [rpict options] -x $X -y $Y -fac scene.oct > out.hdr
Parameters defined externally:
X : -vp X coordinate
Y : -vp Y coordinate
Z : -vp Z coordinate
XD : horizontal picture dimension ( pixels )
YD : vertical picture dimension ( pixels )
}
{ Direction of the current pixel (both angles in radians) }
px = XD - $2;
py = YD - $1;
frac(x) : x - floor(x);
altitude = (frac((py-0.5)/(YD)) - 0.5) * PI;
{ to do over-under stereo, azimuth is easy }
azimut = px * 2 * PI / XD;
{ Transformation into a direction vector }
xdir = cos(azimut) * cos(altitude);
ydir = sin(azimut) * cos(altitude);
zdir = sin(altitude);
{ Output line to rtrace; each ray needs: xorg yorg zorg xdir ydir zdir }
$1 = X; $2 = Y; $3 = Z;
$4 = xdir; $5 = ydir; $6 = zdir;
{ EOF }