• Sign Up
• Login
• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Jun 24th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. state_out main( state_in s, inputs in )
2. {
3.   scalar PI = 3.1415926535897;
4.
5. # s: raster_x, raster_y, resolution_x, resolution_y, C, src, memory
6. # out: C
7. state_out out;
8.
9. vector y_axis = vector(0,1,0);
10. //new base...
11. vector portalNormal = ntransform(in.global, vector(0,0,1));
12. normalize( portalNormal );
13.
14. scalar thetaN   =   atan2(portalNormal.x ,portalNormal.z);       //-PI/2 PI/2
15. scalar phiN     =   asin(portalNormal.y) ;                       //-PI/2.0 +PI/2.0
16.
17.
18. scalar thetaP     =  (s.raster_x / s.resolution_x -0.5)*PI();      //-PI/2.0 +PI/2.0
19. scalar phiP       =  (s.raster_y / s.resolution_y -0.5)*PI();      //-PI/2.0 +PI/2.0
20.
21. scalar theta      =  thetaP + thetaN;
22. scalar phi        =  phiP + phiN;
23.
24.
25. if(theta <-PI() )
26. {
27.    theta = PI() - ((abs(theta) % (PI())));
28. }
29. if(theta > PI())
30. {
31.    theta =  -PI()  + (theta % PI());
32. }
33.
34.
35.
36. if(phi >  (PI()/2.0))
37. {
38.     phi = PI()/2.0 - (phi % (PI()/2.0));
39.     if(theta > 0.0)
40.     {
41.         theta = theta - PI();
42.     }
43.     else
44.     {
45.         theta = theta + PI();
46.     }
47. }
48. if(phi <( - PI()/2.0))
49. {
50.    phi   = -PI()/2.0 + (abs(phi) % (PI()/2.0));
51.
52.     if(theta > 0.0)
53.     {
54.         theta = theta - PI();
55.     }
56.     else
57.     {
58.         theta = theta + PI();
59.     }
60. }
61.
62.
63. vector uv = toUVfromThetaPhi( theta, phi);
64.
65. scalar _x = uv.x * width(in.out0);
66. scalar _y = uv.y * height(in.out0);
67. color pixColor = evaluate(in.out0,_x,_y);
68.
69. out.C = pixColor;
70.
71. return out;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top