markv@uoregon.uoregon.edu (Mark VandeWettering) (09/05/88)
First of all thanks to everyone who has expressed an interest in my raytracer. I wish to address some questions globally rather than to each individual. Q: The raytracer seems to work, but how do I display it on my XXX brand workstation? A: Well, there are many answers to this. We only have black and white sun workstations here, so I have to display my images on an ancient and probably quite rare Tek4115 graphics terminal which has only 8 bitplanes. What I do is take the output of this raytracer, and pipe it through a program to convert it to the Utah Raster Toolkit format that we use here at the U of O. We have several programs to display these files on a wide variety of devices. The utah Raster Toolkit is available via anonymous FTP from cis.utah.edu, or you can send them some amount of money, and they can make you a tape (I don't have exact details here). The only problem with this is the guts of my conversion program are not original, they consist of some code that Eugene Miya posted to this group awhile ago (never write what you can beg, borrow or steal!), and I would have to contact him before I distributed said program. Also you would have to get the Utah Raster stuff as well. If I get enough mail to warrant posting this stuff, and if I can verify it with Eugene Miya, I will post my programs. My advice: Don't bother hacking pic.c too much. Write a program to display general raster images of an rgb bitmap to whatever device you have on hand. Use dithering if you want black and white. And then POST such programs, so that others can use/improve them. Q: Where can I get Eric Haine's NFF package? A: Simple: I will be reposting it right after this message. Q: Does anyone have any nifty NFF file objects to trace? A: Well, I just converted the teapot to NFF file format (using faceted polygons) but it is pretty big. If someone can suggest an anonymous FTP site where I could put some of these, as well as other revisions to my programs, I would make them available from there. Q: What else am I working on? Well, I would like to add motion blur, and statistically optimized anti-aliasing. I added code so that you can specify colors by name rather than by guessing colors. Parametric patches, tori, and surfaces of revolution would be nice to add too. As soon as I feel the raytracer has been significantly extended, I will repost. Finally, a bug fix (courtesy of Cameron Elliot): Your program will crash on some machines unless you do the following... (The buf array was too small.) Modify screen.c: /* Was before cam... [Ed: Gadzooks, Mark can sure be stupid sometimes....] curbuf = (Pixel *) malloc (xres * sizeof (Pixel)) + 1 ; buf = (Pixel *) malloc (xres * sizeof (Pixel)) + 1; */ curbuf = (Pixel *) malloc ((xres+1) * sizeof (Pixel)) ; buf = (Pixel *) malloc ((xres+1) * sizeof (Pixel)); --- Disclaimer: If employees dont represent an organization what does? Cameron Elliott Portable Cellular Communications Path: ...!uw-beaver!tikal!ptisea!cam Thanks again for the bug fix, and the nice comments! Keep the mail coming! Mark VandeWettering
tom@tnosoes.UUCP (Tom Vijlbrief) (09/07/88)
In article <2683@uoregon.uoregon.edu> markv@drizzle.UUCP (Mark VandeWettering) writes: > > My advice: Don't bother hacking pic.c too much. Write a > program to display general raster images of an rgb bitmap to > whatever device you have on hand. Use dithering if you want > black and white. And then POST such programs, so that others > can use/improve them. This is a posting of two programs which convert the output of the raytracing program to Sun rasterfile format. Ray2sun maps to greyscale. Cray2sun maps to color (3 bit red, 3 bit green and 2 bit blue) The program Ray2sun works fine, but Cray2sun should be much smarter to produce better quality pictures. (E.g. use dithering...) Tom =============================================================================== Tom Vijlbrief TNO Institute for Perception P.O. Box 23 Phone: +31 34 63 62 77 3769 DE Soesterberg E-mail: tnosoes!tom@mcvax.cwi.nl The Netherlands or: uunet!mcvax!tnosoes!tom =============================================================================== #---cut here---cut here---cut here---cut here---cut here--- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files. # This archive created: Wed Sep 7 13:59:00 MET DST 1988 # Archived by: tnosoes!tom@mcvax.cwi.nl export PATH; PATH=/bin:$PATH echo shar: extracting "'Makefile'" '(195 characters)' if test -f 'Makefile' then echo shar: will not over-write existing file "'Makefile'" else sed 's/^X//' << \SHAR_EOF > 'Makefile' XCFLAGS= -O X Xcray2sun: cray2sun.o X cc -o $@ $? X Xray2sun: ray2sun.o X cc -o $@ $? X Xclean: X /bin/rm ray2sun.o ray2sun X Xshar: X /bin/rm -f shar.out X shar ray2sun.c Makefile X Xlint: X lint -hap ray2sun.c SHAR_EOF if test 195 -ne "`wc -c < 'Makefile'`" then echo shar: error transmitting "'Makefile'" '(should have been 195 characters)' fi fi # end of overwriting check echo shar: extracting "'cray2sun.c'" '(1815 characters)' if test -f 'cray2sun.c' then echo shar: will not over-write existing file "'cray2sun.c'" else sed 's/^X//' << \SHAR_EOF > 'cray2sun.c' X/* X * This filter converts ray tracing files to Sun rasterfiles. X * X * Tom Vijlbrief, Dec 1987 (tnosoes!tom@mcvax.cwi.nl or uunet!mcvax!tnosoes!tom) X */ X X#include <stdio.h> X#include <rasterfile.h> X Xstruct rasterfile header; X Xtypedef unsigned char byte; X Xchar *malloc(); XFILE *fopen(); X X#define BUFSIZE 3 X Xbyte colmap[256]; Xbyte buf[BUFSIZE]; X X Xmain(argc, argv) X Xint argc; Xchar *argv[]; X{ X FILE *f; X register int i,j; X int x, y; X X if (argc == 1) X f= stdin; X else if (argc == 2) { X if ((f= fopen(argv[1], "r")) == NULL) { X perror(argv[1]); X exit(1); X } X } else { X fprintf(stderr, "Usage: %s [file]\n", argv[0]); X exit(1); X } X X if (fscanf(f, "%d%d\n", &x, &y) != 2) { X fprintf(stderr, "%s: Ill formatted input file\n", argv[0]); X exit(1); X } X header.ras_magic= 0x59a66a95; X header.ras_width= x; X header.ras_height= y; X header.ras_depth= 8; X header.ras_length= 100 * 100; X header.ras_type= RT_STANDARD; X header.ras_maptype= RMT_EQUAL_RGB; X header.ras_maplength= 3*256; X X if (fwrite(&header, sizeof(header), 1, stdout) == 0) { X perror(argv[0]); X exit(1); X } X X for (i= 0; i < 256; i++) X colmap[i]= (i >> 5) * 36; X if (fwrite(colmap, sizeof(colmap), 1, stdout) == 0) { X perror(argv[0]); X exit(1); X } X for (i= 0; i < 256; i++) X colmap[i]= ((i >> 2) & 0x7) * 36; X if (fwrite(colmap, sizeof(colmap), 1, stdout) == 0) { X perror(argv[0]); X exit(1); X } X for (i= 0; i < 256; i++) X colmap[i]= (i & 0x3) * 85; X if (fwrite(colmap, sizeof(colmap), 1, stdout) == 0) { X perror(argv[0]); X exit(1); X } X X for (i= 0;; i++) { X if (!fread(buf, 3, 1, f)) X break; X buf[0]= (buf[0] & ~0x1F) + ((buf[1] >> 3) & ~0x3) + (buf[2] >> 6); X if (!fwrite(buf, 1, 1, stdout)) { X perror(argv[0]); X exit(1); X } X } X if (i != x * y) { X fprintf(stderr, "%s: Ill formatted input file\n", argv[0]); X exit(1); X } X} SHAR_EOF if test 1815 -ne "`wc -c < 'cray2sun.c'`" then echo shar: error transmitting "'cray2sun.c'" '(should have been 1815 characters)' fi fi # end of overwriting check echo shar: extracting "'ray2sun.c'" '(1592 characters)' if test -f 'ray2sun.c' then echo shar: will not over-write existing file "'ray2sun.c'" else sed 's/^X//' << \SHAR_EOF > 'ray2sun.c' X/* X * This filter converts ray tracing files to Sun rasterfiles. X * X * Tom Vijlbrief, Dec 1987 (tnosoes!tom@mcvax.cwi.nl or uunet!mcvax!tnosoes!tom) X */ X X#include <stdio.h> X#include <rasterfile.h> X Xstruct rasterfile header; X Xtypedef unsigned char byte; X Xchar *malloc(); XFILE *fopen(); X X#define BUFSIZE 3 X Xbyte colmap[256]; Xbyte buf[BUFSIZE]; X X Xmain(argc, argv) X Xint argc; Xchar *argv[]; X{ X FILE *f; X register int i,j; X int x, y; X X if (argc == 1) X f= stdin; X else if (argc == 2) { X if ((f= fopen(argv[1], "r")) == NULL) { X perror(argv[1]); X exit(1); X } X } else { X fprintf(stderr, "Usage: %s [file]\n", argv[0]); X exit(1); X } X X if (fscanf(f, "%d%d\n", &x, &y) != 2) { X fprintf(stderr, "%s: Ill formatted input file\n", argv[0]); X exit(1); X } X header.ras_magic= 0x59a66a95; X header.ras_width= x; X header.ras_height= y; X header.ras_depth= 8; X header.ras_length= 100 * 100; X header.ras_type= RT_STANDARD; X header.ras_maptype= RMT_EQUAL_RGB; X header.ras_maplength= 3*256; X X if (fwrite(&header, sizeof(header), 1, stdout) == 0) { X perror(argv[0]); X exit(1); X } X X for (i= 0; i < 256; i++) X colmap[i]= i; X X if (fwrite(colmap, sizeof(colmap), 1, stdout) == 0 X || fwrite(colmap, sizeof(colmap), 1, stdout) == 0 X || fwrite(colmap, sizeof(colmap), 1, stdout) == 0) { X perror(argv[0]); X exit(1); X } X X for (i= 0;; i++) { X if (!fread(buf, 3, 1, f)) X break; X buf[0]= (buf[0] + buf[1] + buf[2]) / 3; X if (!fwrite(buf, 1, 1, stdout)) { X perror(argv[0]); X exit(1); X } X } X if (i != x * y) { X fprintf(stderr, "%s: Ill formatted input file\n", argv[0]); X exit(1); X } X} SHAR_EOF if test 1592 -ne "`wc -c < 'ray2sun.c'`" then echo shar: error transmitting "'ray2sun.c'" '(should have been 1592 characters)' fi fi # end of overwriting check # End of shell archive exit 0 =============================================================================== Tom Vijlbrief TNO Institute for Perception P.O. Box 23 Phone: +31 34 63 62 77 3769 DE Soesterberg E-mail: tnosoes!tom@mcvax.cwi.nl The Netherlands or: uunet!mcvax!tnosoes!tom ===============================================================================