forked from bartvdbraak/blender
yse BLI_math for the compositor in more places.
This commit is contained in:
parent
7fec7070d7
commit
e1241030db
@ -1002,9 +1002,7 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu,
|
||||
bp++;
|
||||
|
||||
if (*fp != 0.0f) {
|
||||
in[0] += (*fp) * bp->vec[0];
|
||||
in[1] += (*fp) * bp->vec[1];
|
||||
in[2] += (*fp) * bp->vec[2];
|
||||
madd_v3_v3fl(in, bp->vec, *fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1106,9 +1104,7 @@ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *
|
||||
bp++;
|
||||
|
||||
if (*fp != 0.0f) {
|
||||
coord_fp[0] += (*fp) * bp->vec[0];
|
||||
coord_fp[1] += (*fp) * bp->vec[1];
|
||||
coord_fp[2] += (*fp) * bp->vec[2];
|
||||
madd_v3_v3fl(coord_fp, bp->vec, *fp);
|
||||
|
||||
if (tilt_fp)
|
||||
(*tilt_fp) += (*fp) * bp->alfa;
|
||||
|
@ -1301,6 +1301,8 @@ ImBuf *BKE_tracking_sample_pattern_imbuf(int frame_width, int frame_height, ImBu
|
||||
(void) frame_height;
|
||||
(void) search_ibuf;
|
||||
(void) marker;
|
||||
(void) track;
|
||||
(void) use_mask;
|
||||
|
||||
pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat);
|
||||
|
||||
|
@ -87,6 +87,8 @@ MINLINE void add_v2_v2(float r[2], const float a[2]);
|
||||
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2]);
|
||||
MINLINE void add_v3_v3(float r[3], const float a[3]);
|
||||
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
||||
MINLINE void add_v4_v4(float r[4], const float a[4]);
|
||||
MINLINE void add_v4_v4v4(float r[4], const float a[4], const float b[4]);
|
||||
|
||||
MINLINE void sub_v2_v2(float r[2], const float a[2]);
|
||||
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2]);
|
||||
@ -103,6 +105,7 @@ MINLINE void mul_v2_v2(float r[2], const float a[2]);
|
||||
MINLINE void mul_v3_v3(float r[3], const float a[3]);
|
||||
MINLINE void mul_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
||||
MINLINE void mul_v4_fl(float r[4], float f);
|
||||
MINLINE void mul_v4_v4fl(float r[3], const float a[3], float f);
|
||||
|
||||
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f);
|
||||
MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);
|
||||
@ -110,6 +113,7 @@ MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], floa
|
||||
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f);
|
||||
MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3]);
|
||||
MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f);
|
||||
MINLINE void madd_v4_v4v4(float r[4], const float a[4], const float b[4]);
|
||||
|
||||
MINLINE void negate_v2(float r[2]);
|
||||
MINLINE void negate_v2_v2(float r[2], const float a[2]);
|
||||
|
@ -272,6 +272,22 @@ MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
|
||||
r[2] = a[2] + b[2];
|
||||
}
|
||||
|
||||
MINLINE void add_v4_v4(float r[4], const float a[4])
|
||||
{
|
||||
r[0] += a[0];
|
||||
r[1] += a[1];
|
||||
r[2] += a[2];
|
||||
r[3] += a[3];
|
||||
}
|
||||
|
||||
MINLINE void add_v4_v4v4(float r[4], const float a[4], const float b[4])
|
||||
{
|
||||
r[0] = a[0] + b[0];
|
||||
r[1] = a[1] + b[1];
|
||||
r[2] = a[2] + b[2];
|
||||
r[3] = a[3] + b[3];
|
||||
}
|
||||
|
||||
MINLINE void sub_v2_v2(float r[2], const float a[2])
|
||||
{
|
||||
r[0] -= a[0];
|
||||
@ -361,6 +377,14 @@ MINLINE void mul_v4_fl(float r[4], float f)
|
||||
r[3] *= f;
|
||||
}
|
||||
|
||||
MINLINE void mul_v4_v4fl(float r[4], const float a[4], float f)
|
||||
{
|
||||
r[0] = a[0] * f;
|
||||
r[1] = a[1] * f;
|
||||
r[2] = a[2] * f;
|
||||
r[3] = a[3] * f;
|
||||
}
|
||||
|
||||
MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
|
||||
{
|
||||
r[0] += a[0] * f;
|
||||
@ -409,6 +433,14 @@ MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
|
||||
r[3] += a[3] * f;
|
||||
}
|
||||
|
||||
MINLINE void madd_v4_v4v4(float r[4], const float a[4], const float b[4])
|
||||
{
|
||||
r[0] += a[0] * b[0];
|
||||
r[1] += a[1] * b[1];
|
||||
r[2] += a[2] * b[2];
|
||||
r[3] += a[3] * b[3];
|
||||
}
|
||||
|
||||
MINLINE void mul_v3_v3v3(float r[3], const float v1[3], const float v2[3])
|
||||
{
|
||||
r[0] = v1[0] * v2[0];
|
||||
|
@ -329,9 +329,7 @@ void MemoryBuffer::readEWA(float result[4], float fx, float fy, float dx, float
|
||||
float tc[4];
|
||||
const float wt = EWA_WTS[(Q < 0.f) ? 0 : (unsigned int)Q];
|
||||
read(tc, clipuv(u, width), clipuv(v, height));
|
||||
result[0] += tc[0]*wt;
|
||||
result[1] += tc[1]*wt;
|
||||
result[2] += tc[2]*wt;
|
||||
madd_v3_v3fl(result, tc, wt);
|
||||
result[3] += result[3] ? tc[3]*wt : 0.f;
|
||||
d += wt;
|
||||
}
|
||||
|
@ -35,6 +35,9 @@ class NodeOperation;
|
||||
#include "list"
|
||||
#include "BLI_threads.h"
|
||||
|
||||
#include "BLI_math_color.h"
|
||||
#include "BLI_math_vector.h"
|
||||
|
||||
class ReadBufferOperation;
|
||||
|
||||
/**
|
||||
|
@ -37,16 +37,10 @@ void AlphaOverKeyOperation::executePixel(float *outputValue, float x, float y, P
|
||||
inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers);
|
||||
|
||||
if (inputOverColor[3] <= 0.0f) {
|
||||
outputValue[0] = inputColor1[0];
|
||||
outputValue[1] = inputColor1[1];
|
||||
outputValue[2] = inputColor1[2];
|
||||
outputValue[3] = inputColor1[3];
|
||||
copy_v4_v4(outputValue, inputColor1);
|
||||
}
|
||||
else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
|
||||
outputValue[0] = inputOverColor[0];
|
||||
outputValue[1] = inputOverColor[1];
|
||||
outputValue[2] = inputOverColor[2];
|
||||
outputValue[3] = inputOverColor[3];
|
||||
copy_v4_v4(outputValue, inputOverColor);
|
||||
}
|
||||
else {
|
||||
float premul = value[0]*inputOverColor[3];
|
||||
|
@ -38,16 +38,10 @@ void AlphaOverMixedOperation::executePixel(float outputValue[4], float x, float
|
||||
inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers);
|
||||
|
||||
if (inputOverColor[3] <= 0.0f) {
|
||||
outputValue[0] = inputColor1[0];
|
||||
outputValue[1] = inputColor1[1];
|
||||
outputValue[2] = inputColor1[2];
|
||||
outputValue[3] = inputColor1[3];
|
||||
copy_v4_v4(outputValue, inputColor1);
|
||||
}
|
||||
else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
|
||||
outputValue[0] = inputOverColor[0];
|
||||
outputValue[1] = inputOverColor[1];
|
||||
outputValue[2] = inputOverColor[2];
|
||||
outputValue[3] = inputOverColor[3];
|
||||
copy_v4_v4(outputValue, inputOverColor);
|
||||
}
|
||||
else {
|
||||
float addfac = 1.0f - this->x + inputOverColor[3]*this->x;
|
||||
|
@ -38,16 +38,10 @@ void AlphaOverPremultiplyOperation::executePixel(float *outputValue, float x, fl
|
||||
|
||||
/* Zero alpha values should still permit an add of RGB data */
|
||||
if (inputOverColor[3]<0.0f) {
|
||||
outputValue[0] = inputColor1[0];
|
||||
outputValue[1] = inputColor1[1];
|
||||
outputValue[2] = inputColor1[2];
|
||||
outputValue[3] = inputColor1[3];
|
||||
copy_v4_v4(outputValue, inputColor1);
|
||||
}
|
||||
else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
|
||||
outputValue[0] = inputOverColor[0];
|
||||
outputValue[1] = inputOverColor[1];
|
||||
outputValue[2] = inputOverColor[2];
|
||||
outputValue[3] = inputOverColor[3];
|
||||
copy_v4_v4(outputValue, inputOverColor);
|
||||
}
|
||||
else {
|
||||
float mul = 1.0f - value[0]*inputOverColor[3];
|
||||
|
@ -62,36 +62,27 @@ void BilateralBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
|
||||
int maxy = ceil(y + space);
|
||||
float deltaColor;
|
||||
this->inputDeterminatorProgram->read(determinatorReferenceColor, x, y, inputBuffers, data);
|
||||
|
||||
blurColor[0] = 0.0f;
|
||||
blurColor[1] = 0.0f;
|
||||
blurColor[2] = 0.0f;
|
||||
blurColor[3] = 0.0f;
|
||||
|
||||
zero_v4(blurColor);
|
||||
blurDivider = 0.0f;
|
||||
for (int yi = miny ; yi < maxy ; yi+=QualityStepHelper::getStep()) {
|
||||
for (int xi = minx ; xi < maxx ; xi+=QualityStepHelper::getStep()) {
|
||||
// read determinator
|
||||
this->inputDeterminatorProgram->read(determinator, xi, yi, inputBuffers, data);
|
||||
deltaColor = fabsf(determinatorReferenceColor[0] - determinator[0])+
|
||||
fabsf(determinatorReferenceColor[1] - determinator[1])+
|
||||
fabsf(determinatorReferenceColor[2] - determinator[2]); // do not take the alpha channel into account
|
||||
deltaColor = (fabsf(determinatorReferenceColor[0] - determinator[0]) +
|
||||
fabsf(determinatorReferenceColor[1] - determinator[1]) +
|
||||
fabsf(determinatorReferenceColor[2] - determinator[2])); // do not take the alpha channel into account
|
||||
if (deltaColor< sigmacolor) {
|
||||
// add this to the blur
|
||||
this->inputColorProgram->read(tempColor, xi, yi, inputBuffers, data);
|
||||
blurColor[0]+=tempColor[0];
|
||||
blurColor[1]+=tempColor[1];
|
||||
blurColor[2]+=tempColor[2];
|
||||
blurColor[3]+=tempColor[3];
|
||||
add_v4_v4(blurColor, tempColor);
|
||||
blurDivider += 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (blurDivider > 0.0f) {
|
||||
color[0] = blurColor[0]/blurDivider;
|
||||
color[1] = blurColor[1]/blurDivider;
|
||||
color[2] = blurColor[2]/blurDivider;
|
||||
color[3] = blurColor[3]/blurDivider;
|
||||
mul_v4_v4fl(color, blurColor, 1.0f / blurDivider);
|
||||
}
|
||||
else {
|
||||
color[0] = 0.0f;
|
||||
|
@ -79,14 +79,7 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
|
||||
|
||||
inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST, inputBuffers);
|
||||
if (tempBoundingBox[0] >0.0f) {
|
||||
tempColor[0] = 0;
|
||||
tempColor[1] = 0;
|
||||
tempColor[2] = 0;
|
||||
tempColor[3] = 0;
|
||||
float overallmultiplyerr = 0;
|
||||
float overallmultiplyerg = 0;
|
||||
float overallmultiplyerb = 0;
|
||||
float overallmultiplyera = 0;
|
||||
float overallmultiplyer[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
|
||||
float *buffer = inputBuffer->getBuffer();
|
||||
int bufferwidth = inputBuffer->getWidth();
|
||||
@ -103,6 +96,8 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
|
||||
maxy = min(maxy, inputBuffer->getRect()->ymax);
|
||||
maxx = min(maxx, inputBuffer->getRect()->xmax);
|
||||
|
||||
zero_v4(tempColor);
|
||||
|
||||
int step = getStep();
|
||||
int offsetadd = getOffsetAdd();
|
||||
|
||||
@ -113,21 +108,15 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
|
||||
float u = this->bokehMidX - (nx-x) *m;
|
||||
float v = this->bokehMidY - (ny-y) *m;
|
||||
inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
|
||||
tempColor[0] += bokeh[0] * buffer[bufferindex];
|
||||
tempColor[1] += bokeh[1] * buffer[bufferindex+1];
|
||||
tempColor[2] += bokeh[2]* buffer[bufferindex+2];
|
||||
tempColor[3] += bokeh[3]* buffer[bufferindex+3];
|
||||
overallmultiplyerr += bokeh[0];
|
||||
overallmultiplyerg += bokeh[1];
|
||||
overallmultiplyerb += bokeh[2];
|
||||
overallmultiplyera += bokeh[3];
|
||||
madd_v4_v4v4(tempColor, bokeh, &buffer[bufferindex]);
|
||||
add_v4_v4(overallmultiplyer, bokeh);
|
||||
bufferindex +=offsetadd;
|
||||
}
|
||||
}
|
||||
color[0] = tempColor[0] * (1.0f / overallmultiplyerr);
|
||||
color[1] = tempColor[1] * (1.0f / overallmultiplyerg);
|
||||
color[2] = tempColor[2] * (1.0f / overallmultiplyerb);
|
||||
color[3] = tempColor[3] * (1.0f / overallmultiplyera);
|
||||
color[0] = tempColor[0] * (1.0f / overallmultiplyer[0]);
|
||||
color[1] = tempColor[1] * (1.0f / overallmultiplyer[1]);
|
||||
color[2] = tempColor[2] * (1.0f / overallmultiplyer[2]);
|
||||
color[3] = tempColor[3] * (1.0f / overallmultiplyer[3]);
|
||||
}
|
||||
else {
|
||||
inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers);
|
||||
|
@ -79,9 +79,7 @@ void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSamp
|
||||
if (*fac >= 1.0f)
|
||||
curvemapping_evaluate_premulRGBF(workingCopy, color, image);
|
||||
else if (*fac <= 0.0f) {
|
||||
color[0] = image[0];
|
||||
color[1] = image[1];
|
||||
color[2] = image[2];
|
||||
copy_v3_v3(color, image);
|
||||
}
|
||||
else {
|
||||
float col[4], mfac = 1.0f - *fac;
|
||||
@ -140,9 +138,7 @@ void ConstantLevelColorCurveOperation::executePixel(float *color, float x, float
|
||||
if (*fac >= 1.0f)
|
||||
curvemapping_evaluate_premulRGBF(this->curveMapping, color, image);
|
||||
else if (*fac <= 0.0f) {
|
||||
color[0] = image[0];
|
||||
color[1] = image[1];
|
||||
color[2] = image[2];
|
||||
copy_v3_v3(color, image);
|
||||
}
|
||||
else {
|
||||
float col[4], mfac = 1.0f - *fac;
|
||||
|
@ -43,9 +43,7 @@ void ConvertKeyToPremulOperation::executePixel(float *outputValue, float x, floa
|
||||
this->inputColor->read(inputValue, x, y, sampler, inputBuffers);
|
||||
alpha = inputValue[3];
|
||||
|
||||
outputValue[0] = inputValue[0] * alpha;
|
||||
outputValue[1] = inputValue[1] * alpha;
|
||||
outputValue[2] = inputValue[2] * alpha;
|
||||
mul_v3_v3fl(outputValue, inputValue, alpha);
|
||||
|
||||
/* never touches the alpha */
|
||||
outputValue[3] = alpha;
|
||||
|
@ -44,14 +44,10 @@ void ConvertPremulToKeyOperation::executePixel(float *outputValue, float x, floa
|
||||
alpha = inputValue[3];
|
||||
|
||||
if (fabsf(alpha) < 1e-5f) {
|
||||
outputValue[0] = 0.f;
|
||||
outputValue[1] = 0.f;
|
||||
outputValue[2] = 0.f;
|
||||
zero_v3(outputValue);
|
||||
}
|
||||
else {
|
||||
outputValue[0] = inputValue[0] / alpha;
|
||||
outputValue[1] = inputValue[1] / alpha;
|
||||
outputValue[2] = inputValue[2] / alpha;
|
||||
mul_v3_v3fl(outputValue, inputValue, 1.0f / alpha);
|
||||
}
|
||||
|
||||
/* never touches the alpha */
|
||||
|
@ -60,9 +60,8 @@ void ConvertRGBToYCCOperation::executePixel(float *outputValue, float x, float y
|
||||
rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->mode);
|
||||
|
||||
/* divided by 255 to normalize for viewing in */
|
||||
outputValue[0] = color[0]/255.f; /* Y */
|
||||
outputValue[1] = color[1]/255.f; /* Cb*/
|
||||
outputValue[2] = color[2]/255.f; /* Cr*/
|
||||
/* R,G,B --> Y,Cb,Cr */
|
||||
mul_v3_v3fl(outputValue, color, 1.0f / 255.0f);
|
||||
outputValue[3] = inputColor[3];
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,8 @@ void ConvertYCCToRGBOperation::executePixel(float *outputValue, float x, float y
|
||||
inputOperation->read(inputColor, x, y, sampler, inputBuffers);
|
||||
|
||||
/* need to un-normalize the data */
|
||||
inputColor[0] *= 255.f; /* Y */
|
||||
inputColor[1] *= 255.f; /* Cb*/
|
||||
inputColor[2] *= 255.f; /* Cr*/
|
||||
/* R,G,B --> Y,Cb,Cr */
|
||||
mul_v3_fl(inputColor, 255.0f);
|
||||
|
||||
ycc_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2], this->mode);
|
||||
outputValue[3] = inputColor[3];
|
||||
|
@ -26,12 +26,6 @@
|
||||
ConvolutionEdgeFilterOperation::ConvolutionEdgeFilterOperation() : ConvolutionFilterOperation()
|
||||
{
|
||||
}
|
||||
inline void addFilter(float *result, float*input, float value)
|
||||
{
|
||||
result[0] += input[0] * value;
|
||||
result[1] += input[1] * value;
|
||||
result[2] += input[2] * value;
|
||||
}
|
||||
|
||||
void ConvolutionEdgeFilterOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data)
|
||||
{
|
||||
@ -64,48 +58,48 @@ void ConvolutionEdgeFilterOperation::executePixel(float *color,int x, int y, Mem
|
||||
res2[3] = 0.0f;
|
||||
|
||||
this->inputOperation->read(in1, x1, y1, inputBuffers, NULL);
|
||||
addFilter(res1, in1, this->filter[0]);
|
||||
addFilter(res2, in1, this->filter[0]);
|
||||
madd_v3_v3fl(res1, in1, this->filter[0]);
|
||||
madd_v3_v3fl(res2, in1, this->filter[0]);
|
||||
|
||||
this->inputOperation->read(in1, x2, y1, inputBuffers, NULL);
|
||||
addFilter(res1, in1, this->filter[1]);
|
||||
addFilter(res2, in1, this->filter[3]);
|
||||
madd_v3_v3fl(res1, in1, this->filter[1]);
|
||||
madd_v3_v3fl(res2, in1, this->filter[3]);
|
||||
|
||||
this->inputOperation->read(in1, x3, y1, inputBuffers, NULL);
|
||||
addFilter(res1, in1, this->filter[2]);
|
||||
addFilter(res2, in1, this->filter[6]);
|
||||
madd_v3_v3fl(res1, in1, this->filter[2]);
|
||||
madd_v3_v3fl(res2, in1, this->filter[6]);
|
||||
|
||||
this->inputOperation->read(in1, x1, y2, inputBuffers, NULL);
|
||||
addFilter(res1, in1, this->filter[3]);
|
||||
addFilter(res2, in1, this->filter[1]);
|
||||
madd_v3_v3fl(res1, in1, this->filter[3]);
|
||||
madd_v3_v3fl(res2, in1, this->filter[1]);
|
||||
|
||||
this->inputOperation->read(in2, x2, y2, inputBuffers, NULL);
|
||||
addFilter(res1, in2, this->filter[4]);
|
||||
addFilter(res2, in2, this->filter[4]);
|
||||
madd_v3_v3fl(res1, in2, this->filter[4]);
|
||||
madd_v3_v3fl(res2, in2, this->filter[4]);
|
||||
|
||||
this->inputOperation->read(in1, x3, y2, inputBuffers, NULL);
|
||||
addFilter(res1, in1, this->filter[5]);
|
||||
addFilter(res2, in1, this->filter[7]);
|
||||
madd_v3_v3fl(res1, in1, this->filter[5]);
|
||||
madd_v3_v3fl(res2, in1, this->filter[7]);
|
||||
|
||||
this->inputOperation->read(in1, x1, y3, inputBuffers, NULL);
|
||||
addFilter(res1, in1, this->filter[6]);
|
||||
addFilter(res2, in1, this->filter[2]);
|
||||
madd_v3_v3fl(res1, in1, this->filter[6]);
|
||||
madd_v3_v3fl(res2, in1, this->filter[2]);
|
||||
|
||||
this->inputOperation->read(in1, x2, y3, inputBuffers, NULL);
|
||||
addFilter(res1, in1, this->filter[7]);
|
||||
addFilter(res2, in1, this->filter[5]);
|
||||
madd_v3_v3fl(res1, in1, this->filter[7]);
|
||||
madd_v3_v3fl(res2, in1, this->filter[5]);
|
||||
|
||||
this->inputOperation->read(in1, x3, y3, inputBuffers, NULL);
|
||||
addFilter(res1, in1, this->filter[8]);
|
||||
addFilter(res2, in1, this->filter[8]);
|
||||
madd_v3_v3fl(res1, in1, this->filter[8]);
|
||||
madd_v3_v3fl(res2, in1, this->filter[8]);
|
||||
|
||||
color[0] = sqrt(res1[0]*res1[0]+res2[0]*res2[0]);
|
||||
color[1] = sqrt(res1[1]*res1[1]+res2[1]*res2[1]);
|
||||
color[2] = sqrt(res1[2]*res1[2]+res2[2]*res2[2]);
|
||||
color[0] = sqrt(res1[0] * res1[0] + res2[0] * res2[0]);
|
||||
color[1] = sqrt(res1[1] * res1[1] + res2[1] * res2[1]);
|
||||
color[2] = sqrt(res1[2] * res1[2] + res2[2] * res2[2]);
|
||||
|
||||
color[0] = color[0]*value[0] + in2[0] * mval;
|
||||
color[1] = color[1]*value[0] + in2[1] * mval;
|
||||
color[2] = color[2]*value[0] + in2[2] * mval;
|
||||
color[0] = color[0] * value[0] + in2[0] * mval;
|
||||
color[1] = color[1] * value[0] + in2[1] * mval;
|
||||
color[2] = color[2] * value[0] + in2[2] * mval;
|
||||
|
||||
color[3] = in2[3];
|
||||
}
|
||||
|
@ -69,10 +69,6 @@ void ConvolutionFilterOperation::deinitExecution()
|
||||
|
||||
void ConvolutionFilterOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data)
|
||||
{
|
||||
color[0] = 0.0;
|
||||
color[1] = 0.0;
|
||||
color[2] = 0.0;
|
||||
color[3] = 0.0;
|
||||
float in1[4];
|
||||
float in2[4];
|
||||
int x1 = x - 1;
|
||||
@ -89,57 +85,32 @@ void ConvolutionFilterOperation::executePixel(float *color,int x, int y, MemoryB
|
||||
CLAMP(y3, 0, getHeight()-1);
|
||||
float value[4];
|
||||
this->inputValueOperation->read(value, x2, y2, inputBuffers, NULL);
|
||||
float mval = 1.0f - value[0];
|
||||
const float mval = 1.0f - value[0];
|
||||
|
||||
zero_v4(color);
|
||||
this->inputOperation->read(in1, x1, y1, inputBuffers, NULL);
|
||||
color[0] += in1[0] * this->filter[0];
|
||||
color[1] += in1[1] * this->filter[0];
|
||||
color[2] += in1[2] * this->filter[0];
|
||||
color[3] += in1[3] * this->filter[0];
|
||||
madd_v4_v4fl(color, in1, this->filter[0]);
|
||||
this->inputOperation->read(in1, x2, y1, inputBuffers, NULL);
|
||||
color[0] += in1[0] * this->filter[1];
|
||||
color[1] += in1[1] * this->filter[1];
|
||||
color[2] += in1[2] * this->filter[1];
|
||||
color[3] += in1[3] * this->filter[1];
|
||||
madd_v4_v4fl(color, in1, this->filter[1]);
|
||||
this->inputOperation->read(in1, x3, y1, inputBuffers, NULL);
|
||||
color[0] += in1[0] * this->filter[2];
|
||||
color[1] += in1[1] * this->filter[2];
|
||||
color[2] += in1[2] * this->filter[2];
|
||||
color[3] += in1[3] * this->filter[2];
|
||||
madd_v4_v4fl(color, in1, this->filter[2]);
|
||||
this->inputOperation->read(in1, x1, y2, inputBuffers, NULL);
|
||||
color[0] += in1[0] * this->filter[3];
|
||||
color[1] += in1[1] * this->filter[3];
|
||||
color[2] += in1[2] * this->filter[3];
|
||||
color[3] += in1[3] * this->filter[3];
|
||||
madd_v4_v4fl(color, in1, this->filter[3]);
|
||||
this->inputOperation->read(in2, x2, y2, inputBuffers, NULL);
|
||||
color[0] += in2[0] * this->filter[4];
|
||||
color[1] += in2[1] * this->filter[4];
|
||||
color[2] += in2[2] * this->filter[4];
|
||||
color[3] += in2[3] * this->filter[4];
|
||||
madd_v4_v4fl(color, in2, this->filter[4]);
|
||||
this->inputOperation->read(in1, x3, y2, inputBuffers, NULL);
|
||||
color[0] += in1[0] * this->filter[5];
|
||||
color[1] += in1[1] * this->filter[5];
|
||||
color[2] += in1[2] * this->filter[5];
|
||||
color[3] += in1[3] * this->filter[5];
|
||||
madd_v4_v4fl(color, in1, this->filter[5]);
|
||||
this->inputOperation->read(in1, x1, y3, inputBuffers, NULL);
|
||||
color[0] += in1[0] * this->filter[6];
|
||||
color[1] += in1[1] * this->filter[6];
|
||||
color[2] += in1[2] * this->filter[6];
|
||||
color[3] += in1[3] * this->filter[6];
|
||||
madd_v4_v4fl(color, in1, this->filter[6]);
|
||||
this->inputOperation->read(in1, x2, y3, inputBuffers, NULL);
|
||||
color[0] += in1[0] * this->filter[7];
|
||||
color[1] += in1[1] * this->filter[7];
|
||||
color[2] += in1[2] * this->filter[7];
|
||||
color[3] += in1[3] * this->filter[7];
|
||||
madd_v4_v4fl(color, in1, this->filter[7]);
|
||||
this->inputOperation->read(in1, x3, y3, inputBuffers, NULL);
|
||||
color[0] += in1[0] * this->filter[8];
|
||||
color[1] += in1[1] * this->filter[8];
|
||||
color[2] += in1[2] * this->filter[8];
|
||||
color[3] += in1[3] * this->filter[8];
|
||||
madd_v4_v4fl(color, in1, this->filter[8]);
|
||||
|
||||
color[0] = color[0]*value[0] + in2[0] * mval;
|
||||
color[1] = color[1]*value[0] + in2[1] * mval;
|
||||
color[2] = color[2]*value[0] + in2[2] * mval;
|
||||
color[3] = color[3]*value[0] + in2[3] * mval;
|
||||
color[0] = color[0] * value[0] + in2[0] * mval;
|
||||
color[1] = color[1] * value[0] + in2[1] * mval;
|
||||
color[2] = color[2] * value[0] + in2[2] * mval;
|
||||
color[3] = color[3] * value[0] + in2[3] * mval;
|
||||
}
|
||||
|
||||
bool ConvolutionFilterOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
|
||||
|
@ -85,10 +85,7 @@ void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBu
|
||||
|
||||
this->inputProgram->read(col, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, COM_PS_NEAREST, inputBuffers);
|
||||
|
||||
col2[0] += col[0];
|
||||
col2[1] += col[1];
|
||||
col2[2] += col[2];
|
||||
col2[3] += col[3];
|
||||
add_v4_v4(col2, col);
|
||||
|
||||
/* double transformations */
|
||||
ltx += tx;
|
||||
@ -96,10 +93,8 @@ void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBu
|
||||
lrot += rot;
|
||||
lsc += sc;
|
||||
}
|
||||
color[0] = col2[0]/iterations;
|
||||
color[1] = col2[1]/iterations;
|
||||
color[2] = col2[2]/iterations;
|
||||
color[3] = col2[3]/iterations;
|
||||
|
||||
mul_v4_v4fl(color, col2, 1.0f / iterations);
|
||||
}
|
||||
|
||||
void DirectionalBlurOperation::deinitExecution()
|
||||
|
@ -138,21 +138,15 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory
|
||||
index = ((ny-y)+this->rady) * (this->radx*2+1) + (minx-x+this->radx);
|
||||
int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
|
||||
for (int nx = minx ; nx < maxx ; nx +=step) {
|
||||
float multiplyer = gausstab[index];
|
||||
tempColor[0] += multiplyer * buffer[bufferindex];
|
||||
tempColor[1] += multiplyer * buffer[bufferindex+1];
|
||||
tempColor[2] += multiplyer * buffer[bufferindex+2];
|
||||
tempColor[3] += multiplyer * buffer[bufferindex+3];
|
||||
const float multiplyer = gausstab[index];
|
||||
madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer);
|
||||
overallmultiplyer += multiplyer;
|
||||
index += step;
|
||||
bufferindex +=offsetadd;
|
||||
}
|
||||
}
|
||||
float divider = 1.0f / overallmultiplyer;
|
||||
color[0] = tempColor[0] * divider;
|
||||
color[1] = tempColor[1] * divider;
|
||||
color[2] = tempColor[2] * divider;
|
||||
color[3] = tempColor[3] * divider;
|
||||
|
||||
mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer);
|
||||
}
|
||||
|
||||
void GaussianBokehBlurOperation::deinitExecution()
|
||||
|
@ -99,19 +99,12 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
|
||||
int bufferindex = ((minx - bufferstartx)*4)+((miny-bufferstarty)*4*bufferwidth);
|
||||
for (int nx = minx ; nx < maxx ; nx +=step) {
|
||||
index = (nx-x)+this->rad;
|
||||
float multiplyer = gausstab[index];
|
||||
tempColor[0] += multiplyer * buffer[bufferindex];
|
||||
tempColor[1] += multiplyer * buffer[bufferindex+1];
|
||||
tempColor[2] += multiplyer * buffer[bufferindex+2];
|
||||
tempColor[3] += multiplyer * buffer[bufferindex+3];
|
||||
const float multiplyer = gausstab[index];
|
||||
madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer);
|
||||
overallmultiplyer += multiplyer;
|
||||
bufferindex +=offsetadd;
|
||||
bufferindex += offsetadd;
|
||||
}
|
||||
float divider = 1.0f / overallmultiplyer;
|
||||
color[0] = tempColor[0] * divider;
|
||||
color[1] = tempColor[1] * divider;
|
||||
color[2] = tempColor[2] * divider;
|
||||
color[3] = tempColor[3] * divider;
|
||||
mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer);
|
||||
}
|
||||
|
||||
void GaussianXBlurOperation::deinitExecution()
|
||||
|
@ -95,18 +95,11 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
|
||||
for (int ny = miny ; ny < maxy ; ny +=step) {
|
||||
index = (ny-y)+this->rad;
|
||||
int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
|
||||
float multiplyer = gausstab[index];
|
||||
tempColor[0] += multiplyer * buffer[bufferindex];
|
||||
tempColor[1] += multiplyer * buffer[bufferindex+1];
|
||||
tempColor[2] += multiplyer * buffer[bufferindex+2];
|
||||
tempColor[3] += multiplyer * buffer[bufferindex+3];
|
||||
const float multiplyer = gausstab[index];
|
||||
madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer);
|
||||
overallmultiplyer += multiplyer;
|
||||
}
|
||||
float divider = 1.0f / overallmultiplyer;
|
||||
color[0] = tempColor[0] * divider;
|
||||
color[1] = tempColor[1] * divider;
|
||||
color[2] = tempColor[2] * divider;
|
||||
color[3] = tempColor[3] * divider;
|
||||
mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer);
|
||||
}
|
||||
|
||||
void GaussianYBlurOperation::deinitExecution()
|
||||
|
@ -42,28 +42,20 @@ void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTil
|
||||
xm = x - i;
|
||||
xp = x + i;
|
||||
tbuf1->read(c, x, y);
|
||||
c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
|
||||
mul_v3_fl(c, f1);
|
||||
tbuf1->read(tc, (settings->angle ? xm : x), ym);
|
||||
c[0]+=tc[0]*f2;
|
||||
c[1]+=tc[1]*f2;
|
||||
c[2]+=tc[2]*f2;
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
tbuf1->read(tc, (settings->angle ? xp : x), yp);
|
||||
c[0]+=tc[0]*f2;
|
||||
c[1]+=tc[1]*f2;
|
||||
c[2]+=tc[2]*f2;
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
c[3] = 1.0f;
|
||||
tbuf1->writePixel(x, y, c);
|
||||
|
||||
tbuf2->read(c, x, y);
|
||||
c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
|
||||
mul_v3_fl(c, f1);
|
||||
tbuf2->read(tc, xm, (settings->angle ? yp : y));
|
||||
c[0]+=tc[0]*f2;
|
||||
c[1]+=tc[1]*f2;
|
||||
c[2]+=tc[2]*f2;
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
tbuf2->read(tc, xp, (settings->angle ? ym : y));
|
||||
c[0]+=tc[0]*f2;
|
||||
c[1]+=tc[1]*f2;
|
||||
c[2]+=tc[2]*f2;
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
c[3] = 1.0f;
|
||||
tbuf2->writePixel(x, y, c);
|
||||
|
||||
@ -77,28 +69,20 @@ void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTil
|
||||
xm = x - i;
|
||||
xp = x + i;
|
||||
tbuf1->read(c, x, y);
|
||||
c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
|
||||
mul_v3_fl(c, f1);
|
||||
tbuf1->read(tc, (settings->angle ? xm : x), ym);
|
||||
c[0]+=tc[0]*f2;
|
||||
c[1]+=tc[1]*f2;
|
||||
c[2]+=tc[2]*f2;
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
tbuf1->read(tc, (settings->angle ? xp : x), yp);
|
||||
c[0]+=tc[0]*f2;
|
||||
c[1]+=tc[1]*f2;
|
||||
c[2]+=tc[2]*f2;
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
c[3] = 1.0f;
|
||||
tbuf1->writePixel(x, y, c);
|
||||
|
||||
tbuf2->read(c, x, y);
|
||||
c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
|
||||
mul_v3_fl(c, f1);
|
||||
tbuf2->read(tc, xm, (settings->angle ? yp : y));
|
||||
c[0]+=tc[0]*f2;
|
||||
c[1]+=tc[1]*f2;
|
||||
c[2]+=tc[2]*f2;
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
tbuf2->read(tc, xp, (settings->angle ? ym : y));
|
||||
c[0]+=tc[0]*f2;
|
||||
c[1]+=tc[1]*f2;
|
||||
c[2]+=tc[2]*f2;
|
||||
madd_v3_v3fl(c, tc, f2);
|
||||
c[3] = 1.0f;
|
||||
tbuf2->writePixel(x, y, c);
|
||||
}
|
||||
|
@ -55,9 +55,7 @@ void InvertOperation::executePixel(float *out, float x, float y, PixelSampler sa
|
||||
out[2] = (1.0f - inputColor[2])*value + inputColor[2]*invertedValue;
|
||||
}
|
||||
else {
|
||||
out[0] = inputColor[0];
|
||||
out[1] = inputColor[1];
|
||||
out[2] = inputColor[2];
|
||||
copy_v3_v3(out, inputColor);
|
||||
}
|
||||
|
||||
if (alpha)
|
||||
|
@ -47,9 +47,7 @@ void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *in
|
||||
|
||||
float output[4];
|
||||
this->imageReader->read(output, x, y, inputBuffers, NULL);
|
||||
output[0] *= avg->al;
|
||||
output[1] *= avg->al;
|
||||
output[2] *= avg->al;
|
||||
mul_v3_fl(output, avg->al);
|
||||
float dr = output[0] + this->data->offset;
|
||||
float dg = output[1] + this->data->offset;
|
||||
float db = output[2] + this->data->offset;
|
||||
@ -63,10 +61,7 @@ void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *in
|
||||
output[2] = powf(MAX2(output[2], 0.0f), igm);
|
||||
}
|
||||
|
||||
color[0] = output[0];
|
||||
color[1] = output[1];
|
||||
color[2] = output[2];
|
||||
color[3] = output[3];
|
||||
copy_v4_v4(color, output);
|
||||
}
|
||||
void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
|
||||
{
|
||||
@ -94,10 +89,7 @@ void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, Mem
|
||||
I_a = I_l + ia * (I_g - I_l);
|
||||
output[2] /= (output[2] + powf(f * I_a, m));
|
||||
|
||||
color[0] = output[0];
|
||||
color[1] = output[1];
|
||||
color[2] = output[2];
|
||||
color[3] = output[3];
|
||||
copy_v4_v4(color, output);
|
||||
}
|
||||
|
||||
void TonemapOperation::deinitExecution()
|
||||
@ -143,18 +135,14 @@ void *TonemapOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuff
|
||||
while (p--) {
|
||||
float L = 0.212671f * bc[0] + 0.71516f * bc[1] + 0.072169f * bc[2];
|
||||
Lav += L;
|
||||
cav[0] += bc[0];
|
||||
cav[1] += bc[1];
|
||||
cav[2] += bc[2];
|
||||
add_v3_v3(cav, bc);
|
||||
lsum += logf(MAX2(L, 0.0f) + 1e-5f);
|
||||
maxl = (L > maxl) ? L : maxl;
|
||||
minl = (L < minl) ? L : minl;
|
||||
bc+=4;
|
||||
}
|
||||
data->lav = Lav * sc;
|
||||
data->cav[0] = cav[0]*sc;
|
||||
data->cav[1] = cav[1]*sc;
|
||||
data->cav[2] = cav[2]*sc;
|
||||
mul_v3_v3fl(data->cav, cav, sc);
|
||||
maxl = log((double)maxl + 1e-5); minl = log((double)minl + 1e-5); avl = lsum * sc;
|
||||
data->auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.f;
|
||||
float al = exp((double)avl);
|
||||
|
@ -61,10 +61,7 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
|
||||
tempColor[2] = 0;
|
||||
tempColor[3] = 0;
|
||||
float tempSize[4];
|
||||
float overallmultiplyerr = 0;
|
||||
float overallmultiplyerg = 0;
|
||||
float overallmultiplyerb = 0;
|
||||
float overallmultiplyera = 0;
|
||||
float overallmultiplyer[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
int miny = y - maxBlur;
|
||||
int maxy = y + maxBlur;
|
||||
@ -76,10 +73,8 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
|
||||
tempColor[1] += readColor[1];
|
||||
tempColor[2] += readColor[2];
|
||||
tempColor[3] += readColor[3];
|
||||
overallmultiplyerr += 1;
|
||||
overallmultiplyerg += 1;
|
||||
overallmultiplyerb += 1;
|
||||
overallmultiplyera += 1;
|
||||
add_v4_v4(tempColor, readColor);
|
||||
add_v3_fl(overallmultiplyer, 1.0f);
|
||||
|
||||
for (int ny = miny ; ny < maxy ; ny += QualityStepHelper::getStep()) {
|
||||
for (int nx = minx ; nx < maxx ; nx += QualityStepHelper::getStep()) {
|
||||
@ -97,22 +92,17 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
|
||||
float v = 256 + dy*256/size;
|
||||
inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
|
||||
inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers);
|
||||
tempColor[0] += bokeh[1]*readColor[0];
|
||||
tempColor[1] += bokeh[2]*readColor[1];
|
||||
tempColor[2] += bokeh[2]*readColor[2];
|
||||
tempColor[3] += bokeh[3]*readColor[3];
|
||||
overallmultiplyerr += bokeh[0];
|
||||
overallmultiplyerg += bokeh[1];
|
||||
overallmultiplyerb += bokeh[2];
|
||||
overallmultiplyera += bokeh[3];
|
||||
madd_v4_v4v4(tempColor, bokeh, readColor);
|
||||
add_v4_v4(overallmultiplyer, bokeh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
color[0] = tempColor[0] / overallmultiplyerr;
|
||||
color[1] = tempColor[1] / overallmultiplyerg;
|
||||
color[2] = tempColor[2] / overallmultiplyerb;
|
||||
color[3] = tempColor[3] / overallmultiplyera;
|
||||
|
||||
color[0] = tempColor[0] * (1.0f / overallmultiplyer[0]);
|
||||
color[1] = tempColor[1] * (1.0f / overallmultiplyer[1]);
|
||||
color[2] = tempColor[2] * (1.0f / overallmultiplyer[2]);
|
||||
color[3] = tempColor[3] * (1.0f / overallmultiplyer[3]);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user