ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/genSH.cal
Revision: 1.1
Committed: Wed Feb 16 15:51:45 2005 UTC (19 years, 2 months ago) by greg
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad3R7P2, rad3R7P1, rad4R2, rad4R1, rad4R0, rad3R8, rad3R9, rad4R2P1, rad5R3, HEAD
Log Message:
Added fitting and synthesis modules for Spherical Harmonics

File Contents

# User Rev Content
1 greg 1.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     }