Schnee (schnee) wrote,

  • Mood:


Hot on the heels of the previous entry, here's another instalment of "old farts recollecting":

That's one of the sample images from Vivid (version 1.0, in this case), a raytracer originally written by Stephen B. Coy in 1989. I used to toy around with that quite a bit in my younger days (although rendering complex scenes on a 386DX-40 took a long time, up to several weeks in some cases), and I'm delighted that it's still working even today on a modern machine. *s*

That is, Vivid 1.0 and 3.0 are working; Vivid 2.0 just yields an error message ("VIVID287.EXE is not a valid Win32 application"). It doesn't work in DOSBox, either; instead, you get an exception and a register dump that isn't really helpful (to me):


DOS/16M: [35] Unexpected Interrupt=0001  at 0070:35BB
code=0000 ss=0130 ds=0020 es=0038
ax=0004 bx=0040 cx=0010 dx=5000 sp=8374 bp=8380 si=840A di=0404

And file(1) also can't make much sense of the executable:

$ file vivid287.exe
vivid287.exe: MS-DOS executable, NE (unknown OS 0)

But be that as it may, Vivid 1.0 and 3.0 are working, and I haven't run into files from 2.0 that 3.0 can't render yet, so it's not a big deal.

Vivid 3.0 outputs TGA files, too, so you can easily view the results. Vivid 1.0 has its own output image format; it comes with an IMG2GIF utility, but obviously, that'll take you from truecolor to palette-based images, which most likely isn't what you'll want. You could cheat and use the IMG2T24 utility from Vivid 2.0 that converts to TGA, but then you could just as well use Vivid 3.0 right away, ne? ^^

Back in the day, you probably would've used Image Alchemy to convert pictures; it's still being sold, apparently, and you can download a demo version, but it's limited to 640x480 images.

That said, the demo version does handle Vivid's image format, and identifies it as an "Alias PIX / Vivid IMG file", which fits in nicely with the bit from Vivid's documentation that says "This format is compatible with that used by Alias Research. (I think.)". Alias is most well-known for Maya these days, I think (although Maya didn't exist back then); tools for converting Alias PIX files seem to be difficult to come across, though.

However, after some sleuthing, I came across a collection of "some useful tools [for] folks using the RenderMan Standard" that includes a pix2tiff program; Google indexes a cached copy of the "bitmap utilities" page listing this, and the Internet Archive's Wayback Machine has a copy of the site that includes the tarball (whew).

With a couple of Makefile tweaks, it compiles on Cygwin, too, and the resulting utility works like a charm (although apparently, it is impossible to statically link executables on Cygwin, which means you can't use it outside of your Cygwin shell). So you'll be able to convert your files to TIFF this way, and then use another converter to end up with something modern, like PNG.

The alternative, of course, is to write your own converter, which (fortunately) is very easy, as the format is just a very simple RLE format. Curiously, Murray's and vanRyper's Encyclopedia of Graphics File Formats doesn't seem to list it (the 1st edition, anyway; I don't have a copy of the 2nd), despite listing the scene description language, but the Vivid documentation itself describes the format, so here's a quick something written in Perl, using GD (self-explanatory, I hope):

use GD;

die "Usage: $0 file\n" unless(scalar @ARGV);

open IMAGE, "<", $ARGV[0];
binmode IMAGE;

read IMAGE, $header, 10;
($width, $height, $firstscan, $lastscan, $depth) = unpack("nnnnn", $header);

die("Bit depth is $depth, not 24. Are you sure this is a Vivid IMG file?\n") unless($depth == 24);
warn("Scanline headers ignored\n") if($firstscan != 0 or $lastscan != ($height - 1));

$output = GD::Image->newTrueColor($width, $height);
$drawn = $line = 0;

while(read(IMAGE, $pixels, 4)) {
	($repeat, $blue, $green, $red) = unpack("CCCC", $pixels);
	$color = $output->colorResolve($red, $green, $blue);

	$output->line($drawn, $line, $drawn + $repeat - 1, $line, $color);

	if(($drawn += $repeat) >= $width) {
		$drawn = 0;

($outfile = $ARGV[0]) =~ s/\.img$/.png/i;
open OUTFILE, ">", $outfile;
binmode OUTFILE;

print OUTFILE $output->png;

close IMAGE;
close OUTFILE;

It does produce warnings, as Vivid 1.0 apparently strays from its own documentation, but it works. :) In practice, however, if you want to play around with Vivid, I'd still recommend using 3.0; it's just that much faster.

Tags: nostalgia, old farts recollecting, perl, raytracing, scripts, software, vivid
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded