tahoma2d/toonz/sources/stdfx/iwa_pnperspectivefx.h

113 lines
3.4 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_PNPerspectiveFx
2021-02-13 14:00:13 +13:00
render perspective noise pattern.
2016-03-19 06:57:51 +13:00
------------------------------------------------------------*/
#ifndef IWA_PN_PERSPECTIVE_H
#define IWA_PN_PERSPECTIVE_H
#include "tfxparam.h"
#include "stdfx.h"
#include "tparamset.h"
2021-02-13 14:00:13 +13:00
struct double3 {
double x, y, z;
2016-03-19 06:57:51 +13:00
};
2021-02-13 14:00:13 +13:00
struct double4 {
double x, y, z, w;
2016-03-19 06:57:51 +13:00
};
2021-02-13 14:00:13 +13:00
// parameters
2016-03-19 06:57:51 +13:00
struct PN_Params {
2021-02-13 14:00:13 +13:00
enum RenderMode {
Noise = 0,
Noise_NoResample,
WarpHV,
Fresnel,
WarpHV2
} renderMode;
enum NoiseType { Perlin = 0, Simplex } noiseType;
double size; // noise size of the first generation
int octaves; // generation count
TPointD offset; // offset of the first generation
double p_intensity; // intensity ratio between gen
double p_size; // size ratio between gen
double p_offset; // offset ratio between gen
TPointD eyeLevel;
int drawLevel; // vertical distance from the bottom to the top of the drawing
// region
2016-06-15 18:43:10 +12:00
bool alp_rend_sw;
2021-02-13 14:00:13 +13:00
double waveHeight; // used in the WarpHV and Fresnel modes
double fy_2;
double A;
double3 cam_pos;
double base_fresnel_ref; // used in the Fresnel mode
double top_fresnel_ref; // used in the Fresnel mode
double int_sum;
TAffine aff;
double time;
double p_evolution;
2016-03-19 06:57:51 +13:00
};
class Iwa_PNPerspectiveFx final : public TStandardZeraryFx {
2016-06-15 18:43:10 +12:00
FX_PLUGIN_DECLARATION(Iwa_PNPerspectiveFx)
2021-02-13 14:00:13 +13:00
TIntEnumParamP m_renderMode;
TIntEnumParamP m_noiseType;
TDoubleParamP m_size;
TDoubleParamP m_evolution;
TIntEnumParamP m_octaves;
TPointParamP m_offset;
TDoubleParamP m_persistance_intensity;
TDoubleParamP m_persistance_size;
TDoubleParamP m_persistance_evolution;
TDoubleParamP m_persistance_offset;
TDoubleParamP m_fov; // vertical angle of camera fov in degrees
TPointParamP m_eyeLevel; // vanishing point
TBoolParamP m_alpha_rendering; // specify if render noise pattern to the
// alpha channel as well
TDoubleParamP m_waveHeight;
TBoolParamP m_normalize_fresnel; // normalize fresnel reflectivity
TDoubleParamP m_normalize_margin;
2016-06-15 18:43:10 +12:00
template <typename RASTER, typename PIXEL>
2021-02-13 14:00:13 +13:00
void setOutputRaster(double4 *srcMem, const RASTER dstRas, TDimensionI dim,
2016-06-15 18:43:10 +12:00
int drawLevel, const bool alp_rend_sw);
void getPNParameters(TTile &tile, double frame,
const TRenderSettings &settings, PN_Params &params,
TDimensionI &dimOut);
2021-02-13 14:00:13 +13:00
// render for 2 Noise modes
void calcPerinNoise_CPU(double4 *out_host, TDimensionI &dimOut, PN_Params &p,
2016-06-15 18:43:10 +12:00
bool doResample);
2021-02-13 14:00:13 +13:00
// render for WarpHV / Fresnel modes
void calcPNNormal_CPU(double4 *out_host, TDimensionI &dimOut, PN_Params &p,
2016-06-15 18:43:10 +12:00
bool isSubWave = false);
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
Iwa_PNPerspectiveFx();
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
bool doGetBBox(double frame, TRectD &bBox,
const TRenderSettings &info) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool canHandle(const TRenderSettings &info, double frame) override;
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void doCompute(TTile &tile, double frame,
const TRenderSettings &rend_sets) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void doCompute_CPU(TTile &tile, double frame, const TRenderSettings &settings,
2021-02-13 14:00:13 +13:00
double4 *out_host, TDimensionI &dimOut,
2016-06-15 18:43:10 +12:00
PN_Params &pnParams);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void getParamUIs(TParamUIConcept *&concepts, int &length) override;
2016-03-19 06:57:51 +13:00
};
#endif