POV-Ray : Newsgroups : povray.general : scattering media oddities Server Time
2 Nov 2024 17:21:20 EDT (-0400)
  scattering media oddities (Message 1 to 10 of 10)  
From: Kai
Subject: scattering media oddities
Date: 14 Mar 2010 13:55:01
Message: <web.4b9d2163e007c332ebb0f1fc0@news.povray.org>
To model a foam plastic object (like
http://de.wikipedia.org/wiki/Datei:Haushaltsschwaemme.jpg ) I tried a
appropriate surface texture combined with a dense scattered media.

The results are good, except when some feature is placed in the foam object.
Such a feature should only be visible on a very short distance below the
surface, but it's visible throughout the whole object. I've tracked down this
issue to the scattering media.

In the following sample scene the blue cylinder should disappear quickly, but
it's visible through the whole media filled box. If the box is divided into
parts (just set fogDivisions > 1), the visibility issue get's better. With
subdivisions one get's band artifacts, however, and for more complex objects
this wouldn't be of much help anyhow. I'm using povray Unix 3.6.1.

Are there better alternatives to model this case?


#include "colors.inc"

#declare aR = 0.15;

#declare fogDepth = 10;
#declare fogDivisions = 1; // 1, 2, 4, 8

camera {
   location <15, 15, -25>
   look_at  <0, 5,  0>
   angle 45
}

light_source {
   <60, 50, -40>, color White
   parallel
   point_at <0, 5, 0>
}

plane {
   y, 0
   texture {
      pigment {
  color White
      }
      finish {
  ambient aR
  diffuse 0.6
      }
   }
}

#declare M_fog =
material {
   texture { pigment { color rgbf <1,1,1,1> } }
   interior {
      media {
  scattering { 1,
     White*0.8
  }
      }
   }
}

#declare i = 0;
#declare fogStep = fogDepth/fogDivisions;
#while(i < fogDivisions)
   box {
      <-5, 0.01, -5 + i*fogStep>, <10, 13, -5 + (i+1)*fogStep - 0.01>
      hollow
      material { M_fog }
   }
#declare i = i + 1;
#end

cylinder {
   <-4, 5,-8>, <-4, 5, 50>, 1
   texture {
      pigment { color <0.5, 0.5, 1> }
      finish { diffuse 0.6 ambient aR }
   }
}


Post a reply to this message

From: Alain
Subject: Re: scattering media oddities
Date: 14 Mar 2010 16:07:15
Message: <4b9d41f3$1@news.povray.org>

> To model a foam plastic object (like
> http://de.wikipedia.org/wiki/Datei:Haushaltsschwaemme.jpg ) I tried a
> appropriate surface texture combined with a dense scattered media.
>
> The results are good, except when some feature is placed in the foam object.
> Such a feature should only be visible on a very short distance below the
> surface, but it's visible throughout the whole object. I've tracked down this
> issue to the scattering media.
>
> In the following sample scene the blue cylinder should disappear quickly, but
> it's visible through the whole media filled box. If the box is divided into
> parts (just set fogDivisions>  1), the visibility issue get's better. With
> subdivisions one get's band artifacts, however, and for more complex objects
> this wouldn't be of much help anyhow. I'm using povray Unix 3.6.1.
>
> Are there better alternatives to model this case?
>
>
> #include "colors.inc"
>
> #declare aR = 0.15;
>
> #declare fogDepth = 10;
> #declare fogDivisions = 1; // 1, 2, 4, 8
>
> camera {
>     location<15, 15, -25>
>     look_at<0, 5,  0>
>     angle 45
> }
>
> light_source {
>     <60, 50, -40>, color White
>     parallel
>     point_at<0, 5, 0>
> }
>
> plane {
>     y, 0
>     texture {
>        pigment {
>    color White
>        }
>        finish {
>    ambient aR
>    diffuse 0.6
>        }
>     }
> }
>
> #declare M_fog =
> material {
>     texture { pigment { color rgbf<1,1,1,1>  } }
>     interior {
>        media {
>    scattering { 1,
>       White*0.8
>    }
>        }
>     }
> }
>
> #declare i = 0;
> #declare fogStep = fogDepth/fogDivisions;
> #while(i<  fogDivisions)
>     box {
>        <-5, 0.01, -5 + i*fogStep>,<10, 13, -5 + (i+1)*fogStep - 0.01>
>        hollow
>        material { M_fog }
>     }
> #declare i = i + 1;
> #end
>
> cylinder {
>     <-4, 5,-8>,<-4, 5, 50>, 1
>     texture {
>        pigment { color<0.5, 0.5, 1>  }
>        finish { diffuse 0.6 ambient aR }
>     }
> }
>
>
>

You want to model a lump of foam, but you model a box filled with smoke. 
That's not the same thing.
Despite the dimention of your object, your media is not what I call dense.

You should try with an isosurface using some function that have 
repeating holes, like leopard. Use "all_intersections. Use a material 
with some transparency, an interior with an ior of about 1.4 to 1.7, 
fade_color fade_distance and fade_power 1 or fade_power 1001.
The texture should have some transparency:
  rgbf<Red_Value, Green_Value, Blue_Value, 0.7>
Add some specular to the finish: specular 0.5 roughness 0.01.

If you want, you can keep your media, but you probably don't need it.

In the global_settings set max_trace_level to a relatively large value, 
like 90 to 255 and increase adc_bailout to something like 0.01 to 0.05.
max_trace_level allows you to dig deeper into the object and prevent 
black spots.
adc_bailout keep the render time under controll at the price of a little 
less precision.


Alain


Post a reply to this message

From: Kai
Subject: Re: scattering media oddities
Date: 14 Mar 2010 17:45:00
Message: <web.4b9d57e21a9a49ceebb0f1fc0@news.povray.org>
Alain <aze### [at] qwertyorg> wrote:
> You want to model a lump of foam, but you model a box filled with smoke.
> That's not the same thing.

Both media show the physical process of scattering due to scatterers (quote from
wikipedia: "The types of non-uniformities which can cause scattering, sometimes
known as scatterers or scattering centers, are too numerous to list, but a small
sample includes particles, bubbles, droplets, density fluctuations in fluids,
defects in crystalline solids, surface roughness, cells in organisms, ...")

The idea was to use the media scattering to exploit the (probably) higher
efficiency and not modeling the micro cells of the foam explicitly.

The objective is to get the scattering look of a dense media, without overly
bright surface. Single foam cells do not need to be visible. The picture I
posted was a little misleading in this aspect, but it shows nicely the desired
light glow at the edges of surfaces in shadow areas.

> Despite the dimention of your object, your media is not what I call dense.

How could the density be increased? Setting the scatter rgb to higher values
leads to way to high brightness levels on the surface. Using attenuation and
extinction this could be fixed, but was not changing the demonstrated visibility
issues.

And what I still don't get is why a simple division of the same media into
several boxes yields a completely different result.

> You should try with an isosurface using some function that have
> repeating holes, like leopard. Use "all_intersections. Use a material
> with some transparency, an interior with an ior of about 1.4 to 1.7,
> fade_color fade_distance and fade_power 1 or fade_power 1001.
> The texture should have some transparency:
>   rgbf<Red_Value, Green_Value, Blue_Value, 0.7>
> Add some specular to the finish: specular 0.5 roughness 0.01.

My first try was actually to model the foam cells explicitly, I used a script
generated mesh2 with irregular cells for this purpose. Due to the numerous
partly filtering surface layers there was actually no need for fading, but the
light glow due to scattering was not very realistic. And the performance was not
very good, especially with the high number of cells needed to get a fine foam.

Whats wrong is not the foamy look of the surface, but the feature visibility of
objects in the media. If they are behind the media volume, the suddenly
disappear -- instead of fading away with distance. This effect is demonstrated
in the model I posted: just increase the number of media slices, and the object
visibility changes despite the fact that the media effectly stays unchanged and
is only distributed along several boxes. This seems quite illogical to me.


Post a reply to this message

From: waggy
Subject: Re: scattering media oddities
Date: 14 Mar 2010 20:10:01
Message: <web.4b9d79ae1a9a49cef99d05c80@news.povray.org>
"Kai" <nomail@nomail> wrote:
> To model a foam plastic object (like
> http://de.wikipedia.org/wiki/Datei:Haushaltsschwaemme.jpg ) I tried a
> appropriate surface texture combined with a dense scattered media.
>
> The results are good, except when some feature is placed in the foam object.
> Such a feature should only be visible on a very short distance below the
> surface, but it's visible throughout the whole object. I've tracked down this
> issue to the scattering media.
>
> In the following sample scene the blue cylinder should disappear quickly, but
> it's visible through the whole media filled box. If the box is divided into
> parts (just set fogDivisions > 1), the visibility issue get's better. With
> subdivisions one get's band artifacts, however, and for more complex objects
> this wouldn't be of much help anyhow. I'm using povray Unix 3.6.1.
>
> Are there better alternatives to model this case?
>
It sounded like an accuracy issue, so I tried adding "method 3 samples 100" to
the media statement.  This seemed to result in the appearance you're expecting.

~David


Post a reply to this message

From: waggy
Subject: Re: scattering media oddities
Date: 14 Mar 2010 21:55:00
Message: <web.4b9d93431a9a49cef99d05c80@news.povray.org>
I noted earlier,
> It sounded like an accuracy issue, so I tried adding "method 3 samples 100" to
> the media statement.  This seemed to result in the appearance you're expecting.
>
I should add this was on Windows 3.7 beta 35, which seemed to reproduce what you
described originally.  (This particular computer doesn't have 3.6 installed.)
Also, I didn't try to find the smallest sample number increase to get the
accuracy needed.  I hope this helps.


Post a reply to this message

From: Christian Froeschlin
Subject: Re: scattering media oddities
Date: 15 Mar 2010 05:41:43
Message: <4b9e00d7$1@news.povray.org>
waggy wrote:

> It sounded like an accuracy issue, so I tried adding "method 3 samples 100" to
> the media statement.  This seemed to result in the appearance you're expecting.

Also, note that the value for scattering is not limited
to 1.0, you can have thicker media than that.

Alternatively, you might wish to have a look at the new
experimental sslt feature in povray 3.7b, which is intended
for dense material (i.e. scattering which takes place near
the surface only).


Post a reply to this message

From: Alain
Subject: Re: scattering media oddities
Date: 15 Mar 2010 18:31:45
Message: <4b9eb551$1@news.povray.org>

> Alain<aze### [at] qwertyorg>  wrote:
>> You want to model a lump of foam, but you model a box filled with smoke.
>> That's not the same thing.
>
> Both media show the physical process of scattering due to scatterers (quote from
> wikipedia: "The types of non-uniformities which can cause scattering, sometimes
> known as scatterers or scattering centers, are too numerous to list, but a small
> sample includes particles, bubbles, droplets, density fluctuations in fluids,
> defects in crystalline solids, surface roughness, cells in organisms, ...")
>
> The idea was to use the media scattering to exploit the (probably) higher
> efficiency and not modeling the micro cells of the foam explicitly.
>
> The objective is to get the scattering look of a dense media, without overly
> bright surface. Single foam cells do not need to be visible. The picture I
> posted was a little misleading in this aspect, but it shows nicely the desired
> light glow at the edges of surfaces in shadow areas.
>
>> Despite the dimention of your object, your media is not what I call dense.
>
> How could the density be increased? Setting the scatter rgb to higher values
> leads to way to high brightness levels on the surface. Using attenuation and
> extinction this could be fixed, but was not changing the demonstrated visibility
> issues.
>
> And what I still don't get is why a simple division of the same media into
> several boxes yields a completely different result.
>
>> You should try with an isosurface using some function that have
>> repeating holes, like leopard. Use "all_intersections. Use a material
>> with some transparency, an interior with an ior of about 1.4 to 1.7,
>> fade_color fade_distance and fade_power 1 or fade_power 1001.
>> The texture should have some transparency:
>>    rgbf<Red_Value, Green_Value, Blue_Value, 0.7>
>> Add some specular to the finish: specular 0.5 roughness 0.01.
>
> My first try was actually to model the foam cells explicitly, I used a script
> generated mesh2 with irregular cells for this purpose. Due to the numerous
> partly filtering surface layers there was actually no need for fading, but the
> light glow due to scattering was not very realistic. And the performance was not
> very good, especially with the high number of cells needed to get a fine foam.
>
> Whats wrong is not the foamy look of the surface, but the feature visibility of
> objects in the media. If they are behind the media volume, the suddenly
> disappear -- instead of fading away with distance. This effect is demonstrated
> in the model I posted: just increase the number of media slices, and the object
> visibility changes despite the fact that the media effectly stays unchanged and
> is only distributed along several boxes. This seems quite illogical to me.
>
>
>
You should be concious of a stiff limitation/assumption with medias:
ALL medias assume that any ray going through the media will only 
interact with it about 1 time or less. That is, NO multiple interactions.

As Christian Froelichlin mentioned, you may have beter results using the 
current 3.7 beta and the SSLT feature. It assume that there are MANY 
interactions between any ray and the material encountered.
With that, you model your object as a box with a buzzy normal and some 
fine texture, or an isosurface that have a rough surface using something 
like f_granite, f_agate or f_wrinkles.

You can also use your actual model and add fade_color, fade_distance and 
fade_power 1001 to your interior.
Adding some ior and playing with the normal will also increase the 
beleivability.

Try this:
Add the following to your box just before it's closing bracket:
  normal{granite 0.3 scale 0.01}

Then, change your material ass follow:
#declare M_fog =
material {
  texture {
   pigment { color rgbf <1,1,1,1> }
   finish{specular 0.3 roughness 0.01}
	}
  interior {
   //fade_color rgb<0.5, 0.5, 0.5> fade_distance 0.01 fade_power 1001
   //media {  scattering { 1,     White *0.08  }      }
   ior 1.44
    }
}

Render like this, then, try uncommenting the media or the fade_... lines.
With just the ior and normal, the surface becomes very grainny and your 
cylinder quickly "dissolve" away.
Play with the scale and depth of the normal as well as the ior to 
controll the effect.
Antialiasing will change the general aspect, making it much smoother.


Alain


Post a reply to this message

From: Alain
Subject: Re: scattering media oddities
Date: 19 Mar 2010 21:59:52
Message: <4ba42c18$1@news.povray.org>


I did some testing using isosurface and came with that:

#declare Scl = 130;
// act as scale 1/130 for a pattern or an object
#include "functions.inc"
// a very usefull collections of various functions.
isosurface{
	function{ f_granite(x*Scl,y*Sclm,z*Scl) }
	threshold 0.3
// Alter this value to change the "filling" of the shape
	contained_by{box{<-5, 0.01, -5><10, 13, 7>}}
	max_gradient 2
// The reported max_gradient is much larger, but any holes
// are not perceptible at the scale used
	all_intersections // needed as we use tranparency
	material {
		texture { pigment { color rgbf <1,1,1,0.3> } }
		interior {fade_color rgb<1,0.5,0.3>
			fade_distance 0.01 fade_power 1001
			ior 1.4
			//media {  scattering { 1,     White *0.08  samples 3}
// if you use nedia, you should use a low count as you can go through
// a LOT of surfaces.
       }
			}
		}
	finish{specular 0.2 roughness 0.01}
	
	}

With the transparency used and adc_bailout, max_trace_level was only 
4/255, but, if you use more transparency, you'll encounter more surfaces.
It shows transparency near the corners. The cylinder progressively 
disapear in the mass.

You can try with other functions.


I also used normal perturbations and set an ior for the containing box 
giving interesting results. I also used colour fading. With that trick, 
the cylinder dissolves into the box:

#declare i = 0;
#declare fogStep = fogDepth/fogDivisions;
#while(i < fogDivisions)
    box {
       <-5, 0.01, -5 + i*fogStep>, <10, 13, -5 + (i+1)*fogStep - 0.01>
       hollow
material {
    texture { pigment { color rgbf <1,1,1,1> }  finish{specular 0.3 
roughness 0.01}
	}
    interior {
    	fade_color rgb<0.95, 0.90, 0.85> fade_distance 0.5 fade_power 1001
	media {  scattering { 1,     White *0.08  }      }
	ior 1.44
    }
}

    normal{granite 0.5 scale 0.01}
    }
#declare i = i + 1;
#end




Alain


Post a reply to this message

From: Kai
Subject: Re: scattering media oddities
Date: 20 Mar 2010 03:05:01
Message: <web.4ba472ec1a9a49cec94e5b500@news.povray.org>
Thanks to all of you for the helpful suggestions!

I've installed the Unix beta, learned
about the new gamma and experimented
quite a bit. At the end of the post
I put a new demo scene, which is intended
for default 3.7's gamma. To check for a
good foam, I've included two camera alternatives,
a front and a back view. The back view shows
nicely the glow effect of the light (if present),
the front view if everything else (lighted surface,
disappearing objects, shadow edges, cavities) looks right.

I've tried the suggested subsurface scattering.
The glow effect, the disappearing object and the
shadow edges are ok. I used black pigment, as
the surface seems to be dominated by the subsurface's color.
Overall a not to bad result, but for me it's still hard
to get a feeling for the params. Hue and lightness of
the surface are not easy to control. Some black speckles
remain on the surface (black pigment), for whiter pigments
the surface tends to get overly bright. The cavity's faces
also seem to be overly bright compared to the outer faces.

The media alternative looks quite ok, like a very fine
grained foam which could be used for protective packaging.
But the cylinder does still not disappear.
Setting samples to a high value did not helped here.
That's basically the same problem I had as I came
up with the inital post.

The isosurface proposed by Alain looks also good, yielding
a less dense and coarser, spongy foam. I've added a second scene
showing the same demo objects for this approach.
For my demo objects I got CSG/solidity issues, however.
The foam disappears behind the cavity and the interior settings
do not seem to have any visual effect. Perhaps I did something
wrong or the isosurf is just to complex for stable CSG ops?
Compared to the media and subsurf approach, this alternative
does not show a pronounced glowing effect from the rear view,
but this may be due to not working interior settings as I would
expect the ior to bend around some light for a nice glow.

------------------------ subsurf and media ------------------------
#include "colors.inc"

#declare lightLevel = 2.0;
#declare aR = 0.01;

global_settings {
   // globals for subsurface scattering
   mm_per_unit 10
   subsurface { samples 400, 40 }
}

camera {
   location <+10, 20, -25> /* front view */
   //location <-10, 20, +25> /* back view */
   look_at  <0, 5,  0>
   angle 45
}

light_source {
   <60, 50, -40>, color White*lightLevel
   spotlight
   point_at <0, 5, 0>
   radius 10
   falloff 15
}

plane {
   y, 0
   texture {
      pigment {
  color White
      }
      finish {
  ambient aR
  diffuse 0.6
      }
   }
}


// foam material (uncomment one of the alternatives)

/*
//    subsurface
#declare foam =
material {
   texture {
      pigment {
  color rgbf <0.9,0.9,0.65,0.0>*0.0
      }
      normal {
  granite 0.6
      }
      scale 0.2

      finish {
  ambient aR
  diffuse 0.5
  specular 0.8
  roughness 0.01

  subsurface {
     < 2.29, 2.39, 1.97>, <0.003, 0.0034, 0.046>
  }
      }
   }
}
*/

//    media
#declare foam =
material {
   texture {
      pigment {
  color rgbf <0.9,0.9,0.65,0.7>
      }
      normal {
  granite 0.6
      }
      scale 0.2

      finish {
  ambient aR
  diffuse 0.5
  specular 0.8
  roughness 0.01
      }
   }
   interior {
      media {
  scattering {
     1, White*2
  }
  samples 100, 100
      }
   }
}


// test objects
box {
   <-2, 10.01, -2>, <2, 12, 2>
   hollow
   material { foam }
}

difference {
   box {
      <-5, 0.01, -5>, <5, 10, 5>
   }
   box {
      <0, 5, -6>, <4, 9, +1>
   }
   hollow
   material { foam }
}

cylinder {
   <-2, 6,-6>, <-2, 6, 6>, 1
   texture {
      pigment { color <0.5, 0.5, 1> }
      finish { diffuse 0.6 ambient aR }
   }
}
------------------------ isosurf ----------------------------------
#include "colors.inc"
#include "functions.inc"

#declare lightLevel = 2.0;
#declare aR = 0.01;

global_settings {
   max_trace_level 100
}

camera {
   location <+10, 20, -25> /* front view */
   //location <-10, 20, +25> /* back view */
   look_at  <0, 5,  0>
   angle 45
}

light_source {
   <60, 50, -40>, color White*lightLevel
   spotlight
   point_at <0, 5, 0>
   radius 10
   falloff 15
}

plane {
   y, 0
   texture {
      pigment {
  color White
      }
      finish {
  ambient aR
  diffuse 0.6
      }
   }
}

#declare Scl = 5;
union {
   isosurface {
      function{ f_granite(x*Scl,y*Scl,z*Scl) }
      threshold 0.3
      contained_by {
  box {
     <-2, 10.01, -2>, <2, 12, 2>
  }
      }
      max_gradient 2
      all_intersections
   }
   difference {
      isosurface {
  function{ f_granite(x*Scl,y*Scl,z*Scl) }
  threshold 0.3
  contained_by {
     box {
        <-5, 0.01, -5>, <5, 10, 5>
     }
  }
  max_gradient 2
  all_intersections
      }
      box {
  <0, 5, -6>, <4, 9, +1>
      }
   }
   material {
      texture {
  pigment { color rgbf <0.9,0.9,0.65,0.3> }
  finish {
     specular 0.2
     roughness 0.01
     ambient aR
     diffuse 0.6
  }
      }
      interior {
  fade_color <0.5,0.5,0.3>
  fade_distance 0.01 fade_power 2
  ior 1.4
      }
   }
}

cylinder {
   <-2, 6,-6>, <-2, 6, 6>, 1
   texture {
      pigment { color <0.5, 0.5, 1> }
      finish { diffuse 0.6 ambient aR }
   }
}
-------------------------------------------------------------------


Post a reply to this message

From: clipka
Subject: Re: scattering media oddities
Date: 21 Mar 2010 23:05:44
Message: <4ba6de88$1@news.povray.org>
Kai schrieb:

> I've tried the suggested subsurface scattering.
> The glow effect, the disappearing object and the
> shadow edges are ok. I used black pigment, as
> the surface seems to be dominated by the subsurface's color.

Yes, the subsurface scattering algorithm employed does indeed account 
for diffuse illumination, and so should best be used with "diffuse 0" 
or, as you did, a black pigment (at least as it is currently implemented).

> Overall a not to bad result, but for me it's still hard
> to get a feeling for the params. Hue and lightness of
> the surface are not easy to control.

While the current syntax is ideal for specifying materials with known 
physical parameters, and also particularly well-suited for the 
underlying algorithm, it is also known to be hard to control.

I recommend not spending too much time trying to master the parameters, 
as the syntax will be subject to change; while it is not trivial to 
"reverse engineer" the physical parameters of a material from its 
apparent color under uniform lighting conditions (what would normally be 
described in POV-Ray by the combination of pigment and diffuse value) as 
well as the "mean free path" of light traveling through the material (an 
RGB parameter that is said to be comparatively intuitive, governing how 
"translucent" the material will appear), there are algorithms to find 
matching parameters, so there's hope that the final SDL syntax for 
subsurface scattering will hide the physical coefficients from the user, 
and instead use the classic pigment/diffuse parameters plus an 
additional "translucency" RGB parameter.


Post a reply to this message

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