POV-Ray : Newsgroups : povray.newusers : color_map : Re: color_map Server Time
20 Sep 2024 18:59:00 EDT (-0400)
  Re: color_map  
From: ltong
Date: 24 Aug 2012 02:00:11
Message: <web.50371771f6ca84721cd19dea0@news.povray.org>
Alain <kua### [at] videotronca> wrote:

> > Great, now I can get something pretty close :)
> >
> > It is Fn(x,z,y) that I used for color_map, btw.
> >
> > Maybe the last question: in a user-defined pattern, does the output variable (Fn
> > in this example) give value_n [0,1] for color_map? I experimented with it a bit,
> > got somewhat unexpected results...
> >
> >     // the basic functions for the beam brightness
> >     #declare FALLOFF  = 1; // just an example, toy with it
> >     #declare a = 0.35;
> >     #declare b = 0;
> >     #declare c = 1;
> >     #declare FnRadial = function(r) {a*exp(-(r-b)*(r-b)/2/c/c)}
> >     #declare FnAxial  = function(z) { pow(FALLOFF,z) }
> >
> >     // helper function to compute radius from x,y
> >     #declare FnR = function(x,y) { sqrt(x*x+y*y) }
> >
> >     // the resulting 3D function
> >     #declare Fn = function(x,y,z) { FnRadial(FnR(x,y)) * FnAxial(z) }
> >
> >
> > object {gauss
> >    hollow
> >    pigment { color rgbf<1, 1, 1, 1> }
> >    interior {
> >      media {
> >        emission    color rgb < 1.0, 0.0, 0.0>*5
> >        density{ function {Fn(x,z,y)}
> >                  color_map {
> >                    [0 color rgb <0.0, 0.0, 0.0>]
> >                    [0.15 color rgb <0.1, 0.05, 0.0>]
> >                    [0.32 color rgb <0.3, 0.05, 0.0>]
> >                    [0.42 color rgb <0.5, 0.05, 0.0>]
> >                    [0.52 color rgb <0.7, 0.05, 0.0>]
> >                    [0.67 color rgb <0.9, 0.05, 0.0>]
> >                    [1.0 color rgb <1.0, 0.05, 0.0>]
> >                           }
> >               } // end density
> >       }//end media
> >      } //end interior
> >     scale <1,1.5,1>*0.5
> >     translate<0,2.0,0.0>
> > }
> >
> >
>
> Your FnAxial function have a value of zero along the Z axis that climb
> to 1 at a radius of 1. It's similar to the wood pattern.
> Make sure that your Gauss object extend along the Z axis.
>
> As your map stand now, it's black on the axis and return rgb<1,0.05,0>
> on the edge.
> To get a bright spot in the center fading to black at the edge, you
> should invert the colours of your map.

Thanks! Seems I misunderstood the function pow. Anyway, it produces somehow
acceptable results. I reversed the colormap, but do not see a dramatic change,
so still wondering how value_n is computed here... Guess it's FnRadial*FnAxial?

>
> As your emission colour is pure red, the green component of your map
> have absolutely no effect. Mabe it would be beter to use emission rgb 5.
> The final colour is the product of the value of emission and the entry
> of the color_map.
>
>
> Another alternative don't use media nor any function. You can use a
> plain light_source with the cylindrical attribute.
> You now control the bright spot using "radius", the overall width with
> "falloff" and the curve with "tightness"
> radius and falloff are expressed in degree.

Thanks! A cylindrical light_source is a good idea, but it doesn't have a
"focused" effect - the smallest in the beam waist and expands along z.

>
> This would give you a nice smooth illumination:
>
> light_source{10*y rgb<5,0,0> cylindrical
>  point_at 0
>  radius 0 //no notable "hot spot"
>  falloff 1 // total width angle
>  tightness 4 // gives a nice curve
> // range from 1 to 100
> }
>
> The actual diameter og the beam is dictated by falloff and the lenght of
> the location to point_at vector.
>
> Now, you can use some scattering media to make the beam visible if you
> want or need.
>
>
> Alain


Post a reply to this message

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