ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/sky2spectra.cal
Revision: 1.3
Committed: Fri Mar 1 00:21:54 2024 UTC (2 months, 2 weeks ago) by greg
Branch: MAIN
Changes since 1.2: +15 -4 lines
Log Message:
docs: Added example for sky vector/matrix in place of HDR image

File Contents

# Content
1 { RCSid $Id: sky2spectra.cal,v 1.2 2024/02/29 15:40:56 greg Exp $ }
2 {
3 Convert RGB sky to spectral sky using, for example:
4
5 rcomb -fc -c XYZ input_sky.hdr -f skyfact.cal -f sky2spectra.cal \
6 -c `cnt 20 | rcalc -f skyfact.cal -e 'wl=780-20*($1+.5)' \
7 -e '$1=S0(wl);$2=S1(wl);$3=S2(wl)'` \
8 | getinfo -r 'WAVELENGTH_SPLITS= 780 588 480 380' \
9 > output_sky.hsr
10
11 The above produces a 20-component output from 380 to 780 nm.
12
13 Similarly, you can convert an RGB sky vector or matrix using:
14
15 rcomb -ff -c XYZ color_sky.mtx -f skyfact.cal -f sky2spectra.cal \
16 -c `cnt 20 | rcalc -f skyfact.cal -e 'wl=780-20*($1+.5)' \
17 -e '$1=S0(wl);$2=S1(wl);$3=S2(wl)'` \
18 | getinfo -r 'WAVELENGTH_SPLITS= 780 588 480 380' \
19 > spectral_sky.mtx
20
21 by G. Ward
22 2/29/2024
23 }
24
25 in_Y = ci(1,2);
26 xyzM = 1/(ci(1,1) + in_Y + ci(1,3));
27 in_x = ci(1,1)*xyzM;
28 in_y = in_Y*xyzM;
29
30 in_M1 = M1(in_x,in_y);
31 in_M2 = M2(in_x,in_y);
32
33 co_Multiplier = in_Y / (S0normf + in_M1*S1normf + in_M2*S2normf) / 179;
34
35 co(n) = co_Multiplier * select(n, 1, in_M1, in_M2);