# Glitter

The first thing to note in this example is that we have read in the auxiliary surface from disk rather than generating it anew. Notice that the `random_number_seed` line has disappeared. This will save a few seconds of computer time.

  `RenderWorld_data_file ocean 5 5`
  `n_points_x` `1024` `1`
  `n_points_y` `1024` `1`
  `dx` `0.1`
  `dy` `0.1`
  `spectrum_file` `spec2.dat`
  `generate_file` `no`
  `end`
  `number_aux_oceans` `0`
  `number_disturbances` `0`
  `box_depth 20.`
  `reference_time` `0`
  `surface_type` `round`
  `radius` `6371230`
  `max_distance` `100`
  `double_distance` `60`
  `wind_type` `fixed`
  `wind_direction` `90`
  `wind_velocity` `8`
  `waves yes`
  `water_type 3`
  `external_exact` `no`
  `glitter` `yes`
  `whitecaps` `no`
  `textures` `no`
  `sunbeams` `no`
  `exclude_items no`
  `number_of_bands` `3`
  `band_ids 1 2 3`
  `index_of_refraction` `1.34 1.34 1.34`
  `end`

We turn on glitter by changing `no` to `yes` on the `glitter` line. This will slow the code down (typically about 20%), but adds dramatically to the realism of the image if the camera is facing toward the sun. The setting `yes` in conjunction with the line `external_exact` `no` calculates glitter for a sunlight which is only affected by the air, and ignores any other objects which might be present. When `external_exact` has other values their can be an impact on glitter. This is discussed in more detail in the section ``Reflection and Transmission of Objects Through the Ocean Surface.''

A second option for the `glitter` line is `yes_exact`. With this option the glitter is calculated as before, but other objects present in the scene may attenuate the sunlight, depending on their properties and the glitter geometry. This allows you to keep the computational burden of objects reflecting in the water low (via `external_exact` `no`) but have the glitter shadowed properly by those objects.

### Enhanced Glitter

``

The choices `glitter` `yes` and `glitter` `yes_exact` invoke a sophisticated rendering algorithm somewhat tuned to the conditions on the earth. To have more control over the character of the glitter, a third choice, `glitter` `enhanced` exists. The examples in the section demonstrate how to use it.

The concept behind enhanced glitter is to provide the user with the flexibility to modify the local structure of individual spots of glitter. The entire glitter field in an image is the sum of many distinct glitter spots. The `enhanced` option divides a glitter spot into two components: a central core of high intensity, and an ``aureole'' of falling intensity around the core. This allows the user to separately control these two components as a function of angle in the camera plane. The method of control manipulates the width of a glitter spot in the image plane by controlling the roll-off from the center, and by clipping the outer edge of the glitter spot. In addition, the core of the glitter can be assigned arbitrary brightness and color.

The first example below is an ocean file with the`glitter` `enhanced` in its simplest option. This ocean file is like other ocean files, except that between the glitter line and the whitecaps line an additional four lines have been introduced.

  `RenderWorld_data_file ocean 5 5`
  `n_points_x` `1536` `1`
  `n_points_y` `1536` `1`
  `dx` `0.5`
  `dy` `0.5`
  `spectrum_file` `spec.dat`
  `generate_file` `yes`
  `seed` `1011`
  `end`
  `number_aux_oceans` `0`
  `number_disturbances` `0`
  `box_depth 20.`
  `reference_time` `0`
  `surface_type` `flat`
  `max_distance` `180`
  `double_distance` `200`
  `wind_type` `fixed`
  `wind_direction` `160`
  `wind_velocity` `10`
  `waves yes`
  `water_type` `3`
  `external_exact` `no`
  `glitter` `enhanced`
  `sharpening` `no`
  `sharpening_factor` `2.0`
  `prob_threshold` `0.5`
  `saturation` `no`
  `whitecaps` `no`
  `textures no`
  `sunbeams no`
  `exclude_items no`
  `number_of_bands 3`
  `band_ids 1 2 3`
  `index_of_refraction` `1.34 1.34 1.34`
  `end`

The first inserted line is `sharpening` `no`. This indicates that the glitter enhancement is global over the entire ocean surface. The `sharpening` `yes` option is discussed later for allowing the enhancement to be dependent on ocean position. The line `sharpening_factor` `2.0` provides the degree to which the width of the glitter spot is changed. Values greater than 1 actually broaden the spot, whereas values less than 1 sharpen it. A value of exactly zero will cause problems, so do not use it.

The glitter spot can also be clipped, so that below a threshold of the width of the spot, the glitter is removed. The line `prob_threshold` `0.5` performs this clipping. The value 0.5 specifies the fraction of the spot width at which to perform the clipping.

The options for the `saturation` line control adjustment of the core of the glitter spots. The setting `saturation` `yes` allows the user to artificially boost or suppress the central region of a glitter spot. After specifying `yes`, an additional four lines are inserted after the `index_of_refraction line. The first of these lines, saturation_band` `1``,` determines which band is used to compare the criteria for the existence of a glitter spot core, in this case it is the red band`.`

  `RenderWorld_data_file ocean 5 5`
  `n_points_x` `1536` `1`
  `n_points_y` `1536` `1`
  `dx` `0.5`
  `dy` `0.5`
  `spectrum_file` `spec.dat`
  `generate_file` `yes`
  `seed` `1011`
  `end`
  `number_aux_oceans` `0`
  `number_disturbances` `0`
  `box_depth 20.`
  `reference_time` `0`
  `surface_type` `flat`
  `max_distance` `180`
  `double_distance` `200`
  `wind_type` `fixed`
  `wind_direction` `160`
  `wind_velocity` `10`
  `waves yes`
  `water_type` `3`
  `external_exact` `no`
  `glitter` `enhanced`
  `sharpening` `no`
  `sharpening_factor` `2.0`
  `prob_threshold` `0.5`
  `saturation` `yes`
  `whitecaps` `no`
  `textures` `no`
  `sunbeams no`
  `exclude_items no`
  `number_of_bands 3`
  `band_ids 1 2 3`
  `index_of_refraction` `1.34 1.34 1.34`
  `saturation_band` `1`
  `saturation_threshold` `500``.`
  `sub_saturation_scale` `0.5 0.5 0.5`
  `saturation_value` `1000. 1000. 1000.`
  `end`

The `saturation_threshold` parameter is the intensity of reflected glitter light in the `saturation_band` at which a glitter core is declared. All larger intensities are also in the core. Upon declaring a glitter core, the intensity in all channels in the core is given by the set of intensities in `saturation_value`. If glitter light does not lie in the core, the set of parameters on the line `sub_saturation_scale` will scale the intensity in each band.

In the next example below, the glitter core `saturation` controls have been turned off, but the `sharpening` option has been changed to `yes` to allow the user to change the sharpness of the glitter as a function of angle. In this case, instead of giving a single sharpening factor as before, a file name leads to a ``key-frame style'' list of sharpness as a function of angle in the camera plane. An example of the file is listed after the ocean file. When an angle between those in the sharpening.dat file are needed, RenderWorld interpolates to get the value.

  `RenderWorld_data_file ocean 5 5`
  `n_points_x` `1536` `1`
  `n_points_y` `1536` `1`
  `dx` `0.5`
  `dy` `0.5`
  `spectrum_file` `spec.dat`
  `generate_file` `yes`
  `seed` `1011`
  `end`
  `number_aux_oceans` `0`
  `number_disturbances` `0`
  `box_depth 20.`
  `reference_time` `0`
  `surface_type` `flat`
  `max_distance` `180`
  `double_distance` `200`
  `wind_type` `fixed`
  `wind_direction` `160`
  `wind_velocity` `10`
  `waves yes`
  `water_type` `3`
  `external_exact` `no`
  `glitter` `enhanced`
  `sharpening` `yes`
  `file` `sharpening.dat`
  `prob_threshold` `0.5`
  `saturation` `no`
  `whitecaps` `no`
  `textures no`
  `sunbeams no`
  `exclude_items no`
  `number_of_bands 3`
  `band_ids 1 2 3`
  `index_of_refraction` `1.34 1.34 1.34`
  `end`

The file `sharpening.dat` is as shown below:

  `number_of_times` `3`
  `angle sharpening_factor`
  `` `90 1.0`
  `100 2.0`
  `110 4.0`
  `end`

Contents