7 |
|
|
8 |
|
#include "platform.h" |
9 |
|
#include "standard.h" |
10 |
+ |
#include "random.h" |
11 |
|
#include "view.h" |
12 |
|
|
13 |
|
typedef void putfunc(FVECT ro, FVECT rd); |
25 |
|
|
26 |
|
double pa = 1.; |
27 |
|
|
28 |
+ |
double pj = 0.; |
29 |
+ |
|
30 |
|
int zfd = -1; |
31 |
|
|
32 |
|
int fromstdin = 0; |
99 |
|
exit(1); |
100 |
|
} |
101 |
|
break; |
102 |
< |
case 'p': /* pixel aspect ratio */ |
103 |
< |
pa = atof(argv[++i]); |
102 |
> |
case 'p': /* pixel aspect or jitter */ |
103 |
> |
if (argv[i][2] == 'a') |
104 |
> |
pa = atof(argv[++i]); |
105 |
> |
else if (argv[i][2] == 'j') |
106 |
> |
pj= atof(argv[++i]); |
107 |
> |
else |
108 |
> |
goto userr; |
109 |
|
break; |
110 |
|
case 'i': /* get pixels from stdin */ |
111 |
|
fromstdin = 1; |
156 |
|
|
157 |
|
|
158 |
|
static void |
159 |
+ |
jitterloc( |
160 |
+ |
RREAL loc[2] |
161 |
+ |
) |
162 |
+ |
{ |
163 |
+ |
if (pj > FTINY) { |
164 |
+ |
loc[0] += pj*(.5 - frandom())/rs.xr; |
165 |
+ |
loc[1] += pj*(.5 - frandom())/rs.yr; |
166 |
+ |
} |
167 |
+ |
} |
168 |
+ |
|
169 |
+ |
|
170 |
+ |
static void |
171 |
|
pix2rays( |
172 |
|
FILE *fp |
173 |
|
) |
175 |
|
static FVECT rorg, rdir; |
176 |
|
float zval; |
177 |
|
double px, py; |
178 |
+ |
RREAL loc[2]; |
179 |
|
int pp[2]; |
180 |
|
double d; |
181 |
|
register int i; |
189 |
|
progname, px, py); |
190 |
|
exit(1); |
191 |
|
} |
192 |
+ |
loc[0] = px/rs.xr; loc[1] = py/rs.yr; |
193 |
|
if (zfd >= 0) { |
194 |
< |
loc2pix(pp, &rs, px/rs.xr, py/rs.yr); |
194 |
> |
loc2pix(pp, &rs, loc[0], loc[1]); |
195 |
|
if (lseek(zfd, |
196 |
|
(pp[1]*scanlen(&rs)+pp[0])*sizeof(float), |
197 |
|
SEEK_SET) < 0 || |
202 |
|
exit(1); |
203 |
|
} |
204 |
|
} |
205 |
< |
d = viewray(rorg, rdir, &vw, px/rs.xr, py/rs.yr); |
205 |
> |
jitterloc(loc); |
206 |
> |
d = viewray(rorg, rdir, &vw, loc[0], loc[1]); |
207 |
|
if (d < -FTINY) |
208 |
|
rorg[0] = rorg[1] = rorg[2] = |
209 |
|
rdir[0] = rdir[1] = rdir[2] = 0.; |
227 |
|
static void |
228 |
|
putrays(void) |
229 |
|
{ |
230 |
< |
static RREAL loc[2]; |
231 |
< |
static FVECT rorg, rdir; |
230 |
> |
RREAL loc[2]; |
231 |
> |
FVECT rorg, rdir; |
232 |
|
float *zbuf = NULL; |
233 |
|
int sc; |
234 |
|
double d; |
252 |
|
} |
253 |
|
for (si = 0; si < scanlen(&rs); si++) { |
254 |
|
pix2loc(loc, &rs, si, sc); |
255 |
+ |
jitterloc(loc); |
256 |
|
d = viewray(rorg, rdir, &vw, loc[0], loc[1]); |
257 |
|
if (d < -FTINY) |
258 |
|
rorg[0] = rorg[1] = rorg[2] = |