POV-Ray : Newsgroups : povray.advanced-users : Difficulty with overlapping objects with media interiors Server Time
1 Jul 2024 06:07:19 EDT (-0400)
  Difficulty with overlapping objects with media interiors (Message 1 to 5 of 5)  
From: Jim Hart
Subject: Difficulty with overlapping objects with media interiors
Date: 28 Mar 2009 09:40:00
Message: <web.49ce27f3b1701548bc0fe280@news.povray.org>
Hi. I am having a problem figuring out why POV-Ray is not allowing me to overlap
several objects that have emission media interiors. I have attempted to vary
both pigment and finish, but it seems that the resulting images show the
surfaces of the objects when they intermix with the interior media of another
(an effect I do NOT want). Here is a simple illustration to show my point. I
modified a simple example from the POV-Ray documentation. If you set "NumOrbs"
to 1, you get the familiar glowing orb. With NumOrbs=2, it seems to look okay.
But as you add more orbs (that overlap), the surfaces of the orbs interact and
become visible. I have attempted adjusting the pigment (filter and transmit
values), finish, and even the density_map of the interior, without success.
Also, wrapping the spheres with a UNION has no effect. I am sure I am just
overlooking something obvious, but can't figure this out. Can anyone help me
understand WHY POVRay is doing this? Thanks in advance for your advice!

 background { rgb 1 }
 camera { location <0,4,0> //<3,4,-5>*.8
          look_at 0
          angle 35 }
 light_source { <20,40,10>, 1 }

 box // floor
 { <-1.5,-1.01,-1.5>, <1.5,-1.2,1.5>
   pigment { checker rgb 0.75, rgb 0.25 scale 0.2 }
 }

#declare NumOrbs = 3;
union {
#declare i = 0;
#while (i < NumOrbs)
 sphere // transparent sphere containing media
 { 0,
   1
   pigment { rgbft <1,1,1,0,1> }
   finish {
       ambient 0
       //diffuse 0
       //brilliance 0
       //specular 0
   }
   hollow
   interior
   { media
     { emission 1
       density
       { spherical density_map
         { [0 rgb 0 ]
           [0.4 rgb <1,0,0>]
           [0.8 rgb <1,1,0>]
           [1 rgb 1]
         }
       }
     }
     //ior 1
   }
   translate <-0.5+i/2,0,0>
 }
 #declare i  = i + 1;
#end
}


Post a reply to this message

From: clipka
Subject: Re: Difficulty with overlapping objects with media interiors
Date: 28 Mar 2009 11:10:00
Message: <web.49ce3cd9abe32fb222390e420@news.povray.org>
"Jim Hart" <nomail@nomail> wrote:
> Hi. I am having a problem figuring out why POV-Ray is not allowing me to overlap
> several objects that have emission media interiors. I have attempted to vary
> both pigment and finish, but it seems that the resulting images show the
> surfaces of the objects when they intermix with the interior media of another
> (an effect I do NOT want).

Yes, I've seen that effect too some time ago, and actually gave up trying to
work around it because it wasn't too prominent in the particular scene I was
working on.

My current guess is that this could be a problem of sample distribution within
an object. Ideally, the distribution should be something like this ("|"
denoting the object's surface, and "*" denoting a sample being taken; note that
I'm aware that adaptive sampling is a bit more complicated):

   |--*----*----*----*----*--|

or:

   |*----*----*----*----*----|

I.e. the whole distance should be subdivided into as many subsections of equal
size as there are samples, and one sample taken per such subsection. However,
maybe the samples are instead distributed such that the first sample is taken
right at the beginning of the whole distance, and the last one at the very end,
i.e.:

   |*-----*-----*-----*-----*|

If this is the case, it would be no surprise to see artifacts at the interface
between two objects, even if they have the same interior properties:

   |*-----*-----*-----*-----*|*-----*-----*-----*|

Here, the density function value at the interface between the objects receives
twice as much weight as any other.

So that's what I guess is happening, although I haven't been able to find any
confirmation of this in the code so far.


Post a reply to this message

From: clipka
Subject: Re: Difficulty with overlapping objects with media interiors
Date: 28 Mar 2009 11:30:01
Message: <web.49ce4199abe32fb222390e420@news.povray.org>
"Jim Hart" <nomail@nomail> wrote:
Just took the time to not only read your problem description, but also have a
look at your code and run it, to find that you probably have a different
problem than I had, and that it should be solvable.

What happens is that POV only takes into account the media of *one* object at a
time. This is not a really good thing, but difficult to change. In POV,
whenever a ray enters an object A, it is considered inside *that* object, and
no other, regardless whether the ray was in thin air or inside some other
object B; POV does make a mental note that object A seems to be nested inside
B, and will switch back to B as soon as the ray leaves A (unless the ray leaves
B first, of course), but that's how far the influence of B goes while the ray is
also in A.
So obviously, when two objects overlap, it makes a difference from which the ray
enters the intersection: It is always the object encountered later that wins.

So in order to work around this issue, you must "mix" the media yourself in the
overlapping area.

You'll probably have to define your spheres without a material first, make a
union of them, and then equip that union with as many media{} statements as you
have spheres (make sure to translate each of them like you translated the
corresponding sphere).


Post a reply to this message

From: Jim Hart
Subject: Re: Difficulty with overlapping objects with media interiors
Date: 28 Mar 2009 15:00:01
Message: <web.49ce7335abe32fb28bc0fe280@news.povray.org>
> So in order to work around this issue, you must "mix" the media yourself in the
> overlapping area.
>
> You'll probably have to define your spheres without a material first, make a
> union of them, and then equip that union with as many media{} statements as you
> have spheres (make sure to translate each of them like you translated the
> corresponding sphere).

I was able to get close to what I needed by doing as you suggested. I will
continue to work on it, but here is a modified program that creates a glow
cylinder by creating and translating media interiors within the cylinder.
Thanks for the hint!!

 background { rgb 0 }
 camera { location <0,6,0>
          look_at 0
          //angle 35
          }
 light_source { <20,40,10>, 1 }

 box // floor
 { <-1.5,-1.01,-1.5>, <1.5,-1.2,1.5>
   pigment { checker rgb 0.75, rgb 0.25 scale 0.2 }
 }

#declare NumGlows = 10;
#declare Radius = 1;

#declare Rod = cylinder { <-1,0,0>, <1,0,0> Radius
   pigment { rgbft <1,1,1,0,1> }
  #declare i = 0;
  #while (i < NumGlows)
    hollow
    interior
    { media
      { emission .3
        density
        { spherical density_map
          { [0 rgb 0 ]
            [0.4 rgb <1,0,0>]
            [0.8 rgb <1,1,0>]
            [1 rgb 1]
          }
        }
        translate x*(-1+2*i/(NumGlows-1))
      }
    }
    #declare i  = i + 1;
  #end
}

object { Rod scale 3*x }


Post a reply to this message

From: Kenneth
Subject: Re: Difficulty with overlapping objects with media interiors
Date: 30 Mar 2009 02:00:05
Message: <web.49d05e7aabe32fb2f50167bc0@news.povray.org>
"Jim Hart" <nomail@nomail> wrote:
> Hi. I am having a problem figuring out why POV-Ray is not allowing me to overlap
> several objects that have emission media interiors. I have attempted to vary
> both pigment and finish, but it seems that the resulting images show the
> surfaces of the objects when they intermix with the interior media of another
> (an effect I do NOT want).

My own experience with this frustrating 'visible container' problem has usually
boiled down to two things:
1) The media samples being different in the overlapping objects--they should be
the same (if that's possible in your scene)
2) Which object (of two overlapping objects) the camera 'ray' sees first. The
first (or 'outer') object actually sets the samples for any other media
container(s) that happen to be inside it/partially inside it. The outer one
completely overrides the inner one. That's an odd but
kind of understandable thing, and doesn't really cause problems. Yet the
'protruding' part of the inner object--the part that's outside the main object
and not overlapping--takes on its own samples count there; the boundary between
the two is really where the  'visible' container artifacts show up.

The solution that almost always works for me is to try and set the samples equal
for both objects--and/or to crank up samples (in one or both) until the problem
is minimized. (Sometimes it's just a matter of not having *enough* samples in
*either* object.) To help explain that further: One media sphere *completely*
enclosed by another will usually NOT show any boundary problems--unless the
larger sphere's sample count is just TOO low.

BTW, as has been stated in many posts over the years, it's best to use media
method 3 intervals 1, and just vary the samples count. (Method 3 will create
more intervals if it needs them.)

KW


Post a reply to this message

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