artisteacher fd1c1e
#pragma once
shun_iwasawa a35b8f
shun_iwasawa a35b8f
/*------------------------------------
shun_iwasawa a35b8f
Iwa_BokehFx
shun_iwasawa a35b8f
Apply an off-focus effect to the source image, using user input iris image.
shun_iwasawa a35b8f
It considers characteristics of films (which is known as Hurter–Driffield
shun_iwasawa a35b8f
curves)
shun_iwasawa a35b8f
or human eye's perception (which is known as Weber–Fechner law).
shun_iwasawa a35b8f
For filtering process I used KissFFT, an FFT library by Mark Borgerding,
shun_iwasawa a35b8f
distributed with a 3-clause BSD-style license.
shun_iwasawa a35b8f
------------------------------------*/
shun_iwasawa a35b8f
shun_iwasawa a35b8f
#ifndef IWA_BOKEHFX_H
shun_iwasawa a35b8f
#define IWA_BOKEHFX_H
shun_iwasawa a35b8f
shun_iwasawa a35b8f
#include "stdfx.h"
shun_iwasawa a35b8f
#include "tfxparam.h"
shun_iwasawa a35b8f
#include "traster.h"
shun_iwasawa a35b8f
shun_iwasawa a35b8f
#include <qlist></qlist>
shun_iwasawa a35b8f
#include <qthread></qthread>
shun_iwasawa a35b8f
shun_iwasawa a35b8f
#include "tools/kiss_fftnd.h"
shun-iwasawa 1b1839
#include "iwa_bokeh_util.h"
shun_iwasawa a35b8f
shun_iwasawa a35b8f
const int LAYER_NUM = 5;
shun_iwasawa a35b8f
shun-iwasawa 1b1839
class Iwa_BokehFx : public Iwa_BokehCommonFx {
shun_iwasawa a35b8f
  FX_PLUGIN_DECLARATION(Iwa_BokehFx)
shun_iwasawa a35b8f
shun_iwasawa a35b8f
  struct LAYERPARAM {
shun_iwasawa a35b8f
    TRasterFxPort m_source;
shun_iwasawa a35b8f
    TBoolParamP m_premultiply;
shun_iwasawa a35b8f
    TDoubleParamP m_distance;  // The layer distance from the camera (0-1)
shun_iwasawa a35b8f
    TDoubleParamP m_bokehAdjustment;  // Factor for adjusting distance (= focal
shun_iwasawa a35b8f
                                      // distance - layer distance) (0-2.0)
shun_iwasawa a35b8f
  } m_layerParams[LAYER_NUM];
shun_iwasawa a35b8f
shun_iwasawa a35b8f
  // Sort source layers by distance
shun_iwasawa a35b8f
  QList<int> getSortedSourceIndices(double frame);</int>
shun_iwasawa a35b8f
  // Compute the bokeh size for each layer. The source tile will be enlarged by
shun_iwasawa a35b8f
  // the largest size of them.
shun-iwasawa 1b1839
  QMap<int, double=""> getIrisSizes(const double frame,</int,>
shun-iwasawa 1b1839
                                 const QList<int> sourceIndices,</int>
shun-iwasawa 1b1839
                                 const double bokehPixelAmount,
shun-iwasawa 1b1839
                                 double &maxIrisSize);
shun_iwasawa a35b8f
shun_iwasawa a35b8f
public:
shun_iwasawa a35b8f
  Iwa_BokehFx();
shun_iwasawa a35b8f
shun-iwasawa ce90c2
  void doCompute(TTile &tile, double frame,
shun-iwasawa ce90c2
                 const TRenderSettings &settings) override;
shun_iwasawa a35b8f
};
shun_iwasawa a35b8f
artisteacher fd1c1e
#endif