4 |
|
/* |
5 |
|
* ranimove1.c |
6 |
|
* |
7 |
< |
* Basic frame rendering routines for ranimate(1). |
7 |
> |
* Basic frame rendering routines for ranimove(1). |
8 |
|
* |
9 |
|
* Created by Gregory Ward on Wed Jan 08 2003. |
10 |
|
*/ |
367 |
|
continue; |
368 |
|
} |
369 |
|
if (!sample_here(x, y)) { /* just cast */ |
370 |
< |
rayorigin(&ir, NULL, PRIMARY, 1.0); |
370 |
> |
rayorigin(&ir, PRIMARY, NULL, NULL); |
371 |
|
if (!localhit(&ir, &thescene)) { |
372 |
|
if (ir.ro != &Aftplane) |
373 |
|
sourcehit(&ir); |
385 |
|
} |
386 |
|
if (nprocs > 1) { /* get sample */ |
387 |
|
int rval; |
388 |
< |
rayorigin(&ir, NULL, PRIMARY, 1.0); |
388 |
> |
rayorigin(&ir, PRIMARY, NULL, NULL); |
389 |
|
ir.rno = n; |
390 |
|
rval = ray_pqueue(&ir); |
391 |
|
if (!rval) |
745 |
|
printf("\tFiltering frame\n"); |
746 |
|
fflush(stdout); |
747 |
|
} |
748 |
< |
/* normalize samples */ |
749 |
< |
for (y = vres; y--; ) { |
750 |
< |
for (x = hres; x--; ) { |
751 |
< |
n = fndx(x, y); |
752 |
< |
if (sbuffer[n] <= 1) |
753 |
< |
continue; |
754 |
< |
w = 1.0/(double)sbuffer[n]; |
748 |
> |
/* normalize samples */ |
749 |
> |
for (y = vres; y--; ) |
750 |
> |
for (x = hres; x--; ) { |
751 |
> |
n = fndx(x, y); |
752 |
> |
if (sbuffer[n] <= 1) |
753 |
> |
continue; |
754 |
> |
w = 1.0/(double)sbuffer[n]; |
755 |
> |
scalecolor(cbuffer[n], w); |
756 |
> |
} |
757 |
> |
/* interpolate samples */ |
758 |
> |
for (y = vres; y--; ) |
759 |
> |
for (x = hres; x--; ) { |
760 |
> |
n = fndx(x, y); |
761 |
> |
if (sbuffer[n]) |
762 |
> |
continue; |
763 |
> |
nc = getclosest(neigh, NPINTERP, x, y); |
764 |
> |
setcolor(cbuffer[n], 0., 0., 0.); |
765 |
> |
wsum = 0.; |
766 |
> |
while (nc-- > 0) { |
767 |
> |
copycolor(cval, cbuffer[neigh[nc]]); |
768 |
> |
w = sample_wt((neigh[nc]%hres) - x, |
769 |
> |
(neigh[nc]/hres) - y); |
770 |
> |
scalecolor(cval, w); |
771 |
> |
addcolor(cbuffer[n], cval); |
772 |
> |
wsum += w; |
773 |
> |
} |
774 |
> |
if (wsum > FTINY) { |
775 |
> |
w = 1.0/wsum; |
776 |
|
scalecolor(cbuffer[n], w); |
777 |
|
} |
778 |
< |
} |
779 |
< |
/* interpolate samples */ |
759 |
< |
for (y = vres; y--; ) { |
760 |
< |
for (x = hres; x--; ) { |
761 |
< |
n = fndx(x, y); |
762 |
< |
if (sbuffer[n]) |
763 |
< |
continue; |
764 |
< |
nc = getclosest(neigh, NPINTERP, x, y); |
765 |
< |
setcolor(cbuffer[n], 0., 0., 0.); |
766 |
< |
wsum = 0.; |
767 |
< |
while (nc-- > 0) { |
768 |
< |
copycolor(cval, cbuffer[neigh[nc]]); |
769 |
< |
w = sample_wt((neigh[nc]%hres) - x, |
770 |
< |
(neigh[nc]/hres) - y); |
771 |
< |
scalecolor(cval, w); |
772 |
< |
addcolor(cbuffer[n], cval); |
773 |
< |
wsum += w; |
774 |
< |
} |
775 |
< |
if (wsum > FTINY) { |
776 |
< |
w = 1.0/wsum; |
777 |
< |
scalecolor(cbuffer[n], w); |
778 |
< |
} |
779 |
< |
} |
780 |
< |
} |
781 |
< |
/* motion blur if requested */ |
778 |
> |
} |
779 |
> |
/* motion blur if requested */ |
780 |
|
if (mblur > .02) { |
781 |
< |
int xs, ys, xl, yl; |
782 |
< |
int rise, run; |
783 |
< |
long rise2, run2; |
784 |
< |
int n2; |
785 |
< |
int cnt; |
786 |
< |
/* sum in motion streaks */ |
787 |
< |
memset(outbuffer, '\0', sizeof(COLOR)*hres*vres); |
788 |
< |
memset(wbuffer, '\0', sizeof(float)*hres*vres); |
789 |
< |
for (y = vres; y--; ) { |
790 |
< |
for (x = hres; x--; ) { |
781 |
> |
int xs, ys, xl, yl; |
782 |
> |
int rise, run; |
783 |
> |
long rise2, run2; |
784 |
> |
int n2; |
785 |
> |
int cnt; |
786 |
> |
/* sum in motion streaks */ |
787 |
> |
memset(outbuffer, '\0', sizeof(COLOR)*hres*vres); |
788 |
> |
memset(wbuffer, '\0', sizeof(float)*hres*vres); |
789 |
> |
for (y = vres; y--; ) |
790 |
> |
for (x = hres; x--; ) { |
791 |
|
n = fndx(x, y); |
792 |
|
if (xmbuffer[n] == MO_UNK) { |
793 |
|
run = rise = 0; |
808 |
|
else ys = 1; |
809 |
|
rise2 = run2 = 0L; |
810 |
|
if (rise > run) { |
811 |
< |
cnt = rise + 1; |
812 |
< |
w = 1./cnt; |
813 |
< |
copycolor(cval, cbuffer[n]); |
814 |
< |
scalecolor(cval, w); |
815 |
< |
while (cnt) { |
816 |
< |
if (rise2 >= run2) { |
817 |
< |
if ((xl >= 0) & (xl < hres) & |
811 |
> |
cnt = rise + 1; |
812 |
> |
w = 1./cnt; |
813 |
> |
copycolor(cval, cbuffer[n]); |
814 |
> |
scalecolor(cval, w); |
815 |
> |
while (cnt) |
816 |
> |
if (rise2 >= run2) { |
817 |
> |
if ((xl >= 0) & (xl < hres) & |
818 |
|
(yl >= 0) & (yl < vres)) { |
819 |
< |
n2 = fndx(xl, yl); |
820 |
< |
addcolor(outbuffer[n2], cval); |
821 |
< |
wbuffer[n2] += w; |
822 |
< |
} |
823 |
< |
yl += ys; |
824 |
< |
run2 += run; |
825 |
< |
cnt--; |
826 |
< |
} else { |
827 |
< |
xl += xs; |
828 |
< |
rise2 += rise; |
829 |
< |
} |
830 |
< |
} |
819 |
> |
n2 = fndx(xl, yl); |
820 |
> |
addcolor(outbuffer[n2], |
821 |
> |
cval); |
822 |
> |
wbuffer[n2] += w; |
823 |
> |
} |
824 |
> |
yl += ys; |
825 |
> |
run2 += run; |
826 |
> |
cnt--; |
827 |
> |
} else { |
828 |
> |
xl += xs; |
829 |
> |
rise2 += rise; |
830 |
> |
} |
831 |
|
} else { |
832 |
|
cnt = run + 1; |
833 |
|
w = 1./cnt; |
834 |
|
copycolor(cval, cbuffer[n]); |
835 |
|
scalecolor(cval, w); |
836 |
< |
while (cnt) { |
837 |
< |
if (run2 >= rise2) { |
838 |
< |
if ((xl >= 0) & (xl < hres) & |
836 |
> |
while (cnt) |
837 |
> |
if (run2 >= rise2) { |
838 |
> |
if ((xl >= 0) & (xl < hres) & |
839 |
|
(yl >= 0) & (yl < vres)) { |
840 |
< |
n2 = fndx(xl, yl); |
841 |
< |
addcolor(outbuffer[n2], |
842 |
< |
cval); |
843 |
< |
wbuffer[n2] += w; |
840 |
> |
n2 = fndx(xl, yl); |
841 |
> |
addcolor(outbuffer[n2], |
842 |
> |
cval); |
843 |
> |
wbuffer[n2] += w; |
844 |
> |
} |
845 |
> |
xl += xs; |
846 |
> |
rise2 += rise; |
847 |
> |
cnt--; |
848 |
> |
} else { |
849 |
> |
yl += ys; |
850 |
> |
run2 += run; |
851 |
|
} |
847 |
– |
xl += xs; |
848 |
– |
rise2 += rise; |
849 |
– |
cnt--; |
850 |
– |
} else { |
851 |
– |
yl += ys; |
852 |
– |
run2 += run; |
853 |
– |
} |
854 |
– |
} |
852 |
|
} |
853 |
< |
} |
854 |
< |
/* compute final results */ |
855 |
< |
for (y = vres; y--; ) { |
856 |
< |
for (x = hres; x--; ) { |
857 |
< |
n = fndx(x, y); |
858 |
< |
if (wbuffer[n] <= FTINY) |
859 |
< |
continue; |
860 |
< |
w = 1./wbuffer[n]; |
861 |
< |
scalecolor(outbuffer[n], w); |
862 |
< |
} |
863 |
< |
} |
864 |
< |
} |
868 |
< |
} else { |
869 |
< |
for (n = hres*vres; n--; ) { |
853 |
> |
} |
854 |
> |
/* compute final results */ |
855 |
> |
for (y = vres; y--; ) |
856 |
> |
for (x = hres; x--; ) { |
857 |
> |
n = fndx(x, y); |
858 |
> |
if (wbuffer[n] <= FTINY) |
859 |
> |
continue; |
860 |
> |
w = 1./wbuffer[n]; |
861 |
> |
scalecolor(outbuffer[n], w); |
862 |
> |
} |
863 |
> |
} else |
864 |
> |
for (n = hres*vres; n--; ) |
865 |
|
copycolor(outbuffer[n], cbuffer[n]); |
871 |
– |
} |
872 |
– |
} |
866 |
|
/* |
867 |
|
for (n = hres*vres; n--; ) |
868 |
< |
if (!sbuffer[n]) |
869 |
< |
setcolor(outbuffer[n], 0., 0., 0.); |
868 |
> |
if (!sbuffer[n]) |
869 |
> |
setcolor(outbuffer[n], 0., 0., 0.); |
870 |
|
*/ |
871 |
|
/* adjust exposure */ |
872 |
|
if ((expval < 0.99) | (expval > 1.01)) |
873 |
|
for (n = hres*vres; n--; ) |
874 |
|
scalecolor(outbuffer[n], expval); |
875 |
< |
return; |
875 |
> |
#if 0 |
876 |
|
{ |
877 |
|
float *sbuf = (float *)malloc(sizeof(float)*hres*vres); |
878 |
|
char fnm[256]; |
883 |
|
write_map(sbuf, fnm); |
884 |
|
free((void *)sbuf); |
885 |
|
} |
886 |
+ |
#endif |
887 |
|
} |
888 |
|
|
889 |
|
|