|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "trop.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "stdfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpluginmanager.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixelutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tspectrumparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttzpimagefx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "gradients.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tunit.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamuiconcept.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qcoreapplication></qcoreapplication>
|
|
Toshihiro Shimizu |
890ddd |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
e280ae |
#ifdef _MSC_VER
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(disable : 4996)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#undef max
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool isAlmostIsotropic(const TAffine &aff) { return aff.isIsotropic(0.001); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class FadeFx final : public TStandardRasterFx {
|
|
Shinya Kitaoka |
120a6e |
FX_PLUGIN_DECLARATION(FadeFx)
|
|
Shinya Kitaoka |
120a6e |
TRasterFxPort m_input;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_value;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
FadeFx() : m_value(50) {
|
|
Shinya Kitaoka |
120a6e |
m_value->setValueRange(0, 100);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "value", m_value);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
addInputPort("Source", m_input);
|
|
shun-iwasawa |
481b59 |
enableComputeInFloat(true);
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
~FadeFx(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
38fd86 |
bool doGetBBox(double frame, TRectD &bBox,
|
|
Shinya Kitaoka |
38fd86 |
const TRenderSettings &info) override {
|
|
Shinya Kitaoka |
120a6e |
if (m_input.isConnected()) {
|
|
Shinya Kitaoka |
120a6e |
bool ret = m_input->doGetBBox(frame, bBox, info);
|
|
Shinya Kitaoka |
120a6e |
// devo scurire bgColor
|
|
Shinya Kitaoka |
120a6e |
return ret;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
bBox = TRectD();
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
38fd86 |
void doCompute(TTile &tile, double frame,
|
|
Shinya Kitaoka |
38fd86 |
const TRenderSettings &ri) override {
|
|
Shinya Kitaoka |
120a6e |
if (!m_input.isConnected()) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_input->compute(tile, frame, ri);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double v = 1 - m_value->getValue(frame) / 100;
|
|
Shinya Kitaoka |
120a6e |
TRop::rgbmScale(tile.getRaster(), tile.getRaster(), 1, 1, 1, v);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
38fd86 |
bool canHandle(const TRenderSettings &info, double frame) override {
|
|
Shinya Kitaoka |
38fd86 |
return true;
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class SpiralFx final : public TStandardZeraryFx {
|
|
Shinya Kitaoka |
120a6e |
FX_PLUGIN_DECLARATION(SpiralFx)
|
|
shun-iwasawa |
83f5ee |
TIntEnumParamP m_type;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_freq;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_phase;
|
|
Shinya Kitaoka |
120a6e |
TSpectrumParamP m_spectrum;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
83f5ee |
enum SpiralType { Archimedean, Logarithmic };
|
|
shun-iwasawa |
83f5ee |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SpiralFx()
|
|
shun-iwasawa |
83f5ee |
: m_type(new TIntEnumParam(Archimedean, "Archimedean"))
|
|
shun-iwasawa |
83f5ee |
, m_freq(0.1) // args, "Freq")
|
|
Shinya Kitaoka |
120a6e |
, m_phase(0.0) // args, "Phase")
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
// m_freq->setDefaultValue(0.1);
|
|
Shinya Kitaoka |
120a6e |
// m_phase->setDefaultValue(0.0);
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 transparent(0, 0, 0, 0);
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
TPixel32 colors[] = {
|
|
Shinya Kitaoka |
120a6e |
TPixel32::Magenta,
|
|
Shinya Kitaoka |
120a6e |
TPixel32::Black,
|
|
Shinya Kitaoka |
120a6e |
TPixel32::Red,
|
|
Shinya Kitaoka |
120a6e |
TPixel32::Yellow,
|
|
Shinya Kitaoka |
120a6e |
transparent};
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Tact Yoshida |
1d7cf9 |
std::vector<tspectrum::colorkey> colors = {</tspectrum::colorkey>
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(0, TPixel32::Magenta),
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(0.25, TPixel32::Black),
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(0.5, TPixel32::Red),
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(0.75, TPixel32::Yellow),
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(1, transparent)};
|
|
Tact Yoshida |
1d7cf9 |
m_spectrum = TSpectrumParamP(colors);
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
83f5ee |
m_type->addItem(Logarithmic, "Logarithmic");
|
|
shun-iwasawa |
83f5ee |
bindParam(this, "type", m_type);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "colors", m_spectrum);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "freq", m_freq);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "phase", m_phase);
|
|
Shinya Kitaoka |
120a6e |
m_freq->setValueRange(0, 1);
|
|
Shinya Kitaoka |
120a6e |
// m_spectrum->setDefaultValue(tArrayCount(colors), colors);
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
~SpiralFx(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
bool doGetBBox(double, TRectD &bBox, const TRenderSettings &info) override {
|
|
Shinya Kitaoka |
120a6e |
bBox = TConsts::infiniteRectD;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
38fd86 |
bool canHandle(const TRenderSettings &info, double frame) override {
|
|
Shinya Kitaoka |
38fd86 |
return true;
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Toshihiro Shimizu |
890ddd |
void doComputeT(TRasterPT<t> raster, TPointD posTrasf, const TAffine &aff,</t>
|
|
shun-iwasawa |
83f5ee |
const TSpectrumT<t> &spectrum, double freq, double phase,</t>
|
|
shun-iwasawa |
83f5ee |
bool isLogarithmic) {
|
|
Shinya Kitaoka |
120a6e |
raster->lock();
|
|
Shinya Kitaoka |
120a6e |
for (int y = 0; y < raster->getLy(); y++) {
|
|
Shinya Kitaoka |
120a6e |
TPointD posAux = posTrasf;
|
|
Shinya Kitaoka |
120a6e |
T *pix = raster->pixels(y);
|
|
Shinya Kitaoka |
120a6e |
for (int x = 0; x < raster->getLx(); x++) {
|
|
shun-iwasawa |
fe2893 |
double ang = 0.0;
|
|
Shinya Kitaoka |
120a6e |
if (posAux.x != 0 || posAux.y != 0) ang = atan2(posAux.y, posAux.x);
|
|
Shinya Kitaoka |
120a6e |
double r = sqrt(posAux.x * posAux.x + posAux.y * posAux.y);
|
|
shun-iwasawa |
83f5ee |
if (isLogarithmic) r = std::log(r) * 30.0;
|
|
Shinya Kitaoka |
120a6e |
double v = 0.5 * (1 + sin(r * freq + ang + phase));
|
|
Shinya Kitaoka |
120a6e |
*pix++ = spectrum.getPremultipliedValue(v);
|
|
Shinya Kitaoka |
120a6e |
posAux.x += aff.a11;
|
|
Shinya Kitaoka |
120a6e |
posAux.y += aff.a21;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
posTrasf.x += aff.a12;
|
|
Shinya Kitaoka |
120a6e |
posTrasf.y += aff.a22;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
raster->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
shun-iwasawa |
fe2893 |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpiralFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri) {
|
|
shun-iwasawa |
83f5ee |
double phase = m_phase->getValue(frame);
|
|
shun-iwasawa |
83f5ee |
double freq = m_freq->getValue(frame);
|
|
shun-iwasawa |
83f5ee |
bool isLogarithmic = SpiralType(m_type->getValue()) == Logarithmic;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine aff = ri.m_affine.inv();
|
|
Shinya Kitaoka |
120a6e |
TPointD posTrasf = aff * tile.m_pos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (TRaster32P ras32 = tile.getRaster())
|
|
Shinya Kitaoka |
120a6e |
doComputeT<tpixel32>(ras32, posTrasf, aff, m_spectrum->getValue(frame),</tpixel32>
|
|
shun-iwasawa |
83f5ee |
freq, phase, isLogarithmic);
|
|
Shinya Kitaoka |
120a6e |
else if (TRaster64P ras64 = tile.getRaster())
|
|
Shinya Kitaoka |
120a6e |
doComputeT<tpixel64>(ras64, posTrasf, aff, m_spectrum->getValue64(frame),</tpixel64>
|
|
shun-iwasawa |
83f5ee |
freq, phase, isLogarithmic);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
throw TException("SpiralFx: unsupported Pixel Type");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class MultiLinearGradientFx final : public TStandardZeraryFx {
|
|
Shinya Kitaoka |
120a6e |
FX_PLUGIN_DECLARATION(MultiLinearGradientFx)
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_period;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_count;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_cycle;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_wave_amplitude;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_wave_freq;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_wave_phase;
|
|
Shinya Kitaoka |
120a6e |
TSpectrumParamP m_colors;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
a92a49 |
TIntEnumParamP m_curveType;
|
|
shun-iwasawa |
a92a49 |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
MultiLinearGradientFx()
|
|
Shinya Kitaoka |
120a6e |
: m_period(100) // args, "Period")
|
|
Shinya Kitaoka |
120a6e |
, m_count(2) // args, "Count")
|
|
Shinya Kitaoka |
120a6e |
, m_cycle(0.0) // args, "Cycle")
|
|
Shinya Kitaoka |
120a6e |
, m_wave_amplitude(0.0) // args, "Cycle")
|
|
Shinya Kitaoka |
120a6e |
, m_wave_freq(0.0) // args, "Cycle")
|
|
Shinya Kitaoka |
120a6e |
, m_wave_phase(0.0) // args, "Cycle")
|
|
shun-iwasawa |
a92a49 |
// , m_colors (0) //args, "Colors")
|
|
shun-iwasawa |
a92a49 |
, m_curveType(new TIntEnumParam(EaseInOut, "Ease In-Out")) {
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(Linear, "Linear");
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(EaseIn, "Ease In");
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(EaseOut, "Ease Out");
|
|
shun-iwasawa |
a92a49 |
|
|
Tact Yoshida |
1d7cf9 |
std::vector<tspectrum::colorkey> colors = {</tspectrum::colorkey>
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(0, TPixel32::White),
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(0.33, TPixel32::Yellow),
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(0.66, TPixel32::Red),
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(1, TPixel32::White)};
|
|
Tact Yoshida |
1d7cf9 |
m_colors = TSpectrumParamP(colors);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "period", m_period);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "count", m_count);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "cycle", m_cycle);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "wave_amplitude", m_wave_amplitude);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "wave_frequency", m_wave_freq);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "wave_phase", m_wave_phase);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "colors", m_colors);
|
|
shun-iwasawa |
a92a49 |
bindParam(this, "curveType", m_curveType);
|
|
shun-iwasawa |
a92a49 |
|
|
Shinya Kitaoka |
120a6e |
m_period->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Shinya Kitaoka |
120a6e |
m_cycle->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Shinya Kitaoka |
120a6e |
m_wave_amplitude->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Shinya Kitaoka |
120a6e |
m_count->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Shinya Kitaoka |
120a6e |
m_period->setMeasureName("fxLength");
|
|
Shinya Kitaoka |
120a6e |
m_wave_amplitude->setMeasureName("fxLength");
|
|
shun-iwasawa |
481b59 |
enableComputeInFloat(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
~MultiLinearGradientFx(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
bool doGetBBox(double, TRectD &bBox, const TRenderSettings &info) override {
|
|
Shinya Kitaoka |
120a6e |
bBox = TConsts::infiniteRectD;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
// si potrebbe/dovrebbe fare meglio
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
|
|
Shinya Kitaoka |
38fd86 |
bool canHandle(const TRenderSettings &info, double frame) override {
|
|
Shinya Kitaoka |
38fd86 |
return true;
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void getParamUIs(TParamUIConcept *&concepts, int &length) override {
|
|
Shinya Kitaoka |
120a6e |
concepts = new TParamUIConcept[length = 1];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_type = TParamUIConcept::WIDTH;
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_label = "Size";
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_params.push_back(m_period);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
5903e5 |
// From V1.4 LinearGradientFx becomes obsolete and was replaced by
|
|
shun-iwasawa |
5903e5 |
// Iwa_LinearGradientFx which has more flexibility. (iwa_lineargradientfx.cpp)
|
|
shun-iwasawa |
5903e5 |
// This code is kept in order to load the fx made with older OT versions.
|
|
shun-iwasawa |
5903e5 |
// Nov 14, 2019
|
|
shun-iwasawa |
5903e5 |
|
|
Shinya Kitaoka |
d1f6c4 |
class LinearGradientFx final : public TStandardZeraryFx {
|
|
Shinya Kitaoka |
120a6e |
FX_PLUGIN_DECLARATION(LinearGradientFx)
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_period;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_wave_amplitude;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_wave_freq;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_wave_phase;
|
|
Shinya Kitaoka |
120a6e |
TPixelParamP m_color1;
|
|
Shinya Kitaoka |
120a6e |
TPixelParamP m_color2;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
a92a49 |
TIntEnumParamP m_curveType;
|
|
shun-iwasawa |
a92a49 |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
LinearGradientFx()
|
|
Shinya Kitaoka |
120a6e |
: m_period(100) // args, "Period")
|
|
Shinya Kitaoka |
120a6e |
, m_wave_amplitude(0.0) // args, "Cycle")
|
|
Shinya Kitaoka |
120a6e |
, m_wave_freq(0.0) // args, "Cycle")
|
|
Shinya Kitaoka |
120a6e |
, m_wave_phase(0.0) // args, "Cycle")
|
|
Shinya Kitaoka |
120a6e |
, m_color1(TPixel32::Black)
|
|
Shinya Kitaoka |
120a6e |
, m_color2(TPixel32::White)
|
|
shun-iwasawa |
a92a49 |
// , m_colors (0) //args, "Colors")
|
|
shun-iwasawa |
a92a49 |
, m_curveType(new TIntEnumParam(EaseInOut, "Ease In-Out")) {
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(Linear, "Linear");
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(EaseIn, "Ease In");
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(EaseOut, "Ease Out");
|
|
shun-iwasawa |
a92a49 |
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "period", m_period);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "wave_amplitude", m_wave_amplitude);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "wave_frequency", m_wave_freq);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "wave_phase", m_wave_phase);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "color1", m_color1);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "color2", m_color2);
|
|
shun-iwasawa |
a92a49 |
bindParam(this, "curveType", m_curveType);
|
|
shun-iwasawa |
a92a49 |
|
|
Shinya Kitaoka |
120a6e |
m_period->setValueRange(0, std::numeric_limits<double>::max());</double>
|
|
Shinya Kitaoka |
120a6e |
m_wave_amplitude->setValueRange(0, std::numeric_limits<double>::max());</double>
|
|
Shinya Kitaoka |
120a6e |
m_period->setMeasureName("fxLength");
|
|
Shinya Kitaoka |
120a6e |
m_wave_amplitude->setMeasureName("fxLength");
|
|
shun-iwasawa |
481b59 |
enableComputeInFloat(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
~LinearGradientFx(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
bool doGetBBox(double, TRectD &bBox, const TRenderSettings &info) override {
|
|
Shinya Kitaoka |
120a6e |
bBox = TConsts::infiniteRectD;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
// si potrebbe/dovrebbe fare meglio
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
|
|
Shinya Kitaoka |
38fd86 |
bool canHandle(const TRenderSettings &info, double frame) override {
|
|
Shinya Kitaoka |
38fd86 |
return true;
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void getParamUIs(TParamUIConcept *&concepts, int &length) override {
|
|
Shinya Kitaoka |
120a6e |
concepts = new TParamUIConcept[length = 1];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_type = TParamUIConcept::WIDTH;
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_label = "Size";
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_params.push_back(m_period);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
void doComputeT(TRasterPT<t> ras, TPointD posTrasf,</t>
|
|
Shinya Kitaoka |
120a6e |
const TSpectrumT<t> &spectrum, double period, double count,</t>
|
|
Shinya Kitaoka |
120a6e |
double w_amplitude, double w_freq, double w_phase, double cycle,
|
|
Shinya Kitaoka |
120a6e |
const TAffine &aff) {
|
|
Shinya Kitaoka |
120a6e |
double shift = 0;
|
|
Shinya Kitaoka |
120a6e |
double maxRadius = period * count / 2.;
|
|
Shinya Kitaoka |
120a6e |
double freq = 1.0 / period;
|
|
Shinya Kitaoka |
120a6e |
int j;
|
|
Shinya Kitaoka |
120a6e |
ras->lock();
|
|
Shinya Kitaoka |
120a6e |
for (j = 0; j < ras->getLy(); j++) {
|
|
Shinya Kitaoka |
120a6e |
TPointD posAux = posTrasf;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// TPointD pos = tile.m_pos;
|
|
Shinya Kitaoka |
120a6e |
// pos.y += j;
|
|
Shinya Kitaoka |
120a6e |
T *pix = ras->pixels(j);
|
|
Shinya Kitaoka |
120a6e |
T *endPix = pix + ras->getLx();
|
|
Shinya Kitaoka |
120a6e |
while (pix < endPix) {
|
|
Shinya Kitaoka |
120a6e |
if (w_amplitude) shift = w_amplitude * sin(w_freq * posAux.y + w_phase);
|
|
shun-iwasawa |
fe2893 |
double radius = posAux.x + shift;
|
|
shun-iwasawa |
fe2893 |
double t = 1;
|
|
Shinya Kitaoka |
120a6e |
if (fabs(radius) < maxRadius) {
|
|
Shinya Kitaoka |
120a6e |
t = (radius + maxRadius + cycle) * freq;
|
|
Shinya Kitaoka |
120a6e |
t -= floor(t);
|
|
Shinya Kitaoka |
120a6e |
} else if (radius < 0)
|
|
shun-iwasawa |
fe2893 |
t = 0;
|
|
Shinya Kitaoka |
120a6e |
double polinomfactor = (-2 * t + 3) * (t * t);
|
|
Shinya Kitaoka |
120a6e |
// pos.x += 1.0;
|
|
Shinya Kitaoka |
120a6e |
*pix++ = spectrum.getPremultipliedValue(polinomfactor);
|
|
Shinya Kitaoka |
120a6e |
posAux.x += aff.a11;
|
|
Shinya Kitaoka |
120a6e |
posAux.y += aff.a21;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
posTrasf.x += aff.a12;
|
|
Shinya Kitaoka |
120a6e |
posTrasf.y += aff.a22;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
ras->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
shun-iwasawa |
fe2893 |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void LinearGradientFx::doCompute(TTile &tile, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &ri) {
|
|
shun-iwasawa |
481b59 |
assert((TRaster32P)tile.getRaster() || (TRaster64P)tile.getRaster() ||
|
|
shun-iwasawa |
481b59 |
(TRasterFP)tile.getRaster());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double period = m_period->getValue(frame) / ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
double count = 1.0;
|
|
Shinya Kitaoka |
120a6e |
double cycle = 0;
|
|
Shinya Kitaoka |
120a6e |
double w_amplitude = m_wave_amplitude->getValue(frame) / ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
double w_freq = m_wave_freq->getValue(frame) * ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
double w_phase = m_wave_phase->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
w_freq *= 0.01 * M_PI_180;
|
|
Shinya Kitaoka |
120a6e |
|
|
Tact Yoshida |
1d7cf9 |
std::vector<tspectrum::colorkey> colors = {</tspectrum::colorkey>
|
|
Shinya Kitaoka |
120a6e |
TSpectrum::ColorKey(0, m_color1->getValue(frame)),
|
|
Shinya Kitaoka |
120a6e |
TSpectrum::ColorKey(1, m_color2->getValue(frame))};
|
|
Tact Yoshida |
1d7cf9 |
TSpectrumParamP m_colors = TSpectrumParamP(colors);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TAffine aff = ri.m_affine.inv();
|
|
Shinya Kitaoka |
120a6e |
TPointD posTrasf = aff * tile.m_pos;
|
|
Shinya Kitaoka |
120a6e |
multiLinear(tile.getRaster(), posTrasf, m_colors, period, count, w_amplitude,
|
|
shun-iwasawa |
a92a49 |
w_freq, w_phase, cycle, aff, frame,
|
|
shun-iwasawa |
a92a49 |
(GradientCurveType)m_curveType->getValue());
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
if (TRaster32P ras32 = tile.getRaster())
|
|
Shinya Kitaoka |
120a6e |
doComputeT<tpixel32>(</tpixel32>
|
|
Shinya Kitaoka |
120a6e |
ras32, posTrasf,
|
|
Shinya Kitaoka |
120a6e |
m_colors->getValue(frame),
|
|
Shinya Kitaoka |
120a6e |
period, count, w_amplitude, w_freq, w_phase, cycle, aff);
|
|
Shinya Kitaoka |
120a6e |
else if (TRaster64P ras64 = tile.getRaster())
|
|
Shinya Kitaoka |
120a6e |
doComputeT<tpixel64>(</tpixel64>
|
|
Shinya Kitaoka |
120a6e |
ras64, posTrasf,
|
|
Shinya Kitaoka |
120a6e |
m_colors->getValue64(frame),
|
|
Shinya Kitaoka |
120a6e |
period, count, w_amplitude, w_freq, w_phase, cycle, aff);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
throw TException("MultiLinearGradientFx: unsupported Pixel Type");
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MultiLinearGradientFx::doCompute(TTile &tile, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &ri) {
|
|
shun-iwasawa |
481b59 |
assert((TRaster32P)tile.getRaster() || (TRaster64P)tile.getRaster() ||
|
|
shun-iwasawa |
481b59 |
(TRasterFP)tile.getRaster());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double period = m_period->getValue(frame) / ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
double count = m_count->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
double cycle = m_cycle->getValue(frame) / ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
double w_amplitude = m_wave_amplitude->getValue(frame) / ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
double w_freq = m_wave_freq->getValue(frame) * ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
double w_phase = m_wave_phase->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
w_freq *= 0.01 * M_PI_180;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TAffine aff = ri.m_affine.inv();
|
|
Shinya Kitaoka |
120a6e |
TPointD posTrasf = aff * tile.m_pos;
|
|
Shinya Kitaoka |
120a6e |
multiLinear(tile.getRaster(), posTrasf, m_colors, period, count, w_amplitude,
|
|
shun-iwasawa |
a92a49 |
w_freq, w_phase, cycle, aff, frame,
|
|
shun-iwasawa |
a92a49 |
(GradientCurveType)m_curveType->getValue());
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
if (TRaster32P ras32 = tile.getRaster())
|
|
Shinya Kitaoka |
120a6e |
doComputeT<tpixel32>(</tpixel32>
|
|
Shinya Kitaoka |
120a6e |
ras32, posTrasf,
|
|
Shinya Kitaoka |
120a6e |
m_colors->getValue(frame),
|
|
Shinya Kitaoka |
120a6e |
period, count, w_amplitude, w_freq, w_phase, cycle, aff);
|
|
Shinya Kitaoka |
120a6e |
else if (TRaster64P ras64 = tile.getRaster())
|
|
Shinya Kitaoka |
120a6e |
doComputeT<tpixel64>(</tpixel64>
|
|
Shinya Kitaoka |
120a6e |
ras64, posTrasf,
|
|
Shinya Kitaoka |
120a6e |
m_colors->getValue64(frame),
|
|
Shinya Kitaoka |
120a6e |
period, count, w_amplitude, w_freq, w_phase, cycle, aff);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
throw TException("MultiLinearGradientFx: unsupported Pixel Type");
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class RadialGradientFx final : public TStandardZeraryFx {
|
|
Shinya Kitaoka |
120a6e |
FX_PLUGIN_DECLARATION(RadialGradientFx)
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_period;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_innerperiod;
|
|
Shinya Kitaoka |
120a6e |
TPixelParamP m_color1;
|
|
Shinya Kitaoka |
120a6e |
TPixelParamP m_color2;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
a92a49 |
TIntEnumParamP m_curveType;
|
|
shun-iwasawa |
a92a49 |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RadialGradientFx()
|
|
Shinya Kitaoka |
120a6e |
: m_period(100.0)
|
|
Shinya Kitaoka |
120a6e |
, m_innerperiod(0.0) // args, "Period")
|
|
Shinya Kitaoka |
120a6e |
, m_color1(TPixel32::White)
|
|
Shinya Kitaoka |
120a6e |
, m_color2(TPixel32::Transparent)
|
|
shun-iwasawa |
a92a49 |
// , m_colors (0) //args, "Colors")
|
|
shun-iwasawa |
a92a49 |
, m_curveType(new TIntEnumParam()) {
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(EaseInOut, "Ease In-Out");
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(Linear, "Linear");
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(EaseIn, "Ease In");
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(EaseOut, "Ease Out");
|
|
shun-iwasawa |
a92a49 |
m_curveType->setDefaultValue(Linear);
|
|
shun-iwasawa |
a92a49 |
m_curveType->setValue(Linear);
|
|
shun-iwasawa |
a92a49 |
|
|
Shinya Kitaoka |
120a6e |
m_period->setMeasureName("fxLength");
|
|
Shinya Kitaoka |
120a6e |
m_innerperiod->setMeasureName("fxLength");
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "period", m_period);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "innerperiod", m_innerperiod);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "color1", m_color1);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "color2", m_color2);
|
|
shun-iwasawa |
a92a49 |
bindParam(this, "curveType", m_curveType);
|
|
Shinya Kitaoka |
120a6e |
m_period->setValueRange(0.0, std::numeric_limits<double>::max());</double>
|
|
Shinya Kitaoka |
120a6e |
m_innerperiod->setValueRange(0.0, std::numeric_limits<double>::max());</double>
|
|
shun-iwasawa |
481b59 |
|
|
shun-iwasawa |
481b59 |
enableComputeInFloat(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
~RadialGradientFx(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
bool doGetBBox(double, TRectD &bBox, const TRenderSettings &info) override {
|
|
Shinya Kitaoka |
120a6e |
bBox = TConsts::infiniteRectD;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
// si potrebbe/dovrebbe fare meglio
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
|
|
Shinya Kitaoka |
38fd86 |
bool canHandle(const TRenderSettings &info, double frame) override {
|
|
Shinya Kitaoka |
38fd86 |
return true;
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void getParamUIs(TParamUIConcept *&concepts, int &length) override {
|
|
Shinya Kitaoka |
120a6e |
concepts = new TParamUIConcept[length = 2];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_type = TParamUIConcept::RADIUS;
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_label = "Inner Size";
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_params.push_back(m_innerperiod);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
concepts[1].m_type = TParamUIConcept::RADIUS;
|
|
Shinya Kitaoka |
120a6e |
concepts[1].m_label = "Outer Size";
|
|
Shinya Kitaoka |
120a6e |
concepts[1].m_params.push_back(m_period);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class MultiRadialGradientFx final : public TStandardZeraryFx {
|
|
Shinya Kitaoka |
120a6e |
FX_PLUGIN_DECLARATION(MultiRadialGradientFx)
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_period;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_count;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_cycle;
|
|
Shinya Kitaoka |
120a6e |
TSpectrumParamP m_colors;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
a92a49 |
TIntEnumParamP m_curveType;
|
|
shun-iwasawa |
a92a49 |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
MultiRadialGradientFx()
|
|
Shinya Kitaoka |
120a6e |
: m_period(100) // args, "Period")
|
|
Shinya Kitaoka |
120a6e |
, m_count(2) // args, "Count")
|
|
Shinya Kitaoka |
120a6e |
, m_cycle(0.0) // args, "Count")
|
|
shun-iwasawa |
a92a49 |
// , m_colors (0) //args, "Colors")
|
|
shun-iwasawa |
a92a49 |
, m_curveType(new TIntEnumParam()) {
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(EaseInOut, "Ease In-Out");
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(Linear, "Linear");
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(EaseIn, "Ease In");
|
|
shun-iwasawa |
a92a49 |
m_curveType->addItem(EaseOut, "Ease Out");
|
|
shun-iwasawa |
a92a49 |
m_curveType->setDefaultValue(Linear);
|
|
shun-iwasawa |
a92a49 |
m_curveType->setValue(Linear);
|
|
shun-iwasawa |
a92a49 |
|
|
Shinya Kitaoka |
120a6e |
m_period->setMeasureName("fxLength");
|
|
Tact Yoshida |
1d7cf9 |
std::vector<tspectrum::colorkey> colors = {</tspectrum::colorkey>
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(0, TPixel32::White),
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(0.33, TPixel32::Yellow),
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(0.66, TPixel32::Red),
|
|
Tact Yoshida |
1d7cf9 |
TSpectrum::ColorKey(1, TPixel32::White)};
|
|
Tact Yoshida |
1d7cf9 |
m_colors = TSpectrumParamP(colors);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "period", m_period);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "count", m_count);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "cycle", m_cycle);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "colors", m_colors);
|
|
shun-iwasawa |
a92a49 |
bindParam(this, "curveType", m_curveType);
|
|
Shinya Kitaoka |
120a6e |
m_period->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Shinya Kitaoka |
120a6e |
m_cycle->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Shinya Kitaoka |
120a6e |
m_count->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
shun-iwasawa |
481b59 |
|
|
shun-iwasawa |
481b59 |
enableComputeInFloat(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
~MultiRadialGradientFx(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
bool doGetBBox(double, TRectD &bBox, const TRenderSettings &info) override {
|
|
Shinya Kitaoka |
120a6e |
bBox = TConsts::infiniteRectD;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
// si potrebbe/dovrebbe fare meglio
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
|
|
Shinya Kitaoka |
38fd86 |
bool canHandle(const TRenderSettings &info, double frame) override {
|
|
Shinya Kitaoka |
38fd86 |
return true;
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void getParamUIs(TParamUIConcept *&concepts, int &length) override {
|
|
Shinya Kitaoka |
120a6e |
concepts = new TParamUIConcept[length = 1];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_type = TParamUIConcept::RADIUS;
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_label = "Period";
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_params.push_back(m_period);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MultiRadialGradientFx::doCompute(TTile &tile, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &ri) {
|
|
shun-iwasawa |
481b59 |
assert((TRaster32P)tile.getRaster() || (TRaster64P)tile.getRaster() ||
|
|
shun-iwasawa |
481b59 |
(TRasterFP)tile.getRaster());
|
|
Shinya Kitaoka |
120a6e |
double period = m_period->getValue(frame) / ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
double count = m_count->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
double cycle = m_cycle->getValue(frame) / ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TAffine aff = ri.m_affine.inv();
|
|
Shinya Kitaoka |
120a6e |
TPointD posTrasf = aff * tile.m_pos;
|
|
Shinya Kitaoka |
120a6e |
multiRadial(tile.getRaster(), posTrasf, m_colors, period, count, cycle, aff,
|
|
shun-iwasawa |
a92a49 |
frame, 0.0, (GradientCurveType)m_curveType->getValue());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RadialGradientFx::doCompute(TTile &tile, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &ri) {
|
|
shun-iwasawa |
481b59 |
assert((TRaster32P)tile.getRaster() || (TRaster64P)tile.getRaster() ||
|
|
shun-iwasawa |
481b59 |
(TRasterFP)tile.getRaster());
|
|
Shinya Kitaoka |
120a6e |
double period = m_period->getValue(frame) / ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
double innerperiod = m_innerperiod->getValue(frame) / ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
double count = 1.0;
|
|
Shinya Kitaoka |
120a6e |
double cycle = 0.0;
|
|
Shinya Kitaoka |
120a6e |
double inner = 0.0;
|
|
Shinya Kitaoka |
120a6e |
if (innerperiod < period)
|
|
Shinya Kitaoka |
120a6e |
inner = innerperiod / period;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
shun-iwasawa |
fe2893 |
inner = 1 - TConsts::epsilon;
|
|
Tact Yoshida |
1d7cf9 |
std::vector<tspectrum::colorkey> colors = {</tspectrum::colorkey>
|
|
Shinya Kitaoka |
120a6e |
TSpectrum::ColorKey(0, m_color1->getValue(frame)),
|
|
Shinya Kitaoka |
120a6e |
TSpectrum::ColorKey(1, m_color2->getValue(frame))};
|
|
Tact Yoshida |
1d7cf9 |
TSpectrumParamP m_colors = TSpectrumParamP(colors);
|
|
Shinya Kitaoka |
120a6e |
TAffine aff = ri.m_affine.inv();
|
|
Shinya Kitaoka |
120a6e |
TPointD posTrasf = aff * tile.m_pos;
|
|
Shinya Kitaoka |
120a6e |
multiRadial(tile.getRaster(), posTrasf, m_colors, period, count, cycle, aff,
|
|
shun-iwasawa |
a92a49 |
frame, inner, (GradientCurveType)m_curveType->getValue());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class LightSpotFx final : public TStandardZeraryFx {
|
|
Shinya Kitaoka |
120a6e |
FX_PLUGIN_DECLARATION(LightSpotFx)
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_softness;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_a;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_b;
|
|
Shinya Kitaoka |
120a6e |
TPixelParamP m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
LightSpotFx()
|
|
Shinya Kitaoka |
120a6e |
: m_softness(0.2) // args, "Softness")
|
|
Shinya Kitaoka |
120a6e |
, m_a(200) // args, "A")
|
|
Shinya Kitaoka |
120a6e |
, m_b(100) // args, "B")
|
|
Shinya Kitaoka |
120a6e |
, m_color(TPixel::Magenta) // args, "Color")
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
m_a->setMeasureName("fxLength");
|
|
Shinya Kitaoka |
120a6e |
m_b->setMeasureName("fxLength");
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "softness", m_softness);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "a", m_a);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "b", m_b);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "color", m_color);
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
m_a->setDefaultValue(200);
|
|
Shinya Kitaoka |
120a6e |
m_b->setDefaultValue(100);
|
|
Shinya Kitaoka |
120a6e |
m_color->setDefaultValue(TPixel::Magenta);
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
~LightSpotFx(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
bool doGetBBox(double, TRectD &bBox, const TRenderSettings &info) override {
|
|
Shinya Kitaoka |
120a6e |
bBox = TConsts::infiniteRectD;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
// si potrebbe/dovrebbe fare meglio
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
|
|
Shinya Kitaoka |
38fd86 |
bool canHandle(const TRenderSettings &info, double frame) override {
|
|
Shinya Kitaoka |
38fd86 |
return true;
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void getParamUIs(TParamUIConcept *&concepts, int &length) override {
|
|
Shinya Kitaoka |
120a6e |
concepts = new TParamUIConcept[length = 1];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_type = TParamUIConcept::RECT;
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_params.push_back(m_a);
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_params.push_back(m_b);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
void doComputeT(TRasterPT<t> raster, TPointD posTrasf, const TAffine &aff,</t>
|
|
Shinya Kitaoka |
120a6e |
const T &pixelColor, double softness, double a, double b) {
|
|
Shinya Kitaoka |
120a6e |
double aa = a * a;
|
|
Shinya Kitaoka |
120a6e |
double bb = b * b;
|
|
Shinya Kitaoka |
120a6e |
double invaa = 1 / aa;
|
|
Shinya Kitaoka |
120a6e |
double invbb = 1 / bb;
|
|
Shinya Kitaoka |
120a6e |
double num = 2 * (aa + bb);
|
|
Shinya Kitaoka |
120a6e |
double normax = num / (5 * aa + bb);
|
|
Shinya Kitaoka |
120a6e |
int j;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
raster->lock();
|
|
Shinya Kitaoka |
120a6e |
for (j = 0; j < raster->getLy(); j++) {
|
|
Shinya Kitaoka |
120a6e |
TPointD posAux = posTrasf;
|
|
Shinya Kitaoka |
120a6e |
T *pix = raster->pixels(j);
|
|
Shinya Kitaoka |
120a6e |
T *endPix = pix + raster->getLx();
|
|
Shinya Kitaoka |
120a6e |
while (pix < endPix) {
|
|
Shinya Kitaoka |
120a6e |
double yyrot = (posAux.y) * (posAux.y);
|
|
Shinya Kitaoka |
120a6e |
double yvar = (yyrot)*invbb + 1;
|
|
Shinya Kitaoka |
120a6e |
double result;
|
|
Shinya Kitaoka |
120a6e |
double fact, xrot, tempvar, normtmp, outsideslope;
|
|
Shinya Kitaoka |
120a6e |
// pos.x += 1.0;
|
|
Shinya Kitaoka |
120a6e |
xrot = (posAux.x);
|
|
Shinya Kitaoka |
120a6e |
tempvar = xrot * xrot * invaa + yvar;
|
|
Shinya Kitaoka |
120a6e |
fact = tempvar * 0.5;
|
|
Shinya Kitaoka |
120a6e |
if (fact < 1) {
|
|
Shinya Kitaoka |
120a6e |
normtmp = num / (aa + bb + (xrot - a) * (xrot - a) + yyrot);
|
|
Shinya Kitaoka |
120a6e |
result = normtmp;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
outsideslope = 1 / (1 + (fact - 1) * softness);
|
|
Shinya Kitaoka |
120a6e |
result = normax * outsideslope;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (result > 1) result = 1;
|
|
Shinya Kitaoka |
120a6e |
if (result < 0) result = 0;
|
|
shun-iwasawa |
fe2893 |
*pix++ = blend(T::Black, pixelColor, result);
|
|
Shinya Kitaoka |
120a6e |
posAux.x += aff.a11;
|
|
Shinya Kitaoka |
120a6e |
posAux.y += aff.a21;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
posTrasf.x += aff.a12;
|
|
Shinya Kitaoka |
120a6e |
posTrasf.y += aff.a22;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
raster->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
shun-iwasawa |
fe2893 |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void LightSpotFx::doCompute(TTile &tile, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &ri) {
|
|
Shinya Kitaoka |
120a6e |
double a = m_a->getValue(frame) / ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
double b = m_b->getValue(frame) / ri.m_shrinkX;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (a == 0.0 || b == 0.0) {
|
|
Shinya Kitaoka |
120a6e |
if ((TRaster32P)tile.getRaster())
|
|
Shinya Kitaoka |
120a6e |
((TRaster32P)tile.getRaster())->fill(TPixel32::Black);
|
|
Shinya Kitaoka |
120a6e |
else if ((TRaster64P)tile.getRaster())
|
|
Shinya Kitaoka |
120a6e |
((TRaster64P)tile.getRaster())->fill(TPixel64::Black);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TAffine aff = ri.m_affine.inv();
|
|
Shinya Kitaoka |
120a6e |
TPointD posTrasf = aff * tile.m_pos;
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 pixelColor = m_color->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
double softness = m_softness->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
if ((TRaster32P)tile.getRaster())
|
|
Shinya Kitaoka |
120a6e |
doComputeT<tpixel32>(tile.getRaster(), posTrasf, aff, pixelColor, softness,</tpixel32>
|
|
Shinya Kitaoka |
120a6e |
a, b);
|
|
Shinya Kitaoka |
120a6e |
else if ((TRaster64P)tile.getRaster())
|
|
Shinya Kitaoka |
120a6e |
doComputeT<tpixel64>(tile.getRaster(), posTrasf, aff, toPixel64(pixelColor),</tpixel64>
|
|
Shinya Kitaoka |
120a6e |
softness, a, b);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(SpiralFx, "spiralFx")
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(FadeFx, "fadeFx")
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(RadialGradientFx, "radialGradientFx")
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(MultiRadialGradientFx, "multiRadialGradientFx")
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(LinearGradientFx, "linearGradientFx")
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(MultiLinearGradientFx, "multiLinearGradientFx")
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(LightSpotFx, "lightSpotFx")
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
TLIBMAIN {
|
|
Toshihiro Shimizu |
890ddd |
static TPluginInfo info("stdfx");
|
|
Toshihiro Shimizu |
890ddd |
return &info;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
8c6c57 |
/* TODO, move to header */
|
|
Campbell Barton |
8c6c57 |
DV_EXPORT_API void initStdFx();
|
|
Campbell Barton |
8c6c57 |
|
|
Shinya Kitaoka |
120a6e |
DV_EXPORT_API void initStdFx() {}
|