ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/lib/picture.cal
Revision: 1.1
Committed: Wed Mar 12 17:45:48 2003 UTC (21 years, 2 months ago) by greg
Branch: MAIN
Log Message:
Added the rest of the missing files to ray/lib/

File Contents

# User Rev Content
1 greg 1.1 {
2     Calculation of 2d picture coordinates.
3     Picture is projected onto xy plane with lower left corner at origin.
4    
5     A1 - Ratio of height to width for tiles.
6     A2 - Average red value for fadered or grey for fadegrey
7     A3 - Average green value for fadegreen
8     A4 - Average blue value for fadeblue
9     A2, A3, A4 - Chroma key color for mixpict
10     }
11     { straight coordinates }
12     pic_u = Px;
13     pic_v = Py;
14     { picture aspect ratio }
15     pic_aspect = if(arg(0)-.5, arg(1), 1);
16     { compute borders for mixture }
17     inpic = if(and(pic_u, and(pic_v,
18     if(pic_aspect-1, and(1-pic_u,pic_aspect-pic_v),
19     and(1/pic_aspect-pic_u,1-pic_v) ) ) ), 1, 0);
20     { chroma-key mixing }
21     chroma_sum`P = A2 + A3 + A4;
22     chroma_tol`P = 0.02 * chroma_sum`P;
23     intol`P(a,b) : and(a-b+chroma_tol`P, b-a+chroma_tol`P);
24     ischroma`P(r,g,s) = if(FTINY-chroma_sum`P, .001-s,
25     if(.001-s, -1,
26     and(intol`P(r*chroma_sum`P,A2*s),intol`P(g*chroma_sum`P,A3*s))
27     ) );
28     infore(r,g,b) = if(inpic-.5, if(ischroma`P(r,g,r+g+b), 0, 1), 0);
29     { standard tiling }
30     tile_u = mod(pic_u,max(1,1/pic_aspect));
31     tile_v = mod(pic_v,max(1,pic_aspect));
32     { tiling with inversion matching }
33     match_u = tri(pic_u,max(1,1/pic_aspect));
34     match_v = tri(pic_v,max(1,pic_aspect));
35     { brick-type staggering }
36     stag_u = if(pic_aspect-1,
37     frac(if(frac(pic_v/pic_aspect/2)-.5,pic_u,pic_u+.5)),
38     mod(if(frac(pic_v/2)-.5,pic_u,pic_u+.5/pic_aspect),
39     1/pic_aspect));
40     stag_v = tile_v;
41     { fade colors for distant viewing }
42     fadered(r,g,b) = fade(r, A2, T*.1);
43     fadegreen(r,g,b) = fade(g, A3, T*.1);
44     fadeblue(r,g,b) = fade(b, A4, T*.1);
45     fadegrey(r,g,b) = fade(grey(r,g,b), A2, T*.1);