Orbit Trap Controllers

Home • Gallery • Tutorials • Download • Purchase • Site Map
 

Orbit Trap Controllers Overview

Orbit 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:

  • Gradients are the ordered list of gradients available to the controller. The Gradient List Control allows you to add/remove gradients to/from the list, reorder the list, cut/copy/paste gradients between lists on other properties pages, undo/redo list changes, edit gradients in the list using the Gradient Editor, and open the Gradient Browser so you can copy/paste existing gradients from the Built-in Gradients or My Gradients into the list. When you paste a gradient into the list, a copy of the gradient is made so that any changes to the gradient will not affect the original. Your program can access this list using the Gradient Functions.

Textures

The following properties are defined in the Textures section:

  • Textures are the ordered list of textures available to the controller. The Texture List Control allows you to add/remove textures to/from the list, reorder the list, cut/copy/paste textures between lists on other properties pages, undo/redo list changes, and repair broken textures. Your program can access the list using the Texture Functions. Each texture in the list is displayed using the name of the associated texture file without the file extension. If a single texture is selected, the texture's image is displayed in the preview area on the right side of the control. If the texture file no longer exists or cannot be loaded, the name will also include the text [error loading file] and a default texture (a white box) is used. You should replace these items or remove them from the list. To replace a broken texture in the list, simply select it and click the Repair toolbar button and select the replacement.

Properties

The following properties are defined in the Properties section:

  • Opacity Factor is used to scale the resulting color's Alpha value. The Alpha value is an indication of the color's opacity. The Alpha value ranges from 0 to 1, where 0 is transparent and 1 is fully opaque. The Opacity Factor can be used to scale the Alpha value of each color produced by this controller.

  • Scale Opacity, like Opacity Factor, is used to scale the resulting color's Alpha value. Unlike Opacity Factor which uniformly scales each color's Alpha value, Scale Opacity varies the scale factor based on how far the sample is from the trap. Min, Max, and Decay define the following factor: Factor=Min+(Max-Min)*(1-V)^Decay, where V is Abs(Sample.TrapValue). As the sample moves away from the trap, Factor ranges from Max to Min; i.e., the sample gets increasingly transparent. Decay is used to control the shape of the power curve. If Decay is less than 1, Factor decreases slowly and then drops off quickly. If Decay is greater than 1, Factor drops off quickly and then levels out. If Decay equals 1, Factor decreases linearly.

  • Apply 3D is used to turn on 3D processing and enable the 3D Mapping properties (described below). 3D processing uses Sample.TrapValue to obtain a virtual height, and scales the color based on this height in conjunction with the 3D Mapping properties.

  • Apply Depth is used to turn on depth processing and enable the Depth Mapping properties (described below). Depth processing uses Sample.TrapDwell to obtain a virtual depth, and darkens/lightens the color based on this depth in conjunction with the Depth Mapping properties.

  • Add Trans Array is a checkbox that can be checked to add a Transformation Array editor as one of the program's properties pages. Users can add 1 or more transformations to the editor and your program can access the transformations using the Transformation Functions.

  • Force Execution is a checkbox that can be checked to force execution of the instructions. If Force Execution is unchecked, the instructions will execute only if required based on what changes were made to the fractal's properties since the last time the instructions ran. This is rarely checked.

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 Space is the color space you want to adjust. It can be set to HSL (Hue/Saturation/Lightness) or HSV (Hue/Saturation/Value). The HSL color space supports adjustments to the Hue, Saturation, and Lightness of the color. The HSV color space supports adjustments to the Hue, Saturation, and Value of the color.

  • Hue is a value added to the color's Hue. The value should be between -179 and 180.

  • Saturation is a value between -100 and 100 used to scale the color's Saturation. The value is given as a percentage change relative to the color's current Saturation. For example, 25 would increase the color's Saturation by 25 percent of the difference between full saturation and the current value. A value of -40 would reduce the color's Saturation by 40 percent.

  • Lightness is a value between -100 and 100 used to scale the color's Lightness. The value is given as a percentage change relative to the color's current Lightness. Lightness is unique to the HSL color model.

  • Value is a value between -100 and 100 used to scale the color's Value. The value is given as a percentage change relative to the color's current Value. Value is unique to the HSV color model.

Color Adjustment

Color Adjustment section

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.

  • Brightness is a value added to each color's RGB components. The value should be between -1 and 1. Positive values brighten the color, negative values darken the color.

  • Contrast is a value between 0.2 and 8 used to scale each RGB component of the image data about the central value (Contrast Center). Values greater than 1 increase contrast. Values less than 1 decrease contrast.

  • Contrast Center is the central value about which Contrast scaling is applied.

  • Gamma is a power factor applied individually to each color's RGB components. The value should be between 0.2 and 8. Values greater than 1 brighten the color. Values less than 1 darken the color.

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.

  • Map To is the sample field mapped to height when performing 3D processing. In addition to Trap Value, you can set Map To to Composite Height to access the value of compositeHeight, computed by your instructions. It is expected that compositeHeight is set to a value between 0 and 1. A value of 0 maps to a visual high and a value of 1 maps to a visual low.

  • Light Intensity is an integer between 0 and 255 that represents the intensity of the light source. A value of 0 is void of light and a value of 255 is full intensity. This value is normally between 200 and 240.

  • Ambient Light is an integer between 0 and 255 that represents light that reaches the object reflected off other objects. A value of 0 includes no ambient light. This value is normally between 0 and 40. Higher values tend to wash out the color.

  • Specular K is a value between 0 and 1 that represents a specular reflection constant. This value is normally between 0.01 and 0.1 where smaller values result in less specular reflection.

  • Specular N is an integer greater than 0 that represents a specular reflection exponent. This value is normally between 5 and 100. Use small values for larger, less intense highlights, large values for smaller, more intense highlights.

  • Style can be set to Rounded or Edged. Rounded causes the trap to have a rounded appearance as the trap moves away from the trap center. Edged causes the trap to have an edge along the trap center, and appear flat on either side of the edge giving the trap a bar-like appearance. Normally, when you set Style to Edged, you will set Peak to Constant but the other values look good in some situations. Edged does is not compatible with some trap types; e.g., solid traps.

  • Shadow is a value between -1 and 1 that defines the strength of the shadow applied to 1 of the 2 sides of the trap when Style is set to Edged. If Shadow is less than 0, the shadow is applied to the side adjacent to the inside edge. If Shadow is greater than 0, the shadow is applied to the side adjacent to the outside edge. See Trapped Point Value for a discussion of what constitutes an inside/outside edge. The magnitude of Shadow controls how dark the side will appear; i.e., larger magnitudes appear darker. Shadow is disabled unless Style is set to Edged.

  • Shadow Cycles is an integer greater than or equal to 0 that represents the number of cycles applied to the Shadow. If Shadow Cycles is 0, the Shadow value is used for the entire trap. Otherwise, the shadow value oscillates between Shadow and -1*Shadow as the trap angle changes. Shadow Cycles represents the number of oscillations.

  • Peak, Peak Arg (S) and Peak Arg (N) control the location and shape of the trap highlights and are described below.

  • Curvature is used to soften the 3D effect. A value of 1 is maximum curvature and results in the strongest 3D effect. Values greater than 1 increase the radius of curvature and soften the 3D effect.

  • Apply Depth is a Boolean value that, when checked, strengthens the 3D effect by adding depth to the mapped value. In some cases this adds a metallic quality to the resulting colors. You may need to adjust the Depth Power, Depth Factor or the Ambient Light if the resulting image appears too dark.

  • Depth Power defines the shape of the power curve used for depth processing.

  • Depth Factor is the factor applied to the mapped value at maximum depth.

Peak, Peak Arg (S), and Peak Arg (N), control the location and shape of the trap highlights. Peak is one of the following:

  • Center
  • Constant (Position: S)
  • Wave (Amplitude: S, Cycles: N)

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.

  • Depth Power defines the shape of the power curve used for depth processing.

  • Depth Factor is the amount of black (or white if highlighting) that is blended into a color at maximum depth.

  • Highlight Depth is a Boolean value that, when checked, lightens rather than darkens the color based on depth.

Instructions

At 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 Variables

Several built-in variables are available to your instructions:

  • Color color
  • compositeHeight
  • pixel

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 {
  R|Red  |H|Hue
  G|Green|S|Saturation
  B|Blue |L|Lightness |V|Value
  A|Alpha
}

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:
 
  color = Gradient.Color(0, Sample.TrapAngle)

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:
 
  color = Gradient.Color(0, Value)
 
properties:
 
  option Value {
    type = SamplePointValue
    caption = "Value"
    default = Sample.TrapAngle
  }

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:
 
  Maps a sample point value to a gradient index.
 
color:
 
  color = Gradient.Color(ColorScheme, Value)
 
properties:
 
 option ColorScheme {
    type = GradientIndex
    caption = "Color Scheme"
    default = 0
    size = Large
  }
  option Value {
    type = SamplePointValue
    caption = "Value"
    default = Sample.TrapAngle
  }

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:
 
  switch (IndexMap) {
    case IndexMapTypes.TrapDwell: index = Sample.TrapDwellRaw
    case IndexMapTypes.TrapIndex: index = Sample.TrapIndexRaw
    case IndexMapTypes.TrapDelta: index = Sample.TrapDeltaRaw
  }
  color = Colors[WrapIndex(index, Count)]
 
properties:
 
  divider {
    caption = "Index Map"
  }
  enum IndexMapTypes {
    TrapDwell, "Trap Dwell"
    TrapIndex, "Trap Index"
    TrapDelta, "Trap Delta"
  }
  option IndexMap {
    type = IndexMapTypes
    caption = "Index Map"
    default = IndexMapTypes.TrapDwell
  }
  divider {
    caption = "Color Map"
  }
  option Count {
    type = IntegerEnum(1,8)
    caption = "Count"
    details = "Number of colors to use"
    default = 8
  }
  option Colors {
    type = ColorSet[Count]
    caption = "Colors"
    default = FF00AE, FF2020, FF8200, FFFF00, 00FF6C, 00FFFF, 4040FF, AE60FF
  }

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.

Constants

The following constants are available to your instructions:

  • ViewportMagnification

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 Data

The 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:

  • Sample.TrapValue
  • Sample.TrapAngle
  • Sample.TrapAngleBounce
  • Sample.TrapAngleCos
  • Sample.TrapAngleRaw
  • Sample.TrapDwell
  • Sample.TrapDwellRaw
  • Sample.TrapIndex
  • Sample.TrapIndexRaw
  • Sample.TrapDelta
  • Sample.TrapDeltaRaw
  • Sample.TrapCount
  • Sample.TrapCountRaw
  • Sample.Dwell
  • Sample.DwellRaw
  • Sample.Angle
  • Sample.AngleBounce
  • Sample.AngleCos
  • Sample.AngleRaw
  • Sample.Magnitude
  • Sample.RootIndex
  • Sample.RootIndexRaw
  • Sample.SmoothingFactor
  • Sample.Alternate1Value
  • Sample.Alternate1ValueRaw
  • Sample.Alternate1Angle
  • Sample.Alternate1AngleBounce
  • Sample.Alternate1AngleCos
  • Sample.Alternate1AngleRaw
  • Sample.Alternate1Index
  • Sample.Alternate1IndexRaw

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:

  • Sample.Magnitude
  • Sample.RootIndex
  • Sample.RootIndexRaw
  • Sample.SmoothingFactor
  • Sample.Alternate1Value
  • Sample.Alternate1ValueRaw
  • Sample.Alternate1Angle
  • Sample.Alternate1AngleBounce
  • Sample.Alternate1AngleCos
  • Sample.Alternate1AngleRaw
  • Sample.Alternate1Index
  • Sample.Alternate1IndexRaw

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:

  • Sample.Angle
  • Sample.AngleBounce
  • Sample.AngleCos
  • Sample.AngleRaw

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
All rights reserved