POV-Ray : Newsgroups : povray.binaries.images : using an image_map for media density/color : using an image_map for media density/color Server Time
7 Aug 2024 09:21:59 EDT (-0400)
  using an image_map for media density/color  
From: Kenneth
Date: 7 Apr 2006 18:30:00
Message: <web.4436e54a72fe66658ad7a9060@news.povray.org>
I thought I'd try an experiment to see if an image_map with an alpha channel
could be used for determining the density and color of a media-filled
object...specifically to try and make the resulting object *look* solid,
without using a heightfield to do so. Just to see if it was possible.  (I
may be "re-inventing the wheel" here, rehashing old news. Sorry if that's
the case.) My original question about this is at....

http://news.povray.org/povray.general/thread/%3Cweb.4428c5d859cea9017bf568ef0%40news.povray.org%3E/

First, let me thank Bruno Cabasson and Mike Williams for some VERY helpful
code they posted there, which put me on the right track.

For subject matter, I chose a photo I took of a dino skeleton at the Museum
of Natural History in New York. The image's alpha channel was made in
Photoshop.

Image #2 shows what normally happens when an alpha-channel image_map is
applied to a box: the front and back faces are visible, but the intervening
space is empty. I wanted to "solidify" the intervening space. (I added the
box shape just for clarity.)

I first tried using the image_map as a single function, applied to three
different primary-color emission medias. The results were somewhat
promising, but had one major drawback: The function seems to ignore the
image_map's alpha channel (or, if it does recognize it, I couldn't find a
way to access that information, though I tried mightily!) So, the
supposedly-transparent areas were filled with media as well.

But a simple work-around solved that roadblock: using THREE versions of the
image_map.  Two (with the alpha channel removed) are used as functions--one
for absorbing media (image #3), and one for emitting media (image #4--with
its alpha channel areas replaced with black.) The original image_map (with
alpha channel) is projected onto the box as usual; it helps give more
"solidity" to the front--and replaces the need for pigment{rgbt 1} as the
box's texture. (I found that quite interesting!)

Having tried all three media types with various versions of the image_map,
the best visual result seems to come from using both absorbing and emitting
media, overlapped.  The "plug" of absorbing media is definitely needed; it's
primarily responsible for making the media look solid. Using scattering
media (by replacing the three emission medias) worked reasonably well...not
great...and took *forever* to render. So right now, there's no light
interaction with the object, other than its full shadow on the ground.

The subtle moire patterns visible in the media are a mystery, but can be
minimized by using higher and higher samples values. I thought they might
be a result of "coincident media" (if there is such a thing); but shifting
each media around slightly in space didn't affect it.  Could come from any
of a number of causes. AA values in the media, perhaps?

As it is, this technique is not much more than an intriguing experiment
(though I'm just beginning to explore its possibilities.) Adding
warp{turbulence, etc.} to each media creates some wild and interesting
results, for example.  And there's probably a way to fade out all the media
as it progresses in the +z direction...like an image-based vapor trail. If
that's possible, then the technique could also be used to create what looks
like a motion-blurred object.

Ken W.

-----------------
The code...

#declare my_image_function_1 = function{pigment{image_map {png
"dino_skeleton_ABSORPTION.png" map_type 0 interpolate 2}}};

#declare my_image_function_2 = function{pigment{image_map {png
"dino_skeleton_EMISSION.png" map_type 0 interpolate 2}}};

#declare MM = 75; // overall media multiplier...very dense

#declare EM = .75; // extra media multiplier for emission media (yes, .75)

#declare media_samples = 160; // if this is changed, then EM above will
probably need tweaking.


box{<0,0,0>,<1,1,1> hollow
        texture{
      // the original image with its alpha channel...
        pigment {image_map {png "dino_skeleton.png" map_type 0 interpolate 2
once}}

                finish{
                        ambient 1
                        diffuse 0
                      }
               }

        interior{

                // absorbing media--one only
                media{
                        absorption 1*MM // absorbs all colors equally
                        samples media_samples
                        density{ function{my_image_function_1(x,y,z).gray}
                               }
                     }


                // emitting medias--THREE
                media{
                        emission <1,0,0> *MM*EM  // red
                        samples media_samples
                        density{ function{my_image_function_2(x,y,z).red}
                               }
                     }


                media{

                        emission <0,1,0>*MM*EM // green
                        samples media_samples
                        density{ function{my_image_function_2(x,y,z).green}
                               }
                     }

                media{

                        emission <0,0,1>*MM*EM // blue
                        samples media_samples
                        density{ function{my_image_function_2(x,y,z).blue}
                               }
                     }
                } // end of interior

                scale <1.22,1,1> // or whatever

} // end of box


Post a reply to this message


Attachments:
Download 'dino_solid_media.jpg' (301 KB)

Preview of image 'dino_solid_media.jpg'
dino_solid_media.jpg


 

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