1 |
< |
/* Copyright (c) 1992 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1993 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
263 |
|
{ |
264 |
|
char buf[128]; |
265 |
|
register char *cp; |
266 |
– |
register PNODE *p; |
266 |
|
RECT r; |
267 |
|
int x, y; |
268 |
< |
double e; |
269 |
< |
|
268 |
> |
register PNODE *p = &ptrunk; |
269 |
> |
int adapt = 0; |
270 |
> |
double e = 1.0; |
271 |
> |
start: |
272 |
|
for (cp = s; isspace(*cp); cp++) |
273 |
|
; |
274 |
+ |
if (*cp == '@') { |
275 |
+ |
adapt++; |
276 |
+ |
goto start; |
277 |
+ |
} |
278 |
|
if (*cp == '\0') { /* normalize to point */ |
279 |
|
if (dev->getcur == NULL) |
280 |
|
return; |
284 |
|
r.l = r.d = 0; |
285 |
|
r.r = hresolu; r.u = vresolu; |
286 |
|
p = findrect(x, y, &ptrunk, &r, -1); |
282 |
– |
e = 1.0; |
287 |
|
} else { |
288 |
|
if (*cp == '=') { /* absolute setting */ |
289 |
|
p = NULL; |
299 |
|
if (*cp == '\0') |
300 |
|
return; |
301 |
|
} |
298 |
– |
} else { /* normalize to average */ |
299 |
– |
p = &ptrunk; |
300 |
– |
e = 1.0; |
302 |
|
} |
303 |
|
if (*cp == '+' || *cp == '-') /* f-stops */ |
304 |
|
e *= pow(2.0, atof(cp)); |
310 |
|
error(COMMAND, "cannot normalize to zero"); |
311 |
|
return; |
312 |
|
} |
313 |
< |
e *= 0.5 / bright(p->v); |
313 |
> |
if (adapt) |
314 |
> |
e *= 106./pow(1.219+pow(luminance(p->v)/exposure,.4),2.5)/exposure; |
315 |
> |
else |
316 |
> |
e *= 0.5 / bright(p->v); |
317 |
|
} |
318 |
|
if (e <= FTINY || fabs(1.0 - e) <= FTINY) |
319 |
|
return; |
462 |
|
getparam(s+2, "ambient value", 'C', (COLOR *)ambval); |
463 |
|
break; |
464 |
|
case 'a': /* accuracy */ |
465 |
< |
getparam(s+2, "ambient accuracy", 'r', &ambacc); |
465 |
> |
if (getparam(s+2, "ambient accuracy", 'r', &ambacc)) |
466 |
> |
setambacc(ambacc); |
467 |
|
break; |
468 |
|
case 'd': /* divisions */ |
469 |
|
getparam(s+2, "ambient divisions", 'i', &ambdiv); |