Article View: comp.sources.bugs
Article #28Bugs in MTV ray tracing package (v18i070, comp.sources.unix)
From: cnsy
Date: Thu, 22 Jun 1989 20:21
Date: Thu, 22 Jun 1989 20:21
82 lines
2981 bytes
2981 bytes
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) ++ ;
Technical Details
Message-ID:
<18855@vax5.CIT.CORNELL.EDU>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!vax5!cnsyShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!vax5!cnsy From: cnsy@vax5.CIT.CORNELL.EDU Newsgroups: comp.sources.bugs,comp.graphics Subject: Bugs in MTV ray tracing package (v18i070, comp.sources.unix) Summary: view problems and statistics problems Message-ID: <18855@vax5.CIT.CORNELL.EDU> Date: 22 Jun 89 20:21:45 GMT Sender: news@vax5.CIT.CORNELL.EDU Reply-To: cnsy@vax5.cit.cornell.edu (Eric Haines, actually) Organization: 3D/Eye Inc Lines: 82