Bokeh / Depth Of Field

To provide a more realistic look for you applications, Gorilla3D supplies a simple to use Bokeh (or Depth Of Field) component.

In photography, bokeh is the aesthetic quality of the blur produced in the out-of-focus parts of an image produced by a lens.[2][3][4]

Bokeh has been defined as “the way the lens renders out-of-focus points of light”.[5]

Differences in lens aberrations and aperture shape cause some lens designs to blur the image in a way that is pleasing to the eye, while others produce blurring that is unpleasant or distracting (“good” and “bad” bokeh, respectively).[6]

Bokeh occurs for parts of the scene that lie outside the depth of field. Photographers sometimes deliberately use a shallow focus technique to create images with prominent out-of-focus regions.

Bokeh is often most visible around small background highlights, such as specular reflections and light sources, which is why it is often associated with such areas.[6]

However, bokeh is not limited to highlights; blur occurs in all out-of-focus regions of the image.

Source: https://en.wikipedia.org/wiki/Bokeh

Limitations

Due to FMX limitations bokeh rendering have some harsh limitations. In FMX the cameras near and far plane is hardcoded to 1.0 - 1000.0. Therefore it's not possible to build a perfect implementation at the moment, because camera's near/far plane need to be equal to bokeh shaders near/far plane.

Remarks

The component instanciates two render passes automatically: TGorillaRenderPassCustomDepth and TGorillaRenderPassBokeh. Keep this in mind, in case you'll need the custom depth pass for another render pass. Otherwise you will produce unnecessary rendering overhead, by duplicated render passes.

Example

procedure TForm1.CreateBokeh();
begin
  FBokeh := TGorillaBokeh.Create(FViewport);
  FBokeh.AutoFocus := true;
  FBokeh.Fstop := 1;
  FBokeh.FrustumNearFar := PointF(10, 100);
end;

Next step: Internal Model Definition