POV-Ray : Newsgroups : povray.general : using an image_map for media density/color? : Re: using an image_map for media density/color? Server Time
1 Aug 2024 04:10:36 EDT (-0400)
  Re: using an image_map for media density/color?  
From: Kenneth
Date: 29 Mar 2006 13:15:00
Message: <web.442acca136d07041bcf27ce60@news.povray.org>
"Bruno Cabasson" <bru### [at] alcatelaleniaspacefr> wrote:

> This piece of code works:
>
> #declare my_pattern = function
> {
>     pigment
>     {
>         image_map
>         {
>             png "my_image.png"
>             map_type 0
>             interpolate 2
>             once
>         }
>     }
> }
>
> box
> {
>     0, 1
>     pigment {rgbt 1}
>     hollow
>     interior
>     {
>         media
>         {
>             emission Red
>             density {function  {my_pattern(x,y,z).red}}
>         }
>         media
>         {
>             emission Green
>             density {function  {my_pattern(x,y,z).green}}
>         }
>         media
>         {
>             emission Blue
>             density {function  {my_pattern(x,y,z).blue}}
>         }
>     }
> }
>
> Regards


Sorry for the delay in replying; I've been experimenting!

Thanks to both you and Mike Williams for posting these techniques; I
wouldn't have thought of either one.

Your code does indeed work.  Very neat! The trouble, though, is that the
function seems to be ignoring the alpha channel in the image_map image. Or
rather, it treats the alpha channel as pure white, and fills the box with
full media density there. (I tried *LOTS* of odd tricks to get rid of that,
to no avail.) Any idea why?

I did come up with a workaround--getting rid of the alpha channel altogether
and substituting black for it in the image. That wiped out the offending
surrounding media.

Ultimately, I got your technique to work very well (with a few
modifications) by using THREE versions of my image_map...two as functions,
(no alpha channel)
and one (WITH the alpha channel) simply projected onto the box as a regular
pigment--the give the final object more "definition." Plus, using both
absorbing and emitting media, each with separate functions derived from
different versions of my image_map.  The result is a nice solid-looking
object, in the shape of the image, and nicely textured on the outside
"shell"...just what I wanted! Describing this process in detail would be
*most* difficult, so instead, I'll put together a visual description of it,
in steps, and post it soon over at p.b.i., along with the code.

I haven't yet tried Mike Williams' technique; I'll tackle that next.

Just thought I'd add that POV doesn't allow something like emission red as a
color specification (it generates an error). emission <1,0,0> is the
simple workaround, of course.

THANKS AGAIN!

Ken W.


Post a reply to this message

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