|
|
Spider wrote:
>
> Mark Gordon wrote:
> >
> > Graphics Gems IV has the C code for a minimal ray-tracer. It's written
> > in C and runs just over two pages. Unfortunately, it gives absolutely
> > no consideration to speed, since most ray-tracing optimization
> > techniques ultimately involve a space-time tradeoff, and they were
> > shooting for minimal space. Still, it's a place to start. The source
> > code is included in an archive that can be found at
> > http://www.acm.org/tog/GraphicsGems/gemsiv.zip
>
> AFAIK it's far easier to translate and then optimize a small pice of
> code you understand, than to translate a larger, more optimized pice of
> code you don't understand(Nothing personal, but optimized code can be a
> hell to understand if it isn't well commented).
You're correct that it's not as clear as it might be, but it's not as
obfuscated as one might expect, either. The version that fits on an
index card, now THAT'S obfuscated! It could be worse; it was optimized
for a minimum number of tokens in the source code, so it's actually
optimally simple, with no incentive to use non-intuitive variable names,
for instance. It's also not as obfuscated as some of the loop
optimization I've seen. The comments are a bit sparse, but it contains
such functions as the following:
double vdot(A, B)
vec A, B;
{return A.x*B.x + A.y*B.y + A.z*B.z;}
The coding style is unorthodox to say the least, but the intent is
pretty clear. And hey, he asked for "VERY small raytracers". That's
the exact focus of the article I cited. Be careful what you ask for;
you just might get it. ;-)
--
Mark Gordon
mtg### [at] povrayorg
Post a reply to this message
|
|