1 | From levoy@blueridge Fri Nov 6 17:30:29 1992 |
---|
2 | Received: from blueridge.stanford.edu by redclay.stanford.edu (920330.SGI/inc-1.0) |
---|
3 | id AA20730; Fri, 6 Nov 92 17:30:29 -0800 |
---|
4 | Received: by blueridge (920330.SGI/inc-1.0) |
---|
5 | id AA10004; Fri, 6 Nov 92 17:23:44 -0800 |
---|
6 | Date: Fri, 6 Nov 92 17:23:44 -0800 |
---|
7 | From: levoy@blueridge.stanford.edu (Marc Levoy) |
---|
8 | Message-Id: <9211070123.AA10004@blueridge> |
---|
9 | To: turk@redclay.stanford.edu |
---|
10 | Subject: My .opc file format |
---|
11 | Status: RO |
---|
12 | |
---|
13 | NM = 3 |
---|
14 | PIXEL is unsigned char |
---|
15 | Shorts and longs are VAX byte ordering! |
---|
16 | You can use my ~levoy/libs/file.c if you don't want to swap them yourself. |
---|
17 | To convert a .shd file into .opc: |
---|
18 | |
---|
19 | run my den program and type: |
---|
20 | shd |
---|
21 | load |
---|
22 | myfile (.shd is assumed) |
---|
23 | sopc |
---|
24 | myfile (.opc is assumed) |
---|
25 | return |
---|
26 | quit |
---|
27 | |
---|
28 | I have the comb currently in cyb.shd in /kittyhawk/usr/voldata/cyb/test |
---|
29 | I have various versions of the blocks from splatted mesh points in blocks*.shd |
---|
30 | in /kittyhawk/usr/voldata/cyb/custom |
---|
31 | |
---|
32 | If you want to read my .den files, which don't require a shading step, |
---|
33 | I also enclose the format of those files. |
---|
34 | |
---|
35 | |
---|
36 | /********** opacity - 3-d opacity map **********/ |
---|
37 | |
---|
38 | /* Copyright 1990 by Marc Levoy - all rights reserved */ |
---|
39 | |
---|
40 | /* The following declarations show the layout of the .opc file. */ |
---|
41 | /* If changed, the version number must be incremented and code */ |
---|
42 | /* written to handle loading of both old and current versions. */ |
---|
43 | |
---|
44 | /* Version for new .opc files: */ |
---|
45 | #define OPC_CUR_VERSION 1 /* Initial release */ |
---|
46 | short opc_version; /* Version of this .opc file */ |
---|
47 | |
---|
48 | short opc_len[NM]; /* Size of this opacity map */ |
---|
49 | |
---|
50 | long opc_length; /* Total number of opacities in map */ |
---|
51 | /* (= product of lens) */ |
---|
52 | PIXEL *opc_address; /* Pointer to opacity map */ |
---|
53 | |
---|
54 | /* End of layout of .opc file. */ |
---|
55 | |
---|
56 | /* Subscripted access to opacity map */ |
---|
57 | /* (1 char at each IX,IY,IZ) */ |
---|
58 | #define OPC_ADDRESS(IZ,IY,IX) (opc_address+\ |
---|
59 | ((IZ)*opc_len[Y]+(IY))*opc_len[X]+(IX)) |
---|
60 | #define OPC(IZ,IY,IX) (*OPC_ADDRESS(IZ,IY,IX)) |
---|
61 | |
---|
62 | short out_opc_len[NM]; /* Size of output opacity map */ |
---|
63 | long out_opc_length; /* Total number of opacities in map */ |
---|
64 | PIXEL *out_opc_address; /* Pointer to map */ |
---|
65 | |
---|
66 | /* Subscripted access to output map */ |
---|
67 | #define OUT_OPC_ADDRESS(IZ,IY,IX) \ |
---|
68 | (out_opc_address+\ |
---|
69 | ((IZ)*out_opc_len[Y]+\ |
---|
70 | (IY))*out_opc_len[X]+\ |
---|
71 | (IX)) |
---|
72 | #define OUT_OPC(IZ,IY,IX) (*OUT_OPC_ADDRESS(IZ,IY,IX)) |
---|
73 | |
---|
74 | short acc_opc_len[NM]; /* Size of 3-d opacity accumulator */ |
---|
75 | long acc_opc_length; /* Total number of opacities */ |
---|
76 | WPIXELSUM *acc_opc_address; /* Pointer to accumulator */ |
---|
77 | |
---|
78 | /* Subscripted access to accumulator */ |
---|
79 | #define ACC_OPC_ADDRESS(IZ,IY,IX) \ |
---|
80 | (acc_opc_address+\ |
---|
81 | ((IZ)*acc_opc_len[Y]+\ |
---|
82 | (IY))*acc_opc_len[X]+\ |
---|
83 | (IX)) |
---|
84 | #define ACC_OPC(IZ,IY,IX) (*ACC_OPC_ADDRESS(IZ,IY,IX)) |
---|
85 | |
---|
86 | BOOLEAN opc_histogram_exists; /* True if histogram exists */ |
---|
87 | long opacity_histogram[MAX_PIXEL+1]; /* Histogram of opacity map */ |
---|
88 | |
---|
89 | short light_len[NM]; /* Size of light strength map */ |
---|
90 | long light_length; /* Total number of strengths in map */ |
---|
91 | PIXEL *light_address; /* Pointer to map */ |
---|
92 | |
---|
93 | /* Subscripted access to light strength map */ |
---|
94 | #define LIGHT_ADDRESS(IZ,IY,IX) \ |
---|
95 | (light_address+\ |
---|
96 | ((IZ)*light_len[Y]+\ |
---|
97 | (IY))*light_len[X]+\ |
---|
98 | (IX)) |
---|
99 | #define LIGHT(IZ,IY,IX) (*LIGHT_ADDRESS(IZ,IY,IX)) |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | ------------------------------------------------------- |
---|
104 | |
---|
105 | |
---|
106 | |
---|
107 | |
---|
108 | Ignore orig and extr lens, just look at map_len[NM]. |
---|
109 | DENSITY is unsigned char. |
---|
110 | |
---|
111 | |
---|
112 | /********** map - 3-d density map **********/ |
---|
113 | |
---|
114 | /* Copyright 1990 by Marc Levoy - all rights reserved */ |
---|
115 | |
---|
116 | /* The following declarations show the layout of the .den file. */ |
---|
117 | /* If changed, the version number must be incremented and code */ |
---|
118 | /* written to handle loading of both old and current versions. */ |
---|
119 | |
---|
120 | /* Version for new .den files: */ |
---|
121 | #define MAP_CUR_VERSION 1 /* Initial release */ |
---|
122 | short map_version; /* Version of this .den file */ |
---|
123 | |
---|
124 | short orig_min[NM], /* Dimensions of original data file */ |
---|
125 | orig_max[NM], /* (CT: from <file>.header file */ |
---|
126 | orig_len[NM]; /* ED: from <file>.mi file) */ |
---|
127 | |
---|
128 | short extr_min[NM], /* Portion of file extracted for this map */ |
---|
129 | extr_max[NM], /* (mins and maxes will be subset of */ |
---|
130 | extr_len[NM]; /* orig and lengths will be <= orig) */ |
---|
131 | |
---|
132 | short map_min[NM], /* Dimensions of this map */ |
---|
133 | map_max[NM], /* (mins will be 0 in this program and */ |
---|
134 | map_len[NM]; /* lens may be != extr if warps > 0) */ |
---|
135 | |
---|
136 | short map_warps; /* Number of warps since extraction */ |
---|
137 | /* (0 = none) */ |
---|
138 | |
---|
139 | long map_length; /* Total number of densities in map */ |
---|
140 | /* (= product of lens) */ |
---|
141 | DENSITY *map_address; /* Pointer to map */ |
---|
142 | |
---|
143 | /* End of layout of .den file. */ |
---|
144 | |
---|
145 | /* Slow subscripted access to map */ |
---|
146 | /* (assumes nothing about mins or sizeof) */ |
---|
147 | #define SLOW_MAP_ADDRESS(IZ,IY,IX) \ |
---|
148 | (map_address+\ |
---|
149 | ((((IZ)-map_min[Z])*map_len[Y]+\ |
---|
150 | ((IY)-map_min[Y]))*map_len[X]+\ |
---|
151 | ((IX)-map_min[X]))*\ |
---|
152 | sizeof(DENSITY)) |
---|
153 | #define SLOW_MAP(IZ,IY,IX) (*SLOW_MAP_ADDRESS(IZ,IY,IX)) |
---|
154 | |
---|
155 | /* Fast subscripted access to map */ |
---|
156 | /* (assumes mins = 0 and chars) */ |
---|
157 | #define MAP_ADDRESS(IZ,IY,IX) (map_address+\ |
---|
158 | ((IZ)*map_len[Y]+(IY))*map_len[X]+(IX)) |
---|
159 | #define MAP(IZ,IY,IX) (*MAP_ADDRESS(IZ,IY,IX)) |
---|
160 | |
---|
161 | short out_map_len[NM]; /* Size of output density map */ |
---|
162 | long out_map_length; /* Total number of densities in map */ |
---|
163 | /* (= product of lens) */ |
---|
164 | DENSITY *out_map_address; /* Pointer to map */ |
---|
165 | |
---|
166 | /* Fast subscripted access to output map */ |
---|
167 | #define OUT_MAP_ADDRESS(IZ,IY,IX) \ |
---|
168 | (out_map_address+\ |
---|
169 | ((IZ)*out_map_len[Y]+\ |
---|
170 | (IY))*out_map_len[X]+\ |
---|
171 | (IX)) |
---|
172 | #define OUT_MAP(IZ,IY,IX) (*OUT_MAP_ADDRESS(IZ,IY,IX)) |
---|
173 | |
---|
174 | short acc_map_len[NM]; /* Size of density accumulator */ |
---|
175 | long acc_map_length; /* Total number of densities */ |
---|
176 | WDENSITYSUM *acc_map_address; /* Pointer to accumulator */ |
---|
177 | |
---|
178 | /* Fast subscripted access to accumulator */ |
---|
179 | #define ACC_MAP_ADDRESS(IZ,IY,IX) \ |
---|
180 | (acc_map_address+\ |
---|
181 | ((IZ)*acc_map_len[Y]+\ |
---|
182 | (IY))*acc_map_len[X]+\ |
---|
183 | (IX)) |
---|
184 | #define ACC_MAP(IZ,IY,IX) (*ACC_MAP_ADDRESS(IZ,IY,IX)) |
---|
185 | |
---|
186 | /* Cyberware point splatting code */ |
---|
187 | char splat_code; /* One of {'A':add} */ |
---|
188 | |
---|
189 | BOOLEAN map_histogram_exists; /* True if histogram exists */ |
---|
190 | long density_histogram[MAX_DENSITY+1]; /* Histogram of density map */ |
---|
191 | |
---|