POV-Ray : Documentation : 2.5.11.15 Function as pattern
 POV-Ray 3.6 Documentation Online View

#### 2.5.11.15 Function as pattern

Allows you to use a function { } block as pattern.

```   pigment {
function { USER_DEFINED_FUNCTIONS }
[PIGMENT_MODIFIERS...]
}
```

Declaring a function:
By default a function takes three parameters (x,y,z) and you do not have to explicitly specify the parameter names when declaring it. When using the identifier, the parameters must be specified.

```    #declare Foo = function { x + y + z}
pigment {
function { Foo(x, y, z) }
[PIGMENT_MODIFIERS...]
}
```

On the other hand, if you need more or less than three parameters when declaring a function, you also have to explicitly specify the parameter names.

```    #declare Foo = function(x,y,z,t) { x + y + z + t}
pigment {
function { Foo(x, y, z, 4) }
[PIGMENT_MODIFIERS...]
}
```

Using function in a normal:

```    #declare Foo = function { x + y + z}
normal {
function { Foo(x, y, z) } [Bump_Size]
[MODIFIERS...]
}
```
##### 2.5.11.15.1 What can be used

All float expressions and operators (see section "User-Defined Functions") which are legal in POV-Ray. Of special interest here is the `pattern` option, that makes it possible to use patterns as functions

``` #declare FOO = function {
pattern {
checker
}
}
```

User defined functions (like equations).

Since pigments can be declared as functions, they can also be used in functions. They must be declared first. When using the identifier, you have to specify which component of the color vector should be used. To do this, the dot notation is used: Function(x,y,z).red

```   #declare FOO = function {pigment { checker } }
pigment {
function { FOO(x,y,z).green }
[PIGMENT_MODIFIERS...]
}
```

POV-Ray has a large amount of pre-defined functions. These are mainly algebraic surfaces but there is also a mesh function and noise3d function. See section "Internal Functions" for a complete list and some explanation on the parameters to use. These internal functions can be included through the functions.inc include file.

```
#include "functions.inc"
#declare FOO = function {pigment { checker } }
pigment {
function { FOO(x,y,z).green & f_noise3d(x*2, y*3,z)}
[PIGMENT_MODIFIERS...]
}
```