POV-Ray : Newsgroups : povray.binaries.images : A method creat uniform thick shell : Re: A method creat uniform thick shell Server Time
7 May 2024 11:20:37 EDT (-0400)
  Re: A method creat uniform thick shell  
From: Mike Horvath
Date: 29 Jul 2018 17:25:00
Message: <5b5e30ac$1@news.povray.org>
On 7/29/2018 3:57 PM, Tor Olav Kristensen wrote:
> fn_Gradient() is not a function. It is a macro within math.inc. When you pass a
> function to this macro it will create and return a new function that estimates
> the magnitude of the gradient of the function that you passed to it.
> 
> The function that you pass to this macro must take 3 arguments; usually x, y and
> z (but their names doesn't really matter). And the function that it returns
> takes 3 arguments.
> 
> --
> Tor Olav
> http://subcube.com
> 

I tried this code:

#declare f_test = function(var1,var2,var3) 
{pow(var1,2)+pow(var2,2)+pow(var3,2)-1-0.5*f_noise3d(var1*3,var2*3,var3*3)}
#declare f_normalized = function(var1,var2,var3,varA,varB,varC) 
{f_test(var1,var2,var3)/sqrt(4*pow(var1,2)/pow(varA,4)+4*pow(var2,2)/pow(varB,4)+4*pow(var3,2)/pow(varC,4))}

and this code:

SetGradientAccuracy(0.0001)
#declare f_test= function {x*x+y*y+z*z-1-0.5*f_noise3d(x*3,y*3,z*3)}
#declare f_input = function {f_test(x,y,z)}
#declare GradientFn = fn_Gradient(f_input)
#declare f_normalized = function {f_input(x,y,z)/GradientFn(x,y,z)}

And the latter was much slower. Is there a way to speed it up?


Mike


Post a reply to this message

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