POV-Ray : Newsgroups : povray.advanced-users : vturbulence in functions? Server Time
25 Nov 2024 19:42:42 EST (-0500)
  vturbulence in functions? (Message 1 to 9 of 9)  
From: Rune
Subject: vturbulence in functions?
Date: 28 Mar 2002 12:22:24
Message: <3ca35150@news.povray.org>
I need something equivalent to vturbulence() which I can use in a function.
I would then have used it with the .x, .y, and .z operators, just like with
pigment functions. Any idea what I can do?

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:  http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Ring:  http://webring.povray.co.uk


Post a reply to this message

From:
Subject: Re: vturbulence in functions?
Date: 28 Mar 2002 12:32:38
Message: <ahk6au8bcquigiasedibqqast2chjm3u8r@4ax.com>
On Thu, 28 Mar 2002 18:23:00 +0100, "Rune" <run### [at] mobilixnetdk>
wrote:
> I need something equivalent to vturbulence() which I can use in a function.
> I would then have used it with the .x, .y, and .z operators, just like with
> pigment functions. Any idea what I can do?

Noise function is wrong ?
Just use it with some factors, mirrors, etc.
For example:

#include "functions"
#local f_turb_x=function{f_noise(x,y,z)};
#local f_turb_y=function{f_noise(y*2,z*3,x*4)};
#local f_turb_z=function{f_noise(z/2,x/3,y*4)};
#local my_function=function{...};
#local my_turbulenced_function=function{my_function(
  f_turb_x(x,y,z),
  f_turb_y(x,y,z),
  f_turb_z(x,y,z)
)};

ABX


Post a reply to this message

From:
Subject: Re: vturbulence in functions?
Date: 28 Mar 2002 13:03:37
Message: <eam6aucin1odd97vo136br3orqubat7kk8@4ax.com>

wrote:
> Noise function is wrong ?

At least wrong in posted example. I forgot that turbulence should be added to
coordinates. I also forgot that turbulence shoudn't have only positive values.
Here is corrected version, written in more compact way:

#include "functions"
#local my_function=function{...};
#local my_turbulenced_function=

function{my_function(x+f_snoise3d(x,y,z),y+f_snoise3d(y*2,z*3,x*4),z+f_snoise3d(z/2,x/3,y/4))};

Is this enough for you ?

ABX


Post a reply to this message

From: Rune
Subject: Re: vturbulence in functions?
Date: 28 Mar 2002 15:07:15
Message: <3ca377f3@news.povray.org>
"Wlodzimierz ABX Skiba" wrote:
> > Noise function is wrong ?

Turbulence returns a vector for each point in space. f_noise3d returns a
value for each point in space and thus can't simulate turbulence.

> Is this enough for you ?

I'm afraid not...

Just using some factors, mirrors, etc. together with the noise function will
not give an even distribution of the turbulence, as it will in average be
greater in the 8 corners of a cube.

Besides, turbulence has a level of chaos defined by the number of octaves,
while the noise function has no level of chaos at all. This is not so
important in my case though. The important thing is that I need an even
distribution so that the turbulence is equally strong in all directions.

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:  http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Ring:  http://webring.povray.co.uk


Post a reply to this message

From: Christopher James Huff
Subject: Re: vturbulence in functions?
Date: 28 Mar 2002 17:15:37
Message: <chrishuff-B79BBC.17162328032002@netplex.aussie.org>
In article <3ca377f3@news.povray.org>,
 "Rune" <run### [at] mobilixnetdk> wrote:

> Turbulence returns a vector for each point in space. f_noise3d returns a
> value for each point in space and thus can't simulate turbulence.

Turbulence is based on 3D noise. Just use 3 calls to f_noise3d(), each 
with a random offset.


> Besides, turbulence has a level of chaos defined by the number of octaves,
> while the noise function has no level of chaos at all. This is not so
> important in my case though. The important thing is that I need an even
> distribution so that the turbulence is equally strong in all directions.

Use more noise3d() calls at different scales. That is exactly what the 
octaves parameter does.
Look up some pages on Perlin noise for more ideas...

This will be slower than a built-in function, of course. You might try 
and see if you can get the right result by using the function as a 
pattern and turbulating the pattern, then using the pattern as a 
function.

function {pattern {function {FUNCTION} turbulence...}}
FUNCTION will get the turbulated versions of the xyz parameters.

You could also do this to use those values in addition to the 
unturbulated values in a separate function:

#declare turb_x = function {pattern {function {x} turbulence...}}
#declare turb_y = function {pattern {function {y} turbulence...}}
#declare turb_z = function {pattern {function {z} turbulence...}}

The distance turbulence pushes a point (the output of the vturbulence() 
function) would be: < turb_x(x) - x, turb_y(y) - y, turb_z(z) - z>

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Rune
Subject: Re: vturbulence in functions?
Date: 28 Mar 2002 19:55:40
Message: <3ca3bb8c@news.povray.org>
"Christopher James Huff" wrote:
> Turbulence is based on 3D noise. Just use 3 calls
> to f_noise3d(), each with a random offset.

As I said, this will give an uneven distribution. The range of the noise
will have the shape of a box rather than a sphere.

> Use more noise3d() calls at different scales.

Yes, yes, I know, but this is way too slow. It also doesn't solve the
problem above. I don't understand why turbulence is not directly available
in functions somehow. A special warp function would be an obvious addition
to the existing pigment function and transform function, which all return
vectors.

> You might try and see if you can get the right result by
> using the function as a pattern and turbulating the
> pattern, then using the pattern as a function.

> function {pattern {function {FUNCTION} turbulence...}}

I make use of more than the default x y z values in functions. How do I pass
on those from the outer function to the inner function when there's a
pattern wrapper in the way?

> You could also do this to use those values in addition to the
> unturbulated values in a separate function:
>
> #declare turb_x = function {pattern {function {x} turbulence...}}
> #declare turb_y = function {pattern {function {y} turbulence...}}
> #declare turb_z = function {pattern {function {z} turbulence...}}
>
> The distance turbulence pushes a point (the output of the vturbulence()
> function) would be: < turb_x(x) - x, turb_y(y) - y, turb_z(z) - z>

Except that the pattern wrapper will mod the x, y, and z function to cycle
in the 0 to 1 range.

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:  http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Ring:  http://webring.povray.co.uk


Post a reply to this message

From: Christopher James Huff
Subject: Re: vturbulence in functions?
Date: 29 Mar 2002 09:20:18
Message: <chrishuff-E18C28.09210729032002@netplex.aussie.org>
In article <3ca3bb8c@news.povray.org>,
 "Rune" <run### [at] mobilixnetdk> wrote:

> As I said, this will give an uneven distribution. The range of the noise
> will have the shape of a box rather than a sphere.

Noise won't give an even distribution anyway. I think this is the way 
POV combines them though. You can't just throw away bad points and try 
again, like you can with random points. Transforming a cube distribution 
into a spherical one would probably be more trouble than it's worth, and 
slow turbulence down a lot.
You could get something fairly close by simply normalizing the result, 
though.


> I don't understand why turbulence is not directly available in 
> functions somehow. A special warp function would be an obvious 
> addition to the existing pigment function and transform function, 
> which all return vectors.

The vturbulence() function isn't available because it is a vector 
function. The handling of vectors in user-defined functions isn't 
complete yet, that kind of thing will probably happen in later versions.
A warp function analogous to the transform functions would be very 
useful, and I think it's been suggested before...but if you look at the 
code, warps are pretty embedded in patterns. It might have been decided 
it was better to wait until that code was in better shape (or to wait 
for 4.0).


> Except that the pattern wrapper will mod the x, y, and z function to cycle
> in the 0 to 1 range.

I forgot about that...well, the workaround is to scale it down into the 
[0, 1] range in the function and scale it back outside.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Rune
Subject: Re: vturbulence in functions?
Date: 29 Mar 2002 15:42:23
Message: <3ca4d1af@news.povray.org>
"Christopher James Huff" wrote:
> Noise won't give an even distribution anyway.
> I think this is the way POV combines them though.

Well I don't know. Try to render the code below with different values of
Freq.

#declare Freq = 6.2;
#declare C = 10000;
#while (C>0)
   sphere {
      vturbulence(2,0.5,1,Freq*C), 0.05
      pigment {rgb 10}
   }
   #declare C = C-1;
#end
camera {location -100*z look_at 0 angle 3}
plane {-z,-10 pigment {checker rgb 6, rgb 7}}

Setting Freq to any non-integer value gives a rather spherical distribution.
But setting Freq to an integer value gives an exact box-shaped distribution.
More strangely, it seems to be the exact same distribution no matter which
integer value you choose! I find this very confusing, and I think it's
related to the grid-like appearances in the noise pattern.

> A warp function analogous to the transform functions
> would be very useful, and I think it's been suggested
> before...but if you look at the code, warps are pretty
> embedded in patterns. It might have been decided it was
> better to wait until that code was in better shape
> (or to wait for 4.0).

I can only hope...

> I forgot about that...well, the workaround is to scale
> it down into the [0, 1] range in the function and scale
> it back outside.

What do you mean? Using atan2() and tan(), or...?

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:  http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Ring:  http://webring.povray.co.uk


Post a reply to this message

From: Christopher James Huff
Subject: Re: vturbulence in functions?
Date: 29 Mar 2002 16:04:16
Message: <chrishuff-8D0B68.16050529032002@netplex.aussie.org>
In article <3ca4d1af@news.povray.org>,
 "Rune" <run### [at] mobilixnetdk> wrote:

> > I forgot about that...well, the workaround is to scale
> > it down into the [0, 1] range in the function and scale
> > it back outside.
> 
> What do you mean? Using atan2() and tan(), or...?

Well, that's something I hadn't thought of...I was actually talking 
about doing something like having the function return x/TurbSclFact and 
using turb_x(x, y, z)*TurbSclFact, where TurbSclFact is some big value. 
Basically, move the problem somewhere where it probably won't bother 
you. As I said, it is a workaround...
Your idea of using atan2 and tan might work better though...

What I would really like is for patterns to return unclipped values. The 
clipping would be done by the waveforms, for example, "ramp_wave 0, 1" 
would repeatedly ramp from 0 to 1 as the input range increases. You 
would also be able to apply different waveforms to further modify the 
pattern output. Phase and frequency would also be waveform modifiers.

If you don't want to have to specify a waveform for every pattern, there 
could be a default waveform that would be overridden by user-specified 
waveforms...you could specify "no_waveform" or something to get the raw 
pattern output when you need it.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

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