POV-Ray : Newsgroups : povray.general : halo conversion question Server Time
16 Nov 2024 13:23:20 EST (-0500)
  halo conversion question (Message 1 to 3 of 3)  
From: Dan Connelly
Subject: halo conversion question
Date: 12 Jul 1998 16:34:23
Message: <35A90FB6.42A30957@flash.net>
/**************************************************************
I apologize for all the questions, but I have been struggling
with making a fog of a decaying exponential density for some
time now.  And the issue of media has been brought up
by other posters.

I finally figured it out, I think, but within the halo
framework -- I can't figure out how to convert it into
3.1 compliance.  It looks as though my current project
will be in 3.02 TM unless I can figure out the conversion.

A halo solution is the following.  Note the exponential
behavior is effected through the transparancy channel of
the halo color map.

Any ideas on converting this into media?
********************************************************/

#version 3.0
#declare Camera_Location = <1.5, 0.7, -2>;

camera {
  location Camera_Location
  look_at <0, 0.5, 0>
}
light_source {
  Camera_Location
  color rgb 0.5
}
light_source {
  <-100, 100, -100>
  color rgb 0.5
}

box {
  <-0.5, 0, -0.5>,
  <0.5,  1, 0.5>
  hollow
  pigment { rgbf 1 }
  halo {
    attenuating
    planar_mapping
    linear
    max_value 1
    color_map {
      #declare Y = 0;
      #declare dY =0.05;
      #declare A = 5;
      #while (Y < 1 + dY/2)
        [Y rgbt <0, 1, 0, 1-exp(-A*(1-Y))>]
        #declare Y = Y + dY;
      #end
    }
  }
}

plane {
  y,
  0
  pigment {
    color rgb <1, 1, 1>
  }
}

sky_sphere {
  pigment { color rgb 1 }
}

/////////////////////////////////////////
// http://www.flash.net/~djconnel/


Post a reply to this message

From: Chris Colefax
Subject: Re: halo conversion question
Date: 17 Jul 1998 11:11:04
Message: <35AF3584.3576F7DD@geocities.com>
Dan Connelly wrote:
> 
> I apologize for all the questions, but I have been struggling
> with making a fog of a decaying exponential density for some
> time now.  And the issue of media has been brought up
> by other posters.
> 
> I finally figured it out, I think, but within the halo
> framework -- I can't figure out how to convert it into
> 3.1 compliance.  It looks as though my current project
> will be in 3.02 TM unless I can figure out the conversion.
> 
> A halo solution is the following.  Note the exponential
> behavior is effected through the transparancy channel of
> the halo color map.
> 
> Any ideas on converting this into media?

While I won't claim to be an expert at either halos or media, the
following seems to at least approach what you achieved under POV-Ray 3.0
(see original at the end of the message):

   #declare dY =0.05;
   #declare A = 5;

   box {<-0.5, 0, -0.5>, <0.5,  1, 0.5> hollow
      pigment { rgbf 1 }
      interior { media { absorption <1, 1, 1> emission <0, 1, 0>
         density {planar
            color_map {
               #declare Y = 0; #while (Y < 1 + dY/2)
                  [Y rgb exp(-A*(1-Y))]
               #declare Y = Y + dY; #end }
            }}}}

This seems to work because, as the docs explain, the color_map value at
any point is multiplied by the absorption and emission values to get the
final colour.  Therefore, at Y = 0 (which, with the planar pattern,
actually equates to a height of 1 up the y-axis), the color_map value
is  close to 0 (using the above A value).  This brings the absorption
and emission values close to 0, giving a practically transparent media
(at the top of the box).  At Y = 1 (the bottom of the box), the
color_map value is 1, giving the full absorption and emission specified.

I'm sure there are many other ways of achieving the same (or better!)
results, but hopefully this is helpful in some way (it was for me, at
any rate...)


// Originally posted scene

#version 3.0
#declare Camera_Location = <1.5, 0.7, -2>;

camera {
  location Camera_Location
  look_at <0, 0.5, 0>
}
light_source {
  Camera_Location
  color rgb 0.5
}
light_source {
  <-100, 100, -100>
  color rgb 0.5
}

box {
  <-0.5, 0, -0.5>,
  <0.5,  1, 0.5>
  hollow
  pigment { rgbf 1 }
  halo {
    attenuating
    planar_mapping
    linear
    max_value 1
    color_map {
      #declare Y = 0;
      #declare dY =0.05;
      #declare A = 5;
      #while (Y < 1 + dY/2)
        [Y rgbt <0, 1, 0, 1-exp(-A*(1-Y))>]
        #declare Y = Y + dY;
      #end
    }
  }
}

plane {
  y,
  0
  pigment {
    color rgb <1, 1, 1>
  }
}

sky_sphere {
  pigment { color rgb 1 }
}


Post a reply to this message

From: Dan Connelly
Subject: Re: halo conversion question
Date: 17 Jul 1998 19:46:30
Message: <35AFD446.80DE477B@flash.net>
Thenks to Chris for the excellent response!
Sometimes when reading documentation
I read my preconceived interpretation of the parameter name
rather than what is actually on the page; you have done
an excellent job in clarifying this new system.

By the way, this may seem like a little thing, but I like
Chris's way of formatting #whiles to emulate the
look of for-loops.... it is very clear.

Dan


Chris Colefax wrote:
> (djconnel wrote)
> > I have been struggling
> > with making a fog of a decaying exponential density for some
> > time now.....
> > Any ideas on converting this into media?
> 
> This seems to work because, as the docs explain, the color_map value at
> any point is multiplied by the absorption and emission values to get the
> final colour.

-- 
http://www.flash.net/~djconnel/


Post a reply to this message

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