shun-iwasawa a23340
#pragma once
shun-iwasawa a23340
shun-iwasawa a23340
//******************************************************************
shun-iwasawa a23340
// Iwa FractalNoise Fx
shun-iwasawa a23340
// An Fx emulating Fractal Noise effect in Adobe AfterEffect
shun-iwasawa a23340
//******************************************************************
shun-iwasawa a23340
shun-iwasawa a23340
#ifndef IWA_FRACTALNOISEFX_H
shun-iwasawa a23340
#define IWA_FRACTALNOISEFX_H
shun-iwasawa a23340
shun-iwasawa a23340
#include "tfxparam.h"
shun-iwasawa a23340
#include "tparamset.h"
shun-iwasawa a23340
#include "stdfx.h"
shun-iwasawa a23340
shun-iwasawa a23340
class Iwa_FractalNoiseFx final : public TStandardZeraryFx {
shun-iwasawa a23340
  FX_PLUGIN_DECLARATION(Iwa_FractalNoiseFx)
shun-iwasawa a23340
shun-iwasawa a23340
  enum FractalType {
shun-iwasawa a23340
    Basic = 0,
shun-iwasawa a23340
    TurbulentSmooth,
shun-iwasawa a23340
    TurbulentBasic,
shun-iwasawa a23340
    TurbulentSharp,
shun-iwasawa a23340
    Dynamic,
shun-iwasawa a23340
    DynamicTwist,
shun-iwasawa a23340
    Max,
shun-iwasawa a23340
    Rocky,
shun-iwasawa a23340
    FractalTypeCount
shun-iwasawa a23340
  };
shun-iwasawa a23340
shun-iwasawa a23340
  enum NoiseType { Block = 0, Smooth, NoiseTypeCount };
shun-iwasawa a23340
shun-iwasawa a23340
  struct FNParam {
shun-iwasawa a23340
    FractalType fractalType;
shun-iwasawa a23340
    NoiseType noiseType;
shun-iwasawa a23340
    bool invert;
shun-iwasawa a23340
    double rotation;
shun-iwasawa a23340
    TDimensionD scale;
shun-iwasawa a23340
    TPointD offsetTurbulence;
shun-iwasawa a23340
    bool perspectiveOffset;
shun-iwasawa a23340
    double complexity;
shun-iwasawa a23340
    double subInfluence;
shun-iwasawa a23340
    double subScaling;
shun-iwasawa a23340
    double subRotation;
shun-iwasawa a23340
    TPointD subOffset;
shun-iwasawa a23340
    double evolution;
shun-iwasawa a23340
    bool cycleEvolution;
shun-iwasawa a23340
    double cycleEvolutionRange;
shun-iwasawa a23340
    double dynamicIntensity;
shun-iwasawa f9c294
shun-iwasawa f9c294
    bool doConical;
shun-iwasawa f9c294
    double conicalEvolution;
shun-iwasawa f9c294
    double conicalAngle;
shun-iwasawa f9c294
    double cameraFov;
shun-iwasawa f9c294
    double zScale;
shun-iwasawa f9c294
shun-iwasawa a23340
    bool alphaRendering;
shun-iwasawa a23340
  };
shun-iwasawa a23340
shun-iwasawa a23340
protected:
luz paz d5a269
  // Fractal Type フラクタルの種類
shun-iwasawa a23340
  TIntEnumParamP m_fractalType;
luz paz d5a269
  // Noise Type ノイズの種類
shun-iwasawa a23340
  TIntEnumParamP m_noiseType;
luz paz d5a269
  // Invert 反転
shun-iwasawa a23340
  TBoolParamP m_invert;
luz paz d5a269
  /// Contrast コントラスト
luz paz d5a269
  /// Brightness 明るさ
luz paz d5a269
  /// Overflow オーバーフロー
shun-iwasawa a23340
luz paz d5a269
  //- - - Transform トランスフォーム - - -
luz paz d5a269
  // Rotation 回転
shun-iwasawa a23340
  TDoubleParamP m_rotation;
luz paz d5a269
  // Uniform Scaling 縦横比を固定
shun-iwasawa a23340
  TBoolParamP m_uniformScaling;
luz paz d5a269
  // Scale スケール
shun-iwasawa a23340
  TDoubleParamP m_scale;
luz paz d5a269
  // Scale Width スケールの幅
shun-iwasawa a23340
  TDoubleParamP m_scaleW;
luz paz d5a269
  // Scale Height スケールの高さ
shun-iwasawa a23340
  TDoubleParamP m_scaleH;
luz paz d5a269
  // Offset Turbulence 乱気流のオフセット
shun-iwasawa a23340
  TPointParamP m_offsetTurbulence;
luz paz d5a269
  // Perspective Offset 遠近オフセット
shun-iwasawa a23340
  TBoolParamP m_perspectiveOffset;
shun-iwasawa a23340
luz paz d5a269
  // Complexity 複雑度
shun-iwasawa a23340
  TDoubleParamP m_complexity;
shun-iwasawa a23340
luz paz d5a269
  //- - - Sub Settings サブ設定 - - -
luz paz d5a269
  // Sub Influence サブ影響(%)
shun-iwasawa a23340
  TDoubleParamP m_subInfluence;
luz paz d5a269
  // Sub Scaling サブスケール
shun-iwasawa a23340
  TDoubleParamP m_subScaling;
luz paz d5a269
  // Sub Rotation サブ回転
shun-iwasawa a23340
  TDoubleParamP m_subRotation;
luz paz d5a269
  // Sub Offset サブのオフセット
shun-iwasawa a23340
  TPointParamP m_subOffset;
luz paz d5a269
  // Center Subscale サブスケールを中心
shun-iwasawa a23340
  /// TBoolParamP m_centerSubscale;
shun-iwasawa a23340
luz paz d5a269
  // Evolution 展開
shun-iwasawa a23340
  TDoubleParamP m_evolution;
shun-iwasawa a23340
luz paz d5a269
  //- - - Evolution Options 展開のオプション - - -
luz paz d5a269
  // Cycle Evolution サイクル展開
shun-iwasawa a23340
  TBoolParamP m_cycleEvolution;
luz paz d5a269
  // Cycle (in Evolution) サイクル(周期)
shun-iwasawa a23340
  TDoubleParamP m_cycleEvolutionRange;
luz paz d5a269
  /// Random Seed ランダムシード
luz paz d5a269
  /// Opacity  不透明度
luz paz d5a269
  /// Blending Mode 描画モード
shun-iwasawa a23340
luz paz d5a269
  // ダイナミックの度合い
shun-iwasawa a23340
  TDoubleParamP m_dynamicIntensity;
shun-iwasawa a23340
shun-iwasawa 507240
  //- - - Conical Noise - - -
shun-iwasawa f9c294
  TBoolParamP m_doConical;
shun-iwasawa f9c294
  TDoubleParamP m_conicalEvolution;
shun-iwasawa f9c294
  TDoubleParamP m_conicalAngle;
shun-iwasawa f9c294
  TDoubleParamP m_cameraFov;
shun-iwasawa f9c294
  TDoubleParamP m_zScale;
shun-iwasawa f9c294
shun-iwasawa a23340
  // - - - additional parameters - - -
shun-iwasawa a23340
  TBoolParamP m_alphaRendering;
shun-iwasawa a23340
shun-iwasawa a23340
public:
shun-iwasawa a23340
  Iwa_FractalNoiseFx();
shun-iwasawa a23340
  bool canHandle(const TRenderSettings &info, double frame) override {
shun-iwasawa 507240
    return !m_doConical->getValue();
shun-iwasawa a23340
  }
shun-iwasawa a23340
  bool doGetBBox(double frame, TRectD &bBox,
shun-iwasawa a23340
                 const TRenderSettings &ri) override;
shun-iwasawa a23340
  void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
shun-iwasawa a23340
shun-iwasawa a23340
  void obtainParams(FNParam ¶m, const double frame, const TAffine &aff);
shun-iwasawa a23340
shun-iwasawa a23340
  template <typename pixel="" raster,="" typename=""></typename>
shun-iwasawa a23340
  void outputRaster(const RASTER outRas, double *out_buf, const FNParam ¶m);
shun-iwasawa a23340
shun-iwasawa a23340
  void getParamUIs(TParamUIConcept *&concepts, int &length) override;
shun-iwasawa a23340
shun-iwasawa a23340
  // For Dynamic and Dynamic Twist patterns, the position offsets using gradient
shun-iwasawa a23340
  // / rotation of the parent pattern
shun-iwasawa f9c294
  TPointD getSamplePos(double x, double y, const TDimension outDim,
shun-iwasawa a23340
                       const double *out_buf, const int gen, const double scale,
shun-iwasawa a23340
                       const FNParam ¶m);
shun-iwasawa a23340
  // convert the noise
shun-iwasawa a23340
  void convert(double *buf, const FNParam ¶m);
shun-iwasawa a23340
  // composite the base noise pattern
shun-iwasawa a23340
  void composite(double *out, double *buf, const double influence,
shun-iwasawa a23340
                 const FNParam ¶m);
luz paz 67b4e9
  // finalize pattern (converting the color space)
shun-iwasawa a23340
  void finalize(double *out, const FNParam ¶m);
shun-iwasawa a23340
};
shun-iwasawa a23340
shun-iwasawa a23340
#endif