imagico.de
imagico.de

imagico.de

Water

previous: Realistic water with Povray - part 5 current: Realistic water with Povray - part 6 next: water links Navigation

Realistic water with POV-Ray - photons

In this part I describe the use of photons for calculating caustics generated by water surfaces, for the other parts of the tutorial go to the tutorial starting page.

There is one effect related to sunlit water surfaces that was not visible in all the previous samples and that is generally not visible in raytraced simulations by default: reflective and refractive caustics.

Caustics are for example the light effects visible on the bottom of a swimming pool due to the refraction of light at the waves of the water surface. Similarly you can see such light patterns at the bottom of bridges caused by reflected light.

A raytracing algorithm can not simulate such effects because it traces the light "backwards", but in POV-Ray there is a function called "photon mapping" that can overcome this limitation. For details on how this works see external linkNathan Kopp's photons page or the official POV-Ray documentation.

For adding photon simulation to your scene you first of all have to add a photon block to global_settings. This should contain alternatively spacing or count value. With count you can specify the number of photons to shoot, spacing influences the average distance between the photons.

global_settings {
  photons {
    spacing 0.005
  }
}

In addition you have to turn on the photons for every light source you want to shoot photons from. You can independently influence reflection and refraction.

photons {
  reflection off
  refraction on
}

Finally all objects that are supposed to influence the photons need to have a photons block too:

photons {
  target
  reflection off
  refraction on
}

The result of refractive photon calculation looks like the following:

refractive photons refractive photons refractive photons

By default the photons are visible on all surfaces, if you want to turn this off, you can use

photons {
  collect off
}

for single objects.

Varying the spacing value leads to more or less precise caustics and has strong effect on the time required for shooting photons. With count it works the other way round.

global_settings {
  photons {
    spacing [Value]
  }
}

spacing 0.05 spacing 0.008 spacing 0.003
spacing 0.05 spacing 0.008 spacing 0.003

Reflective caustics can be visible on both sunlit and shadowed surfaces, the used scene setup tries to show some typical situations. I used absorbing media on the water to have better contrasts. The photon block for the water is the following:

photons {
  target
  reflection on
  refraction off
}

no photons photons photons
no photons photons photons

Of course there's also the situation that we want caustics from a large water surface. With a plane object this would be simply impossible, but also with a large box or isosurface it would be very inefficient to shoot photons at the whole surface if we only want them for a small part.

The appropriate solution is making the surface consist of two parts, one with photons, one without.

merge {
  difference {
    box { <-10000-10000-20><10000100000> }
    box { <3.00010.0001-21><65.81> }
    photons { collect off }
  }
  box {
    <30-20><6.00015.80010>
    photons { target reflection on refraction off }
  }
}

no photons photons photons

Calculating the photons can take quite a lot of time. Therefore POV-Ray offers the possibility to save and load the photon data. This means that you only have to calculate the photons once and can reuse them in later renders. But be careful when changing geometry and material after generating the photons.

global_settings {
  photons {
    spacing 0.005
    save_file photons.file
  }
}

for saving and

global_settings {
  photons {
    spacing 0.005
    load_file photons.file
  }
}

for loading.

There are many more parameters for influencing photons, a lot of them are not very relevant for water surfaces anyway, but some can be quite useful if you have a close view of the caustics for example. For more detailed information on this see the official POV-Ray documentation.

Back to tutorial index.