3.7.7 functions.inc

This include file contains interfaces to internal functions as well as several predefined functions. The ID's used to access the internal functions through calls to "internal(XX)", are not guaranteed to stay the same between POV-Ray versions, so users are encouraged to use the functions declared here.

The number of required parameters and what they control are also given in the include file, this chapter gives more information.
For starter values of the parameters, check the "i_internal.pov" demo file.

Syntax to be used:

  #include "functions.inc"
  isosurface {
    function { f_torus_gumdrop(x,y,z, P0) }
    ...
  }

  pigment {
    function { f_cross_ellipsoids(x,y,z, P0, P1, P2, P3) }
    COLOR_MAP ...
  )

Some special parameters are found in several of these functions. These are described in the next section and later referred to as "Cross section type", "Field Strength", "Field Limit", "SOR" parameters.

3.7.7.1 Common Parameters

Cross Section Type:
In the helixes and spiral functions, the 9th parameter is the cross section type.
Some shapes are:

0 :
square
0.0 to 1.0 :
rounded squares
1 :
circle
1.0 to 2.0 :
rounded diamonds
2 :
diamond
2.0 to 3.0 :
partially concave diamonds
3 :
concave diamond
3.7.7.1.1 Field Strength

The numerical value at a point in space generated by the function is multiplied by the Field Strength. The set of points where the function evaluates to zero are unaffected by any positive value of this parameter, so if you are just using the function on its own with threshold = 0, the generated surface is still the same.
In some cases, the field strength has a considerable effect on the speed and accuracy of rendering the surface. In general, increasing the field strength speeds up the rendering, but if you set the value too high the surface starts to break up and may disappear completely.
Setting the field strength to a negative value produces the inverse of the surface, like making the function negative.

3.7.7.1.2 Field Limit

This will not make any difference to the generated surface if you are using threshold that is within the field limit (and will kill the surface completely if the threshold is greater than the field limit). However, it may make a huge difference to the rendering times.
If you use the function to generate a pigment, then all points that are a long way from the surface will have the same color, the color that corresponds to the numerical value of the field limit.

3.7.7.1.3 SOR Switch

If greater than zero, the curve is swept out as a surface of revolution (SOR).
If the value is zero or negative, the curve is extruded linearly in the Z direction.

3.7.7.1.4 SOR Offset

If the SOR switch is on, then the curve is shifted this distance in the X direction before being swept out.

3.7.7.1.5 SOR Angle

If the SOR switch is on, then the curve is rotated this number of degrees about the Z axis before being swept out.

3.7.7.1.6 Invert Isosurface

Sometimes, when you render a surface, you may find that you get only the shape of the container. This could be caused by the fact that some of the build in functions are defined inside out.
We can invert the isosurface by negating the whole function:
  -(function) - threshold

3.7.7.2 Internal Functions

Here is a list of the internal functions in the order they appear in the "functions.inc" include file

f_algbr_cyl1(x,y,z, P0, P1, P2, P3, P4). An algebraic cylinder is what you get if you take any 2d curve and plot it in 3d. The 2d curve is simply extruded along the third axis, in this case the z axis.
With the SOR Switch switched on, the figure-of-eight curve will be rotated around the Y axis instead of being extruded along the Z axis.

f_algbr_cyl2(x,y,z, P0, P1, P2, P3, P4). An algebraic cylinder is what you get if you take any 2d curve and plot it in 3d. The 2d curve is simply extruded along the third axis, in this case the z axis.
With the SOR Switch switched on, the cross section curve will be rotated around the Y axis instead of being extruded along the Z axis.

f_algbr_cyl3(x,y,z, P0, P1, P2, P3, P4). An algebraic cylinder is what you get if you take any 2d curve and plot it in 3d. The 2d curve is simply extruded along the third axis, in this case the Z axis.
With the SOR Switch switched on, the cross section curve will be rotated around the Y axis instead of being extruded along the Z axis.

f_algbr_cyl4(x,y,z, P0, P1, P2, P3, P4). An algebraic cylinder is what you get if you take any 2d curve and plot it in 3d. The 2d curve is simply extruded along the third axis, in this case the z axis.
With the SOR Switch switched on, the cross section curve will be rotated around the Y axis instead of being extruded along the Z axis.

f_bicorn(x,y,z, P0, P1). The surface is a surface of revolution.

f_bifolia(x,y,z, P0, P1). The bifolia surface looks something like the top part of a a paraboloid bounded below by another paraboloid.

f_blob(x,y,z, P0, P1, P2, P3, P4). This function generates blobs that are similar to a CSG blob with two spherical components. This function only seems to work with negative threshold settings.

f_blob2(x,y,z, P0, P1, P2, P3). The surface is similar to a CSG blob with two spherical components.

f_boy_surface(x,y,z, P0, P1). For this surface, it helps if the field strength is set low, otherwise the surface has a tendency to break up or disappear entirely. This has the side effect of making the rendering times extremely long.

f_comma(x,y,z, P0). The 'comma' surface is very much like a comma-shape.

f_cross_ellipsoids(x,y,z, P0, P1, P2, P3). The 'cross ellipsoids' surface is like the union of three crossed ellipsoids, one oriented along each axis.

f_crossed_trough(x,y,z, P0)

f_cubic_saddle(x,y,z, P0). For this surface, it helps if the field strength is set quite low, otherwise the surface has a tendency to break up or disappear entirely.

f_cushion(x,y,z, P0)

f_devils_curve(x,y,z, P0)

f_devils_curve_2d(x,y,z, P0, P1, P2, P3, P4, P5). The f_devils_curve_2d curve can be extruded along the z axis, or using the SOR parameters it can be made into a surface of revolution. The X and Y factors control the size of the central feature.

f_dupin_cyclid(x,y,z, P0, P1, P2, P3, P4, P5)

f_ellipsoid(x,y,z, P0, P1, P2). f_ellipsoid generates spheres and ellipsoids. Needs "threshold 1".
Setting these scaling parameters to 1/n gives exactly the same effect as performing a scale operation to increase the scaling by n in the corresponding direction.

f_enneper(x,y,z, P0)

f_flange_cover(x,y,z, P0, P1, P2, P3)

f_folium_surface(x,y,z, P0, P1, P2). A 'folium surface' looks something like a paraboloid glued to a plane.

f_folium_surface_2d(x,y,z, P0, P1, P2, P3, P4, P5). The f_folium_surface_2d curve can be rotated around the X axis to generate the same 3d surface as the f_folium_surface, or it can be extruded in the Z direction (by switching the SOR switch off)

f_glob(x,y,z, P0). One part of this surface would actually go off to infinity if it were not restricted by the contained_by shape.

f_heart(x,y,z, P0)

f_helical_torus(x,y,z, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9). With some sets of parameters, it looks like a torus with a helical winding around it. The winding optionally has grooves around the outside.

f_helix1(x,y,z, P0, P1, P2, P3, P4, P5, P6)

f_helix2(x,y,z, P0, P1, P2, P3, P4, P5, P6). Needs a negated function

f_hex_x(x,y,z, P0). This creates a grid of hexagonal cylinders stretching along the z-axis. The fatness is controlled by the threshold value. When this value equals 0.8660254 or cos(30) the sides will touch, because this is the distance between centers. Negating the function will inverse the surface and create a honey-comb structure. This function is also useful as pigment function.

f_hex_y(x,y,z, P0). This is function forms a lattice of infinite boxes stretching along the z-axis. The fatness is controlled by the threshold value. These boxes are rotated 60 degrees around centers, which are 0.8660254 or cos(30) away from each other. This function is also useful as pigment function.

f_hetero_mf(x,y,z, P0, P1, P2, P3, P4, P5). f_hetero_mf (x,0,z) makes multifractal height fields and patterns of '1/f' noise
'Multifractal' refers to their characteristic of having a fractal dimension which varies with altitude. Built from summing noise of a number of frequencies, the hetero_mf parameters determine how many, and which frequencies are to be summed.
An advantage to using these instead of a height_field {} from an image (a number of height field programs output multifractal types of images) is that the hetero_mf function domain extends arbitrarily far in the x and z directions so huge landscapes can be made without losing resolution or having to tile a height field. Other functions of interest are f_ridged_mf and f_ridge.

f_hunt_surface(x,y,z, P0)

f_hyperbolic_torus(x,y,z, P0, P1, P2)

f_isect_ellipsoids(x,y,z, P0, P1, P2, P3). The 'isect ellipsoids' surface is like the intersection of three crossed ellipsoids, one oriented along each axis.

f_kampyle_of_eudoxus(x,y,z, P0, P1, P2). The 'kampyle of eudoxus' is like two infinite planes with a dimple at the center.

f_kampyle_of_eudoxus_2d(x,y,z, P0, P1, P2, P3, P4, P5)The 2d curve that generates the above surface can be extruded in the Z direction or rotated about various axes by using the SOR parameters.

f_klein_bottle(x,y,z, P0)

f_kummer_surface_v1(x,y,z, P0). The Kummer surface consists of a collection of radiating rods.

f_kummer_surface_v2(x,y,z, P0, P1, P2, P3). Version 2 of the kummer surface only looks like radiating rods when the parameters are set to particular negative values. For positive values it tends to look rather like a superellipsoid.

f_lemniscate_of_gerono(x,y,z, P0). The "Lemniscate of Gerono" surface is an hourglass shape. Two teardrops with their ends connected.

f_lemniscate_of_gerono_2d(x,y,z, P0, P1, P2, P3, P4, P5). The 2d version of the Lemniscate can be extruded in the Z direction, or used as a surface of revolution to generate the equivalent of the 3d version, or revolved in different ways.

f_mesh1(x,y,z, P0, P1, P2, P3, P4) The overall thickness of the threads is controlled by the isosurface threshold, not by a parameter. If you render a mesh1 with zero threshold, the threads have zero thickness and are therefore invisible. Parameters P2 and P4 control the shape of the thread relative to this threshold parameter.

f_mitre(x,y,z, P0). The 'Mitre' surface looks a bit like an ellipsoid which has been nipped at each end with a pair of sharp nosed pliers.

f_nodal_cubic(x,y,z, P0). The 'Nodal Cubic' is something like what you would get if you were to extrude the Stophid2D curve along the X axis and then lean it over.

f_noise3d(x,y,z)

f_noise_generator(x,y,z, P0)

f_odd(x,y,z, P0)

f_ovals_of_cassini(x,y,z, P0, P1, P2, P3). The Ovals of Cassini are a generalization of the torus shape.

f_paraboloid(x,y,z, P0). This paraboloid is the surface of revolution that you get if you rotate a parabola about the Y axis.

f_parabolic_torus(x,y,z, P0, P1, P2)

f_ph(x,y,z) = atan2( sqrt( x*x + z*z ), y )
When used alone, the "PH" function gives a surface that consists of all points that are at a particular latitude, i.e. a cone. If you use a threshold of zero (the default) this gives a cone of width zero, which is invisible. Also look at f_th and f_r

f_pillow(x,y,z, P0)

f_piriform(x,y,z, P0). The piriform surface looks rather like half a lemniscate.

f_piriform_2d(x,y,z, P0, P1, P2, P3, P4, P5, P6). The 2d version of the "Piriform" can be extruded in the Z direction, or used as a surface of revolution to generate the equivalent of the 3d version.

f_poly4(x,y,z, P0, P1, P2, P3, P4). This f_poly4 can be used to generate the surface of revolution of any polynomial up to degree 4.
To put it another way: If we call the parameters A, B, C, D, E; then this function generates the surface of revolution formed by revolving "x = A + By + Cy2 + Dy3 + Ey4" around the Y axis.

f_polytubes(x,y,z, P0, P1, P2, P3, P4, P5). The 'Polytubes' surface consists of a number of tubes. Each tube follows a 2d curve which is specified by a polynomial of degree 4 or less. If we look at the parameters, then this function generates "P0" tubes which all follow the equation " x = P1 + P2y + P3y2 + P4y3 + P5y4 " arranged around the Y axis.
This function needs a positive threshold (fatness of the tubes).

f_quantum(x,y,z, P0). It resembles the shape of the electron density cloud for one of the d orbitals.

f_quartic_paraboloid(x,y,z, P0). The 'Quartic Paraboloid' is similar to a paraboloid, but has a squarer shape.

f_quartic_saddle(x,y,z, P0). The 'Quartic saddle' is similar to a saddle, but has a squarer shape.

f_quartic_cylinder(x,y,z, P0, P1, P2). The 'Quartic cylinder' looks a bit like a cylinder that is swallowed an egg.

f_r(x,y,z) = sqrt( x*x + y*y + z*z )
When used alone, the "R" function gives a surface that consists of all the points that are a specific distance (threshold value) from the origin, i.e. a sphere. Also look at f_ph and f_th

f_ridge(x,y,z, P0, P1, P2, P3, P4, P5). This function is mainly intended for modifying other surfaces as you might use a height field or to use as pigment function. Other functions of interest are f_hetero_mf and f_ridged_mf.

f_ridged_mf(x,y,z, P0, P1, P2, P3, P4, P5). The "Ridged Multifractal" surface can be used to create multifractal height fields and patterns. 'Multifractal' refers to their characteristic of having a fractal dimension which varies with altitude. They are built from summing noise of a number of frequencies. The f_ridged_mf parameters determine how many, and which frequencies are to be summed, and how the different frequencies are weighted in the sum.
An advantage to using these instead of a height_field{} from an image is that the ridged_mf function domain extends arbitrarily far in the x and z directions so huge landscapes can be made without losing resolution or having to tile a height field. Other functions of interest are f_hetero_mf and f_ridge.

f_rounded_box(x,y,z, P0, P1, P2, P3). The Rounded Box is defined in a cube from <-1, -1, -1> to <1, 1, 1>. By changing the " Scale" parameters, the size can be adjusted, without affecting the Radius of curvature.

f_sphere(x,y,z, P0)

f_spikes(x,y,z, P0, P1, P2, P3, P4)

f_spikes_2d(x,y,z, P0, P1, P2, P3) =2-D function : f = f( x, z ) - y

f_spiral(x,y,z, P0, P1, P2, P3, P4, P5)

f_steiners_roman(x,y,z, P0). The "Steiners Roman" is composed of four identical triangular pads which together make up a sort of rounded tetrahedron. There are creases along the X, Y and Z axes where the pads meet.

f_strophoid(x,y,z, P0, P1, P2, P3). The "Strophoid" is like an infinite plane with a bulb sticking out of it.

f_strophoid_2d(x,y,z, P0, P1, P2, P3, P4, P5, P6). The 2d strophoid curve can be extruded in the Z direction or rotated about various axes by using the SOR parameters.

f_superellipsoid(x,y,z, P0, P1). Needs a negative field strength or a negated function.

f_th(x,y,z) = atan2( x, z )
f_th() is a function that is only useful when combined with other surfaces.
It produces a value which is equal to the "theta" angle, in radians, at any point. The theta angle is like the longitude coordinate on the Earth. It stays the same as you move north or south, but varies from east to west. Also look at f_ph and f_r

f_torus(x,y,z, P0, P1)

f_torus2(x,y,z, P0, P1, P2). This is different from the f_torus function which just has the major and minor radii as parameters.

f_torus_gumdrop(x,y,z, P0). The "Torus Gumdrop" surface is something like a torus with a couple of gumdrops hanging off the end.

f_umbrella(x,y,z, P0)

f_witch_of_agnesi(x,y,z, P0, P1, P2, P3, P4, P5). The "Witch of Agnesi" surface looks something like a witches hat.

f_witch_of_agnesi_2d(x,y,z, P0, P1, P2, P3, P4, P5). The 2d version of the "Witch of Agnesi" curve can be extruded in the Z direction or rotated about various axes by use of the SOR parameters.

3.7.7.3 Pre defined functions

eval_pigment(Pigm, Vect), This macro evaluates the color of a pigment at a specific point. Some pigments require more information than simply a point, slope pattern based pigments for example, and will not work with this macro. However, most pigments will work fine.
Parameters:

f_snoise3d(x, y, z). Just like f_noise3d(), but returns values in the range [-1, 1].

f_sine_wave(val, amplitude, frequency). Turns a ramping waveform into a sine waveform.

f_scallop_wave(val, amplitude, frequency). Turns a ramping waveform into a "scallop_wave" waveform.

3.7.7.3.1 Pattern functions

Predefined pattern functions, useful for building custom function patterns or performing "displacement mapping" on isosurfaces. Many of them are not really useful for these purposes, they are simply included for completeness.

Some are not implemented at all because they require special parameters that must be specified in the definition, or information that is not available to pattern functions. For this reason, you probably would want to define your own versions of these functions.

All of these functions take three parameters, the XYZ coordinates of the point to evaluate the pattern at.

f_agate(x, y, z)
f_boxed(x, y, z)
f_bozo(x, y, z)
f_brick(x, y, z)
f_bumps(x, y, z)
f_checker(x, y, z)
f_crackle(x, y, z)
This pattern has many more options, this function uses the defaults.
f_cylindrical(x, y, z)
f_dents(x, y, z)
f_gradientX(x, y, z)
f_gradientY(x, y, z)
f_gradientZ(x, y, z)
f_granite(x, y, z)
f_hexagon(x, y, z)
f_leopard(x, y, z)
f_mandel(x, y, z)
Only the basic mandel pattern is implemented, its variants and the other fractal patterns are not implemented.
f_marble(x, y, z)
f_onion(x, y, z)
f_planar(x, y, z)
f_radial(x, y, z)
f_ripples(x, y, z)
f_spherical(x, y, z)
f_spiral1(x, y, z)
f_spiral2(x, y, z)
f_spotted(x, y, z)
f_waves(x, y, z)
f_wood(x, y, z)
f_wrinkles(x, y, z)