POV-Ray : Newsgroups : povray.general : Minimum Distance Function : Re: Minimum Distance Function Server Time
15 Aug 2022 09:56:13 EDT (-0400)
  Re: Minimum Distance Function  
From: jceddy
Date: 6 Jul 2022 21:35:00
Message: <web.62c6375e6fb4e448bf6748e65d51d79c@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jceddy" <jce### [at] gmailcom> wrote:
> > Is there already functionality implementing a minimum distance to an arbitrary
> > object that I missed? I looked for one, but haven't actually asked directly.
> I don't believe there is - accessible from the SDL, anyway.  I know that in the
> past, people have asked about ways to make pigment patterns based on the
> distance of an object from the camera.
> Can't find those threads at the moment...
> > I am still playing with it a bit, but am thinking that if it might be useful for
> > other folks, I should do it "right" so I can submit it over on github.
> You are correct - it would be a useful thing to have.
> >on the
> > right the the object rendered as an isosurface using the minimum distance
> > function with a very short annealing period (BTW, the function flips the sign to
> > negative for points inside the object, so you have a clean 0.0 threshold at the
> > surface of the object).
> So, I'm curious, and confused.
> This sounds a lot like ray-marching, mixed with signed distance functions.
> And how are you taking an algorithm and having that work with a function {} ?
> I don't know what you're exactly doing, or the details of how simulated
> annealing work, but I'd likely approach this (naively, wrongly) by using the
> bounding box and trace (), and only scanning a grid of points corresponding to
> the resolution of the render, arranged on a plane just behind the bounding box
> and perpendicular to the camera to look_at vector.
> And that sounds like a macro more than a proper function...
> - Bill

After cruising around the forums a bit, I realize that I probably should have
posted this in programming instead of general.

I actually changed the povray source code to add a new built-in function type,
and patter type to call directly. The implementation is in the C++ source and
just exposed to SDL via a couple of new parser directives.

On my phone ATM, so will probably put something over in programming later
(unless there is a way for a forum admin to just move this thread or something).

I'm currently experimenting with some other options besides simulated annealing
for improving the initial estimate...simulated annealing is good for general
purpose because it helps avoid finding locally optimal solutions when it is not
the globally optimal one. For a lot of purposes though, a quick simple march of
rays could be good and fast enough, or even doing what I am doing now and then
just a simple gradient descent around the initial estimate to find the nearest
locally optimal solution.

It could be that a minimum_distance implementation could come with a few options
to allow the user to choose between different methods to balance
quality/performance and pick what works best with what they are doing.

Post a reply to this message

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