|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "texception.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "stdfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixelutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tbasefx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trop.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamset.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Local namespace stuff
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum Status {
|
|
Toshihiro Shimizu |
890ddd |
NoPortsConnected = 0,
|
|
Toshihiro Shimizu |
890ddd |
Port0Connected = 1 << 1,
|
|
Toshihiro Shimizu |
890ddd |
Port1Connected = 1 << 2,
|
|
Toshihiro Shimizu |
890ddd |
StatusGood = Port0Connected | Port1Connected
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline Status operator|(const Status &l, const Status &r)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return Status(((int)l | (int)r));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline int operator&(const Status &l)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return int(l);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Status getFxStatus(const TRasterFxPort &port0, const TRasterFxPort &port1)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Status status = NoPortsConnected;
|
|
Toshihiro Shimizu |
890ddd |
if (port0.isConnected())
|
|
Toshihiro Shimizu |
890ddd |
status = status | Port0Connected;
|
|
Toshihiro Shimizu |
890ddd |
if (port1.isConnected())
|
|
Toshihiro Shimizu |
890ddd |
status = status | Port1Connected;
|
|
Toshihiro Shimizu |
890ddd |
return status;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void makeRectCoherent(TRectD &rect, const TPointD &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
rect -= pos;
|
|
Toshihiro Shimizu |
890ddd |
rect.x0 = tfloor(rect.x0);
|
|
Toshihiro Shimizu |
890ddd |
rect.y0 = tfloor(rect.y0);
|
|
Toshihiro Shimizu |
890ddd |
rect.x1 = tceil(rect.x1);
|
|
Toshihiro Shimizu |
890ddd |
rect.y1 = tceil(rect.y1);
|
|
Toshihiro Shimizu |
890ddd |
rect += pos;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================
|
|
Toshihiro Shimizu |
890ddd |
// Glow functions
|
|
Toshihiro Shimizu |
890ddd |
//------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
template <typename t=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
void fade(TRasterPT<t> ras, double fade, T color) //Why it is not in TRop..??</t>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (fade <= 0.0)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double maxChannelValueD = T::maxChannelValue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(fade <= 1.0);
|
|
Toshihiro Shimizu |
890ddd |
ras->lock();
|
|
Toshihiro Shimizu |
890ddd |
for (int j = 0; j < ras->getLy(); j++) {
|
|
Toshihiro Shimizu |
890ddd |
T *pix = ras->pixels(j);
|
|
Toshihiro Shimizu |
890ddd |
T *endPix = pix + ras->getLx();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (; pix < endPix; ++pix) {
|
|
Toshihiro Shimizu |
890ddd |
if (pix->m > 0) {
|
|
Toshihiro Shimizu |
890ddd |
if (pix->m == T::maxChannelValue) {
|
|
Toshihiro Shimizu |
890ddd |
pix->r = troundp(pix->r + fade * (color.r - pix->r));
|
|
Toshihiro Shimizu |
890ddd |
pix->g = troundp(pix->g + fade * (color.g - pix->g));
|
|
Toshihiro Shimizu |
890ddd |
pix->b = troundp(pix->b + fade * (color.b - pix->b));
|
|
Toshihiro Shimizu |
890ddd |
pix->m = troundp(pix->m + fade * (color.m - pix->m));
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
int val;
|
|
Toshihiro Shimizu |
890ddd |
double factor = pix->m / maxChannelValueD;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
val = troundp(pix->r + fade * (color.r * factor - pix->r));
|
|
Toshihiro Shimizu |
890ddd |
pix->r = (val > T::maxChannelValue) ? T::maxChannelValue : val;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
val = troundp(pix->g + fade * (color.g * factor - pix->g));
|
|
Toshihiro Shimizu |
890ddd |
pix->g = (val > T::maxChannelValue) ? T::maxChannelValue : val;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
val = troundp(pix->b + fade * (color.b * factor - pix->b));
|
|
Toshihiro Shimizu |
890ddd |
pix->b = (val > T::maxChannelValue) ? T::maxChannelValue : val;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
val = troundp(pix->m + fade * (color.m * factor - pix->m));
|
|
Toshihiro Shimizu |
890ddd |
pix->m = (val > T::maxChannelValue) ? T::maxChannelValue : val;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ras->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=====================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=================
|
|
Toshihiro Shimizu |
890ddd |
// Glow Fx
|
|
Toshihiro Shimizu |
890ddd |
//-----------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class GlowFx : public TBaseRasterFx
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FX_DECLARATION(GlowFx)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterFxPort m_lighted, m_light;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_value;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_brightness;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_fade;
|
|
Toshihiro Shimizu |
890ddd |
TPixelParamP m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
GlowFx() : m_value(10.0), m_brightness(100.0), m_color(TPixel::White), m_fade(0.0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_value->setMeasureName("fxLength");
|
|
Toshihiro Shimizu |
890ddd |
m_color->enableMatte(true);
|
|
Toshihiro Shimizu |
890ddd |
m_value->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Toshihiro Shimizu |
890ddd |
m_brightness->setValueRange(0, (std::numeric_limits<double>::max)());</double>
|
|
Toshihiro Shimizu |
890ddd |
m_fade->setValueRange(0.0, 100.0);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "value", m_value);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "brightness", m_brightness);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "color", m_color);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "fade", m_fade);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
addInputPort("Light", m_light);
|
|
Toshihiro Shimizu |
890ddd |
addInputPort("Source", m_lighted);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~GlowFx()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool doGetBBox(double frame, TRectD &bbox, const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (getActiveTimeRegion().contains(frame))
|
|
Toshihiro Shimizu |
890ddd |
if (m_light.isConnected()) {
|
|
Toshihiro Shimizu |
890ddd |
TRectD b0, b1;
|
|
Toshihiro Shimizu |
890ddd |
bool ret = m_light->doGetBBox(frame, b0, info);
|
|
Toshihiro Shimizu |
890ddd |
bbox = b0.enlarge(tceil(m_value->getValue(frame)));
|
|
Toshihiro Shimizu |
890ddd |
if (m_lighted.isConnected()) {
|
|
Toshihiro Shimizu |
890ddd |
ret = ret && m_lighted->doGetBBox(frame, b1, info);
|
|
Toshihiro Shimizu |
890ddd |
bbox += b1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return ret;
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_lighted.isConnected())
|
|
Toshihiro Shimizu |
890ddd |
return m_lighted->doGetBBox(frame, bbox, info);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void buildLightRects(const TRectD &tileRect, TRectD &inRect, TRectD &outRect, double blur)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (inRect != TConsts::infiniteRectD) //Could be, if the input light is a zerary Fx
|
|
Toshihiro Shimizu |
890ddd |
makeRectCoherent(inRect, tileRect.getP00());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int blurI = tceil(blur);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//It seems that the TRop::blur does wrong with these (cuts at the borders).
|
|
Toshihiro Shimizu |
890ddd |
//I don't know why - they would be best...
|
|
Toshihiro Shimizu |
890ddd |
//TRectD blurOutRect((lightRect).enlarge(blurI) * tileRect);
|
|
Toshihiro Shimizu |
890ddd |
//lightRect = ((tileRect).enlarge(blurI) * lightRect);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//So we revert to the sum of the two
|
|
Toshihiro Shimizu |
890ddd |
outRect = inRect = ((tileRect).enlarge(blurI) * inRect) + ((inRect).enlarge(blurI) * tileRect);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void doCompute(TTile &tile, double frame, const TRenderSettings &ri)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Status status = getFxStatus(m_light, m_lighted);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (status & NoPortsConnected)
|
|
Toshihiro Shimizu |
890ddd |
//If no port, just do nothing :)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Calculate source
|
|
Toshihiro Shimizu |
890ddd |
if (status & Port1Connected)
|
|
Toshihiro Shimizu |
890ddd |
m_lighted->compute(tile, frame, ri);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Calculate light
|
|
Toshihiro Shimizu |
890ddd |
if (status & Port0Connected) {
|
|
Toshihiro Shimizu |
890ddd |
//Init light infos
|
|
Toshihiro Shimizu |
890ddd |
TDimension tileSize(tile.getRaster()->getSize());
|
|
Toshihiro Shimizu |
890ddd |
TRectD tileRect(tile.m_pos, TDimensionD(tileSize.lx, tileSize.ly));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double scale = sqrt(fabs(ri.m_affine.det()));
|
|
Toshihiro Shimizu |
890ddd |
double blur = m_value->getValue(frame) * scale;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Build the light interesting rect
|
|
Toshihiro Shimizu |
890ddd |
TRectD lightRect, blurOutRect;
|
|
Toshihiro Shimizu |
890ddd |
m_light->getBBox(frame, lightRect, ri);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
buildLightRects(tileRect, lightRect, blurOutRect, blur);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if ((lightRect.getLx() <= 0) || (lightRect.getLy() <= 0))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if ((blurOutRect.getLx() <= 0) || (blurOutRect.getLy() <= 0))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Calculate the light tile
|
|
Toshihiro Shimizu |
890ddd |
TTile lightTile;
|
|
Toshihiro Shimizu |
890ddd |
TDimension lightSize(tround(lightRect.getLx()), tround(lightRect.getLy()));
|
|
Toshihiro Shimizu |
890ddd |
m_light->allocateAndCompute(lightTile, lightRect.getP00(), lightSize, tile.getRaster(), frame, ri);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Init glow parameters
|
|
Toshihiro Shimizu |
890ddd |
TPixel32 color = m_color->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double brightness = m_brightness->getValue(frame) / 100.0;
|
|
Toshihiro Shimizu |
890ddd |
double fade = m_fade->getValue(frame) / 100.0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Now, apply the glow
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//First, deal with the fade
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRasterP light = lightTile.getRaster();
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P light32 = light;
|
|
Toshihiro Shimizu |
890ddd |
TRaster64P light64 = light;
|
|
Toshihiro Shimizu |
890ddd |
if (light32)
|
|
Toshihiro Shimizu |
890ddd |
::fade(light32, fade, color);
|
|
Toshihiro Shimizu |
890ddd |
else if (light64)
|
|
Toshihiro Shimizu |
890ddd |
::fade(light64, fade, toPixel64(color));
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Then, build the blur
|
|
Toshihiro Shimizu |
890ddd |
TRasterP blurOut;
|
|
Toshihiro Shimizu |
890ddd |
if (blur > 0) {
|
|
Toshihiro Shimizu |
890ddd |
//Build a temporary output to the blur
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRasterP light(lightTile.getRaster());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
blurOut = light->create(
|
|
Toshihiro Shimizu |
890ddd |
tround(blurOutRect.getLx()),
|
|
Toshihiro Shimizu |
890ddd |
tround(blurOutRect.getLy()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Apply the blur. Please note that SSE2 should not be used for now - I've seen it
|
|
Toshihiro Shimizu |
890ddd |
//doing strange things to the blur...
|
|
Toshihiro Shimizu |
890ddd |
TPointD displacement(lightRect.getP00() - blurOutRect.getP00());
|
|
Toshihiro Shimizu |
890ddd |
TRop::blur(blurOut, light, blur, tround(displacement.x), tround(displacement.y), false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
blurOut = lightTile.getRaster();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Apply the rgbm scale
|
|
Toshihiro Shimizu |
890ddd |
TRop::rgbmScale(blurOut, blurOut, 1, 1, 1, brightness);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Apply the add
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRectD interestingRect(tileRect * blurOutRect);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRect interestingTileRect(
|
|
Toshihiro Shimizu |
890ddd |
tround(interestingRect.x0 - tileRect.x0),
|
|
Toshihiro Shimizu |
890ddd |
tround(interestingRect.y0 - tileRect.y0),
|
|
Toshihiro Shimizu |
890ddd |
tround(interestingRect.x1 - tileRect.x0) - 1,
|
|
Toshihiro Shimizu |
890ddd |
tround(interestingRect.y1 - tileRect.y0) - 1);
|
|
Toshihiro Shimizu |
890ddd |
TRect interestingBlurRect(
|
|
Toshihiro Shimizu |
890ddd |
tround(interestingRect.x0 - blurOutRect.x0),
|
|
Toshihiro Shimizu |
890ddd |
tround(interestingRect.y0 - blurOutRect.y0),
|
|
Toshihiro Shimizu |
890ddd |
tround(interestingRect.x1 - blurOutRect.x0) - 1,
|
|
Toshihiro Shimizu |
890ddd |
tround(interestingRect.y1 - blurOutRect.y0) - 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if ((interestingTileRect.getLx() <= 0) || (interestingTileRect.getLy() <= 0))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if ((interestingBlurRect.getLx() <= 0) || (interestingBlurRect.getLy() <= 0))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterP tileInterestRas(tile.getRaster()->extract(interestingTileRect));
|
|
Toshihiro Shimizu |
890ddd |
TRasterP blurInterestRas(blurOut->extract(interestingBlurRect));
|
|
Toshihiro Shimizu |
890ddd |
TRop::add(blurInterestRas, tileInterestRas, tileInterestRas);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual void doDryCompute(TRectD &rect,
|
|
Toshihiro Shimizu |
890ddd |
double frame,
|
|
Toshihiro Shimizu |
890ddd |
const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Status status = getFxStatus(m_light, m_lighted);
|
|
Toshihiro Shimizu |
890ddd |
if (status & NoPortsConnected)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (status & Port1Connected)
|
|
Toshihiro Shimizu |
890ddd |
m_lighted->dryCompute(rect, frame, info);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (status & Port0Connected) {
|
|
Toshihiro Shimizu |
890ddd |
double scale = sqrt(fabs(info.m_affine.det()));
|
|
Toshihiro Shimizu |
890ddd |
double blur = m_value->getValue(frame) * scale;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD lightRect, blurOutRect;
|
|
Toshihiro Shimizu |
890ddd |
m_light->getBBox(frame, lightRect, info);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
buildLightRects(rect, lightRect, blurOutRect, blur);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if ((lightRect.getLx() <= 0) || (lightRect.getLy() <= 0))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if ((blurOutRect.getLx() <= 0) || (blurOutRect.getLy() <= 0))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_light->dryCompute(lightRect, frame, info);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Just like the blur
|
|
Toshihiro Shimizu |
890ddd |
bool canHandle(const TRenderSettings &info, double frame)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_light.isConnected())
|
|
Toshihiro Shimizu |
890ddd |
return (m_value->getValue(frame) == 0) ? true : isAlmostIsotropic(info.m_affine);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getMemoryRequirement(const TRectD &rect, double frame, const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double scale = sqrt(fabs(info.m_affine.det()));
|
|
Toshihiro Shimizu |
890ddd |
double blur = m_value->getValue(frame) * scale;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return TRasterFx::memorySize(rect.enlarge(blur), info.m_bpp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *getXsheetPort() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return getInputPort(1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(GlowFx, "glowFx")
|
|
Toshihiro Shimizu |
890ddd |
//==================================================================
|