POV-Ray : Newsgroups : povray.newusers : color_map Server Time
31 Oct 2024 22:22:35 EDT (-0400)
  color_map (Message 1 to 10 of 15)  
Goto Latest 10 Messages Next 5 Messages >>>
From: ltong
Subject: color_map
Date: 16 Aug 2012 23:30:01
Message: <web.502db9f843085f341cd19dea0@news.povray.org>
This is certainly simple for advanced users, but I'm having problem to figure it
out. The documentation says value_n in color_map is calculated using x,y,z
location of a point where color_n will be applied. So, how is value_n calculated
exactly? How does one know which position value_n represents in an object? I
would guess translation and rotation don't affect. Many thanks in advance!


Post a reply to this message

From: Le Forgeron
Subject: Re: color_map
Date: 17 Aug 2012 04:10:29
Message: <502dfc75$1@news.povray.org>
Le 17/08/2012 05:26, ltong a écrit :
> This is certainly simple for advanced users, but I'm having problem to figure it
> out. The documentation says value_n in color_map is calculated using x,y,z
> location of a point where color_n will be applied. So, how is value_n calculated
> exactly? How does one know which position value_n represents in an object? I
> would guess translation and rotation don't affect. Many thanks in advance!
> 
> 
> 


Hello,

when referencing documentation which might need clarification, please
provide at least an exact reference to it, or cite it.

For instance,
> http://wiki.povray.org/content/Reference:Color_Map
states that:

=== begin quote ===

Each of the various pattern types available is in fact a mathematical
function that takes any x, y, z location and turns it into a number
between 0.0 and 1.0 inclusive. That number is used to specify what mix
of colors to use from the color map.

=== end quote ===


So, the value_n used for the color_map is computed by the pattern. The
pattern you choose to associate for the pigment that uses the color_map

Regarding influence of rotation/translation/scale/transform, please check:
>>
http://wiki.povray.org/content/Documentation:Tutorial_Section_2.2#Transforming_Textures_and_Objects

Have a nice day.


Post a reply to this message

From: ltong
Subject: Re: color_map
Date: 17 Aug 2012 04:40:00
Message: <web.502e0285f6ca84721cd19dea0@news.povray.org>
Le_Forgeron <lef### [at] freefr> wrote:
> Le 17/08/2012 05:26, ltong a écrit :
> > This is certainly simple for advanced users, but I'm having problem to figure it
> > out. The documentation says value_n in color_map is calculated using x,y,z
> > location of a point where color_n will be applied. So, how is value_n calculated
> > exactly? How does one know which position value_n represents in an object? I
> > would guess translation and rotation don't affect. Many thanks in advance!
> >
> >
> >
>
>
> Hello,
>
> when referencing documentation which might need clarification, please
> provide at least an exact reference to it, or cite it.
>
> For instance,
> > http://wiki.povray.org/content/Reference:Color_Map
> states that:
>
> === begin quote ===
>
> Each of the various pattern types available is in fact a mathematical
> function that takes any x, y, z location and turns it into a number
> between 0.0 and 1.0 inclusive. That number is used to specify what mix
> of colors to use from the color map.
>
> === end quote ===
>
>
> So, the value_n used for the color_map is computed by the pattern. The
> pattern you choose to associate for the pigment that uses the color_map
>
> Regarding influence of rotation/translation/scale/transform, please check:
> >>
http://wiki.povray.org/content/Documentation:Tutorial_Section_2.2#Transforming_Textures_and_Objects
>
> Have a nice day.

Thanks a lot!

Sorry for forgetting to put the reference, the one you showed is exactly the one
I meant.

Will read through the pattern Section, and thanks for the link!


Post a reply to this message

From: Warp
Subject: Re: color_map
Date: 17 Aug 2012 11:04:19
Message: <502e5d72@news.povray.org>
ltong <nomail@nomail> wrote:
> This is certainly simple for advanced users, but I'm having problem to figure it
> out. The documentation says value_n in color_map is calculated using x,y,z
> location of a point where color_n will be applied. So, how is value_n calculated
> exactly? How does one know which position value_n represents in an object? I
> would guess translation and rotation don't affect. Many thanks in advance!

One important thing to understand is that color maps (or pigments in
general) are actually not dependent on any object (with the exception of
the aoi and slope patterns, which are probably the only ones that do depend
on an object).

A pigment and everything that it contains is basically a three-dimensional
function that fills the entire universe. In principle you could render a
pigment as the coloring of the entire three-dimensional universe, without
any object. (In fact, if you had voxel rendering capabilities, you could do
exactly this.)

What happens when you apply it to an object is that the surface of the
object gets colored by this universe-filling pigment at the places where
this surface is located. (It's a bit like the object's surface "intersects"
with the pigment, and you see the color of the pigment at those places.)

These universe-filling pigments are defined in terms of a three-dimensional
function. This is a function that assigns a value between 0.0 and 1.0 to
each point in space. (In other words, take any point in the universe, and
this function gives you a value between 0.0 and 1.0 for that point.)

POV-Ray offers many ready-made functions for this, called patterns. (You
can also create your own by writing a user-defined function and using it
as a pattern.)

Maps can be used to assign pigment-defining characteristics (such as colors)
to those values. For example with a color map you can tell that all points
in space with the value 0.0 are red, all points with the value 0.7 are blue,
and all points with the value 1.0 are black. (The colors for all the other
values are interpolated between those, as to give a smooth transition.)

In other words, take any point in space, and now the pigment tells you what
color it has.

When you apply this pigment to an object, it will color the surface of the
object as I described above. (Basically what happens that for each point on
the surface of the object the pigment tells what color is there.)

There's a way to concretely visualize how the object "intersects" with
the pigment: Translate the object in an animation, but do not translate
the pigment with it. (There are several ways how this can be achieved,
one of which is to simple apply the reverse translation to the pigment
as you are applying to the object.) You can see visually how the object's
surface "cuts" the three-dimensional pigment as it moves through space.
(This demonstrates quite well how the pigment is independent of the object.)

-- 
                                                          - Warp


Post a reply to this message

From: clipka
Subject: Re: color_map
Date: 17 Aug 2012 17:36:06
Message: <502eb946$1@news.povray.org>
Am 17.08.2012 17:04, schrieb Warp:

> What happens when you apply it to an object is that the surface of the
> object gets colored by this universe-filling pigment at the places where
> this surface is located. (It's a bit like the object's surface "intersects"
> with the pigment, and you see the color of the pigment at those places.)

Or, to take an analogy, POV-Ray's standard way of handling pigments is 
like carving an object out of a given solid material, such as a piece of 
wood.

This is very much unlike UV-mapping (as frequently used by other 3D 
renderers), which is more akin to wrapping the object in patterned paper.


Post a reply to this message

From: ltong
Subject: Re: color_map
Date: 21 Aug 2012 23:00:00
Message: <web.50344a32f6ca84721cd19dea0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 17.08.2012 17:04, schrieb Warp:
>
> > What happens when you apply it to an object is that the surface of the
> > object gets colored by this universe-filling pigment at the places where
> > this surface is located. (It's a bit like the object's surface "intersects"
> > with the pigment, and you see the color of the pigment at those places.)
>
> Or, to take an analogy, POV-Ray's standard way of handling pigments is
> like carving an object out of a given solid material, such as a piece of
> wood.
>
> This is very much unlike UV-mapping (as frequently used by other 3D
> renderers), which is more akin to wrapping the object in patterned paper.

Thanks, Warp and clipka!

What I'm trying now is to get some light beams, for example, a focused Gaussian
laser beam. I first create an object of the shape of a Gaussian beam using
difference {box, torus} or sth like that. Then I try to create the light effect
using a color_map inside pigment_interior_media_density, which I learned from
web. However, i couldn't find any build-in patterns for a Gaussian beam, in
which the intensity is the highest in the center and attenuates gradually to the
edges, it has a gradient along the axis as well. Any suggestions for such a
pattern? Or maybe alternative way to achieve it?

Also, I still do not understand it quite well. According to what Warp says, it
is surface of an object that gets colored, so only those x,y,z on the surface
would be useful to create the color map? Then is it possible to use color_map
create colors inside a "hollowed" object?


Post a reply to this message

From: clipka
Subject: Re: color_map
Date: 22 Aug 2012 07:11:22
Message: <5034be5a$1@news.povray.org>
Am 22.08.2012 04:55, schrieb ltong:

> What I'm trying now is to get some light beams, for example, a focused Gaussian
> laser beam. I first create an object of the shape of a Gaussian beam using
> difference {box, torus} or sth like that. Then I try to create the light effect
> using a color_map inside pigment_interior_media_density, which I learned from
> web. However, i couldn't find any build-in patterns for a Gaussian beam, in
> which the intensity is the highest in the center and attenuates gradually to the
> edges, it has a gradient along the axis as well. Any suggestions for such a
> pattern? Or maybe alternative way to achieve it?

I would suggest trying the function pattern, which (as the name 
suggests) allows you to plug in arbitrary functions.

I guess for a Gaussian beam, the function will be based on the Gauss 
function in some way (don't ask me about details there, I'm not familiar 
with laser beams :-) Wikipedia might know something helpful). The 
gradient along the axis is most likely an exponential falloff:

   // the basic functions for the beam brightness
   #declare FALLOFF  = 0.99; // just an example, toy with it
   #declare FnRadial = function(r) { /* ask Wikipedia */ }
   #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) }


> Also, I still do not understand it quite well. According to what Warp says, it
> is surface of an object that gets colored, so only those x,y,z on the surface
> would be useful to create the color map? Then is it possible to use color_map
> create colors inside a "hollowed" object?

What Warp said applies to the pigment of opqaue objects, but you're 
working with media now, where you'll get the full 3D structure.


Post a reply to this message

From: ltong
Subject: Re: color_map
Date: 22 Aug 2012 23:25:00
Message: <web.5035a239f6ca84721cd19dea0@news.povray.org>
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>
}


clipka <ano### [at] anonymousorg> wrote:
> Am 22.08.2012 04:55, schrieb ltong:
>
> > What I'm trying now is to get some light beams, for example, a focused Gaussian
> > laser beam. I first create an object of the shape of a Gaussian beam using
> > difference {box, torus} or sth like that. Then I try to create the light effect
> > using a color_map inside pigment_interior_media_density, which I learned from
> > web. However, i couldn't find any build-in patterns for a Gaussian beam, in
> > which the intensity is the highest in the center and attenuates gradually to the
> > edges, it has a gradient along the axis as well. Any suggestions for such a
> > pattern? Or maybe alternative way to achieve it?
>
> I would suggest trying the function pattern, which (as the name
> suggests) allows you to plug in arbitrary functions.
>
> I guess for a Gaussian beam, the function will be based on the Gauss
> function in some way (don't ask me about details there, I'm not familiar
> with laser beams :-) Wikipedia might know something helpful). The
> gradient along the axis is most likely an exponential falloff:
>
>    // the basic functions for the beam brightness
>    #declare FALLOFF  = 0.99; // just an example, toy with it
>    #declare FnRadial = function(r) { /* ask Wikipedia */ }
>    #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) }
>
>
> > Also, I still do not understand it quite well. According to what Warp says, it
> > is surface of an object that gets colored, so only those x,y,z on the surface
> > would be useful to create the color map? Then is it possible to use color_map
> > create colors inside a "hollowed" object?
>
> What Warp said applies to the pigment of opqaue objects, but you're
> working with media now, where you'll get the full 3D structure.


Post a reply to this message

From: Alain
Subject: Re: color_map
Date: 23 Aug 2012 21:03:07
Message: <5036d2cb$1@news.povray.org>

> 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.

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.

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

From: ltong
Subject: Re: color_map
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

Goto Latest 10 Messages Next 5 Messages >>>

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