POV-Ray : Newsgroups : povray.newusers : Transparent Objects Become Black Server Time
27 Dec 2024 12:22:02 EST (-0500)
  Transparent Objects Become Black (Message 1 to 10 of 37)  
Goto Latest 10 Messages Next 10 Messages >>>
From: bubble person
Subject: Transparent Objects Become Black
Date: 11 Nov 2021 08:10:00
Message: <web.618d154df4d11d43a6f27af47c94cc22@news.povray.org>
Hello Forum,

I am relatively new to POV-RAY, but have a functional script .

I am simulating air bubbles in a glass tube full of gel.  I am running into a
funny problem where, if I add too many bubbles to the script, they go from being
transparent and rendered correctly, to a completely opaque, black object through
which no light shines.

Things that don't seem to work:

1) Increasing the  max_trace_level

2) I have tried to be sure that the inner surface of the gel is not in contact
with the air bubble by reducing the bubble radius by epsilon (.0001).  Oddly
enough, the script with up to 4 bubbles works only when the two surfaces are
coincident, and subtracting an epsilon value (.0001,.001,.01) causes the bubbles
to turn black, no matter the number.

I would love your input on this issue as I am stumped.  I cannot figure out why
this renders without issue when I only have a certain number of objects defined.


The order of my file:

In my scene, centered at the origin, I have bubbles, inside of gel, inside of a
glass tube, inside of water, inside of a plexiglass cylinder.

My code

1) I define variables, set trace level, and place the camera

2) I create a distributed area light source on a rectangular box

3) I define the bubbles I want in the gel

4) I create the glass tube into which the gel will sit

5) I create the gel region with voids into which the bubbles sit.

6) I then add water around the glass tube, and then a plexiglass perimeter.


Post a reply to this message


Attachments:
Download 'test-script.pov.txt' (15 KB)

From: jr
Subject: Re: Transparent Objects Become Black
Date: 11 Nov 2021 10:20:00
Message: <web.618d339528696f32d6c295506cde94f1@news.povray.org>
hi,

"bubble_person" <nomail@nomail> wrote:
> Hello Forum,
>
> I am relatively new to POV-RAY, but have a functional script .
>
> I am simulating air bubbles in a glass tube full of gel.  I am running into a
> funny problem where, if I add too many bubbles to the script, they go from being
> transparent and rendered correctly, to a completely opaque, black object through
> which no light shines.

not sure if it will help, or is even related to "the issue", but if I change the
"bubble_r" to "(bubble_r - epsilon)" in the five spheres following comment "Add
Bubble Voids here", they're visible.

quick comment re "new to POV-Ray".  you have five identical (apart from
location) spheres.  have a look at macros, they're ideal in such a situation.
<https://wiki.povray.org/content/Reference:User_Defined_Macros#The_macro_Directive>


regards, jr.


Post a reply to this message

From: Alain Martel
Subject: Re: Transparent Objects Become Black
Date: 11 Nov 2021 12:08:51
Message: <618d4e23$1@news.povray.org>
Le 2021-11-11 à 08:06, bubble_person a écrit :
> Hello Forum,
> 
> I am relatively new to POV-RAY, but have a functional script .
> 
> I am simulating air bubbles in a glass tube full of gel.  I am running into a
> funny problem where, if I add too many bubbles to the script, they go from being
> transparent and rendered correctly, to a completely opaque, black object through
> which no light shines.
> 
> Things that don't seem to work:
> 
> 1) Increasing the  max_trace_level
> 
> 2) I have tried to be sure that the inner surface of the gel is not in contact
> with the air bubble by reducing the bubble radius by epsilon (.0001).  Oddly
> enough, the script with up to 4 bubbles works only when the two surfaces are
> coincident, and subtracting an epsilon value (.0001,.001,.01) causes the bubbles
> to turn black, no matter the number.
> 
> I would love your input on this issue as I am stumped.  I cannot figure out why
> this renders without issue when I only have a certain number of objects defined.
> 
> 
> The order of my file:
> 
> In my scene, centered at the origin, I have bubbles, inside of gel, inside of a
> glass tube, inside of water, inside of a plexiglass cylinder.
> 
> My code
> 
> 1) I define variables, set trace level, and place the camera
> 
> 2) I create a distributed area light source on a rectangular box
> 
> 3) I define the bubbles I want in the gel
> 
> 4) I create the glass tube into which the gel will sit
> 
> 5) I create the gel region with voids into which the bubbles sit.
> 
> 6) I then add water around the glass tube, and then a plexiglass perimeter.
> 
> 
> 
> 

The first thing that I would to would be to increase max_trace_level 
further still. It can go up to 255.

Note : Your area_light is oblique. If you want it to be flat, then, it's 
size should be something like this :
area_light 160*x 200*z 65 65
adaptive 0 // start with zero, then, increase if needed
Size of area_light adjusted to match the light_box dimensions.

During testing, you should disable the area_light. It makes testing and 
debugging faster.

The 100 by 100 get silently increased to 129 by 129 when adaptive is 
used. That increase DO NOT affect the rendering time.

Using dispersion 1 is the same as not using dispersion. It must be 
slightly different than 1. Realistic values are usually in the 1.01 to 
1.08. Values less than 1 result in inverted dispersion.

You are using fade_power 1000 !? You should use 1 or 1001.
Using 1000 may cause some issues.


Post a reply to this message

From: bubble person
Subject: Re: Transparent Objects Become Black
Date: 11 Nov 2021 12:25:00
Message: <web.618d508f28696f32a6f27af47c94cc22@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> hi,
>
> "bubble_person" <nomail@nomail> wrote:
> > Hello Forum,
> >
> > I am relatively new to POV-RAY, but have a functional script .
> >
> > I am simulating air bubbles in a glass tube full of gel.  I am running into a
> > funny problem where, if I add too many bubbles to the script, they go from being
> > transparent and rendered correctly, to a completely opaque, black object through
> > which no light shines.
>
> not sure if it will help, or is even related to "the issue", but if I change the
> "bubble_r" to "(bubble_r - epsilon)" in the five spheres following comment "Add
> Bubble Voids here", they're visible.
>
> quick comment re "new to POV-Ray".  you have five identical (apart from
> location) spheres.  have a look at macros, they're ideal in such a situation.
> <https://wiki.povray.org/content/Reference:User_Defined_Macros#The_macro_Directive>
>
>
> regards, jr.

Hello Jr.,

Thank you for the response, and I appreciate your pointer to the Macros.  I'll
be taking a deeper look at this.

I tried what you suggested, and for my script, it causes the bubble surface to
be shiny (I can see reflection on the perimeter of the bubble), but it seems
like the center of the bubble remains black, unrendered, or something like that.
 Light is certainly not going through it.

In previous cases, light refracts through the center of the bubbles, so the fact
that the center is still dark tells me that I'm still encountering an issue.

One other idea that I had was using the "clipped_by{}" function when defining
the voids.  I reordered the merge{} definition for the gel and the used the
clipped_by{} function to subtract out the bubble voids.

I did this and the centers seem to have reappeared for all the bubbles.  The
light is refracting through the bubbles which is good, but I'm worried that I
might be missing a subtlety about how the "difference{}" and "clipped_by{}"
functions work.  I'm not sure why this has worked, and it's worrying me when my
goal is to simulate realistic refraction through this volume.


Post a reply to this message

From: Kenneth
Subject: Re: Transparent Objects Become Black
Date: 11 Nov 2021 12:55:00
Message: <web.618d505428696f324cef624e6e066e29@news.povray.org>
Hi! Welcome to the forum.

Your sphere voids are not really 'black' but opaque (like silhouettes) due to
your light's position.

After stripping-out everything that was non-essential in your code, I
narrowed-down the problem to your 'gel' object and its differenced spheres (the
'voids'). It was only then that I realized that the problem is really with the
spheres themselves: In your code section "Add Bubble Definitions here", you need
to #declare those individual objects, then use *those* definitions in your gel
object. The sphere objects you actually used in your gel object are 'redefined'
there and have 'default' textures (which have no transparency.) So in effect,
your original five sphere definitions are not even being used; and the ones you
did use are simply opaque.

I've included my stripped-down scene to give you a better idea of what is
required, code-wise. I hope this helps you to understand the idea of #declaring
objects beforehand. Of course, it's not always necessary; you could have written
your five complete sphere definitions IN the gel object instead, without using
#declares.


[Some notes: In your own code, you used  ambient_light White. Nothing wrong with
that, but in case you don't know, ambient_light is just a *multiplier* for the
finish(ambient...} values in a scene. So here, you are simply multiplying your
ambient values by <1,1,1>, which is the White color.  Also, it looks like you
have a redundant or extra use of rotate <...> for your sphere voids. You should
eliminate one set of those, unless it's for some purpose.]

--- simplified code ---
#version 3.8;
global_settings{assumed_gamma 1.0 max_trace_level 50}

background{rgb <.1,.05,.05>}

#include "colors.inc"

#default{finish{ambient 0 emission 0 diffuse .9}}

#declare epsilon       = .0001;
#declare light_loc_x   = 0;
#declare light_loc_y   = 0;
#declare light_loc_z   = 90;

#declare tube_base    =  -55;
#declare tube_height  = 92;
#declare tube_rinner  = 13;

#declare gel_height   = 0.9*tube_height;
#declare bubble_r     = 0.8;

// [additional camera]
camera {
  perspective
  location  <-40, 19, -5>
  look_at   <0, 19,  0>
  right     x*image_width/image_height
 // rotate -180*clock*y
}

light_source {
<light_loc_x, light_loc_y,light_loc_z>
color White
  }


// Creating bubbles that go into voids of gel


// Add Bubble Definitions Here:

#declare SPH_1 =
sphere{ <4.708,7.784,4.171>, (bubble_r)
 texture {
  pigment{ color rgbt<.99,.99,.99,0.9>}
            finish { phong .001 }
              }
}

#declare SPH_2 =
sphere{ <1.862,29.796,-6.023>, (bubble_r)
 texture {
  pigment{ color rgbt<.99,.99,.99,0.9>}
  finish { phong .001 }
    }
}

#declare SPH_3 =
sphere{ <-7.205,20.129,-3.448>, (bubble_r)
 texture {
  pigment{ color rgbt<.99,.99,.99,0.9>}
  finish { phong .001 }
    } // end of texture
}

#declare SPH_4 =
sphere{ <1.424,17.806,-9.772>, (bubble_r)
 texture {
  pigment{ color rgbt<.99,.99,.99,0.9>}
  finish { phong .001 }
    } // end of texture
}

#declare SPH_5 =
sphere{ <-5.249,17.494,-3.139>, (bubble_r)
 texture {
  pigment{ color rgbt<.99,.99,.99,0.9>}
  finish { phong .001 }
    } // end of texture
}

// --- Creating gel and the bubble voids ---

difference{
 merge{
  sphere { <0,tube_base,0>, tube_rinner-epsilon}
  cylinder{<0,tube_base,0>, <0,gel_height,0>,
                                tube_rinner-epsilon}
   texture { pigment{ color rgbt<.99,.99,.99,0.9>}
   finish { phong .001 }
                      } // end of texture
  } // end merge (gel matrix)

// subtract Bubble Voids Here:

 object{SPH_1}  // bubble
 object{SPH_2}  // bubble
 object{SPH_3}  // bubble
 object{SPH_4}  // bubble
 object{SPH_5}  // bubble

 } // End difference for bubbles


Post a reply to this message

From: bubble person
Subject: Re: Transparent Objects Become Black
Date: 11 Nov 2021 13:20:00
Message: <web.618d5ec928696f32a6f27af47c94cc22@news.povray.org>
Alain Martel <kua### [at] videotronca> wrote:

> > Hello Forum,
> >
> > I am relatively new to POV-RAY, but have a functional script .
> >
> > I am simulating air bubbles in a glass tube full of gel.  I am running into a
> > funny problem where, if I add too many bubbles to the script, they go from being
> > transparent and rendered correctly, to a completely opaque, black object through
> > which no light shines.
> >
> > Things that don't seem to work:
> >
> > 1) Increasing the  max_trace_level
> >
> > 2) I have tried to be sure that the inner surface of the gel is not in contact
> > with the air bubble by reducing the bubble radius by epsilon (.0001).  Oddly
> > enough, the script with up to 4 bubbles works only when the two surfaces are
> > coincident, and subtracting an epsilon value (.0001,.001,.01) causes the bubbles
> > to turn black, no matter the number.
> >
> > I would love your input on this issue as I am stumped.  I cannot figure out why
> > this renders without issue when I only have a certain number of objects defined.
> >
> >
> > The order of my file:
> >
> > In my scene, centered at the origin, I have bubbles, inside of gel, inside of a
> > glass tube, inside of water, inside of a plexiglass cylinder.
> >
> > My code
> >
> > 1) I define variables, set trace level, and place the camera
> >
> > 2) I create a distributed area light source on a rectangular box
> >
> > 3) I define the bubbles I want in the gel
> >
> > 4) I create the glass tube into which the gel will sit
> >
> > 5) I create the gel region with voids into which the bubbles sit.
> >
> > 6) I then add water around the glass tube, and then a plexiglass perimeter.
> >
> >
> >
> >
>
> The first thing that I would to would be to increase max_trace_level
> further still. It can go up to 255.
>
> Note : Your area_light is oblique. If you want it to be flat, then, it's
> size should be something like this :
> area_light 160*x 200*z 65 65
> adaptive 0 // start with zero, then, increase if needed
> Size of area_light adjusted to match the light_box dimensions.
>
> During testing, you should disable the area_light. It makes testing and
> debugging faster.
>
> The 100 by 100 get silently increased to 129 by 129 when adaptive is
> used. That increase DO NOT affect the rendering time.
>
> Using dispersion 1 is the same as not using dispersion. It must be
> slightly different than 1. Realistic values are usually in the 1.01 to
> 1.08. Values less than 1 result in inverted dispersion.
>
> You are using fade_power 1000 !? You should use 1 or 1001.
> Using 1000 may cause some issues.

Hello Alain,

Thank you so much for your reply and suggestions.  As you may have noticed, I am
still in the process of understanding the different features.

In the case of max_trace_level, I have put this all the way up to the max as you
suggested, but this did not resolve the issue from my original script.  I'll
have to keep digging for a solution in that regard.

For the area_light, I was certainly not clear on the pov-ray documentation and
examples.  From what I understand, I am creating a box (light box) that is
parallel with the xy-plan, onto which I'm stretching an array of 100x100 light
sources.  And as you stated, by adding the adaptive, feature, this gets
increased when running (Great thing to know!  I wasn't completely clear on what
happened in the background).

I am, however, still confused on why the area_light would be tilted.  As you
mentioned, I want a light parallel to the xy plane, and thought that this was
the case.

Given this example below, my understanding is that my light_box is a box that is
160x200x2 units (x,y,z) and collared white.  I then locate my light_source at
<light_loc_x, light_loc_y,light_loc_z>.  I then use the area_light feature to
define two points <-10, -10, 10>, <10, 10, 10> from the origin to indicate the
vectors over which to stretch the light.

#declare light_box = box{ <-80,-100,0>, <80,100,2>
        pigment{color White}
       } //end light box
light_source {
    <light_loc_x, light_loc_y,light_loc_z>
    color White
    area_light <-10, -10, 10>, <10, 10, 10>, 100, 100
    adaptive 1
    jitter
    looks_like { light_box }
  }


As I look closely at this and my response, I'm very much confused about the
area_light.

Given my example above, how would you define an area light parallel to the
xy-plane that is, say, + 80 units in the Z-direction, and fits to the dimensions
of the light_box that I defined?  I've missed something important in the
documentation.

Finally, with the fade_power, how is 1000 bad, but 1 or 1001 good?  I did a
little copy-pasting of this part from an example, so I had not really asked
myself what realistic values should be.

Thank you again for all of your comments and insights.  I've got more digging to
do!


Post a reply to this message

From: Kenneth
Subject: Re: Transparent Objects Become Black
Date: 11 Nov 2021 13:35:00
Message: <web.618d61e728696f324cef624e6e066e29@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
>
> ... So in effect, your original five sphere definitions are not even being
> used; and the ones you did use are simply opaque.

Correction: In your scene, both sets of spheres ARE being rendered at the same
time... by mistake of course...and they exactly overlap, which is probably why
you (and I!) were seeing odd results during various experiments. When multiple
objects occupy the same exact space, POV-ray's built-in precision with its
calculations can sometimes show one object or the other, or else 'coincident
surface' speckles or other oddities.


Post a reply to this message

From: Bald Eagle
Subject: Re: Transparent Objects Become Black
Date: 11 Nov 2021 19:10:00
Message: <web.618db04828696f321f9dae3025979125@news.povray.org>
"bubble_person" <nomail@nomail> wrote:
> Alain Martel <kua### [at] videotronca> wrote:

> > Note : Your area_light is oblique. If you want it to be flat, then, it's
> > size should be something like this :
> > area_light 160*x 200*z 65 65

> For the area_light, I was certainly not clear on the pov-ray documentation and
> examples.  From what I understand, I am creating a box (light box) that is
> parallel with the xy-plan, onto which I'm stretching an array of 100x100 light
> sources.


>
> I am, however, still confused on why the area_light would be tilted.  As you
> mentioned, I want a light parallel to the xy plane, and thought that this was
> the case.

I'm confused also.  I'm not entirely certain that using looks_like will tilt the
area light array.  (I'm not sure of the top of my head how to accurately
visualize the actual area light.)




> Given this example below, my understanding is that my light_box is a box that is
> 160x200x2 units (x,y,z) and collared white.  I then locate my light_source at
> <light_loc_x, light_loc_y,light_loc_z>.  I then use the area_light feature to
> define two points <-10, -10, 10>, <10, 10, 10> from the origin to indicate the
> vectors over which to stretch the light.
>
> #declare light_box = box{ <-80,-100,0>, <80,100,2>
>         pigment{color White}
>        } //end light box
> light_source {
>     <light_loc_x, light_loc_y,light_loc_z>
>     color White
>     area_light <-10, -10, 10>, <10, 10, 10>, 100, 100
>     adaptive 1
>     jitter
>     looks_like { light_box }
>   }

So, a few things, in no particular order or importance:

It's ... weird to be that you're making a box of one size and an area light of
another.  Use the same dimensions.

Also kinda clunky that you're defining location x, y, and z separately, when you
could just declare a vector.

Is your light box visible in the scene? (I can't see it)  If not, can you just
use  a light source without the looks_like attribute?

Just in case you didn't know, when x, y, and z are used outside of function {}
equation definitions, they refer to vectors  (<1, 0, 0>, etc.)
So you can do something like 10*x to get <10, 0, 0>

Also, we have a weird thing in POV-Ray called automatic vector promotion.  They
way it works is, say you are making your light box, and you need two 3D vectors.
 If you are making a unit cube centered at the origin, you can do something
like:
box {-0.5, 0.5}, and the automatic vector promotion will promote --- expand ---
the scalar quantities into the 3D vectors that POV-Ray's parser is expecting for
those parameters.
So what you'd wind up with is the equivalent of:
box {<-0.5, -0.5, -0.5>, <0.5, 0.5, 0.5>}

This can be convenient for certain things, and a real PITA with others (rgbft
color vectors)

I noticed that Kenneth tracked down your core issue - and you may want to try
modeling individual components separately, one by one, in a standalone scene so
that you can see exactly what is going on.  That would have shown you that your
spheres have the default texture, not the one you _thought_ you were using.

You're making a tube filled with stuff that will be in some rotated position.
Rather than rotating every individual component to line up with a rotated tube,
model your tube around the origin, place everything inside it, and then rotate
the whole union {} of everything all at once.

To save a million lines of code, declare your material, ONCE, and then use that
declared material name.

To save even more internal gymnastics, write a loop to make all of your spheres
inside of a union, and then apply that material to the entire union of spheres,
not to each individual sphere.

Think in a hierarchies and flowcharts.

Busy here doing other things and juggling crises, but looking forward to seeing
your progress and answering any questions when time allows.  :)

- Bill


Post a reply to this message

From: bubble person
Subject: Re: Transparent Objects Become Black
Date: 12 Nov 2021 04:05:00
Message: <web.618e2dd428696f32a6f27af47c94cc22@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> "Kenneth" <kdw### [at] gmailcom> wrote:
> >
> > ... So in effect, your original five sphere definitions are not even being
> > used; and the ones you did use are simply opaque.
>
> Correction: In your scene, both sets of spheres ARE being rendered at the same
> time... by mistake of course...and they exactly overlap, which is probably why
> you (and I!) were seeing odd results during various experiments. When multiple
> objects occupy the same exact space, POV-ray's built-in precision with its
> calculations can sometimes show one object or the other, or else 'coincident
> surface' speckles or other oddities.

Hello Kenneth,

Thank you for all of your sleuthing and the stripped-down example.  This has
really cleared up a fundamental misunderstanding that I was having about
inserting objects.  I was under the impression that the spheres defined in the
difference{} function were only there to carve out holes.  I didn't realise I
could actually define material properties for those voids.  That's the reason I
defined the bubbles twice, thinking I had to scoop out the region, and then fill
it with a bubble with the desired material properties.  It makes a lot of sense
that I was getting funny results with the doubly-defined bubbles occupying the
same space!

I also appreciate the example of the object definitions. As you can see with my
long-winded scripting, I was pushing my basic knowledge of the program as far as
I could without adding the hierarchical structures that would make it elegant.
haha!  This gives me some good footing to streamline my POV-RAY scripting.

I'll keep everyone updated as I try to make the script cleaner using your
examples and the input of others in the post.

Sincerely,

bubble_person


Post a reply to this message

From: jr
Subject: Re: Transparent Objects Become Black
Date: 12 Nov 2021 08:10:00
Message: <web.618e677e28696f32d6c295506cde94f1@news.povray.org>
hi,

"bubble_person" <nomail@nomail> wrote:
> ...
> Hello Jr.,
> ...

good to see (from yr reply to Kenneth) that "you're sorted" :-).  re voids,
there's also the 'hollow' keyword, which may be of use.
<https://wiki.povray.org/content/Reference:Hollow_Object_Modifier>


regards, jr.


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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