5. Bokeh_pigment

5.1. Description

Ce patch modifie le calcul du focal blur.

5.2. Syntaxe

camera { ... bokeh_pigment { pigment_densite } ... }

Les rayons envoyés pour le calcul du focal blur sont répartis en fonction de la valeur du pigment pigment_densite pris dans un carré [0,1]x[0,1] en x,y. La densité est la moyenne des trois composantes R,G et B de la couleur du pigment. Par défaut dans povray les rayons sont choisis dans [0,1]x[0,1] uniformément.

5.3. Exemples

image de test bokeh
Image initiale

une image de test.

focal blur de pov
Focal blur de pov
camera
{
  location <5,5,-5> up y right x look_at <0,1,0>
  focal_point <0,0,4> aperture 3 blur_samples 4000
}
focal et bokeh avec un pigment hexagonal
Focal et bokeh avec un pigment hexagonal
camera
{
  location <5,5,-5> up y right x look_at <0,1,0>
  focal_point <0,0,4> aperture 3 blur_samples 4000
  bokeh_pigment
  {
    hexagon color rgb 1 color rgb 0 color rgb 0    rotate 90*x  scale .5  translate <.5 ,.5 ,0>
  }
}

et le pigment correspondant :

pigment pour bokeh avec un pigment hexagonal
Le pigment hexagonal

focal et bokeh avec un pigment horizontal
Focal et bokeh avec un autre pigment
camera
{
  location <5,5,-5> up y right x look_at <0,1,0>
  focal_point <0,0,4> aperture 3 blur_samples 4000
  bokeh_pigment 
  {
    gradient y color_map { [0.02 color rgb 1][0.05 color rgb 0] } scale .55 translate <.5,.5,0>
  }
}

et le pigment correspondant :

pigment pour bokeh avec un autre pigment
Le pigment gradient

5.4. Program

Look for #ifdef BOKEH_PATCH in sources

The samples used in the focal blur are found by dividing [0,1]x[0,1] in a grid of size x=size y=sqrt(nb_samples/4). Then for each sub square we randomly choose a number of samples proportional to the value of the pigment in this sub square (pigment computed at the center of the sub square). If the pigment is uniform we have 4 random samples by sub squares.

In function focal_blur, a Clip_Colour(C, C) was commented to have better results.

Possible improvements/problems

  • Some problems can arise for pigment with fast variations
  • Should use a function rather than a pigment to decribe density
  • Needs fixing for adaptive number of samples (bokehsamples array)
  • Needs a better way to find the samples !