Orbit Trap Controllers |
|
|
Orbit Trap Controllers OverviewOrbit Trap Controllers are programs (called controllers hereafter) used by the Fractal Science Kit fractal generator to map sample data collected during the fractal iteration, to colors for display. Each controller is composed of a set of properties and instructions. The properties are in a set of sections at the top of the page and the instructions are at the bottom of the page. To view the instructions, use the editor's Toggle Code View button to hide the properties and expand the instructions to fill the space. As the sample points are processed by the Fractal Science Kit fractal generator, each sample is passed to the (single) Orbit Trap Master Controller who calls 0 or more Orbit Trap Controllers to process the sample. The controller's instructions are responsible for assigning a Color to the special variable color based on selected fields in the sample. The properties include a set of gradients and/or textures that can be accessed within your instructions, as required. You can use sample data to select which gradient/texture to reference, and to index into the selected gradient/texture to obtain a color. Alternatively, you can use sample data to create a color directly. Orbit Trap Controllers have many similarities with Classic Controllers but have several specialized features that make working with orbit trap data much easier. Unlike Classic Controllers, Orbit Trap Controllers are only called if the point is trapped. After the color is returned from your instructions, the controller uses the property settings on this page to further process the color as defined below. See also:
Each program is composed of a set of properties and instructions. Gradients
The following properties are defined in the Gradients section:
Textures
The following properties are defined in the Textures section:
Properties
The following properties are defined in the Properties section:
Color Space Adjustment
The Color Space Adjustment section is used to adjust individual components of the HSL (Hue/Saturation/Lightness) or HSV (Hue/Saturation/Value) color space. The adjustments are applied to the color returned by your program. To use these settings, you select the color space you want to adjust (HSL or HSV) and then set the values for the individual components associated with the selected color space. The HSL color model supports Hue, Saturation, and Lightness components. The HSV color model supports Hue, Saturation, and Value components. The Hue is identical in both color models but the Saturation is quite different. The Lightness and Value components are unique to the HSL and HSV color models, respectively. See HSL and HSV for details on these color models. The following properties are defined in the Color Space Adjustment section.
Color Adjustment
The Color Adjustment section is used to adjust the brightness, contrast, and gamma of the color returned by your program. The following properties are defined in the Color Adjustment section.
3D Mapping
The 3D Mapping section applies 3D shading to the color returned by your program. Sample.TrapValue is mapped to a virtual height and a simple 3D shading model is applied to the image. Properties are provided to control the light intensity, ambient light, and specular reflection. Additional properties control the sample/height mapping. The following properties are defined in the 3D Mapping section.
Peak, Peak Arg (S), and Peak Arg (N), control the location and shape of the trap highlights. Peak is one of the following:
Peak Arg (S) and Peak Arg (N), or S and N for short, are used by some of the settings to vary the effect as indicated in the text of the setting. Peak of Center (the default) displays the highlight down the center of the trap. Changing Peak to Constant, moves the highlight toward the inside edge if S<0 or the outside edge if S>0. Wave moves the peak in a sine wave as the trap angle goes from 0 to 360. N is the integer number of cycles in the wave pattern and S is the Amplitude of the wave. Depth Mapping
The Depth Mapping section applies depth shading to the color returned by your program. Sample.TrapDwell is mapped to a virtual depth and a simple depth shading model is applied to the image. Properties are provided to control the power/factor used to define the sample/depth mapping, and to lighten rather than darken the colors as the depth increases. Typically, you would activate the Depth Mapping to darken samples with large dwells to make it appear these points were receding into the distance. Check Highlight Depth to make the points fade to white rather than fade to black. The Depth Mapping is applied only if the Method property on the Orbit Trap properties page is set to Trap First Point. In all other cases, Depth Mapping is ignored. The following properties are defined in the Depth Mapping section.
InstructionsAt the bottom of the window is an editor pane named Instructions. The editor pane is a simple text editor to view/edit your Program Instructions. See Editing Text for details. The instructions are divided into sections. Within each section are statements that conform to the Programming Language syntax. In addition to the Standard Sections, Orbit Trap Controllers support 1 other section: color: This section is responsible for setting the color for the current sample point. The color is returned in the built-in variable color. Built-in VariablesSeveral built-in variables are available to your instructions:
Controllers can access the above built-in variables. color is used to return the color computed by the program. compositeHeight is used to return a value for the Map To setting in the 3D Mapping section. That is, if the 3D Mapping section's Map To is set to Composite Height, the instructions should set compositeHeight to a value between 0 and 1 for this purpose. Otherwise, compositeHeight need not be set. compositeHeight is rarely used. pixel is the location in the complex plane of the current sample point and is read-only. color is a Color object defined as: Object Color { Each of the fields should be a floating point value between 0 and 1, inclusive. See the Color Functions for details. The Color object supports the RGB, HSL, and HSV color models but the Fractal Science Kit expects color to conform to the RGB color model. If your program generates a color using the HSL or HSV color model, you must convert the color to the RGB color model prior to returning. The color's Alpha value is used to set the color's opacity. A value of 0 makes the color totally transparent and a value of 1 makes the color totally opaque. Values between 0 and 1 can be used to define colors that are translucent. The controller's Opacity Factor and Scale Opacity properties are applied to color's Alpha value set by the instructions. Example: color: This example calls the Gradient Function Gradient.Color to map the normalized trap angle (Sample.TrapAngle) to a color using the 1st gradient in the controller's list of gradients (i.e., gradient 0). Another common method of accessing the sample data is to use a SamplePointValue Option to allow the user to select a field from the Sample object (described below) using the associated property on the Properties Page. Example: color: This example maps a user selected SamplePointValue called Value, to a gradient index thereby obtaining a color. Unlike other option types, a SamplePointValue option does not return a constant, but instead, uses the SamplePointValue setting to access the corresponding component of the current sample which is returned by the option (in this case, Value). In this example, the option's default value is given as Sample.TrapAngle which equates to the previous example if the user does not change it. Example: comment: Like the previous example, this controller maps a user selected SamplePointValue to a gradient index thereby obtaining a color. However, instead of simply using controller 0 as in the previous example, this controller calls the function Gradient.Color(ColorScheme,Value) to map the sample data to a color using the gradient in the controller's list of gradients indexed by ColorScheme. See GradientIndex Options for details. Example: color: This example allows the user to define a ColorSet Option with up to 8 colors (returned in the array Colors[]) and an index map (IndexMap) set to Trap Dwell, Trap Index, or Trap Delta. Based on the index map, the program sets index to either Sample.TrapDwellRaw, Sample.TrapIndexRaw, or Sample.TrapDeltaRaw, and then uses index to access 1 of the colors found in Colors[]. Note the call to WrapIndex to wrap index to a value between 0 and Count-1 inclusive. See the built-in Orbit Trap Controllers for more complex examples that map textures or geometric patterns to the traps. ConstantsThe following constants are available to your instructions:
ViewportMagnification is the current fractal's magnification. The magnification can be viewed by executing the Resize command on the View menu of the Fractal Window. Accessing Sample DataThe data associated with the sample being processed is accessed by the controller using the Sample object. The Sample object is a read-only object that contains all the collected data for the sample point. Many of the fields have been normalized based on normalization settings for the associated field, and the value is between 0 and 1. In some cases both the raw value and the normalized value are available. The following fields are associated with the Sample object for Orbit Trap Controller programs:
Many of the Sample.Trap... values are set by the Orbit Trap instructions when the point is trapped. However, depending on other trap related properties, the Fractal Science Kit may combine several trapped points into a single point saved with the sample. The following discussion is from the perspective of a point trapped by a single trap but you should be aware that this is not always the case and these values may be the result of blending several trapped points into a single point. See Orbit Trap Blend for details. Sample.TrapValue is a measure of how close a point is to the trap. The interpretation of the value depends on whether the trap is a curve or a solid shape. For curves, Sample.TrapValue is the signed distance to the closest point on the trap as a percent of the curve width. The sign indicates on which side of the curve the point lies. For solid shapes, Sample.TrapValue is a level set value given as a percent of the distance from the center of the shape. Sample.TrapValue ranges from -1 to 1 for curves and 0 to 1 for solid shapes. See Trapped Point Value for details. Sample.TrapAngleRaw is the angle (in radians) assigned to the point by the trap. This is usually the angle formed by the vector from the trap center to the point and a horizontal line through the trap center but other definitions are possible. All of the other angle values are normalized to the range 0 to 1. Sample.TrapAngle is a straight linear mapping of the angle where 0 to 360 maps to 0 to 1. Sample.TrapAngleBounce maps angles from 0 to 180 into values from 0 to 1, and maps angles from 180 to 360 into values from 1 to 0. That is, as the angle increases from 0 to 360, Sample.TrapAngleBounce starts at 0, increases to 1 at the half-way point (180), and then decreases (bounces) back to 0. Sample.TrapAngleCos is identical to Sample.TrapAngleBounce except that it uses a cosine based wave rather than a triangle based wave so it is smoother at the extremes. See Trapped Point Angle for details. Sample.TrapDwellRaw is the dwell value of the orbit point that was trapped. Sample.TrapDwell is the normalized dwell value. Sample.TrapIndexRaw and Sample.TrapDeltaRaw are the Index value and Delta value assigned to the point by the trap instructions. Sample.TrapIndex and Sample.TrapDelta are the normalized values. See Trapped Point Index/Delta for details. Sample.TrapCountRaw is the number of traps that trapped the point. Sample.TrapCount is the normalized count. All the remaining fields are described in the Classic Controllers section. However, the following fields are not initialized if the Orbit Opacity On property is checked on the Orbit Trap page:
In addition, if the Orbit Opacity On property is checked, the following fields are not smoothed even if Smooth Angle is checked in the Orbit Generation section of the Mandelbrot / Julia / Newton page:
The reason for these exceptions is that when Orbit Opacity On is checked, the controllers are called during sample generation to process each of the trapped points but these fields are not initialized/smoothed until after sample generation is complete. |
|
Copyright © 2004-2010 Hilbert, LLC |