POV-Ray : Newsgroups : povray.newusers : cant get density{sphereical} to work : Re: cant get density{sphereical} to work Server Time
7 Jul 2024 07:05:45 EDT (-0400)
  Re: cant get density{sphereical} to work  
From: Alain
Date: 6 Mar 2010 13:13:17
Message: <4b929b3d@news.povray.org>

> hello all
>
> I'm just playing about with povray getting used to what going on ...BUT...
>
> i either don't understand something or haven't turned something on as a simple
> scene  will not render a sphere with a spherical density modifier for the
> containing medium i was expecting to see a sphere with a decreasing radial
> colour density, instead its just not there. a variation on this is  if i use a
> density_map in which case only the outer most layer is viable.... WHY is this
> happening? as it doesn't seem to be a very complicated thing to get to work,
> even the example in the povray tutorial wont work.
>
> I'm working in Linux (ubuntu 9.04 64 bit) Persistence of Vision(tm) Ray Tracer
> Version 3.6.1 (Debian  (x86_64-linux-gnu-g+
> + 4.3.3 @ x86_64-pc-Linux-gnu))
> though the problem also happens in windows version
>
> what do i change please thanks
>
> James
>
> code follows:
>
> #include "colors.inc"
> #include "textures.inc"
> global_settings{ambient_light 0
> max_trace_level 10
> }
>
>
> camera {
>      location<0, 0, 0>
>      look_at<0, 0,  10>
>    }
>
> plane{<0, 1, 0>, -2
>      pigment {
>        checker color Red, color Blue
>      }
>
>
> }
>
> sphere {
>      <0, 0, 10>, 2
> texture {pigment{ Clear}}
>
>      interior{
> media{method 3
>
> scattering{4,White}
> density {spherical density_map
>           { [0 rgb .01]
>             [0.4 rgb<1,0,0>]
>             [0.8 rgb<1,1,0>]
>             [1 rgb 1]
>           }
>
> }
> }
> }
>      hollow
>    }
>
> light_source {<0, 100, 0>  <2,2,2>
>   fade_distance 75
>   fade_power 2
>
>   }
>
>
>
>
The spherical pattern is defined at the origin. It evaluate to 1 at 
ABSOLUTE coordinate <0,0,0> and to 0 everywhere where the distance from 
there is 1 or more.

Your sphere center is situated at 10 units from the origin and, given 
it's radius, no point is closer that 8 units.

You have 2 solutions:
First and best: Define your sphere at the origin, then translate if 
where you want it.
sphere {
     <0, 0, 0>, 2
texture {pigment{ Clear}}
     interior{media{method 3
scattering{4,White}
density {spherical density_map
          { [0 rgb .01]
            [0.4 rgb <1,0,0>]
            [0.8 rgb <1,1,0>]
            [1 rgb 1]
          }
}
}
}
     hollow
translate<0,0,10>  }

Alternatively, you can translate the medis itself:
sphere {
     <0, 0, 10>, 2
texture {pigment{ Clear}}
     interior{media{method 3
scattering{4,White}
density {spherical density_map
          { [0 rgb .01]
            [0.4 rgb <1,0,0>]
            [0.8 rgb <1,1,0>]
            [1 rgb 1]
          }translate <0,0,10>
}
}
}
     hollow
   }

The first is beter. If you ever want, or need, to change the sphere's 
location, you only need to change the translate at the end.

Using the second solution, you need to change the location of the sphere 
and the translate of the media. Also, if you ever scale or rotate the 
sphere, with the first method, the media will get scaled/rotated with 
the sphere.

It's generaly considered a good practice to define all objects at the 
origin. Then to apply any scaling and rotation, then to translate the 
objects to there desired location.
scale and rotate are always performed relative the world's origin, never 
relative to the center of the objects.

Alain


Post a reply to this message

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