Toshihiro Shimizu 890ddd
/*------------------------------------
Toshihiro Shimizu 890ddd
 Iwa_DirectionalBlurFx
Toshihiro Shimizu 890ddd
 ボケ足の伸ばし方を選択でき、参照画像を追加した DirectionalBlur
Toshihiro Shimizu 890ddd
//------------------------------------*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "iwa_directionalblurfx.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tparamuiconcept.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
enum FILTER_TYPE {
Toshihiro Shimizu 890ddd
	Linear = 0,
Toshihiro Shimizu 890ddd
	Gaussian,
Toshihiro Shimizu 890ddd
	Flat
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*------------------------------------------------------------
Toshihiro Shimizu 890ddd
 参照画像の輝度を0〜1に正規化してホストメモリに読み込む
Toshihiro Shimizu 890ddd
------------------------------------------------------------*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename pixel="" raster,="" typename=""></typename>
Toshihiro Shimizu 890ddd
void Iwa_DirectionalBlurFx::setReferenceRaster(const RASTER srcRas,
Toshihiro Shimizu 890ddd
											   float *dstMem,
Toshihiro Shimizu 890ddd
											   TDimensionI dim)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	float *dst_p = dstMem;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	for (int j = 0; j < dim.ly; j++) {
Toshihiro Shimizu 890ddd
		PIXEL *pix = srcRas->pixels(j);
Toshihiro Shimizu 890ddd
		for (int i = 0; i < dim.lx; i++, pix++, dst_p++) {
Toshihiro Shimizu 890ddd
			(*dst_p) = ((float)pix->r * 0.3f +
Toshihiro Shimizu 890ddd
						(float)pix->g * 0.59f +
Toshihiro Shimizu 890ddd
						(float)pix->b * 0.11f) /
Toshihiro Shimizu 890ddd
					   (float)PIXEL::maxChannelValue;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*------------------------------------------------------------
Toshihiro Shimizu 890ddd
 ソース画像を0〜1に正規化してホストメモリに読み込む
Toshihiro Shimizu 890ddd
------------------------------------------------------------*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename pixel="" raster,="" typename=""></typename>
Toshihiro Shimizu 890ddd
void Iwa_DirectionalBlurFx::setSourceRaster(const RASTER srcRas,
Toshihiro Shimizu 890ddd
											float4 *dstMem,
Toshihiro Shimizu 890ddd
											TDimensionI dim)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	float4 *chann_p = dstMem;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	for (int j = 0; j < dim.ly; j++) {
Toshihiro Shimizu 890ddd
		PIXEL *pix = srcRas->pixels(j);
Toshihiro Shimizu 890ddd
		for (int i = 0; i < dim.lx; i++, pix++, chann_p++) {
Toshihiro Shimizu 890ddd
			(*chann_p).x = (float)pix->r / (float)PIXEL::maxChannelValue;
Toshihiro Shimizu 890ddd
			(*chann_p).y = (float)pix->g / (float)PIXEL::maxChannelValue;
Toshihiro Shimizu 890ddd
			(*chann_p).z = (float)pix->b / (float)PIXEL::maxChannelValue;
Toshihiro Shimizu 890ddd
			(*chann_p).w = (float)pix->m / (float)PIXEL::maxChannelValue;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*------------------------------------------------------------
Toshihiro Shimizu 890ddd
 出力結果をChannel値に変換してタイルに格納
Toshihiro Shimizu 890ddd
------------------------------------------------------------*/
Toshihiro Shimizu 890ddd
template <typename pixel="" raster,="" typename=""></typename>
Toshihiro Shimizu 890ddd
void Iwa_DirectionalBlurFx::setOutputRaster(float4 *srcMem,
Toshihiro Shimizu 890ddd
											const RASTER dstRas,
Toshihiro Shimizu 890ddd
											TDimensionI dim,
Toshihiro Shimizu 890ddd
											int2 margin)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	int out_j = 0;
Toshihiro Shimizu 890ddd
	for (int j = margin.y; j < dstRas->getLy() + margin.y; j++, out_j++) {
Toshihiro Shimizu 890ddd
		PIXEL *pix = dstRas->pixels(out_j);
Toshihiro Shimizu 890ddd
		float4 *chan_p = srcMem;
Toshihiro Shimizu 890ddd
		chan_p += j * dim.lx + margin.x;
Toshihiro Shimizu 890ddd
		for (int i = 0; i < dstRas->getLx(); i++, pix++, chan_p++) {
Toshihiro Shimizu 890ddd
			float val;
Toshihiro Shimizu 890ddd
			val = (*chan_p).x * (float)PIXEL::maxChannelValue + 0.5f;
Toshihiro Shimizu 890ddd
			pix->r = (typename PIXEL::Channel)((val > (float)PIXEL::maxChannelValue) ? (float)PIXEL::maxChannelValue : val);
Toshihiro Shimizu 890ddd
			val = (*chan_p).y * (float)PIXEL::maxChannelValue + 0.5f;
Toshihiro Shimizu 890ddd
			pix->g = (typename PIXEL::Channel)((val > (float)PIXEL::maxChannelValue) ? (float)PIXEL::maxChannelValue : val);
Toshihiro Shimizu 890ddd
			val = (*chan_p).z * (float)PIXEL::maxChannelValue + 0.5f;
Toshihiro Shimizu 890ddd
			pix->b = (typename PIXEL::Channel)((val > (float)PIXEL::maxChannelValue) ? (float)PIXEL::maxChannelValue : val);
Toshihiro Shimizu 890ddd
			val = (*chan_p).w * (float)PIXEL::maxChannelValue + 0.5f;
Toshihiro Shimizu 890ddd
			pix->m = (typename PIXEL::Channel)((val > (float)PIXEL::maxChannelValue) ? (float)PIXEL::maxChannelValue : val);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Iwa_DirectionalBlurFx::Iwa_DirectionalBlurFx()
Toshihiro Shimizu 890ddd
	: m_angle(0.0), m_intensity(10.0), m_bidirectional(false), m_filterType(new TIntEnumParam(Linear, "Linear"))
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_intensity->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
	m_angle->setMeasureName("angle");
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bindParam(this, "angle", m_angle);
Toshihiro Shimizu 890ddd
	bindParam(this, "intensity", m_intensity);
Toshihiro Shimizu 890ddd
	bindParam(this, "bidirectional", m_bidirectional);
Toshihiro Shimizu 890ddd
	bindParam(this, "filterType", m_filterType);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	addInputPort("Source", m_input);
Toshihiro Shimizu 890ddd
	addInputPort("Reference", m_reference);
Toshihiro Shimizu 890ddd
	m_intensity->setValueRange(0, (std::numeric_limits<double>::max)());</double>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_filterType->addItem(Gaussian, "Gaussian");
Toshihiro Shimizu 890ddd
	m_filterType->addItem(Flat, "Flat");
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void Iwa_DirectionalBlurFx::doCompute(TTile &tile,
Toshihiro Shimizu 890ddd
									  double frame,
Toshihiro Shimizu 890ddd
									  const TRenderSettings &settings)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	/*- 接続していない場合は処理しない -*/
Toshihiro Shimizu 890ddd
	if (!m_input.isConnected()) {
Toshihiro Shimizu 890ddd
		tile.getRaster()->clear();
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPointD blurVector;
Toshihiro Shimizu 890ddd
	double angle = m_angle->getValue(frame) * (TConsts::pi / 180);
Toshihiro Shimizu 890ddd
	double intensity = m_intensity->getValue(frame);
Toshihiro Shimizu 890ddd
	bool bidirectional = m_bidirectional->getValue();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	blurVector.x = intensity * cos(angle);
Toshihiro Shimizu 890ddd
	blurVector.y = intensity * sin(angle);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double shrink = (settings.m_shrinkX + settings.m_shrinkY) / 2.0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- 平行移動成分を消したアフィン変換をかけ、ボケベクトルを変形 -*/
Toshihiro Shimizu 890ddd
	TAffine aff = settings.m_affine;
Toshihiro Shimizu 890ddd
	aff.a13 = aff.a23 = 0;
Toshihiro Shimizu 890ddd
	TPointD blur = (1.0 / shrink) * (aff * blurVector);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- ボケの実際の長さを求める -*/
Toshihiro Shimizu 890ddd
	double blurValue = norm(blur);
Toshihiro Shimizu 890ddd
	/*- ボケの実際の長さがほぼ0なら入力画像をそのまま return -*/
Toshihiro Shimizu 890ddd
	if (areAlmostEqual(blurValue, 0, 1e-3)) {
Toshihiro Shimizu 890ddd
		m_input->compute(tile, frame, settings);
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*-  表示の範囲を得る -*/
Toshihiro Shimizu 890ddd
	TRectD bBox = TRectD(
Toshihiro Shimizu 890ddd
		tile.m_pos /*- Render画像上(Pixel単位)の位置  -*/
Toshihiro Shimizu 890ddd
		,
Toshihiro Shimizu 890ddd
		TDimensionD(/*- Render画像上(Pixel単位)のサイズ  -*/
Toshihiro Shimizu 890ddd
					tile.getRaster()->getLx(), tile.getRaster()->getLy()));
Toshihiro Shimizu 890ddd
	/*- 上下左右のマージンを得る -*/
Toshihiro Shimizu 890ddd
	double minX, maxX, minY, maxY;
Toshihiro Shimizu 890ddd
	if (blur.x > 0.0) /*- X成分が正の場合 -*/
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		maxX = blur.x;
Toshihiro Shimizu 890ddd
		minX = (bidirectional) ? -blur.x : 0.0;
Toshihiro Shimizu 890ddd
	} else /*- X成分が負の場合 -*/
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		maxX = (bidirectional) ? -blur.x : 0.0;
Toshihiro Shimizu 890ddd
		minX = blur.x;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	if (blur.y > 0.0) /*- Y成分が正の場合 -*/
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		maxY = blur.y;
Toshihiro Shimizu 890ddd
		minY = (bidirectional) ? -blur.y : 0.0;
Toshihiro Shimizu 890ddd
	} else /*-  Y成分が負の場合 -*/
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		maxY = (bidirectional) ? -blur.y : 0.0;
Toshihiro Shimizu 890ddd
		minY = blur.y;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	int marginLeft = (int)ceil(abs(minX));
Toshihiro Shimizu 890ddd
	int marginRight = (int)ceil(abs(maxX));
Toshihiro Shimizu 890ddd
	int marginTop = (int)ceil(abs(maxY));
Toshihiro Shimizu 890ddd
	int marginBottom = (int)ceil(abs(minY));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- マージンは、フィルタの上下左右を反転した寸法になる -*/
Toshihiro Shimizu 890ddd
	TRectD enlargedBBox(bBox.x0 - (double)marginRight,
Toshihiro Shimizu 890ddd
						bBox.y0 - (double)marginTop,
Toshihiro Shimizu 890ddd
						bBox.x1 + (double)marginLeft,
Toshihiro Shimizu 890ddd
						bBox.y1 + (double)marginBottom);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	std::cout << "Margin Left:" << marginLeft << " Right:" << marginRight << " Bottom:" << marginBottom << " Top:" << marginTop << std::endl;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TDimensionI enlargedDimIn(/*- Pixel単位に四捨五入 -*/
Toshihiro Shimizu 890ddd
							  (int)(enlargedBBox.getLx() + 0.5), (int)(enlargedBBox.getLy() + 0.5));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TTile enlarge_tile;
Toshihiro Shimizu 890ddd
	m_input->allocateAndCompute(
Toshihiro Shimizu 890ddd
		enlarge_tile, enlargedBBox.getP00(), enlargedDimIn, tile.getRaster(), frame, settings);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- 参照画像が有ったら、メモリに取り込む -*/
Toshihiro Shimizu 890ddd
	float *reference_host = 0;
Toshihiro Shimizu 890ddd
	TRasterGR8P reference_host_ras;
Toshihiro Shimizu 890ddd
	if (m_reference.isConnected()) {
Toshihiro Shimizu 890ddd
		TTile reference_tile;
Toshihiro Shimizu 890ddd
		m_reference->allocateAndCompute(
Toshihiro Shimizu 890ddd
			reference_tile, enlargedBBox.getP00(), enlargedDimIn, tile.getRaster(), frame, settings);
Toshihiro Shimizu 890ddd
		/*- ホストのメモリ確保 -*/
Toshihiro Shimizu 890ddd
		reference_host_ras = TRasterGR8P(sizeof(float) * enlargedDimIn.lx, enlargedDimIn.ly);
Toshihiro Shimizu 890ddd
		reference_host_ras->lock();
Toshihiro Shimizu 890ddd
		reference_host = (float *)reference_host_ras->getRawData();
Toshihiro Shimizu 890ddd
		/*- 参照画像の輝度を0〜1に正規化してホストメモリに読み込む -*/
Toshihiro Shimizu 890ddd
		TRaster32P ras32 = (TRaster32P)reference_tile.getRaster();
Toshihiro Shimizu 890ddd
		TRaster64P ras64 = (TRaster64P)reference_tile.getRaster();
Toshihiro Shimizu 890ddd
		if (ras32)
Toshihiro Shimizu 890ddd
			setReferenceRaster<traster32p, tpixel32="">(ras32, reference_host, enlargedDimIn);</traster32p,>
Toshihiro Shimizu 890ddd
		else if (ras64)
Toshihiro Shimizu 890ddd
			setReferenceRaster<traster64p, tpixel64="">(ras64, reference_host, enlargedDimIn);</traster64p,>
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//-------------------------------------------------------
Toshihiro Shimizu 890ddd
	/*- 計算範囲 -*/
Toshihiro Shimizu 890ddd
	TDimensionI dimOut(tile.getRaster()->getLx(), tile.getRaster()->getLy());
Toshihiro Shimizu 890ddd
	TDimensionI filterDim(marginLeft + marginRight + 1, marginTop + marginBottom + 1);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	doCompute_CPU(tile, frame, settings,
Toshihiro Shimizu 890ddd
				  blur,
Toshihiro Shimizu 890ddd
				  bidirectional,
Toshihiro Shimizu 890ddd
				  marginLeft, marginRight,
Toshihiro Shimizu 890ddd
				  marginTop, marginBottom,
Toshihiro Shimizu 890ddd
				  enlargedDimIn,
Toshihiro Shimizu 890ddd
				  enlarge_tile,
Toshihiro Shimizu 890ddd
				  dimOut,
Toshihiro Shimizu 890ddd
				  filterDim,
Toshihiro Shimizu 890ddd
				  reference_host);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*-  参照画像が刺さっている場合、メモリを解放する -*/
Toshihiro Shimizu 890ddd
	if (reference_host) {
Toshihiro Shimizu 890ddd
		reference_host_ras->unlock();
Toshihiro Shimizu 890ddd
		reference_host = 0;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void Iwa_DirectionalBlurFx::doCompute_CPU(TTile &tile,
Toshihiro Shimizu 890ddd
										  double frame,
Toshihiro Shimizu 890ddd
										  const TRenderSettings &settings,
Toshihiro Shimizu 890ddd
										  TPointD &blur,
Toshihiro Shimizu 890ddd
										  bool bidirectional,
Toshihiro Shimizu 890ddd
										  int marginLeft, int marginRight,
Toshihiro Shimizu 890ddd
										  int marginTop, int marginBottom,
Toshihiro Shimizu 890ddd
										  TDimensionI &enlargedDimIn,
Toshihiro Shimizu 890ddd
										  TTile &enlarge_tile,
Toshihiro Shimizu 890ddd
										  TDimensionI &dimOut,
Toshihiro Shimizu 890ddd
										  TDimensionI &filterDim,
Toshihiro Shimizu 890ddd
										  float *reference_host)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	/*- メモリ確保 -*/
Toshihiro Shimizu 890ddd
	TRasterGR8P in_ras(sizeof(float4) * enlargedDimIn.lx, enlargedDimIn.ly);
Toshihiro Shimizu 890ddd
	in_ras->lock();
Toshihiro Shimizu 890ddd
	float4 *in = (float4 *)in_ras->getRawData();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TRasterGR8P out_ras(sizeof(float4) * enlargedDimIn.lx, enlargedDimIn.ly);
Toshihiro Shimizu 890ddd
	out_ras->lock();
Toshihiro Shimizu 890ddd
	float4 *out = (float4 *)out_ras->getRawData();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TRasterGR8P filter_ras(sizeof(float) * filterDim.lx, filterDim.ly);
Toshihiro Shimizu 890ddd
	filter_ras->lock();
Toshihiro Shimizu 890ddd
	float *filter = (float *)filter_ras->getRawData();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- ソース画像を0〜1に正規化してホストメモリに読み込む -*/
Toshihiro Shimizu 890ddd
	TRaster32P ras32 = (TRaster32P)enlarge_tile.getRaster();
Toshihiro Shimizu 890ddd
	TRaster64P ras64 = (TRaster64P)enlarge_tile.getRaster();
Toshihiro Shimizu 890ddd
	if (ras32)
Toshihiro Shimizu 890ddd
		setSourceRaster<traster32p, tpixel32="">(ras32, in, enlargedDimIn);</traster32p,>
Toshihiro Shimizu 890ddd
	else if (ras64)
Toshihiro Shimizu 890ddd
		setSourceRaster<traster64p, tpixel64="">(ras64, in, enlargedDimIn);</traster64p,>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- フィルタ作る -*/
Toshihiro Shimizu 890ddd
	makeDirectionalBlurFilter_CPU(filter, blur, bidirectional,
Toshihiro Shimizu 890ddd
								  marginLeft, marginRight, marginTop, marginBottom, filterDim);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (reference_host) /*- 参照画像がある場合 -*/
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		float4 *out_p = out + marginTop * enlargedDimIn.lx;
Toshihiro Shimizu 890ddd
		float *ref_p = reference_host + marginTop * enlargedDimIn.lx;
Toshihiro Shimizu 890ddd
		/*- フィルタリング -*/
Toshihiro Shimizu 890ddd
		for (int y = marginTop; y < dimOut.ly + marginTop; y++) {
Toshihiro Shimizu 890ddd
			out_p += marginRight;
Toshihiro Shimizu 890ddd
			ref_p += marginRight;
Toshihiro Shimizu 890ddd
			for (int x = marginRight; x < dimOut.lx + marginRight; x++, out_p++, ref_p++) {
Toshihiro Shimizu 890ddd
				/*- 参照画像が黒ならソースをそのまま返す -*/
Toshihiro Shimizu 890ddd
				if ((*ref_p) == 0.0f) {
Toshihiro Shimizu 890ddd
					(*out_p) = in[y * enlargedDimIn.lx + x];
Toshihiro Shimizu 890ddd
					continue;
Toshihiro Shimizu 890ddd
				}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				/*- 値を積算する入れ物を用意 -*/
Toshihiro Shimizu 890ddd
				float4 value = {0.0f, 0.0f, 0.0f, 0.0f};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				float *filter_p = filter;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				if ((*ref_p) == 1.0f) {
Toshihiro Shimizu 890ddd
					/*- フィルタのサイズでループ ただし、フィルタはサンプル点の画像を収集するように
Toshihiro Shimizu 890ddd
						用いるため、上下左右反転してサンプルする -*/
Toshihiro Shimizu 890ddd
					for (int fily = -marginBottom; fily < filterDim.ly - marginBottom; fily++) {
Toshihiro Shimizu 890ddd
						/*- サンプル座標 と インデックス の このスキャンラインのうしろ -*/
Toshihiro Shimizu 890ddd
						int2 samplePos = {x + marginLeft, y - fily};
Toshihiro Shimizu 890ddd
						int sampleIndex = samplePos.y * enlargedDimIn.lx + samplePos.x;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
						for (int filx = -marginLeft; filx < filterDim.lx - marginLeft; filx++, filter_p++, sampleIndex--) {
Toshihiro Shimizu 890ddd
							/*- フィルター値が0またはサンプルピクセルが透明ならcontinue -*/
Toshihiro Shimizu 890ddd
							if ((*filter_p) == 0.0f || in[sampleIndex].w == 0.0f)
Toshihiro Shimizu 890ddd
								continue;
Toshihiro Shimizu 890ddd
							/*- サンプル点の値にフィルタ値を掛けて積算する -*/
Toshihiro Shimizu 890ddd
							value.x += in[sampleIndex].x * (*filter_p);
Toshihiro Shimizu 890ddd
							value.y += in[sampleIndex].y * (*filter_p);
Toshihiro Shimizu 890ddd
							value.z += in[sampleIndex].z * (*filter_p);
Toshihiro Shimizu 890ddd
							value.w += in[sampleIndex].w * (*filter_p);
Toshihiro Shimizu 890ddd
						}
Toshihiro Shimizu 890ddd
					}
Toshihiro Shimizu 890ddd
				} else {
Toshihiro Shimizu 890ddd
					for (int fily = -marginBottom; fily < filterDim.ly - marginBottom; fily++) {
Toshihiro Shimizu 890ddd
						for (int filx = -marginLeft; filx < filterDim.lx - marginLeft; filx++, filter_p++) {
Toshihiro Shimizu 890ddd
							/*- フィルター値が0ならcontinue -*/
Toshihiro Shimizu 890ddd
							if ((*filter_p) == 0.0f)
Toshihiro Shimizu 890ddd
								continue;
Toshihiro Shimizu 890ddd
							/*- サンプル座標 -*/
Toshihiro Shimizu 890ddd
							int2 samplePos = {tround((float)x - (float)filx * (*ref_p)),
Toshihiro Shimizu 890ddd
											  tround((float)y - (float)fily * (*ref_p))};
Toshihiro Shimizu 890ddd
							int sampleIndex = samplePos.y * enlargedDimIn.lx + samplePos.x;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
							/*- サンプルピクセルが透明ならcontinue -*/
Toshihiro Shimizu 890ddd
							if (in[sampleIndex].w == 0.0f)
Toshihiro Shimizu 890ddd
								continue;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
							/*- サンプル点の値にフィルタ値を掛けて積算する -*/
Toshihiro Shimizu 890ddd
							value.x += in[sampleIndex].x * (*filter_p);
Toshihiro Shimizu 890ddd
							value.y += in[sampleIndex].y * (*filter_p);
Toshihiro Shimizu 890ddd
							value.z += in[sampleIndex].z * (*filter_p);
Toshihiro Shimizu 890ddd
							value.w += in[sampleIndex].w * (*filter_p);
Toshihiro Shimizu 890ddd
						}
Toshihiro Shimizu 890ddd
					}
Toshihiro Shimizu 890ddd
				}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				/*- 値を格納 -*/
Toshihiro Shimizu 890ddd
				(*out_p) = value;
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
			out_p += marginLeft;
Toshihiro Shimizu 890ddd
			ref_p += marginLeft;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	} else /*- 参照画像が無い場合 -*/
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		float4 *out_p = out + marginTop * enlargedDimIn.lx;
Toshihiro Shimizu 890ddd
		/*- フィルタリング -*/
Toshihiro Shimizu 890ddd
		for (int y = marginTop; y < dimOut.ly + marginTop; y++) {
Toshihiro Shimizu 890ddd
			out_p += marginRight;
Toshihiro Shimizu 890ddd
			for (int x = marginRight; x < dimOut.lx + marginRight; x++, out_p++) {
Toshihiro Shimizu 890ddd
				/*- 値を積算する入れ物を用意 -*/
Toshihiro Shimizu 890ddd
				float4 value = {0.0f, 0.0f, 0.0f, 0.0f};
Toshihiro Shimizu 890ddd
				/*- フィルタのサイズでループ ただし、フィルタはサンプル点の画像を収集するように
Toshihiro Shimizu 890ddd
					用いるため、上下左右反転してサンプルする -*/
Toshihiro Shimizu 890ddd
				int filterIndex = 0;
Toshihiro Shimizu 890ddd
				for (int fily = -marginBottom; fily < filterDim.ly - marginBottom; fily++) {
Toshihiro Shimizu 890ddd
					/*- サンプル座標 と インデックス の このスキャンラインのうしろ -*/
Toshihiro Shimizu 890ddd
					int2 samplePos = {x + marginLeft, y - fily};
Toshihiro Shimizu 890ddd
					int sampleIndex = samplePos.y * enlargedDimIn.lx + samplePos.x;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
					for (int filx = -marginLeft; filx < filterDim.lx - marginLeft; filx++, filterIndex++, sampleIndex--) {
Toshihiro Shimizu 890ddd
						/*- フィルター値が0またはサンプルピクセルが透明ならcontinue -*/
Toshihiro Shimizu 890ddd
						if (filter[filterIndex] == 0.0f || in[sampleIndex].w == 0.0f)
Toshihiro Shimizu 890ddd
							continue;
Toshihiro Shimizu 890ddd
						/*- サンプル点の値にフィルタ値を掛けて積算する -*/
Toshihiro Shimizu 890ddd
						value.x += in[sampleIndex].x * filter[filterIndex];
Toshihiro Shimizu 890ddd
						value.y += in[sampleIndex].y * filter[filterIndex];
Toshihiro Shimizu 890ddd
						value.z += in[sampleIndex].z * filter[filterIndex];
Toshihiro Shimizu 890ddd
						value.w += in[sampleIndex].w * filter[filterIndex];
Toshihiro Shimizu 890ddd
					}
Toshihiro Shimizu 890ddd
				}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				/*- 値を格納 -*/
Toshihiro Shimizu 890ddd
				(*out_p) = value;
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
			out_p += marginLeft;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	in_ras->unlock();
Toshihiro Shimizu 890ddd
	filter_ras->unlock();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- ラスタのクリア -*/
Toshihiro Shimizu 890ddd
	tile.getRaster()->clear();
Toshihiro Shimizu 890ddd
	TRaster32P outRas32 = (TRaster32P)tile.getRaster();
Toshihiro Shimizu 890ddd
	TRaster64P outRas64 = (TRaster64P)tile.getRaster();
Toshihiro Shimizu 890ddd
	int2 margin = {marginRight, marginTop};
Toshihiro Shimizu 890ddd
	if (outRas32)
Toshihiro Shimizu 890ddd
		setOutputRaster<traster32p, tpixel32="">(out, outRas32, enlargedDimIn, margin);</traster32p,>
Toshihiro Shimizu 890ddd
	else if (outRas64)
Toshihiro Shimizu 890ddd
		setOutputRaster<traster64p, tpixel64="">(out, outRas64, enlargedDimIn, margin);</traster64p,>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	out_ras->unlock();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void Iwa_DirectionalBlurFx::makeDirectionalBlurFilter_CPU(float *filter,
Toshihiro Shimizu 890ddd
														  TPointD &blur,
Toshihiro Shimizu 890ddd
														  bool bidirectional,
Toshihiro Shimizu 890ddd
														  int marginLeft, int marginRight,
Toshihiro Shimizu 890ddd
														  int marginTop, int marginBottom,
Toshihiro Shimizu 890ddd
														  TDimensionI &filterDim)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	/*- 必要なら、ガウスフィルタを前計算 -*/
Toshihiro Shimizu 890ddd
	FILTER_TYPE filterType = (FILTER_TYPE)m_filterType->getValue();
Toshihiro Shimizu 890ddd
	std::vector<float> gaussian;</float>
Toshihiro Shimizu 890ddd
	if (filterType == Gaussian) {
Toshihiro Shimizu 890ddd
		gaussian.reserve(101);
Toshihiro Shimizu 890ddd
		for (int g = 0; g < 101; g++) {
Toshihiro Shimizu 890ddd
			float x = (float)g / 100.0f;
Toshihiro Shimizu 890ddd
			//sigma == 0.25
Toshihiro Shimizu 890ddd
			gaussian.push_back(exp(-x * x / 0.125f));
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- フィルタを作る -*/
Toshihiro Shimizu 890ddd
	TPointD p0 = (bidirectional) ? TPointD(-blur.x, -blur.y) : TPointD(0.0f, 0.0f);
Toshihiro Shimizu 890ddd
	TPointD p1 = blur;
Toshihiro Shimizu 890ddd
	float2 vec_p0_p1 = {static_cast<float>(p1.x - p0.x),</float>
Toshihiro Shimizu 890ddd
						static_cast<float>(p1.y - p0.y)};</float>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	float *fil_p = filter;
Toshihiro Shimizu 890ddd
	float intensity_sum = 0.0f;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	for (int fy = -marginBottom; fy <= marginTop; fy++) {
Toshihiro Shimizu 890ddd
		for (int fx = -marginLeft; fx <= marginRight; fx++, fil_p++) {
Toshihiro Shimizu 890ddd
			/*- 現在の座標とブラー直線の距離を求める -*/
Toshihiro Shimizu 890ddd
			/*- P0->サンプル点とP0->P1の内積を求める -*/
Toshihiro Shimizu 890ddd
			float2 vec_p0_sample = {static_cast<float>(fx - p0.x),</float>
Toshihiro Shimizu 890ddd
									static_cast<float>(fy - p0.y)};</float>
Toshihiro Shimizu 890ddd
			float dot = vec_p0_sample.x * vec_p0_p1.x +
Toshihiro Shimizu 890ddd
						vec_p0_sample.y * vec_p0_p1.y;
Toshihiro Shimizu 890ddd
			/*- 軌跡ベクトルの長さの2乗を計算する -*/
Toshihiro Shimizu 890ddd
			float length2 = vec_p0_p1.x * vec_p0_p1.x +
Toshihiro Shimizu 890ddd
							vec_p0_p1.y * vec_p0_p1.y;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			/*- 距離の2乗を求める -*/
Toshihiro Shimizu 890ddd
			float dist2;
Toshihiro Shimizu 890ddd
			float framePosRatio;
Toshihiro Shimizu 890ddd
			/*- P0より手前にある場合 -*/
Toshihiro Shimizu 890ddd
			if (dot <= 0.0f) {
Toshihiro Shimizu 890ddd
				dist2 = vec_p0_sample.x * vec_p0_sample.x +
Toshihiro Shimizu 890ddd
						vec_p0_sample.y * vec_p0_sample.y;
Toshihiro Shimizu 890ddd
				framePosRatio = 0.0f;
Toshihiro Shimizu 890ddd
			} else {
Toshihiro Shimizu 890ddd
				/*- P0〜P1間にある場合 -*/
Toshihiro Shimizu 890ddd
				if (dot < length2) {
Toshihiro Shimizu 890ddd
					float p0_sample_dist2 = vec_p0_sample.x * vec_p0_sample.x +
Toshihiro Shimizu 890ddd
											vec_p0_sample.y * vec_p0_sample.y;
Toshihiro Shimizu 890ddd
					dist2 = p0_sample_dist2 - dot * dot / length2;
Toshihiro Shimizu 890ddd
					framePosRatio = dot / length2;
Toshihiro Shimizu 890ddd
				}
Toshihiro Shimizu 890ddd
				/*- P1より先にある場合 -*/
Toshihiro Shimizu 890ddd
				else {
Toshihiro Shimizu 890ddd
					float2 vec_p1_sample = {static_cast<float>(fx - p1.x),</float>
Toshihiro Shimizu 890ddd
											static_cast<float>(fy - p1.y)};</float>
Toshihiro Shimizu 890ddd
					dist2 = vec_p1_sample.x * vec_p1_sample.x +
Toshihiro Shimizu 890ddd
							vec_p1_sample.y * vec_p1_sample.y;
Toshihiro Shimizu 890ddd
					framePosRatio = 1.0f;
Toshihiro Shimizu 890ddd
				}
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
			/*- 距離が(√2 + 1)/2より遠かったらreturn dist2との比較だから2乗している -*/
Toshihiro Shimizu 890ddd
			if (dist2 > 1.4571f) {
Toshihiro Shimizu 890ddd
				(*fil_p) = 0.0f;
Toshihiro Shimizu 890ddd
				continue;
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			/*-  現在のピクセルのサブピクセル(16*16)が、近傍ベクトルからの距離0.5の範囲にどれだけ
Toshihiro Shimizu 890ddd
				 含まれているかをカウントする -*/
Toshihiro Shimizu 890ddd
			int count = 0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			for (int yy = 0; yy < 16; yy++) {
Toshihiro Shimizu 890ddd
				/*- サブピクセルのY座標 -*/
Toshihiro Shimizu 890ddd
				float subPosY = (float)fy + ((float)yy - 7.5f) / 16.0f;
Toshihiro Shimizu 890ddd
				for (int xx = 0; xx < 16; xx++) {
Toshihiro Shimizu 890ddd
					/*- サブピクセルのX座標 -*/
Toshihiro Shimizu 890ddd
					float subPosX = (float)fx + ((float)xx - 7.5f) / 16.0f;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
					float2 vec_p0_sub = {static_cast<float>(subPosX - p0.x),</float>
Toshihiro Shimizu 890ddd
										 static_cast<float>(subPosY - p0.y)};</float>
Toshihiro Shimizu 890ddd
					float sub_dot = vec_p0_sub.x * vec_p0_p1.x +
Toshihiro Shimizu 890ddd
									vec_p0_sub.y * vec_p0_p1.y;
Toshihiro Shimizu 890ddd
					/*- 距離の2乗を求める -*/
Toshihiro Shimizu 890ddd
					float dist2;
Toshihiro Shimizu 890ddd
					/*- P0より手前にある場合 -*/
Toshihiro Shimizu 890ddd
					if (sub_dot <= 0.0f)
Toshihiro Shimizu 890ddd
						dist2 = vec_p0_sub.x * vec_p0_sub.x + vec_p0_sub.y * vec_p0_sub.y;
Toshihiro Shimizu 890ddd
					else {
Toshihiro Shimizu 890ddd
						/*- P0〜P1間にある場合 -*/
Toshihiro Shimizu 890ddd
						if (sub_dot < length2) {
Toshihiro Shimizu 890ddd
							float p0_sub_dist2 = vec_p0_sub.x * vec_p0_sub.x +
Toshihiro Shimizu 890ddd
												 vec_p0_sub.y * vec_p0_sub.y;
Toshihiro Shimizu 890ddd
							dist2 = p0_sub_dist2 - sub_dot * sub_dot / length2;
Toshihiro Shimizu 890ddd
						}
Toshihiro Shimizu 890ddd
						/*-  P1より先にある場合 -*/
Toshihiro Shimizu 890ddd
						else {
Toshihiro Shimizu 890ddd
							float2 vec_p1_sub = {static_cast<float>(subPosX - p1.x),</float>
Toshihiro Shimizu 890ddd
												 static_cast<float>(subPosY - p1.y)};</float>
Toshihiro Shimizu 890ddd
							dist2 = vec_p1_sub.x * vec_p1_sub.x +
Toshihiro Shimizu 890ddd
									vec_p1_sub.y * vec_p1_sub.y;
Toshihiro Shimizu 890ddd
						}
Toshihiro Shimizu 890ddd
					}
Toshihiro Shimizu 890ddd
					/*- 距離の2乗が0.25より近ければカウントをインクリメント -*/
Toshihiro Shimizu 890ddd
					if (dist2 <= 0.25f)
Toshihiro Shimizu 890ddd
						count++;
Toshihiro Shimizu 890ddd
				}
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
			/*- 保険 カウントが0の場合はフィールド値0でreturn -*/
Toshihiro Shimizu 890ddd
			if (count == 0) {
Toshihiro Shimizu 890ddd
				(*fil_p) = 0.0f;
Toshihiro Shimizu 890ddd
				continue;
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
			/*- countは Max256 -*/
Toshihiro Shimizu 890ddd
			float countRatio = (float)count / 256.0f;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			/*- オフセット値を求める -*/
Toshihiro Shimizu 890ddd
			float offset = (bidirectional) ? abs(framePosRatio * 2.0 - 1.0) : framePosRatio;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			/*- フィルタごとに分ける -*/
Toshihiro Shimizu 890ddd
			float bokeAsiVal;
Toshihiro Shimizu 890ddd
			switch (filterType) {
Toshihiro Shimizu 890ddd
			case Linear:
Toshihiro Shimizu 890ddd
				bokeAsiVal = 1.0f - offset;
Toshihiro Shimizu 890ddd
				break;
Toshihiro Shimizu 890ddd
			case Gaussian: {
Toshihiro Shimizu 890ddd
				int index = (int)floor(offset * 100.0f);
Toshihiro Shimizu 890ddd
				float ratio = offset * 100.0f - (float)index;
Toshihiro Shimizu 890ddd
				bokeAsiVal = gaussian[index] * (1.0f - ratio) + gaussian[index + 1] * ratio;
Toshihiro Shimizu 890ddd
			} break;
Toshihiro Shimizu 890ddd
			case Flat:
Toshihiro Shimizu 890ddd
				bokeAsiVal = 1.0f;
Toshihiro Shimizu 890ddd
				break;
Toshihiro Shimizu 890ddd
			default:
Toshihiro Shimizu 890ddd
				bokeAsiVal = 1.0f - offset;
Toshihiro Shimizu 890ddd
				break;
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			/*- フィールド値の格納 -*/
Toshihiro Shimizu 890ddd
			(*fil_p) = bokeAsiVal * countRatio;
Toshihiro Shimizu 890ddd
			intensity_sum += (*fil_p);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- 正規化 -*/
Toshihiro Shimizu 890ddd
	fil_p = filter;
Toshihiro Shimizu 890ddd
	for (int f = 0; f < filterDim.lx * filterDim.ly; f++, fil_p++) {
Toshihiro Shimizu 890ddd
		if ((*fil_p) == 0.0f)
Toshihiro Shimizu 890ddd
			continue;
Toshihiro Shimizu 890ddd
		(*fil_p) /= intensity_sum;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool Iwa_DirectionalBlurFx::doGetBBox(double frame,
Toshihiro Shimizu 890ddd
									  TRectD &bBox,
Toshihiro Shimizu 890ddd
									  const TRenderSettings &info)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (false == this->m_input.isConnected()) {
Toshihiro Shimizu 890ddd
		bBox = TRectD();
Toshihiro Shimizu 890ddd
		return false;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool ret = m_input->doGetBBox(frame, bBox, info);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (bBox == TConsts::infiniteRectD)
Toshihiro Shimizu 890ddd
		return ret;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPointD blur;
Toshihiro Shimizu 890ddd
	double angle = m_angle->getValue(frame) * (TConsts::pi / 180);
Toshihiro Shimizu 890ddd
	double intensity = m_intensity->getValue(frame);
Toshihiro Shimizu 890ddd
	bool bidirectional = m_bidirectional->getValue();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	blur.x = intensity * cos(angle);
Toshihiro Shimizu 890ddd
	blur.y = intensity * sin(angle);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- 上下左右のマージンを得る -*/
Toshihiro Shimizu 890ddd
	double minX, maxX, minY, maxY;
Toshihiro Shimizu 890ddd
	if (blur.x > 0.0) /*- X成分が正の場合 -*/
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		maxX = blur.x;
Toshihiro Shimizu 890ddd
		minX = (bidirectional) ? -blur.x : 0.0;
Toshihiro Shimizu 890ddd
	} else /*- X成分が負の場合 -*/
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		maxX = (bidirectional) ? -blur.x : 0.0;
Toshihiro Shimizu 890ddd
		minX = blur.x;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	if (blur.y > 0.0) /*- Y成分が正の場合 -*/
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		maxY = blur.y;
Toshihiro Shimizu 890ddd
		minY = (bidirectional) ? -blur.y : 0.0;
Toshihiro Shimizu 890ddd
	} else /*-  Y成分が負の場合 -*/
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		maxY = (bidirectional) ? -blur.y : 0.0;
Toshihiro Shimizu 890ddd
		minY = blur.y;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	int marginLeft = (int)ceil(abs(minX));
Toshihiro Shimizu 890ddd
	int marginRight = (int)ceil(abs(maxX));
Toshihiro Shimizu 890ddd
	int marginTop = (int)ceil(abs(maxY));
Toshihiro Shimizu 890ddd
	int marginBottom = (int)ceil(abs(minY));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TRectD enlargedBBox(bBox.x0 - (double)marginLeft,
Toshihiro Shimizu 890ddd
						bBox.y0 - (double)marginBottom,
Toshihiro Shimizu 890ddd
						bBox.x1 + (double)marginRight,
Toshihiro Shimizu 890ddd
						bBox.y1 + (double)marginTop);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bBox = enlargedBBox;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	return ret;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool Iwa_DirectionalBlurFx::canHandle(const TRenderSettings &info,
Toshihiro Shimizu 890ddd
									  double frame)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return isAlmostIsotropic(info.m_affine) || m_intensity->getValue(frame) == 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void Iwa_DirectionalBlurFx::getParamUIs(TParamUIConcept *&concepts,
Toshihiro Shimizu 890ddd
										int &length)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	concepts = new TParamUIConcept[length = 1];
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	concepts[0].m_type = TParamUIConcept::POLAR;
Toshihiro Shimizu 890ddd
	concepts[0].m_label = "Angle and Intensity";
Toshihiro Shimizu 890ddd
	concepts[0].m_params.push_back(m_angle);
Toshihiro Shimizu 890ddd
	concepts[0].m_params.push_back(m_intensity);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(Iwa_DirectionalBlurFx, "iwa_DirectionalBlurFx")