POV-Ray : Newsgroups : povray.programming : Formula or implementation wrong? : Re: Formula or implementation wrong? Server Time
25 Apr 2024 19:48:49 EDT (-0400)
  Re: Formula or implementation wrong?  
From: clipka
Date: 8 Mar 2009 19:35:00
Message: <web.49b454539216365de7ac5bf00@news.povray.org>
"triple_r" <nomail@nomail> wrote:
> You can find an implementation (PBRT) here.  According to their code,

Um... where's "here"? ;)

> >     double sigma_prime_t = sigma_prime_s + sigma_a;
> >     double F_dr = (-1.440 / Sqr(mu) + 0.710 / mu + 0.668 + 0.0636 * mu);
>
> eta?  Fair enough.  Where did you get the sigma_prime_s and sigma_a from?  Does
> this require evaluation of the mean cosine, or do you assume isotropy?  Should
> these be vector parameters for the rgb values?

Both sigma_prime_s and sigma_a are "input parameters" of the whole smash; R, G
and B values are processed separately, so they're just plain floating-point
values at this stage.


> >     double sigma_t_r = sqrt(3 * sigma_a * sigma_prime_t); // [2]
> >
> >     double  zr = 1.0 / sigma_prime_t;
> >     double  dr = sqrt(Sqr(zr) + Sqr(dist));
>
> "dr = ||x-xr|| is the distance from x to the real source, and dv = ||x-xv|| is
> the distance from x to the virtual source."  I need to take a closer look at
> this section.  You're sure of this formula?

In that particular section of the paper, I assume that "x" should actually read
"xo" (xi doesn't make much sense, as the distances would then be zv and zr
respectively; nor would xv or xr be fitting, and there are no other points of
interest in the model). Enter Pythagoras.

> >     // calculate Rd
> >     double m  = alpha_prime / (4 * M_PI);
> >     double t1 = zr * (sigma_t_r + 1.0/dr);  // [3]
> >     t1        *= exp(-sigma_t_r * dr);
> >     t1        /= (sigma_prime_t * Sqr(dr));
>
> For a second I thought there was an error in your simplification, but except for
> the zr, this looks good.  This does seem much more symmetric, so whether or not
> it works, this form would seem more logical.

It also matches formulae (9) and (10) in this paper:
http://graphics.ucsd.edu/~henrik/papers/fast_bssrdf/


> The code that you've provided looks good for the most part, but I'm assuming
> that you have correct input and output.  This doesn't look easy to debug since
> there aren't many sanity checks for intermediate values.

Right now I'm assuming that I have *something* wrong with the choice and
weighting of sample points.

Theoretically(!), if I'd monte-carlo-integrate over all surface points xi of the
object, "ad infinitum" if it is a plane, and with uniform density, the weighting
of each sample should be 1/numberOfSamples, right? (Just for argument's sake; I
know it's not possible on infinite objects)

So if I'd monte-carlo-integrate instead with a sample density proportional to
some function f(), each sample should be weighted by f()/SUM(f()), or am I
mistaken?

Assuming that I'm dealing with a "locally flat" geometry, I pick sample points
on the surface in a random direction at a distance of

  r = fabs(log(rnd()))/sigma_tr

This should give me a sample density proportional to

  (sigma_tr * exp(-sigma_tr * r) / sigma_tr) / (2*pi * r)

right? (The first term being due to the "radial density" and the other due to
the "angular density")


The further processing is obviously fine, as with the uniform illumination BRDF
approximation (plus single-scattering term) it gives results almost perfectly
matching the diffuse reflectance values presented in the paper.


Post a reply to this message

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