POV-Ray : Newsgroups : povray.general : Tips for Short Code Contest : Tips for Short Code Contest Server Time
31 Jul 2024 18:20:38 EDT (-0400)
  Tips for Short Code Contest  
From: Mike Kost
Date: 12 Oct 2006 14:22:41
Message: <452e87f1@news.povray.org>
After tyring to get a few scenes into 256 bytes for Paul Bourke's short code
contest, here's a few tips I've stumbled on to squeeze the last bits from
the sdl.

1. What Camera?

It helps to remove the camera declaration out of the scene. The default
camera is located at <0,0,0> and looking at <0,0,1>. If you must move the
camera, the camera will continue to look in the +z direction from it's new
location, the equivalent of 'camera{location loc look_at loc+z}'. This
prevents having to use 'look_at <a,b,c>' 

2. Colors

In SCC round 3, Tek noted
(http://local.wasp.uwa.edu.au/~pbourke/rendering/scc3/final/swokwz_l.pov -
at the bottom) that the direction vectors can be used for colors. 
 x = <1,0,0> (red)
 y = <0,1,0> (green)
 z = <0,0,1> (blue)

What's even better is that you can throw out the rgb reference if you use
vectors, i.e.:
 'pigment{color x}' = 'pigment{color rgb <1,0,0>}'

3. Vector Substitution

A constant 'C' will be interpreted as '<C,C,C>' if the parser needs a
vector. This can be quite useful since '1-z' is equivalent to '<1,1,0>',
but with less than half the bytes.

4. Spaces Are Optional

Brackets, braces, and parentheses are not the only characters that help
remove spaces. Povray does not require spaces before pound signs ('#'),
(sometimes) does not need spaces after numbers, and (sometimes) does not
need spaces before decimal points ('.'). The following will parse:
#macro a(b)#if(b<5)box{-1,1scale.5translate y-3pigment{color x}}#end#end

5. Reorder The Math

Watch for leading minus signs: they can sometimes be placed elsewhere in the
equation. For example '-x+1' can also be '1-x'. Also, place numbers last to
combine with #4 above and remove a space, i.e. 'translate 3+y pigment{color
x}' -> 'translate y+3pigment{color x}'

6. Isosurfaces

If you're using isosurfaces, don't forget that the default bounding box is
'contained_by{box{-1,1}}'. If your bounding box is the same size or smaller
(suck up that rendering time hit), remove the contained_by directive if you
don't need it. 

7. Scaling

When scaling in only one axis, it's customary to make all the other scaling
factors be one because scaling by zero is illegal, i.e. 'scale <1,1,10>'.
Povray converts all zero scaling factors to ones, so use 'scale 10*z'. 

Mike
--
http://povray.tashcorp.net


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.