POV-Ray : Newsgroups : povray.advanced-users : Media and density question Server Time
29 Jul 2024 00:34:44 EDT (-0400)
  Media and density question (Message 1 to 6 of 6)  
From: Erhard Ducke
Subject: Media and density question
Date: 1 Dec 2003 12:24:15
Message: <0utmsvk3jucrmv28dljhnmpbgd264rmbgm@4ax.com>
Hi!
I try to make a sphere media with a spherical density.
The density should be 1 at the center and constant until x percent of the
radius are reached. Then the density should falloff linear until the radius
of the sphere is reached.
How can I achieve this? density_map?

//********************************
                    media {
                        scattering {3, <1,1,1>}
                        intervals 1
                        density_map {
                        ???
                        }
                    }
//***********************************


Can anyone give an example?
Thanks!

-- 
Erhard Ducke


Post a reply to this message

From: Tim Nikias v2 0
Subject: Re: Media and density question
Date: 1 Dec 2003 13:13:01
Message: <3fcb84ad@news.povray.org>
density_map{spherical color_map{[0 rgb 0][1 rgb 1]} scale Sphere_Radius}

Sphere_Radius would have to be either the radius of the sphere, or you leave
that out when declaring the unit-sphere (sphere{0,1 hollow etc}) and apply
transformations AFTER the materials.

To change the colors, just use different rgb values. Note that the 0 index
of the color_map will be everywhere around the sphere. The spherical-pattern
begins at the origin with color_map 1 and fills a sphere of radius 1 until
color_map 0.

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>
Email: tim.nikias (@) nolights.de


> Hi!
> I try to make a sphere media with a spherical density.
> The density should be 1 at the center and constant until x percent of the
> radius are reached. Then the density should falloff linear until the
radius
> of the sphere is reached.
> How can I achieve this? density_map?
>
> //********************************
>                     media {
>                         scattering {3, <1,1,1>}
>                         intervals 1
>                         density_map {
>                         ???
>                         }
>                     }
> //***********************************
>
>
> Can anyone give an example?
> Thanks!
>
> -- 
> Erhard Ducke


Post a reply to this message

From: Slime
Subject: Re: Media and density question
Date: 1 Dec 2003 14:07:36
Message: <3fcb9178$1@news.povray.org>
Note that color_map{[0 rgb 0][1 rgb 1]} is redundant for the spherical
density map; you can leave it out.

It's redundant for most patterns, actually - all but the oldest such as bozo
which come with fairly useless default color maps.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Warp
Subject: Re: Media and density question
Date: 2 Dec 2003 06:08:55
Message: <3fcc72c7@news.povray.org>
Tim Nikias v2.0 <tim.nikias (@) nolights.de> wrote:
> density_map{spherical color_map{[0 rgb 0][1 rgb 1]} scale Sphere_Radius}

  He wanted a constant density up to certain radius, after which the
density should drop linearly to 0 on the outer surface of the pattern.
  So instead of the [1 rgb 1] he should write [1-P rgb 1] where P is the
desired percentage of the radius (between 0 and 1).

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Erhard Ducke
Subject: Re: Media and density question
Date: 2 Dec 2003 09:58:59
Message: <nk9psvcnts17omiukiqjcc3541mht4ag7e@4ax.com>
On 2 Dec 2003 06:08:55 -0500, Warp <war### [at] tagpovrayorg> wrote:

>  He wanted a constant density up to certain radius, after which the
>density should drop linearly to 0 on the outer surface of the pattern.
>  So instead of the [1 rgb 1] he should write [1-P rgb 1] where P is the
>desired percentage of the radius (between 0 and 1).

//*************************************
         media {
              scattering {4, <1,1,1>}
              intervals 1
                   
              density {
                    spherical scale (SphereRadius)
                        density_map { 
                            [0 rgb 0]
                            [.1*SphereRadius rgb 1]
                            [1 rgb 1]
                        }
                      }
                    }
 //**************************************

The above code is working now...
Density remains constant from center to 0.9*SphereRadius and drops linearly
to 0 on the outer surface of the sphere...
I wonder whether the density can be modified to drop logarithmical, not
linear, this would give even a better effect...
-- 
Erhard Ducke


Post a reply to this message

From: Christopher James Huff
Subject: Re: Media and density question
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.