1 |
{ RCSid $Id$ } |
2 |
{ |
3 |
Synthesize light probe using Spherical Harmonic coefficients |
4 |
|
5 |
2/16/2005 G. Ward |
6 |
|
7 |
Constants: |
8 |
map - light probe mapping (1=angular, 2=mirror) |
9 |
rcoef(i) - red coefficient array |
10 |
gcoef(i) - green coefficient array |
11 |
bcoef(i) - blue coefficient array |
12 |
Usage: |
13 |
pcomb -x 640 -y 640 -e 'map:1' -f spharm.cal -f genSH.cal \ |
14 |
-f coef.cal > probe.pic |
15 |
} |
16 |
map : 1; { just angular for now } |
17 |
|
18 |
h = 1/xres*x - .5; |
19 |
v = 1/yres*y - .5; |
20 |
|
21 |
beta_ang = 2*PI*sqrt(h*h + v*v); |
22 |
gamma_ang = atan2(v, h); |
23 |
sine_beta_ang = sin(beta_ang); |
24 |
Dx_ang = cos(beta_ang); |
25 |
Dy_ang = cos(gamma_ang)*sine_beta_ang; |
26 |
Dz_ang = sin(gamma_ang)*sine_beta_ang; |
27 |
theta_ang = acos(Dz_ang); |
28 |
phi_ang = atan2(Dy_ang, Dx_ang); |
29 |
|
30 |
cond = select(map, PI-1e-4-beta_ang); |
31 |
theta = select(map, theta_ang); |
32 |
phi = select(map, phi_ang); |
33 |
|
34 |
ro = if(cond, SphericalHarmonicF(rcoef,theta_ang,phi_ang), 0); |
35 |
go = if(cond, SphericalHarmonicF(gcoef,theta_ang,phi_ang), 0); |
36 |
bo = if(cond, SphericalHarmonicF(bcoef,theta_ang,phi_ang), 0); |
37 |
|
38 |
{ Uncomment for luminance only } |
39 |
{ |
40 |
lo = if(cond, SphericalHarmonicF(lcoef,theta_ang,phi_ang), 0); |
41 |
} |