POV-Ray : Newsgroups : povray.advanced-users : Media and density question : Re: Media and density question Server Time
28 Jul 2024 22:15:45 EDT (-0400)
  Re: Media and density question  
From: Christopher James Huff
Date: 2 Dec 2003 10:55:28
Message: <cjameshuff-4033C4.10544702122003@netplex.aussie.org>
In article <nk9psvcnts17omiukiqjcc3541mht4ag7e@4ax.com>,
 Erhard Ducke <duc### [at] gentlemansclubde> wrote:

> I wonder whether the density can be modified to drop logarithmical, not
> linear, this would give even a better effect...

Difficult with the spherical pattern, it would be easiest with a 
function pattern. For inverse-square falloff:

density {function {1/pow(f_r(x, y, z), 2)}}

Or what I've seen called "gaussian" falloff:
function {exp(-f_r(x, y, z))}

However, note that inverse-square will reach 1 at a distance of 1, and 
shoot up towards infinity at r = 0. The values outside the [0, 1] range 
will get wrapped around. There are several ways to get around this...for 
example, you could scale the pattern values down and clip them to the 
[0, 1] range in the function, then specify a brighter than 1 color for 
the white in the color map to bring the density back up. Or you could 
use a different falloff function, such as the one used for distance 
falloff in POV-Ray's light sources. The gaussian function won't have 
this problem.

Also, neither inverse-square nor gaussial falloff will ever reach zero. 
If you just want a smooth falloff with a finite radius, you might want 
to try cosine falloff:

function {cos(min(1, f_r(x, y, z))*pi)/2 + 0.5}

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

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