|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "texception.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trop.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "stdfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trasterfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamuiconcept.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class BaseRaylitFx : public TStandardRasterFx {
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
TRasterFxPort m_input;
|
|
Shinya Kitaoka |
120a6e |
TPointParamP m_p;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_z;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_intensity;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_decay;
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_smoothness;
|
|
Shinya Kitaoka |
120a6e |
TBoolParamP m_includeInput;
|
|
shun-iwasawa |
255f14 |
TDoubleParamP m_radius;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
BaseRaylitFx()
|
|
Shinya Kitaoka |
120a6e |
: m_p(TPointD(0, 0))
|
|
Shinya Kitaoka |
120a6e |
, m_z(300.0)
|
|
Shinya Kitaoka |
120a6e |
, m_intensity(60)
|
|
Shinya Kitaoka |
120a6e |
, m_decay(1.0)
|
|
Shinya Kitaoka |
120a6e |
, m_smoothness(100)
|
|
shun-iwasawa |
255f14 |
, m_includeInput(false)
|
|
shun-iwasawa |
255f14 |
, m_radius(0.0) {
|
|
Shinya Kitaoka |
120a6e |
m_p->getX()->setMeasureName("fxLength");
|
|
Shinya Kitaoka |
120a6e |
m_p->getY()->setMeasureName("fxLength");
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
255f14 |
m_radius->setMeasureName("fxLength");
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "p", m_p);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "z", m_z);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "intensity", m_intensity);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "decay", m_decay);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "smoothness", m_smoothness);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "includeInput", m_includeInput);
|
|
shun-iwasawa |
255f14 |
bindParam(this, "radius", m_radius);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
addInputPort("Source", m_input);
|
|
shun-iwasawa |
255f14 |
m_radius->setValueRange(0.0, std::numeric_limits<double>::max());</double>
|
|
shun-iwasawa |
481b59 |
|
|
shun-iwasawa |
481b59 |
enableComputeInFloat(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
~BaseRaylitFx() {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
38fd86 |
bool doGetBBox(double frame, TRectD &bBox,
|
|
Shinya Kitaoka |
38fd86 |
const TRenderSettings &info) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
38fd86 |
bool canHandle(const TRenderSettings &info, double frame) override {
|
|
Shinya Kitaoka |
38fd86 |
return false;
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
120a6e |
int getMemoryRequirement(const TRectD &rect, double frame,
|
|
Shinya Kitaoka |
473e70 |
const TRenderSettings &info) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
38fd86 |
void doDryCompute(TRectD &rect, double frame,
|
|
Shinya Kitaoka |
38fd86 |
const TRenderSettings &info) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void getParamUIs(TParamUIConcept *&concepts, int &length) override {
|
|
shun-iwasawa |
255f14 |
concepts = new TParamUIConcept[length = 3];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_type = TParamUIConcept::POINT;
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_label = "Center";
|
|
Shinya Kitaoka |
120a6e |
concepts[0].m_params.push_back(m_p);
|
|
shun-iwasawa |
255f14 |
|
|
shun-iwasawa |
255f14 |
concepts[1].m_type = TParamUIConcept::RADIUS;
|
|
shun-iwasawa |
255f14 |
concepts[1].m_label = "Radius";
|
|
shun-iwasawa |
255f14 |
concepts[1].m_params.push_back(m_radius);
|
|
shun-iwasawa |
255f14 |
concepts[1].m_params.push_back(m_p);
|
|
shun-iwasawa |
255f14 |
|
|
shun-iwasawa |
888af2 |
concepts[2].m_type = TParamUIConcept::COMPASS;
|
|
shun-iwasawa |
255f14 |
concepts[2].m_params.push_back(m_p);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool BaseRaylitFx::doGetBBox(double frame, TRectD &bBox,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &info) {
|
|
Shinya Kitaoka |
120a6e |
if (m_input.isConnected()) {
|
|
shun-iwasawa |
255f14 |
bool ret = m_input->doGetBBox(frame, bBox, info);
|
|
Shinya Kitaoka |
120a6e |
if (ret) bBox = TConsts::infiniteRectD;
|
|
Shinya Kitaoka |
120a6e |
return ret;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
bBox = TRectD();
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void BaseRaylitFx::doDryCompute(TRectD &rect, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &ri) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_input.isConnected()) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRectD bboxIn;
|
|
Shinya Kitaoka |
120a6e |
m_input->getBBox(frame, bboxIn, ri);
|
|
Shinya Kitaoka |
120a6e |
if (bboxIn == TConsts::infiniteRectD) bboxIn = rect;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TDimension sizeIn(std::max(tceil(bboxIn.getLx()), 1),
|
|
Shinya Kitaoka |
120a6e |
std::max(tceil(bboxIn.getLy()), 1));
|
|
Shinya Kitaoka |
120a6e |
bboxIn = TRectD(bboxIn.getP00(), TDimensionD(sizeIn.lx, sizeIn.ly));
|
|
Shinya Kitaoka |
120a6e |
m_input->dryCompute(bboxIn, frame, ri);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int BaseRaylitFx::getMemoryRequirement(const TRectD &rect, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &info) {
|
|
Shinya Kitaoka |
120a6e |
TRectD bboxIn;
|
|
Shinya Kitaoka |
120a6e |
m_input->getBBox(frame, bboxIn, info);
|
|
Shinya Kitaoka |
120a6e |
if (bboxIn == TConsts::infiniteRectD) return -1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (bboxIn.isEmpty()) return 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return TRasterFx::memorySize(bboxIn, info.m_bpp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class RaylitFx final : public BaseRaylitFx {
|
|
Shinya Kitaoka |
120a6e |
FX_PLUGIN_DECLARATION(RaylitFx)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
TPixelParamP m_color;
|
|
Shinya Kitaoka |
120a6e |
TBoolParamP m_invert;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RaylitFx() : m_color(TPixel(255, 80, 0)), m_invert(false) {
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "color", m_color);
|
|
Shinya Kitaoka |
120a6e |
bindParam(this, "invert", m_invert);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void doCompute(TTile &tile, double frame, const TRenderSettings &) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(RaylitFx, "raylitFx")
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void RaylitFx::doCompute(TTile &tileOut, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &ri) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_input.isConnected()) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double scale = sqrt(fabs(ri.m_affine.det()));
|
|
Shinya Kitaoka |
120a6e |
int shrink = (ri.m_shrinkX + ri.m_shrinkY) / 2;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD p(ri.m_affine * m_p->getValue(frame));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRectD rectIn(tileOut.m_pos, TDimensionD(tileOut.getRaster()->getLx(),
|
|
Shinya Kitaoka |
120a6e |
tileOut.getRaster()->getLy()));
|
|
Shinya Kitaoka |
120a6e |
TRectD bboxIn;
|
|
Shinya Kitaoka |
120a6e |
m_input->getBBox(frame, bboxIn, ri);
|
|
Shinya Kitaoka |
120a6e |
if (bboxIn == TConsts::infiniteRectD) bboxIn = rectIn;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!bboxIn.isEmpty()) {
|
|
Shinya Kitaoka |
120a6e |
TPoint posIn, posOut;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TTile tileIn;
|
|
Shinya Kitaoka |
120a6e |
TDimension sizeIn(std::max(tceil(bboxIn.getLx()), 1),
|
|
Shinya Kitaoka |
120a6e |
std::max(tceil(bboxIn.getLy()), 1));
|
|
Shinya Kitaoka |
120a6e |
m_input->allocateAndCompute(tileIn, bboxIn.getP00(), sizeIn,
|
|
Shinya Kitaoka |
120a6e |
tileOut.getRaster(), frame, ri);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRop::RaylitParams params;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
params.m_scale = scale;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginSrc.x = params.m_lightOriginDst.x = p.x;
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginSrc.y = params.m_lightOriginDst.y = p.y;
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginSrc.z = params.m_lightOriginDst.z =
|
|
Shinya Kitaoka |
120a6e |
(int)m_z->getValue(frame);
|
|
shun-iwasawa |
481b59 |
// currently tile should be nonlinear
|
|
shun-iwasawa |
481b59 |
assert(!tileOut.getRaster()->isLinear());
|
|
shun-iwasawa |
481b59 |
params.m_color = m_color->getValue(frame, tileOut.getRaster()->isLinear(),
|
|
shun-iwasawa |
481b59 |
ri.m_colorSpaceGamma);
|
|
Shinya Kitaoka |
120a6e |
params.m_intensity = m_intensity->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
params.m_decay = m_decay->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
params.m_smoothness = m_smoothness->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
params.m_invert = m_invert->getValue();
|
|
Shinya Kitaoka |
120a6e |
params.m_includeInput = m_includeInput->getValue();
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginSrc.x -= (int)tileIn.m_pos.x;
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginSrc.y -= (int)tileIn.m_pos.y;
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginDst.x -= (int)tileOut.m_pos.x;
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginDst.y -= (int)tileOut.m_pos.y;
|
|
shun-iwasawa |
255f14 |
params.m_radius = m_radius->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRop::raylit(tileOut.getRaster(), tileIn.getRaster(), params);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class ColorRaylitFx final : public BaseRaylitFx {
|
|
Shinya Kitaoka |
120a6e |
FX_PLUGIN_DECLARATION(ColorRaylitFx)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
ColorRaylitFx() : BaseRaylitFx() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void doCompute(TTile &tile, double frame, const TRenderSettings &) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorRaylitFx::doCompute(TTile &tileOut, double frame,
|
|
Shinya Kitaoka |
120a6e |
const TRenderSettings &ri) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_input.isConnected()) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double scale = sqrt(fabs(ri.m_affine.det()));
|
|
Shinya Kitaoka |
120a6e |
int shrink = (ri.m_shrinkX + ri.m_shrinkY) / 2;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD p(ri.m_affine * m_p->getValue(frame));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRectD rectIn(tileOut.m_pos, TDimensionD(tileOut.getRaster()->getLx(),
|
|
Shinya Kitaoka |
120a6e |
tileOut.getRaster()->getLy()));
|
|
Shinya Kitaoka |
120a6e |
TRectD bboxIn;
|
|
Shinya Kitaoka |
120a6e |
m_input->getBBox(frame, bboxIn, ri);
|
|
Shinya Kitaoka |
120a6e |
if (bboxIn == TConsts::infiniteRectD) bboxIn = rectIn;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!bboxIn.isEmpty()) {
|
|
Shinya Kitaoka |
120a6e |
TPoint posIn, posOut;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TTile tileIn;
|
|
Shinya Kitaoka |
120a6e |
TDimension sizeIn(std::max(tceil(bboxIn.getLx()), 1),
|
|
Shinya Kitaoka |
120a6e |
std::max(tceil(bboxIn.getLy()), 1));
|
|
Shinya Kitaoka |
120a6e |
m_input->allocateAndCompute(tileIn, bboxIn.getP00(), sizeIn,
|
|
Shinya Kitaoka |
120a6e |
tileOut.getRaster(), frame, ri);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRop::RaylitParams params;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
params.m_scale = scale;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginSrc.x = params.m_lightOriginDst.x = p.x;
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginSrc.y = params.m_lightOriginDst.y = p.y;
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginSrc.z = params.m_lightOriginDst.z =
|
|
Shinya Kitaoka |
120a6e |
(int)m_z->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
params.m_intensity = m_intensity->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
params.m_decay = m_decay->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
params.m_smoothness = m_smoothness->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
params.m_includeInput = m_includeInput->getValue();
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginSrc.x -= (int)tileIn.m_pos.x;
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginSrc.y -= (int)tileIn.m_pos.y;
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginDst.x -= (int)tileOut.m_pos.x;
|
|
Shinya Kitaoka |
120a6e |
params.m_lightOriginDst.y -= (int)tileOut.m_pos.y;
|
|
shun-iwasawa |
255f14 |
params.m_radius = m_radius->getValue(frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRop::glassRaylit(tileOut.getRaster(), tileIn.getRaster(), params);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(ColorRaylitFx, "colorRaylitFx")
|