POV-Ray : Newsgroups : povray.advanced-users : Stochastics expertise needed Server Time
2 May 2024 00:22:12 EDT (-0400)
  Stochastics expertise needed (Message 17 to 26 of 26)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: lelama
Subject: Re: Stochastics expertise needed
Date: 27 Aug 2016 05:30:00
Message: <web.57c15b268629941b7a63dc9f0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 27.08.2016 um 05:49 schrieb clipka:
> > Am 27.08.2016 um 01:18 schrieb lelama:
> >
> >> You parametrize your sphere by t,y using the formula  x= r cos t, y,z= r sin t
> >> with  y in [-1,1] and r=sqrt(1-y^2).
> >>
> >> Then you choose t uniformly, and for y, you choose your distribution as you want
> >> (this is you free parameter). Then the density around a point x,y,z depends only
> >> on y.
> > ....
> >> This shoud satisfy all your needs if I'm not wrong.
> >
> > Gee, I you have indeed nailed it!
>
> Hm... this still leaves me with a quest for an easy-to-generate random
> distribution in the range [0..1) with a nicely configurable peak at 0,
> and an easy-to-compute probability density function.
>
> I guess I want the derivative of the probability density function to be
> zero at the peak, and ideally also at 1.

Hi,

There is a proposal at the end of my previous message. Using uniform
distribution for y,t,d and throwing away some "bad" points, you get
whatever distribution you want. If you don't like the piecewised
affine d that I suggested (the derivative of the density probabilty is not zero
at y=1, so maybe not suitable for you), you can choose any positive function d
instead with the same construction.

By the way, the parameter c1 is not useful in my formula for the function d. One
can take c1=1 and adjust only the parameters p ( p close to 1 means that the
peak is very localised around y=1 ) and c2 ( the higher the c2, the bigger the
difference of intensity between y=1 and the zone with low uniform intensity).

have a good day,


Post a reply to this message

From: clipka
Subject: Re: Stochastics expertise needed
Date: 27 Aug 2016 06:13:24
Message: <57c167c4$1@news.povray.org>
Am 27.08.2016 um 11:26 schrieb lelama:

>> Hm... this still leaves me with a quest for an easy-to-generate random
>> distribution in the range [0..1) with a nicely configurable peak at 0,
>> and an easy-to-compute probability density function.
>>
>> I guess I want the derivative of the probability density function to be
>> zero at the peak, and ideally also at 1.
> 
> Hi,
> 
> There is a proposal at the end of my previous message. Using uniform
> distribution for y,t,d and throwing away some "bad" points, you get
> whatever distribution you want. If you don't like the piecewised
> affine d that I suggested (the derivative of the density probabilty is not zero
> at y=1, so maybe not suitable for you), you can choose any positive function d
> instead with the same construction.

The monte-carlo approach of generating arbitrarily distributed random
numbers is only practical if the points to throw away are reasonably
few, in other words if d(y)>>0 for most of the function. Unfortunately
that's specifically not the case I'm aiming for -- I want d(y)>>0 only
in a small portion near y=0.


Post a reply to this message

From: lelama
Subject: Re: Stochastics expertise needed
Date: 27 Aug 2016 07:05:01
Message: <web.57c172d08629941b7a63dc9f0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 27.08.2016 um 11:26 schrieb lelama:
>
> >> Hm... this still leaves me with a quest for an easy-to-generate random
> >> distribution in the range [0..1) with a nicely configurable peak at 0,
> >> and an easy-to-compute probability density function.
> >>
> >> I guess I want the derivative of the probability density function to be
> >> zero at the peak, and ideally also at 1.
> >
> > Hi,
> >
> > There is a proposal at the end of my previous message. Using uniform
> > distribution for y,t,d and throwing away some "bad" points, you get
> > whatever distribution you want. If you don't like the piecewised
> > affine d that I suggested (the derivative of the density probabilty is not zero
> > at y=1, so maybe not suitable for you), you can choose any positive function d
> > instead with the same construction.
>
> The monte-carlo approach of generating arbitrarily distributed random
> numbers is only practical if the points to throw away are reasonably
> few, in other words if d(y)>>0 for most of the function. Unfortunately
> that's specifically not the case I'm aiming for -- I want d(y)>>0 only
> in a small portion near y=0.


Hmm, Yes, I see your objection.

A possibility then is to divide the surface under the graph of the function d
into smaller parts. For instance, in the piecewise affine case, the area under
the graph can be decomposed as a union of a rectangle R with measure r and a
triangle T with measure t . It is not too hard to make a uniform distribution
for points in R and an other uniform distribution for points in T.

Let t0,r0 be integers such that (t0,r0) is a vector proportional to the
measusrements (t,r) of the triangle and the rectangle.

Then choosing alternativly t points in the Triangle and r points in the
Rectangle with the uniform distributions discussed above yield the required
distribution without the problem you mentioned.

hth,
Laurent.


Post a reply to this message

From: Bald Eagle
Subject: Re: Stochastics expertise needed
Date: 27 Aug 2016 07:40:00
Message: <web.57c17b018629941b5e7df57c0@news.povray.org>
I have to be out for most of the day today, but I figured if we were searching
for a "bicycle" that already exists, then a search ought to pick up a nice
parametrizable equation.

I started off with blackbody and Maxwell-Boltzmann distributions, but then
enough coffee kicked in...   ;)

https://www.google.com/#q=brdf+code

http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
https://support.solidangle.com/pages/viewpage.action?pageId=5800819

https://www.google.com/#q=highlight+reflection+distribution


What's the "input" for this algorithm?  A vector?   I'm assuming that the output
is just the vector on the unit sphere.  I'm trying to visualize where this
"plugs in" to the pixel-evaluation chain of events.


Post a reply to this message

From: clipka
Subject: Re: Stochastics expertise needed
Date: 27 Aug 2016 08:41:49
Message: <57c18a8d$1@news.povray.org>
Am 27.08.2016 um 13:35 schrieb Bald Eagle:
> I have to be out for most of the day today, but I figured if we were searching
> for a "bicycle" that already exists, then a search ought to pick up a nice
> parametrizable equation.
> 
> I started off with blackbody and Maxwell-Boltzmann distributions, but then
> enough coffee kicked in...   ;)
> 
> https://www.google.com/#q=brdf+code
> 
> http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
> https://support.solidangle.com/pages/viewpage.action?pageId=5800819
> 
> https://www.google.com/#q=highlight+reflection+distribution
> 
> 
> What's the "input" for this algorithm?  A vector?   I'm assuming that the output
> is just the vector on the unit sphere.  I'm trying to visualize where this
> "plugs in" to the pixel-evaluation chain of events.

Congratulations, it seems like you've just found out what a BRDF is...
now to my problem of generating random numbers with a distribution that
is reasonably close to a given BRDF (in order to get an efficient
sampling), while keeping track of the probability of the numbers we're
generating (in order to compensate for the virtually inevitable mismatch) ;)


Post a reply to this message

From: Bald Eagle
Subject: Re: Stochastics expertise needed
Date: 1 Sep 2016 18:20:00
Message: <web.57c8a8e08629941b5e7df57c0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> Congratulations, it seems like you've just found out what a BRDF is...
> now to my problem of generating random numbers with a distribution that
> is reasonably close to a given BRDF (in order to get an efficient
> sampling), while keeping track of the probability of the numbers we're
> generating (in order to compensate for the virtually inevitable mismatch) ;)

Thanks!   Do I win a prize?   :D

So, after skimming some of the literature, I have a much better idea of what
you're specifically looking for - some form of Importance Sampling.

If you can post a graph of the BRDF that you're trying to simulate for the
purposes of your sampling algorithm, or a means of plotting it themselves, then
that might give anyone following along a nudge forward.

It seems that for any given function plotted between A and B, the probability of
having X land in that interval is the integral (S) of that function.

So, for my square root spline sampling function, f(x) = pow(x, 0.5)
so S(pow(x, 0.5) = 1/1.5 * pow(x, 1.5).

Also,

My apologies, but I'm trying to figure out what you actually mean when you say
"keep track of the probability..."

Do you tallying up the actual results of the random sampling so that you can do
a summation and then divide by the number of random samples?


Post a reply to this message

From: clipka
Subject: Re: Stochastics expertise needed
Date: 2 Sep 2016 01:30:30
Message: <57c90e76$1@news.povray.org>
Am 02.09.2016 um 00:17 schrieb Bald Eagle:

> So, after skimming some of the literature, I have a much better idea of what
> you're specifically looking for - some form of Importance Sampling.

Yes, that's what the experts call it.

> If you can post a graph of the BRDF that you're trying to simulate for the
> purposes of your sampling algorithm, or a means of plotting it themselves, then
> that might give anyone following along a nudge forward.

I can't. That's the crux of the matter: The algorithm needs to cope with
varying BRDFs. It might be Lambertian with a Phong highlight, or
Oren-Nayar with a Blinn-Phong highlight, or (in the future) maybe
Cook-Torrance, He-Torrance, Ward, Schlick, Lafortune, or whatever smart
brains may still come up with and someone decides to implement in POV-Ray.

I therefore intend to use a very simple approximation to generate my
sampling distribution, and compensate for the difference to the BRDF
(which, by the way, may actually not even be a true BRDF, such as
anything involving POV-Ray's brilliance model) by multiplying the
computed colour of the sample with the BRDF (which will actually be
hidden away in the sample computation) and then dividing it by the
probability that my sampling direction generator spits out that
particular sampling direction.

What exact formula to use is something I leave up to whoever can provide
a viable solution.

To give you a rouhg idea at what I'm aiming for, you might try the Phong
model:

    f(L,V) = k (Lm . V) ^n

where Lm is L mirrored at the surface normal.


> Also,
> 
> My apologies, but I'm trying to figure out what you actually mean when you say
> "keep track of the probability..."

What I mean by that is that I want to know the probability density
function of the sample directions.

> Do you tallying up the actual results of the random sampling so that you can do
> a summation and then divide by the number of random samples?

Something along those lines, yes. But I need to weigh the individual
samples by the probability density function of the sample direction
generator (or, more precisely, by the reciprocal thereof).


Post a reply to this message

From: scott
Subject: Re: Stochastics expertise needed
Date: 2 Sep 2016 02:39:06
Message: <57c91e8a@news.povray.org>
>> If you can post a graph of the BRDF that you're trying to simulate for the
>> purposes of your sampling algorithm, or a means of plotting it themselves, then
>> that might give anyone following along a nudge forward.
>
> I can't. That's the crux of the matter: The algorithm needs to cope with
> varying BRDFs. It might be Lambertian with a Phong highlight, or
> Oren-Nayar with a Blinn-Phong highlight, or (in the future) maybe
> Cook-Torrance, He-Torrance, Ward, Schlick, Lafortune, or whatever smart
> brains may still come up with and someone decides to implement in POV-Ray.

...or a BRDF created by interpolating real-life measurement data :-)


Post a reply to this message

From: clipka
Subject: Re: Stochastics expertise needed
Date: 2 Sep 2016 03:38:48
Message: <57c92c88$1@news.povray.org>
Am 02.09.2016 um 08:39 schrieb scott:
>>> If you can post a graph of the BRDF that you're trying to simulate
>>> for the
>>> purposes of your sampling algorithm, or a means of plotting it
>>> themselves, then
>>> that might give anyone following along a nudge forward.
>>
>> I can't. That's the crux of the matter: The algorithm needs to cope with
>> varying BRDFs. It might be Lambertian with a Phong highlight, or
>> Oren-Nayar with a Blinn-Phong highlight, or (in the future) maybe
>> Cook-Torrance, He-Torrance, Ward, Schlick, Lafortune, or whatever smart
>> brains may still come up with and someone decides to implement in
>> POV-Ray.
> 
> ....or a BRDF created by interpolating real-life measurement data :-)

Or that, yes.

(And would that then be a naive interpolation of a data array, or maybe
a spherical harmonics-based approximation?)


Post a reply to this message

From: Bald Eagle
Subject: Re: Stochastics expertise needed
Date: 2 Sep 2016 07:40:00
Message: <web.57c963eb8629941b5e7df57c0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> I can't. That's the crux of the matter: The algorithm needs to cope with
> varying BRDFs. It might be Lambertian with a Phong highlight, or
> Oren-Nayar with a Blinn-Phong highlight, or (in the future) maybe
> Cook-Torrance, He-Torrance, Ward, Schlick, Lafortune, or whatever smart
> brains may still come up with and someone decides to implement in POV-Ray.

Well, for now, you can - if there were a set of equations for the BRDF's that
could be easily plotted over the range 0-1 or 0-pi, then the shape might inspire
an equation to mimic them.   Presumably you already have a few such equations
working with POV-Ray, and some of the special development versions.

I've thought about this a bit and will have some more to say and ask, but for
now:

Is there a way to take the models available and fit a curve to them?
Polynomials, or Taylor series, or something like that?

And now I'm off to work.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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