[Radiance-general] Using vwright/rcalc to do -pj

Greg Ward gward at lmi.net
Mon Nov 15 06:43:18 CET 2004


Hi Mark,

If you use the variable output of vwright,  you actually don't need 
vwrays at all.  Taking the code from the viewray() routine in 
src/common/image.c:

	case VT_PER:			/* perspective view */
		direc[0] = v->vdir[0] + x*v->hvec[0] + y*v->vvec[0];
		direc[1] = v->vdir[1] + x*v->hvec[1] + y*v->vvec[1];
		direc[2] = v->vdir[2] + x*v->hvec[2] + y*v->vvec[2];
		orig[0] = v->vp[0] + v->vfore*direc[0];
		orig[1] = v->vp[1] + v->vfore*direc[1];
		orig[2] = v->vp[2] + v->vfore*direc[2];
		d = normalize(direc);

To reproduce this in an rcalc script, we use the variables output from 
vwright to compute the origin and direction (with jitter) for your view 
using the following file, which we'll call "persp.cal":

						{ Compute horizontal & vertical position on image }
H = (x + rand(.3523*recno-20.2)*jitter)/xres - 0.5;
V = (y + rand(-.1873*recno+400.3)*jitter)/yres - 0.5;
						{ Compute unnormalized view direction }
dirx = idx + ihn*ihx*H + ivn*ivx*V;
diry = idy + ihn*ihy*H + ivn*ivy*V;
dirz = idz + ihn*ihz*H + ivn*ivz*V;
						{ Compute view origin, including fore clipping plane }
orgx = ipx + io*dirx;
orgy = ipy + io*diry;
orgz = ipz + io*dirz;

------------
Here's how you apply it using rcalc:

cnt 480 740 | rcalc -od -i 'x=$2;y=$1' -e 
'xres:740;yres:480;jitter:0.6' \
	-e `vwright i < tempvf` -f persp.cal \
	-e '$1=orgx;$2=orgy;$3=orgz;$4=dirx;$5=diry;$6=dirz' \
	| rtrace -fdc -x 740 -y 480 @opts scene.oct > img.pic

Naturally, you could shorten your rcalc command by sticking the various 
extra settings into persp.cal, but I thought you might like to leave 
that file general.  I arbitrarily chose 0.6 as the jitter amount -- I 
wasn't sure what you wanted for this.  Also, I haven't tested this, so 
I probably screwed up or missed something, which hopefully you'll be 
able to sort out.  Let us know if it works.

-Greg




More information about the Radiance-general mailing list