tahoma2d/toonz/sources/stdfx/iwa_motionblurfx.h

138 lines
5.3 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
/*------------------------------------
Iwa_MotionBlurCompFx
//------------------------------------*/
#ifndef IWA_MOTION_BLUR_COMP_H
#define IWA_MOTION_BLUR_COMP_H
#include "tfxparam.h"
#include "stdfx.h"
#include "motionawarebasefx.h"
class TStageObjectId;
struct float2 {
2016-06-15 18:43:10 +12:00
float x, y;
2016-03-19 06:57:51 +13:00
};
struct float3 {
2016-06-15 18:43:10 +12:00
float x, y, z;
2016-03-19 06:57:51 +13:00
};
struct float4 {
2016-06-15 18:43:10 +12:00
float x, y, z, w;
2016-03-19 06:57:51 +13:00
};
struct int2 {
2016-06-15 18:43:10 +12:00
int x, y;
2016-03-19 06:57:51 +13:00
};
/*- m_premultiTypeの取る値 -*/
enum PremultiTypes {
2016-06-15 18:43:10 +12:00
AUTO = 0,
SOURCE_IS_PREMULTIPLIED,
SOURCE_IS_NOT_PREMUTIPLIED
2016-03-19 06:57:51 +13:00
};
class Iwa_MotionBlurCompFx final : public MotionAwareBaseFx {
2016-06-15 18:43:10 +12:00
FX_PLUGIN_DECLARATION(Iwa_MotionBlurCompFx)
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
TRasterFxPort m_input;
TRasterFxPort m_background;
TDoubleParamP m_hardness; /*- フィルムのガンマ値 -*/
/*-- 左右をぼかすためのパラメータ --*/
TDoubleParamP m_startValue; /*- シャッター開け時のフィルタ値 -*/
/*- シャッター開け時〜現時点までのフィルタ値のガンマ補正値 -*/
TDoubleParamP m_startCurve;
TDoubleParamP m_endValue; /*- シャッター閉じ時のフィルタ値 -*/
/*- 現時点〜シャッター閉じ時までのフィルタ値のガンマ補正値 -*/
TDoubleParamP m_endCurve;
/*- 残像モードのトグル -*/
TBoolParamP m_zanzoMode;
TIntEnumParamP m_premultiType;
/*- ソース画像を0〜1に正規化してホストメモリに読み込む
Premultipyされているか
-*/
template <typename RASTER, typename PIXEL>
bool setSourceRaster(const RASTER srcRas, float4 *dstMem, TDimensionI dim,
PremultiTypes type = AUTO);
/*- 出力結果をChannel値に変換して格納 -*/
template <typename RASTER, typename PIXEL>
void setOutputRaster(float4 *srcMem, const RASTER dstRas, TDimensionI dim,
int2 margin);
/*- フィルタをつくり、正規化する -*/
void makeMotionBlurFilter_CPU(float *filter_p, TDimensionI &filterDim,
int marginLeft, int marginBottom,
float4 *pointsTable, int pointAmount,
float startValue, float startCurve,
float endValue, float endCurve);
/*- 残像フィルタをつくり、正規化する -*/
void makeZanzoFilter_CPU(float *filter_p, TDimensionI &filterDim,
int marginLeft, int marginBottom,
float4 *pointsTable, int pointAmount,
float startValue, float startCurve, float endValue,
float endCurve);
/*- RGB値(0〜1)を露光値に変換 -*/
void convertRGBtoExposure_CPU(float4 *in_tile_p, TDimensionI &dim,
float hardness, bool sourceIsPremultiplied);
/*- 露光値をフィルタリングしてぼかす -*/
void applyBlurFilter_CPU(float4 *in_tile_p, float4 *out_tile_p,
TDimensionI &dim, float *filter_p,
TDimensionI &filterDim, int marginLeft,
int marginBottom, int marginRight, int marginTop,
TDimensionI &outDim);
/*- 露光値をdepremultipy→RGB値(0〜1)に戻す→premultiply -*/
void convertExposureToRGB_CPU(float4 *out_tile_p, TDimensionI &dim,
float hardness);
/*- 背景があり、前景が動かない場合、単純にOverする -*/
void composeWithNoMotion(TTile &tile, double frame,
const TRenderSettings &settings);
/*- 背景を露光値にして通常合成 -*/
void composeBackgroundExposure_CPU(float4 *out_tile_p,
TDimensionI &enlargedDimIn,
int marginRight, int marginTop,
TTile &back_tile, TDimensionI &dimOut,
float hardness);
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
Iwa_MotionBlurCompFx();
2016-06-20 14:23:05 +12:00
void doCompute(TTile &tile, double frame,
const TRenderSettings &settings) override;
2016-06-15 18:43:10 +12:00
void doCompute_CPU(TTile &tile, double frame, const TRenderSettings &settings,
float4 *pointsTable, int pointAmount, double hardness,
double shutterStart, double shutterEnd,
int traceResolution, float startValue, float startCurve,
float endValue, float endCurve, int marginLeft,
int marginRight, int marginTop, int marginBottom,
TDimensionI &enlargedDimIn, TTile &enlarge_tile,
TDimensionI &dimOut, TDimensionI &filterDim,
TTile &back_tile);
2016-06-20 14:23:05 +12:00
bool doGetBBox(double frame, TRectD &bBox,
const TRenderSettings &info) override;
2016-06-15 18:43:10 +12:00
2016-06-19 20:06:29 +12:00
bool canHandle(const TRenderSettings &info, double frame) override;
2016-06-15 18:43:10 +12:00
/*- 参考にしているオブジェクトが動いている可能性があるので、
-*/
2016-06-20 14:23:05 +12:00
std::string getAlias(double frame,
const TRenderSettings &info) const override;
2016-03-19 06:57:51 +13:00
};
#endif