  | 
  | 
 | 
  | 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
Hi, is there anyway to predeclare a pattern (preferably with its
transformations) so that it can later be used equally within various normals or
pigments?
Up to now I only managed to declare it as the one or the other.
or maybe there is a way to fit a declared pigment inside a normal{} block?
 Post a reply to this message 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
From: clipka 
Subject: Re: declared patterns without pigments ( rvalue ) 
Date:  1 Jan 2014 15:58:19 
Message: <52c4816b@news.povray.org> 
 | 
 
 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
Am 01.01.2014 20:32, schrieb Mr:
> Hi, is there anyway to predeclare a pattern (preferably with its
> transformations) so that it can later be used equally within various normals or
> pigments?
>
> Up to now I only managed to declare it as the one or the other.
>
> or maybe there is a way to fit a declared pigment inside a normal{} block?
You can use a so-called "pigment function" (a function that gets its 
values from a pigment), and then use this function in a so-called 
"function pattern".
 Post a reply to this message 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
clipka <ano### [at] anonymous org> wrote:
> Am 01.01.2014 20:32, schrieb Mr:
> > Hi, is there anyway to predeclare a pattern (preferably with its
> > transformations) so that it can later be used equally within various normals or
> > pigments?
> >
> > Up to now I only managed to declare it as the one or the other.
> >
> > or maybe there is a way to fit a declared pigment inside a normal{} block?
>
> You can use a so-called "pigment function" (a function that gets its
> values from a pigment), and then use this function in a so-called
> "function pattern".
excuse me, but would you mind to post an example?  Didn't you rather mean use a
pattern function inside a pigment instead of the opposite?
the tricky thing is that a colormap is currently defined along with the pigment,
I expected it to just get ignored if it's irrelevent to the normal statement or
automatically converted to a grey scale.
 
 Post a reply to this message 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
Am 04.01.2014 22:01, schrieb Mr:
> clipka <ano### [at] anonymous org> wrote:
>> Am 01.01.2014 20:32, schrieb Mr:
>>> Hi, is there anyway to predeclare a pattern (preferably with its
>>> transformations) so that it can later be used equally within various normals or
>>> pigments?
>>>
>>> Up to now I only managed to declare it as the one or the other.
>>>
>>> or maybe there is a way to fit a declared pigment inside a normal{} block?
>>
>> You can use a so-called "pigment function" (a function that gets its
>> values from a pigment), and then use this function in a so-called
>> "function pattern".
>
> excuse me, but would you mind to post an example?  Didn't you rather mean use a
> pattern function inside a pigment instead of the opposite?
>
> the tricky thing is that a colormap is currently defined along with the pigment,
> I expected it to just get ignored if it's irrelevent to the normal statement or
> automatically converted to a grey scale.
You'll have to define the pigment with a linear greyscale color map, i.e.:
   #declare MyPigment = pigment {
     ...
     colour_map {
       [0 rgb 0]
       [1 rgb 1]
     }
   }
You then need to define a function based on that pigment (a so-called 
"pigment function"):
   #declare MyFn = function { pigment { MyPigment } }
Finally, you need to define a normal statement using this function as 
the pattern (a so-called "function pattern"):
   #declare MyNormal = normal {
     function { MyFn(x,y,z).gray }
     ...
   }
(Note that pigment functions are special in that they return a colour 
rather than a scalar value.)
 
 Post a reply to this message 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
"Mr" <nomail@nomail> wrote:
> Hi, is there anyway to predeclare a pattern (preferably with its
> transformations) so that it can later be used equally within various normals or
> pigments?
You can use a pattern function, i.e.:
#declare foo = function {
   pattern {
     checker
   }
 }
 #declare MyNormal = normal {
     function { foo(x,y,z) }
}
You find it at the end of section "2.2.1.6.3 Declaring User-Defined Float
Functions" in http://www.povray.org/documentation/view/3.6.1/231/ .
 Post a reply to this message 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
"Thorsten Froehlich" <nomail@nomail> wrote:
> "Mr" <nomail@nomail> wrote:
> > Hi, is there anyway to predeclare a pattern (preferably with its
> > transformations) so that it can later be used equally within various normals or
> > pigments?
>
> You can use a pattern function, i.e.:
>
> #declare foo = function {
>    pattern {
>      checker
>    }
>  }
>
>  #declare MyNormal = normal {
>      function { foo(x,y,z) }
> }
>
> You find it at the end of section "2.2.1.6.3 Declaring User-Defined Float
> Functions" in http://www.povray.org/documentation/view/3.6.1/231/ .
Thanks to both of you. it works.
 Post a reply to this message 
 | 
  | 
 |   | 
 |   | 
 | 
  | 
 | 
  | 
 |   |