Instead of patching POV-Ray™ with new camera types MegaPOV provides a tool to define any projection type directly inside the scene scripts. This tool is named user_defined camera type. It allows starting camera rays from any point in any direction. Both the location and direction of rays is specified as a set of three functions or as one pigment.
camera {
user_defined
location { FUNCTION_VECTOR }
direction { FUNCTION_VECTOR }
}
FUNCTION_VECTOR:
PIGMENT | 3_USER_DEFINED_FUNCTIONS ...
3_USER_DEFINED_FUNCTIONS:
USER_DEFINED_FUNCTION
USER_DEFINED_FUNCTION
USER_DEFINED_FUNCTION
In the case of 3 functions used to define location or direction, please remember that those functions operate on screen coordinates (u and v) in the area <0,0>-<1,1> so that they are independent of the image resolution. If you want to convert the value from the range 0-1 to the range 0-image_width or 0-image_height you can use the function adj_range from the math.inc include file.
In the case of a pigment used to define location or direction, please remember that the values of the pigment are taken from the area <0,0,0>-<1,1,0>.
Example 2.8. Alternative forms of user_defined camera type definition
Let's imagine we want to recreate the orthographic camera using a user_defined camera:
camera{
orthographic
location <.5,.5,0>
direction z
up y
right x
}
Written as a set of functions it would be:
camera{
user_defined
location{
function{u}
function{v}
function{0}
}
direction{
function{0}
function{0}
function{1}
}
}
Defined with pigments it would be:
camera{
user_defined
location{
pigment{
gradient x
pigment_map{
[0 gradient y color_map{[0 rgb 0][1 rgb x]}]
[1 gradient y color_map{[0 rgb y][1 rgb x+y]}]
}
}
}
direction{
pigment{rgb z}
}
}
Of course if it can make the script shorter, you can mix notations. You can use both functions and pigments in one camera definition:
camera{
user_defined
location{
function{u}
function{v}
function{0}
}
direction{
pigment{rgb z}
}
}