Bugs in MTV ray tracing package (v18i070, comp.sources.unix)

cnsy at vax5.CIT.CORNELL.EDU cnsy at vax5.CIT.CORNELL.EDU
Fri Jun 23 06:21:45 AEST 1989


There are a few bugs in Mark VandeWettering's ray tracer.  They're a bit
subtle, and don't show up in some of the SPD database renderings.  They are:

1) The "up" vector must be rederived from the cross product of the view and
   left vectors so that all three vectors are mutually perpendicular.  This
   bug gave some strange distortions to images like "balls".

2) The hither distance (view->view_dist) should not be used to find the
   frustum width.  In fact, "hither" is needed only for scan line programs,
   and not the ray tracer.  It could be deleted altogether.  To minimize
   code changes, I simply didn't use it but kept it around anyway.

3) The statistics are misleading.  The numbers of reflection and refraction
   rays are counts of potential rays: if the maximum depth is reached, the
   rays are never generated, but are counted as rays.  Along with this, I
   changed the number of "rays cast" to the number of "eye rays" generated.

Anyway, it's still a nice ray tracer, with clean and readable code throughout.

Eric Haines (wrath.cs.cornell.edu)


Patches follow:

diff old/main.c new/main.c
109c112
< 	printf("number of rays cast:	   %-6d\n", nRays);
---
> 	printf("number of eye rays:	   %-6d\n", nRays);
diff old/screen.c new/screen.c
50d49
< 	VecNormalize(upvec) ;
66a66,72
> 	 * Make sure the up vector is perpendicular to the view vector
> 	 */
> 
> 	VecCross(viewvec, leftvec, upvec);
> 	VecNormalize(upvec);
> 
> 	/*
71c77
< 	frustrumwidth = (view -> view_dist) * ((Flt) tan(view -> view_angle)) ;
---
> 	frustrumwidth = ((Flt) tan(view -> view_angle)) ;
129c135
< 			Trace(0, 1.0, &ray, color);
---
> 			Trace(0, 1.0, &ray, color, &nRays);
173c179
< 			Trace(0, 1.0, &ray, color);
---
> 			Trace(0, 1.0, &ray, color, &nRays);
238c244
< 				Trace(0, 1.0, &ray, color);
---
> 				Trace(0, 1.0, &ray, color, &nRays);
diff old/shade.c new/shade.c
112d111
< 		nReflected ++ ;
115c114,115
< 		Trace(level + 1, surf -> surf_ks * weight, &tray, tcol);
---
> 		Trace(level + 1, surf -> surf_ks * weight, &tray, tcol,
> 			&nReflected);
120d119
< 		nRefracted ++ ;
125c124,125
< 		Trace(level + 1, surf -> surf_kt * weight, &tray, tcol) ;
---
> 		Trace(level + 1, surf -> surf_kt * weight, &tray, tcol,
> 			&nRefracted) ;
diff old/trace.c new/trace.c
19c19
< Trace(level, weight, ray, color) 
---
> Trace(level, weight, ray, color, nr) 
23a24
>  int *nr ;
34c35
< 	nRays ++ ;
---
> 	(*nr) ++ ;



More information about the Comp.sources.bugs mailing list