POV-Ray : Newsgroups : povray.general : Spherical density map Server Time
26 Dec 2024 21:49:37 EST (-0500)
  Spherical density map (Message 1 to 3 of 3)  
From: Mike Horvath
Subject: Spherical density map
Date: 7 Jan 2016 17:00:56
Message: <568ee018$1@news.povray.org>
I'm confused about how to set up a spherical density map.

I want a density map that is dense at the origin, and stays dense until 
it gets close to 1 unit away, then fall off sharply.

How would I set this up?

Thanks.


Mike


Post a reply to this message

From: Norbert Kern
Subject: Re: Spherical density map
Date: 7 Jan 2016 17:40:00
Message: <web.568ee912eb3f91942b16ebf70@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:
> I'm confused about how to set up a spherical density map.
>
> I want a density map that is dense at the origin, and stays dense until
> it gets close to 1 unit away, then fall off sharply.
>
> How would I set this up?
>
> Thanks.
>
>
> Mike


Here is a test scene you can play with.
Personally I use two density maps to be more flexible.
Of course one map would be sufficient...

///////////////////////////////////////////////////////////

#version 3.7;

global_settings {
        assumed_gamma 1
        max_trace_level 5
        noise_generator 2
}

#include "stdinc.inc"

#declare cam_loc = <0,0,-8>;
#declare lookat = <0,0,0>;
camera {
        location cam_loc
        look_at lookat
        right x*image_width/image_height
        up y
        angle 15*image_width/image_height
}

#macro Dens (glowcol)

#declare density_1 =
density {
        spherical
        color_map {
                [0.05   rgb 0]
                [0.15   rgb glowcol]
        }
}

#declare density_2 =
density {
        spherical
        color_map {
                [0.05   rgb 0]
                [0.7    rgb glowcol]
        }
}

density {
        average
        density_map {
                [1      density_1]
                [1      density_2]
        }
}

#end

#declare Color_ = <1,0.8,0.3>;
sphere {
        <0,0,0>, 2
        hollow
        pigment {color rgbt 1}
        interior {
                media {
                        emission rgb 1
                        Dens (Color_)
                }
        }
        scale 1
        translate 0
}
////////////////////////////////////////////////

Norbert


Post a reply to this message

From: Alain
Subject: Re: Spherical density map
Date: 7 Jan 2016 21:37:29
Message: <568f20e9$1@news.povray.org>
Le 16-01-07 17:01, Mike Horvath a écrit :
> I'm confused about how to set up a spherical density map.
>
> I want a density map that is dense at the origin, and stays dense until
> it gets close to 1 unit away, then fall off sharply.
>
> How would I set this up?
>
> Thanks.
>
>
> Mike

Knowing that the spherical evaluate to 1 at <0,0,0> and drop to zero at 
radius 1.

Like this:

density {
         spherical
         color_map {
                 [0     rgb 0]
                 [0.8   rgb 10]
         }
}

This gives full density for 80% of the radius, that will sharply drop to 
zero in the last 20% of the radius.
You don't need to drop to zero before the pattern actualy drop to zero, 
so, using 0.05 as a controll value is just wastefull.

Using two densities and averaging them don't offer any real advantage 
and take about twice as long to render. You need to evaluate both 
density, add them and divide the result.

The patterns cylindrical, planar and boxed work the same.
cylindrical evaluate to 1 along the Y axis and drop to zero at radius 1.
planar evaluate at 1 on the X-Z plane and drop to zero at -1 and +1.
boxed conform to box{-1, 1} with a value of zero at the surface.

I can't recoment to ever use stdinc.inc. It include a large number of 
other inc files that you may not need. In Norbert's example, NOT a 
single bit from those includes are ever used.



Alain


Post a reply to this message

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