POV-Ray : Newsgroups : povray.programming : Retrieving OBJECT reference from media, pigment or pattern code ? : Re: Retrieving OBJECT reference from media, pigment or pattern code ? Server Time
30 Apr 2024 00:07:09 EDT (-0400)
  Re: Retrieving OBJECT reference from media, pigment or pattern code ?  
From: Antonio Ferrari
Date: 11 Oct 2007 03:30:01
Message: <web.470dd022a5f6d2324e64f15d0@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:
> Antonio Ferrari wrote:
> > I'de like to know to obtain the current OBJECT pointer in the following
> > procedures:
> >
> > - Evaluate_TPat
>
> It is in the intersection (Isection->Object), the same goes for all patterns.
>
> > - Compute_Pigment
>
> Some as above.
>
> > - Backtrace_Simulate_Media
>
> Some as above.
>
> > - sample_media
>
> You can get it from the caller (see above).
>
> What are you actually trying to do?
>
>  Thorsten



Hi,
first of all thanks for your suggestions. Be patinet, it'a a bit long and
difficult to explain what I'de like to do... I've already tried to explain
my problem in othen posts, but I've received no useful answers...

So, let's start from an object (sphere, box, etc. but also CSGs etc. etc.)
that can accept media in the interior. I'de like to obtain a sort of
Subsurface Scattering. Media allows us to have Subsurface Scattering (I
suppose Monte Carlo technics are implemented...). Media is flexible and
allow to introduce different densities, in particular using functions in x,
y and z.

What I don't know is if light emitted or scattered by medias also interacts
with the other objects and the external world. A real Subsurface Scattering
or BSSRDF methods do that, anyway. I also think that, if future releases of
Povray want to be POWERFUL, they MUST thak into account the best features
of blender or yafray etc. etc.

But now we are come to the point: how can I have a density function that
depends on the distance (minimal distance) of a point <x, y, z>, internal
to one of the objects I've mentiones above? I want a density=0 outside the
object, but inside I'de like density calculate in this way:
density(x,y,z)=A+B*min_distance(<x,y,z>, Object)^C. A, B and C are
constants. min_distance is an operator that calculate the minimal distance
of <x,y,z> from Object.

I know that we could use df3 files, but to generate them we would have to
use external programs... And that for isosurfaces we can consider the
generating function. But I need a more universal method.

min_distance operator doesn't exist in Povray. We could implement a new
operator acting in a way similar to the following macro:

#include "rand.inc"
#macro distToSurface(Obj, vec, samp, rsd)
   #local dist = 1000000;
   #local c=0;
   #while (c<samp)
      #local rdir = VRand_On_Sphere(rsd);
      #declare Norm = <0, 0, 0>;
      #local hit = trace(Obj, vec, rdir, Norm);
      #if (vlength(Norm) != 0)
         #local dist = min(dist, vlength(hit - vec));
      #end
      #local c=c+1;
   #end
#end

I don't know if there are methods more accurate, different from this
sampling one.

Starting from the last idea I've thought to implement something new in
density section, adding the possibility to recognize also a new parameter D
(D=min_distance, as described above) in density functions or maybe adding a
new keword:

interior {
  media {
    ...
    density {
      min_distance_density { 1 + 2*pow(D,3) }
    }
  }
}

It's just an example... min_distance_density is only a stupid idea. Maybe
the function could also use x, y and z parameters.

The core of the problem is to calculate the density values in
density_pattern or Evaluate_TPat or Compute_Pigment or
evaluate_density_pattern and so on. Now I don't know where is the best
point to insert the calculation of the density. Also I don't know at all if
it's possible.

Surely for doing that I need to know the "ACTUAL" object, that is the OBJECT
reference correlated to the VECTOR used when a certain density has to be
taken into account. For df3 files the density values are stored in
DENSITY_FILE_DATA structure. I'm pretty sure that there is a procedure in
which the density values can also be calculated on the fly using a function
with the new parameter D (min_distance).

Oh, I hope I've been sufficiently clear... :-/

Bye,
Antonio


Post a reply to this message

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