POV-Ray : Newsgroups : povray.programming : Location of Noise() and VScale() in source? Server Time
28 Mar 2024 21:16:51 EDT (-0400)
  Location of Noise() and VScale() in source? (Message 1 to 4 of 4)  
From: Bald Eagle
Subject: Location of Noise() and VScale() in source?
Date: 19 Apr 2019 19:45:00
Message: <web.5cba5d793a7caf464eec112d0@news.povray.org>
I was just poking around in the turbulence code, and it references

Noise ()
and
VScale ()

I was wondering where those were located.

I tried

find -type f -exec grep -H ' Noise(' {} \;

But it's not in pattern, texture, normal, or fnintern (that I see)


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Location of Noise() and VScale() in source?
Date: 19 Apr 2019 23:35:00
Message: <web.5cba922955627606284a685a0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> I was just poking around in the turbulence code, and it references
>
> Noise ()
> and
> VScale ()
>
> I was wondering where those were located.
>
> I tried
>
> find -type f -exec grep -H ' Noise(' {} \;
>
> But it's not in pattern, texture, normal, or fnintern (that I see)

Hello Bill

There's a definition of Noise here:
https://github.com/POV-Ray/povray/blob/master/source/core/material/noise.h#L196

In which file did you see VScale ?

BTW: Have you ever tried Midnight Commander ?
I find it very easy to use when searching through a lot of files.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

From: Bald Eagle
Subject: Re: Location of Noise() and VScale() in source?
Date: 20 Apr 2019 08:20:00
Message: <web.5cbb0e56556276064eec112d0@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:

> Hello Bill

Hi TOK, long time no see   :)
Hope you're doing well.

> There's a definition of Noise here:
> https://github.com/POV-Ray/povray/blob/master/source/core/material/noise.h#L196

excellent.
I think with fresh eyes, I see that Noise is a call to PortableNoise - so maybe
that will let me trace the code  :)

inline DBL Noise(const Vector3d& EPoint, int noise_generator) { return
PortableNoise(EPoint, noise_generator); }

> In which file did you see VScale ?

VScale is called from the Turbulence function in texture.cpp

[I don't actually do any real C++, but it looks like "const TURB *Turb" is
declaring use of a constant named TURB which comes from - a class (?) or a
struct (?) or an internal private part of another part of the code called "Turb"
and "dereferences" that with the * ?
Similar later on with "int Octaves=Turb->Octaves;", Lambda and Omega.
I have only the most tenuous grasp of the dot . and arrow -> operators at this
point.]

DBL Turbulence(const VECTOR EPoint, const TURB *Turb, int noise_generator)
{
 int i;
 DBL Lambda, Omega, l, o, value;
 VECTOR temp;
 int Octaves=Turb->Octaves;

 if (noise_generator>1)
 {
  value = (2.0 * Noise(EPoint, noise_generator) - 0.5);
  value = min(max(value,0.0),1.0);
 } else {
  value = Noise(EPoint, noise_generator);
 }

 l = Lambda = Turb->Lambda;
 o = Omega  = Turb->Omega;

 for (i = 2; i <= Octaves; i++)
 {
  VScale(temp,EPoint,l);
  if (noise_generator>1)
   value += o * (2.0 * Noise(temp, noise_generator) - 0.5);
 else
  value += o * Noise(temp, noise_generator);
  if (i < Octaves)
  {
   l *= Lambda;
   o *= Omega;
  }
 }
 return (value);
}

and it resides in /source/backend/math/vector.h

inline void VScale(SNGL_VECT a, const SNGL_VECT b, SNGL k)
{
 a[X] = b[X] * k;
 a[Y] = b[Y] * k;
 a[Z] = b[Z] * k;
}


> BTW: Have you ever tried Midnight Commander ?
> I find it very easy to use when searching through a lot of files.


Nope.  I honestly haven't had the energy and the ability to focus on meticulous
things like this for a while - just so much IRL.
Work, the Plague, car repairs, etc........................................

But I keep hanging on by my fingernails   ;)

I'll take a look at M.C. and see what it's like - thanks for the tip!


Post a reply to this message

From: clipka
Subject: Re: Location of Noise() and VScale() in source?
Date: 20 Apr 2019 11:59:39
Message: <5cbb41eb$1@news.povray.org>
Am 20.04.2019 um 14:19 schrieb Bald Eagle:

> I think with fresh eyes, I see that Noise is a call to PortableNoise - so maybe
> that will let me trace the code  :)

(Technically, `Noise` _may or may not_ be a call to `PortableNoise` - 
that depends on how the binary is compiled, and possibly also the 
features of the CPU it is actually run on. But since it is always a call 
to either that function or an optimized variant that gives the same 
results (the infamous "optimized noise generator"), this distinction is 
only relevant when making changes to the function.)

> VScale is called from the Turbulence function in texture.cpp

My, that's some old code there!

`VScale(a,b,c)` was a function that implemented uniform linear scaling 
of a vector back in the days when we used the C-style 3-element array 
type `VECTOR` to store vectors. That type has been superseded by the 
class type `Vector3d`, which provides operator overloading for the same 
purpose, and instead of `VScale(a,b,c)` we would now write `a=b*c`.

(Also, the `Turbulence` function now resides in `noise.cpp`.)


Post a reply to this message

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