POV-Ray : Newsgroups : povray.newusers : pigments <-> functions : Re: pigments <-> functions Server Time
28 Jul 2024 12:35:55 EDT (-0400)
  Re: pigments <-> functions  
From: clipka
Date: 5 Apr 2009 17:45:00
Message: <web.49d9239ac2ee1ba768105bc50@news.povray.org>
William Tracy <wtr### [at] calpolyedu> wrote:
> Okay. I'm newly returning to Pov, and this is a stupid simple question,
> so I figure I can post this under "new users". :-P
>
> I can create a user-defined function from a pigment. Is it possible to
> create a pigment from a function? The documentation isn't clear to me,
> but seems to say "no".

You can use a function as a pattern (see "3.5.11.15  Function as pattern") and
therefore, in some sense, as a pigment; however, to use a *pigment* function as
a pigment again, preserving all colors, you will probably have to do some
trickery, like:

pigment {
  average
  pigment_map {
    [ 1
      function { myFunc(x,y,z).red }
      color_map {
        [ 0 color red*0 ]
        [ 1 color red*3 ]
      }
    ]
    [ 1
      function { myFunc(x,y,z).green }
      color_map {
        [ 0 color green*0 ]
        [ 1 color green*3 ]
      }
    ]
    [ 1
      function { myFunc(x,y,z).blue }
      color_map {
        [ 0 color blue*0 ]
        [ 1 color blue*3 ]
      }
    ]
  }
}


Post a reply to this message

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