Classic Controllers |
|
|
Classic Controllers OverviewClassic 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) Classic Master Controller who calls 0 or more Classic 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. 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. One of the sample data fields 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.
Depth Mapping
The Depth Mapping section applies depth shading to the color returned by your program. One of the sample data fields 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. 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, Classic 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. compositeDepth is used to return a value for the Map To setting in the Depth Mapping section. That is, if the Depth Mapping section's Map To is set to Composite Depth, the instructions should set compositeDepth to a value between 0 and 1 for this purpose. Otherwise, compositeDepth need not be set. compositeDepth 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 is applied to color's Alpha value set by the instructions. Example: color: This example calls the Gradient Function Gradient.Color to map the sample's normalized magnitude (Sample.Magnitude) 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.Magnitude 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 uses 2 SamplePointValue options (Value1 and Value2) to superimpose 1 design on top of another. The color section is the single statement: color = Gradient.Color( \ As in the previous examples, we call the function Gradient.Color to map the sample to a color, but here we use Value2 to select 1 of the 2 gradients in the controller's list, and use Value1 to index into the selected gradient to obtain a color. Gradient.Color wraps both arguments at the extremes. The 1st argument is an integer index into the list of gradients. If the list contains 2 gradients as in this example, even values map to the 1st gradient and odd values map to the 2nd gradient. The argument is truncated to an integer before use. The 2nd argument to Gradient.Color is a real number between 0 and 1. Values outside this range are wrapped before selecting the color. For example, passing 1.2 would return the color at position 0.2. Example: color: This example maps 3 SamplePointValue options directly to the RGB components for Red, Green, and Blue. 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 Classic Controller programs:
In the discussion below, the properties Bailout, Epsilon, Min Dwell, Max Dwell, Angle Reference Point, Magnitude, Reference Point, and Cos Smoothing, are defined in the Orbit Generation section of the Mandelbrot / Julia / Newton page. Mandelbrot samples can be categorized by whether or not the associated orbit diverged (or converged if the fractal type is Convergent). If the orbit diverged (or converged), the sample is said to be outside the Mandelbrot set. Otherwise, it is said to be inside the set. Sample.IsInside is true if the sample is inside the Mandelbrot set, and false otherwise. That is, for Divergent fractals, Sample.IsInside is true for samples whose orbit did not escape; i.e., the orbit point did not exceed the Bailout value when the maximum number of iterations (Max Dwell) was reached. For Convergent fractals, Sample.IsInside is true for samples whose orbit did not converge; i.e., the distance between 2 consecutive orbit points did not fall below Epsilon when the maximum number of iterations (Max Dwell) was reached. If the sample is outside the Mandelbrot set, Sample.DwellRaw is the dwell value at the end of the fractal iteration and ranges from Min Dwell to Max Dwell. If the sample is inside the Mandelbrot set, Sample.DwellRaw is Max Dwell + 1. I use Max Dwell + 1 rather than Max Dwell to differentiate the case where the point with dwell equal to Max Dwell is outside the Mandelbrot set. Sample.Dwell is the normalized dwell value. The normalized value is between 0 and 1. Sample.AngleRaw is the angle (in radians) between the X axis and a line from the Angle Reference Point to the sample's last orbit point. All of the other angle values are normalized to the range 0 to 1. Sample.Angle is a straight linear mapping of the angle where 0 to 360 maps to 0 to 1. Sample.AngleBounce 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.AngleBounce starts at 0, increases to 1 at the half-way point (180), and then decreases (bounces) back to 0. Sample.AngleCos is identical to Sample.AngleBounce except that it uses a cosine based wave rather than a triangle based wave so it is smoother at the extremes. The interpretation of Sample.Magnitude depends on the settings Magnitude, Reference Point, and Cos Smoothing and whether the point is inside or outside the Mandelbrot set. If the point is inside the Mandelbrot set, Sample.Magnitude is the normalized magnitude of the sample's last orbit point. Sample.Magnitude ranges smoothly from 0 to 1 as the point's unnormalized magnitude ranges from 0 to Bailout (or 0 to Epsilon for Convergent fractals). If the point is outside the Mandelbrot set, Sample.Magnitude is the normalized magnitude of the sample's last orbit point combined with the sample's dwell value such that a continuous value is generated across dwell boundaries. Sample.Magnitude ranges smoothly from 0 to 1 as the dwell increases from Min Dwell to Max Dwell. The Sample.Magnitude for all points with dwell N is less than that for those points with dwell N+1. Sample.Magnitude normalization is based on the Classic properties page settings. If Root Detection is active and you are generating a Julia fractal, the Fractal Science Kit will attempt to identify roots based on the Root Detection properties Epsilon, Threshold, and Max Roots. Root Detection is normally used for Convergent fractals (e.g., Newton fractals), but it can be used to color the samples inside the Mandelbrot set for Divergent fractals too. In that case, the roots represent points of convergence among those points that did not escape. Remember that you will need to uncheck the Clear M-Set Points checkbox and turn off Cycle Detection to color the samples inside the Mandelbrot set. You can access the index of the root to which the sample converged, using the values Sample.RootIndexRaw or Sample.RootIndex. Sample.RootIndexRaw is a value from -1 to 1 less than the number of roots. Samples that converge to one of the roots have a value greater than or equal to 0. Samples that failed to converge to a root have the value -1. Sample.RootIndex is the normalized index and ranges from 0 to 1. Sample.RootIndex=0 for samples that failed to converge to a root. Example: comment: Root Detection is not applicable for Mandelbrot fractals; Sample.RootIndex and Sample.RootIndexRaw are 0 and -1, respectively, for all samples. However, a common approach is to activate Root Detection and use a controller like the one given above (e.g., Gradient Map - Newton) for the Mandelbrot fractal. Then use the Preview Julia feature to explore different Julia fractals by clicking on the Mandelbrot to define the Julia Constant for the preview. The Mandelbrot will be displayed using shades of a single color since Sample.RootIndex is 0 for all samples (the shading is due to 3D processing) but the Julia Preview will be rendered in full color based on the roots found during Root Detection. Sample.SmoothingFactor is a smoothing factor associated with Continuous Potential Smoothing. It is a value that ranges from 0 to 1. If you consider only those samples associated with a given dwell value in a small region of the complex plane, samples with a smoothing factor close to 0 are farthest from the Mandelbrot set and samples with a smoothing factor close to 1 are closest to the Mandelbrot set. In practice, the smoothing factor is used to calculate the (un-normalized) magnitude as: magnitude = dwell - 1 + Sample.SmoothingFactor The Sample.SmoothingFactor is commonly used to smooth values across dwells. The alternate value fields (Sample.Alternate...) are associated with data initialized on the Alternate Mapping pages. The fields named Sample.Alternate1... are associated with the data for Alternate Mapping 1 and the fields named Sample.Alternate2... are associated with the data for Alternate Mapping 2. If the type of either mapping is <None>, the associated sample fields are not initialized. Otherwise, the fields are initialized from the sample's AlternatePointInfo data given by the mapping. Recall that the AlternatePointInfo object is defined as: Object AlternatePointInfo { For example, consider the sample fields associated with Alternate Mapping 1. Sample.Alternate1Value is the normalized Value and Sample.Alternate1ValueRaw is the raw (un-normalized) Value. Sample.Alternate1AngleRaw is the raw radian Angle. All of the other angle values are normalized to the range 0 to 1. Sample.Alternate1Angle is a straight linear mapping of the angle where 0 to 360 maps to 0 to 1. Sample.Alternate1AngleBounce 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.Alternate1AngleBounce starts at 0, increases to 1 at the half-way point (180), and then decreases (bounces) back to 0. Sample.Alternate1AngleCos is identical to Sample.Alternate1AngleBounce except that it uses a cosine based wave rather than a triangle based wave so it is smoother at the extremes. Sample.Alternate1Index is the normalized Index and Sample.Alternate1IndexRaw is the raw Index. The sample fields associated with Alternate Mapping 2 are defined similarly. If orbit trap processing is enabled, the sample fields associated with Alternate Mapping 2 are used to hold orbit trap related data and should not be used directly but rather, you should use the orbit trap fields as described below. Mandelbrot processing can include both classic processing and orbit trap processing. If both are enabled, the sample data related to orbit traps can be used along with the classic data to map the sample to a color. Normally, you would use the Orbit Trap Controllers to process the samples that are trapped but this is not required. If you generate both Classic and Orbit Trap data but you set the Process Orbit Trap property on the Mandelbrot / Julia / Newton page to Generate Data rather than Activate Controllers, the orbit trap data will be generated but the Classic Controllers are called to process the trapped points rather than calling the Orbit Trap Controllers as is usually the case. If orbit trap processing is enabled, Sample.IsTrapped is true if the point was trapped and false otherwise. Each of the other trap related fields (Sample.Trap...) are as described in Orbit Trap Controllers. |
|
Copyright © 2004-2011 Hilbert, LLC |