POV-Ray : Newsgroups : povray.general : POV-Ray speed guide : Re: POV-Ray speed guide Server Time
2 Aug 2024 16:24:02 EDT (-0400)
  Re: POV-Ray speed guide  
From: Tor Olav Kristensen
Date: 17 Nov 2004 23:43:49
Message: <419c2885$1@news.povray.org>
Florian Brucker wrote:
...
>> * The thread about functions you link to contains some wrong information.
> 
>  > [constant expressions evaluated at parse time]
> 
> But it still true that using internal functions for non-constant 
> expressions is faster than using user defined functions, isn't it? As 
> mentioned in that paragraph the subject is above my level of knowledge, 
> so I just quoted Tor's post. I hope I can do some benchmarks myself 
> about it.

Florian,

most of the speedup of Alex Kluchikov's isosurface  code was
due to my use of "temporary" functions to receive pre-
calculated values passed as arguments from other functions.
I found this to be a good way to overcome POV-Ray's lack of
local variables for functions. (This seems to be a common
technique around here now ;)

Back in 2002 I wanted to find a way to make my "Almost Sphere
Spirals" (at POV-Ray HOF) image render faster. First I thought
that if I could rearrange the functions so that they were
easier to read and understand, then maybe afterwards I could
manage to simplify and speed things up. I was quite frustrated
that I couldn't use local variables. Suddenly I got the idea
mentioned above. And fortunately this rearranging also
resulted in code that renders much faster than my original
code. (Now this solution seems obvious to me, but back then it
was a lot of work before I arrived at it.)

Different versions of my SphereSpiralsFunction(), that defines
that shape, can be found here (if anyone is interested):

http://news.povray.org/3C549C14.A9009E4@online.no
http://news.povray.org/povray.text.scene-files/20990/
http://home.no/t-o-k/POV-Ray/Riemann_Sphere-Isosurface.txt


Regarding Thorsten's comment:
My impression from the beta testing of POV-Ray v3.5 was that
internal functions evaluated faster than similar user defined
functions, so I might have assumed that this was still the
case when I wrote that code. I need to test this some day...

(But even if it is now not faster to use internal functions
and "precalculated" constants, I think it is a good
programming practice that results in more readable and less
error prone code.)

-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

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