POV-Ray : Newsgroups : povray.binaries.images : worley noise (not POV-Ray) Server Time
1 Apr 2025 16:53:09 EDT (-0400)
  worley noise (not POV-Ray) (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: ingo
Subject: worley noise (not POV-Ray)
Date: 23 Mar 2025 11:20:00
Message: <web.67e026263742ca0917bac71e8ffb8ce3@news.povray.org>
A plane cut through 4D worleynoise, with a different distance method than
ususal. I used cosine_distance = 1.0 - cosineSimilarity(p, q)
https://en.wikipedia.org/wiki/Cosine_similarity

In each cell a feature vector is created based on the (random) feature point in
it.

for i in featurepoint.len:
  sin(featurePoint[i] * 12.9898 + float(i) * 78.233 + float(worley.seed) *
4.1414) * 0.5 + 0.5

then while rendering another vector is created at the hit point:
  for i in 0..<p.len:
    pointVec[i] = sin(p[i] * 12.9898 + float(i) * 43.5453) * 0.5 + 0.5

now the cosine distances are calculated between the point and nearest
neighbours.

Done in Nim as I couldn't get it going in POV-Ray.

proc cosineSimilarity*(p, q: Point): float =
  ## Calculates the cosine similarity between two vectors.

  if p.len != q.len:
    raise newException(ValueError, "Vectors must have the same dimensions")
  var dotProduct = 0.0
  var normP = 0.0
  var normQ = 0.0
  for i in 0..<p.len:
    dotProduct += p[i] * q[i]
    normP += p[i] * p[i]
    normQ += q[i] * q[i]
  normP = sqrt(normP)
  normQ = sqrt(normQ)
  if normP == 0 or normQ == 0:
    raise newException(ValueError, "Cannot calculate similarity for zero
vector")
  result = dotProduct / (normP * normQ)


proc cosineDistance*(p, q: Point): float =
  ## Calculates the cosine distance between two vectors.
  ## D(p,q) = 1 - cos(θ)
  result = 1.0 - cosineSimilarity(p, q)


ingo


Post a reply to this message


Attachments:
Download 'worley4d_cosine_standard_plane.png' (140 KB)

Preview of image 'worley4d_cosine_standard_plane.png'
worley4d_cosine_standard_plane.png


 

From: jr
Subject: Re: worley noise (not POV-Ray)
Date: 23 Mar 2025 15:45:00
Message: <web.67e063d083b3e9b4c342f2ec6cde94f1@news.povray.org>
hi,

"ingo" <nomail@nomail> wrote:
> A plane cut ...

to reveal new rabbit holes.. :-)



> Done in Nim as I couldn't get it going in POV-Ray.

I liked the image you posted, so hope you keep looking at a SDL solution.  (feel
free to email, fwiw)


regards, jr.


Post a reply to this message

From: ingo
Subject: Re: worley noise (not POV-Ray)
Date: 24 Mar 2025 12:05:00
Message: <web.67e182a083b3e9b417bac71e8ffb8ce3@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> hi,
>
> "ingo" <nomail@nomail> wrote:
> > A plane cut ...
>
> to reveal new rabbit holes.. :-)

My main problem (rabbit hole) was to come up with a Hash macro. But this morning
I thought, POV-Ray has deterministic noise. Use that.

- Shoot ray at point.
- floorInt floorInt ... for as many dimensions you neeed (POV: 3) and get to the
cell corners.
- Get noise values at corners an use them to come up with a feature point in
that cell. (this I do now by hashing the coordinates of the point and a seed)
- Do it for all the neighbour cells.
- for reuse, stick cell id and feature point in a small Least Recently Used
(LRU) Cache. One only needs to cache ~ 10 points to be near the optimum
speed/memory. That (rabbit hole) will be quite a thing to code with lots of
array's doubly linked lists etc. and might not be faster that recalculation.
- from there on you can do the usual sorted / minimum distance thing for Worley
noise.

ingo


Post a reply to this message

From: Bald Eagle
Subject: Re: worley noise (not POV-Ray)
Date: 24 Mar 2025 17:35:00
Message: <web.67e1cff983b3e9b41f9dae3025979125@news.povray.org>
"ingo" <nomail@nomail> wrote:

Thanks for cosine similarity - that might come in handy in the future.
One or more macros would be nice to have in a library.

> Done in Nim as I couldn't get it going in POV-Ray.

What part wasn't working?
The algorithm, or the display of the result?

This looks like the falling characters from the Matrix.
Would be cool to do in color.

- BW


Post a reply to this message

From: Bald Eagle
Subject: Re: worley noise (not POV-Ray)
Date: 24 Mar 2025 18:40:00
Message: <web.67e1dec583b3e9b41f9dae3025979125@news.povray.org>
This got me thinking.

I played around with "plotting" discs at random points in unit cells with the
aim to do a Voronoi type thing.
(with pigment {function {}} )

Which would be sort of redundant with inbuilt crackle.

But if I connected the center cell seed with all 8 surrounding seeds ...
(with cylinders)

and that gave me this faux Delaunay triangulation.
Just because it winds up being X's and not triangles.
But it has that look.


- BW


Post a reply to this message


Attachments:
Download 'unitcellpoints.png' (1683 KB)

Preview of image 'unitcellpoints.png'
unitcellpoints.png


 

From: ingo
Subject: Re: worley noise (not POV-Ray)
Date: 25 Mar 2025 03:25:00
Message: <web.67e2539a83b3e9b417bac71e8ffb8ce3@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> This got me thinking.
> [...]
> But it has that look.
>
>

Wrinkeled paper or weave. nice.

One could do something similar in 3d and create a landscape with it. Use cells
stretched in y direction.

Your cylinders are normals of planes. If you "flip" them so that centre cell is
inside the plane you can intersect all the planes of the neighbour cells to get
a voronoi cell. I posted images of that in the past, can't find them.

Worley noise is a "project" I've come back to every now and then.

I used basic Worley nD noise as a seed for n dimensional Markov chains, also to
grow voxel landscapes or clouds. It uses separation layers or separation sets to
influence the growth towards a target. But that's on hold for the moment, makes
my brain hurt.

Another one I' looking into is Dynamic Time Warping. Some howe create paths
using feature points and then use DTW as a distance metric for the Worley noise.
Currently paths form feature point to feature point with perturbations. But not
getting results yet.
https://en.wikipedia.org/wiki/Dynamic_time_warping

Other experiments, use the anisotropy of the convex hull around the neighbour
feature points to influence directionality of noise. Didn't work out. Tiled
Worley works well. Warped Worley works well. Tiled warped Worley kind of works.
Turning feature points into blobs works but is hard to control.

Why I use Nim? 24 threads of compiled language vs. 1 in interpreted.
When files get bigger and more, I loose oversight in POV-Ray. All the #'s
distract and it gets more difficult to get to a specific part of the code.

ingo


Post a reply to this message

From: William F Pokorny
Subject: Re: worley noise (not POV-Ray)
Date: 25 Mar 2025 06:38:47
Message: <67e287b7$1@news.povray.org>
On 3/24/25 18:37, Bald Eagle wrote:
> But if I connected the center cell seed with all 8 surrounding seeds ...
> (with cylinders)
> 
> and that gave me this faux Delaunay triangulation.
> Just because it winds up being X's and not triangles.
> But it has that look.

Looks cool!

Bill P.


Post a reply to this message

From: Bald Eagle
Subject: Re: worley noise (not POV-Ray)
Date: 25 Mar 2025 08:30:00
Message: <web.67e2a17683b3e9b46563700825979125@news.povray.org>
"ingo" <nomail@nomail> wrote:

> Your cylinders are normals of planes. If you "flip" them so that centre cell is
> inside the plane you can intersect all the planes of the neighbour cells to get
> a voronoi cell. I posted images of that in the past, can't find them.

Yes, but CSG with infinite objects is bad juju, IIRC.  Slow.

> Worley noise is a "project" I've come back to every now and then.

https://news.povray.org/5886499c%241%40news.povray.org


> Another one I' looking into is Dynamic Time Warping. Some howe create paths
> using feature points and then use DTW as a distance metric for the Worley noise.
> Currently paths form feature point to feature point with perturbations. But not
> getting results yet.
> https://en.wikipedia.org/wiki/Dynamic_time_warping
>
> Other experiments, use the anisotropy of the convex hull around the neighbour
> feature points to influence directionality of noise.

Would that be sort of like a function gradient?

> Didn't work out. Tiled
> Worley works well. Warped Worley works well. Tiled warped Worley kind of works.

Are you just using mod(<x, y, z>, N) ?

> Turning feature points into blobs works but is hard to control.

Maybe use cylinders with lengths based on distance to the other point it's being
blobbed with.  Otherwise a static strength value for a sphere is hard to tailor
to multiple neighbors.

> Why I use Nim? 24 threads of compiled language vs. 1 in interpreted.

YES.


Post a reply to this message

From: ingo
Subject: Re: worley noise (not POV-Ray)
Date: 26 Mar 2025 04:15:00
Message: <web.67e3b76783b3e9b417bac71e8ffb8ce3@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:


> https://news.povray.org/5886499c%241%40news.povray.org

Ah, thanks for that one.

>[....]
> > Other experiments, use the anisotropy of the convex hull around the neighbour
> > feature points to influence directionality of noise.
>
> Would that be sort of like a function gradient?

Yes. One of the things I'm trying is to modulate the noise somehow, but it
mostly fails except with turbulence/warp


> > Tiled Worley works well. Warped Worley works well. Tiled warped Worley kind of
works.
>
> Are you just using mod(<x, y, z>, N) ?

Yes, as well for the current point as for the cell. When warped the points may
leave the boundary of a cell so the result is not exact. It does not generate
identical tiles, but similar tiles.


> > Turning feature points into blobs works but is hard to control.
>
> Maybe use cylinders with lengths based on distance to the other point it's being
> blobbed with.

Hadn't thought of cylinders. I'v been working on stretched, oval, blobs base on
maximum an minimum neighbour distance.


Post a reply to this message


Attachments:
Download 'warpedtilednormalized.png' (314 KB)

Preview of image 'warpedtilednormalized.png'
warpedtilednormalized.png


 

From: Bald Eagle
Subject: Re: worley noise (not POV-Ray)
Date: 26 Mar 2025 09:05:00
Message: <web.67e3fb5683b3e9b46563700825979125@news.povray.org>
"ingo" <nomail@nomail> wrote:

> > > Other experiments, use the anisotropy of the convex hull around the neighbour
> > > feature points to influence directionality of noise.
> >
> > Would that be sort of like a function gradient?
>
> Yes. One of the things I'm trying is to modulate the noise somehow, but it
> mostly fails except with turbulence/warp
>
>
> > > Tiled Worley works well. Warped Worley works well. Tiled warped Worley kind of
works.
> >
> > Are you just using mod(<x, y, z>, N) ?
>
> Yes, as well for the current point as for the cell. When warped the points may
> leave the boundary of a cell so the result is not exact. It does not generate
> identical tiles, but similar tiles.

I have a vague sense of what you're doing.
I probably ran into related issues here:
https://news.povray.org/web.6394be0a7dc652cc1f9dae3025979125%40news.povray.org

You might have to look at the order that you're doing things in?
Can you define a warp as a transform to be used in a function?

> > > Turning feature points into blobs works but is hard to control.
> >
> > Maybe use cylinders with lengths based on distance to the other point it's being
> > blobbed with.
>
> Hadn't thought of cylinders. I'v been working on stretched, oval, blobs base on
> maximum an minimum neighbour distance.

Very cool.
I usually forget about cylinders in blobs as well.

- BW


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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