[comp.graphics] MTV-Raytracer on ATARI ST

wagener@unidocv..uucp (Roland Wagener) (03/06/89)

I have ported the MTV-Raytracer on the ATARI ST using the Turbo-C-
Compiler. The Program works fine and it uses about 3 hours CPU-Time
to create the Balls-Picture in 320x200 Resolution.

But there is a bug somewhere in the program. There are white spots in
all reflecting surfaces. This bug does not apear on a IBM-PC programmed
with Zortech-C++. But the PC needs 5 hours for a 200x200-Picture ...

If somebody has ported the Raytracer on the ATARI ST without the disturbing
white spots : Please send the binary in binarys.ST .

I have programmed the octree-reduction-algorithm in two versions. One
version for 16 colours out of 512 and one version for 256 colours out of
256K. The last version needs a aditional graphics-board to show the
pictures.

I will post this C-Source if anyone asks for it.

Thanks in advance for your help ...

Roland & Hartmut Wagener

riley@batcomputer.tn.cornell.edu (Daniel S. Riley) (03/08/89)

In article <1171@laura.UUCP> wagener@unidocv.UUCP (Roland Wagener) writes:
>I have ported the MTV-Raytracer on the ATARI ST using the Turbo-C-
>Compiler. The Program works fine and it uses about 3 hours CPU-Time
>to create the Balls-Picture in 320x200 Resolution.

>But there is a bug somewhere in the program. There are white spots in
>all reflecting surfaces. This bug does not apear on a IBM-PC programmed
>with Zortech-C++. But the PC needs 5 hours for a 200x200-Picture ...

This sounds like a floating point precision problem.  I've been playing
with a number of ray tracers, including MTV, on my Amiga.  I've seen
white spots and other sorts of splotches if I use the Motorola ffp format
floating point routines, which are single precision (32 bit) only.  They 
go away if I use IEEE math libraries (all calculations done with 64 bit
doubles).  3 hours cpu for a 320x200 picture on an 8 MHz 68000 sounds like
single precision to me, but I don't know the ST or Turbo-C that well.

I suppose there must be papers on controlling round-off errors in
ray tracing algorithms, but none of the ray-tracers I've seen make any
special efforts in that regard.  Of course, all the ones I have source
code to are meant to be clean and simple, not fast and convoluted...:-)

-Dan Riley (riley@tcgould.tn.cornell.edu, cornell!batcomputer!riley)
-Wilson Lab, Cornell U.

shirley@m.cs.uiuc.edu (03/09/89)

The problem may be pretty simple.  When a ray is reflected (in the
form "origin + t * direction", the next intersection is chosen to
be the one where t is positive and otherwise the smallest.  There
will always be an intersection at t = 0 (the reflecting surface).
Most ray tracers have some code like

EPSILON = <some small positive number>
for all intersections
	find minimum t > EPSILON

This avoids the problem that occurs when that t = 0 turns into a
t = +small.  If single precision is used the EPSILON must be
bigger.  I think the often-referenced SIGGRAPH ray-tracing
tutorial talks about how to handle this problem in several ways,
but the hack above is the easiest to implement.

Peter Shirley
shirley@cs.uiuc.edu

greg@bilbo (Greg Wageman) (03/09/89)

In article <1171@laura.UUCP> wagener@unidocv.UUCP (Roland Wagener) writes:
>I have ported the MTV-Raytracer on the ATARI ST using the Turbo-C-
>Compiler. The Program works fine and it uses about 3 hours CPU-Time
>to create the Balls-Picture in 320x200 Resolution.

I have also.  Using Mark Williams C version 3.0.6.

>But there is a bug somewhere in the program. There are white spots in
>all reflecting surfaces. This bug does not apear on a IBM-PC programmed
>with Zortech-C++. But the PC needs 5 hours for a 200x200-Picture ...

Are you sure it's a bug, and not specular highlights?  There are
several versions of the MTV raytracer around, some did not implement
the Phong cosine-alpha highlights (some not-quite correct code was
"#ifdef"ed out), while others did.

The highlights appear on surfaces where the sixth (highlight) value in
the NFF surface line is non-zero, such as in the "balls" picture, one
for each light source which is reflected by the surface towards the
eye point.  For example:

  R  G  B  D  S C T I 
f 1 .9 .7 .5 .5 3 0 0

R/G/B - Red, Green, Blue components of surface color, range 0 - 1.0
D     - Diffuse reflection coefficient.
S     - Specular reflection coefficient.
C     - Phong "shine" cosine power, for specular highlights
T     - Transmission value.  Should be range 0-1.0, but due to bugs
	in the shading routine, does not work logically.
I     - Index of refraction.  Irrelevant if T < .01

Could your Atari compiler have ignored the #ifdef and compiled-in the
specular highlights code?

>I have programmed the octree-reduction-algorithm in two versions. One
>version for 16 colours out of 512 and one version for 256 colours out of
>256K. The last version needs a aditional graphics-board to show the
>pictures.
>
>I will post this C-Source if anyone asks for it.

I've written an MTV-to-Spectrum converter, but I used a "best-fit"
algorithm.  I would be interested in comparing the differences.

Longish .signature follows.  Skip now, or don't complain!

Greg Wageman			ARPA:  greg@sj.ate.slb.com
Schlumberger Technologies	BIX:   gwage
1601 Technology Drive		CIS:   74016,352
San Jose, CA 95110-1397		UUCP: ...!uunet!sjsca4!greg
(408) 437-5198
------------------
There's nothing I hate more than a Usenet posting which took three
seconds to compose and three minutes to type, glibly dismissing three
years (or three decades) of an author's work in three lines.
------------------
Opinions expressed herein are solely the responsibility of the author.
(And the author wouldn't have it any other way.)

Mahesh.Neelakanta@f3.n369.z1.FIDONET.ORG (Mahesh Neelakanta) (03/10/89)

In your message :
 > From: wagener@unidocv..uucp (Roland Wagener)
 > Date: 6 Mar 89 10:48:51 GMT
 > Organization: University of Dortmund, W-Germany
 > Message-ID: <1171@laura.UUCP>
 
you said that you would post the source code for anyone. Is the code 
PD. I am using a hp-graphics workstation and my supervisor (at school) 
would like to see some ray-tracing stuff being done.  How can I get 
the software from you ?
 
                              - Mahesh
 



--  
          __     Fidonet : Mahesh Neelakanta at Fidonet Node 1:369/2
         /  \    Internet: Mahesh.Neelakanta@f3.n369.z1.FIDONET.ORG
        / oo|\   UUCP    : ...!novavax!muadib!3!Mahesh.Neelakanta
       (_\  |_)  NOTICE  : Replies to Fidonet addresses MUSG HAVE the
  _    /__\@'__            .fidonet.org in the address or it will fail!
 //   / |     |
((   /  | (*) |  "Speak UUCP Fido, Speak!"
 \\/  \ |__U__|     ______
  \   /_ || \\_    / FIDO \  muadib is a FREE gateway for mail between
   \____)|_) \_)  (________) Usenet and FidoNet. For info write to Root.