POV-Ray : Newsgroups : povray.general : scattering media oddities : Re: scattering media oddities Server Time
30 Jul 2024 00:30:40 EDT (-0400)
  Re: scattering media oddities  
From: Kai
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

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