forked from bartvdbraak/blender
Compositor: Cleanup, don't shortcut float values
Use 0.0f instead of 0.f and so on.
This commit is contained in:
parent
de9ec80e64
commit
1c870f46e7
@ -110,7 +110,7 @@ void ChannelMatteOperation::executePixelSampled(float output[4], float x, float
|
||||
alpha = inColor[3]; /*whatever it was prior */
|
||||
}
|
||||
else if (alpha < limit_min) {
|
||||
alpha = 0.f;
|
||||
alpha = 0.0f;
|
||||
}
|
||||
else { /*blend */
|
||||
alpha = (alpha - limit_min) / limit_range;
|
||||
|
@ -84,16 +84,16 @@ void ChromaMatteOperation::executePixelSampled(float output[4], float x, float y
|
||||
|
||||
/*if within the acceptance angle */
|
||||
/* if kfg is <0 then the pixel is outside of the key color */
|
||||
kfg = x_angle - (fabsf(z_angle) / tanf(acceptance / 2.f));
|
||||
kfg = x_angle - (fabsf(z_angle) / tanf(acceptance / 2.0f));
|
||||
|
||||
if (kfg > 0.f) { /* found a pixel that is within key color */
|
||||
if (kfg > 0.0f) { /* found a pixel that is within key color */
|
||||
alpha = 1.0f - (kfg / gain);
|
||||
|
||||
beta = atan2(z_angle, x_angle);
|
||||
|
||||
/* if beta is within the cutoff angle */
|
||||
if (fabsf(beta) < (cutoff / 2.f)) {
|
||||
alpha = 0.f;
|
||||
if (fabsf(beta) < (cutoff / 2.0f)) {
|
||||
alpha = 0.0f;
|
||||
}
|
||||
|
||||
/* don't make something that was more transparent less transparent */
|
||||
|
@ -28,7 +28,7 @@ inline float colorbalance_cdl(float in, float offset, float power, float slope)
|
||||
float x = in * slope + offset;
|
||||
|
||||
/* prevent NaN */
|
||||
if (x < 0.f) x = 0.f;
|
||||
if (x < 0.0f) x = 0.0f;
|
||||
|
||||
return powf(x, power);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ inline float colorbalance_lgg(float in, float lift_lgg, float gamma_inv, float g
|
||||
float x = (((linearrgb_to_srgb(in) - 1.0f) * lift_lgg) + 1.0f) * gain;
|
||||
|
||||
/* prevent NaN */
|
||||
if (x < 0.f) x = 0.f;
|
||||
if (x < 0.0f) x = 0.0f;
|
||||
|
||||
return powf(srgb_to_linearrgb(x), gamma_inv);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void ColorMatteOperation::executePixelSampled(float output[4], float x, float y,
|
||||
/* multiply by 2 because it wraps on both sides of the hue,
|
||||
* otherwise 0.5 would key all hue's */
|
||||
|
||||
/* hue */ ((h_wrap = 2.f * fabsf(inColor[0] - inKey[0])) < hue || (2.f - h_wrap) < hue)
|
||||
/* hue */ ((h_wrap = 2.0f * fabsf(inColor[0] - inKey[0])) < hue || (2.0f - h_wrap) < hue)
|
||||
)
|
||||
{
|
||||
output[0] = 0.0f; /* make transparent */
|
||||
|
@ -79,8 +79,8 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4], float x
|
||||
float radius;
|
||||
this->m_inputOperation->readSampled(inputValue, x, y, sampler);
|
||||
z = inputValue[0];
|
||||
if (z != 0.f) {
|
||||
float iZ = (1.f / z);
|
||||
if (z != 0.0f) {
|
||||
float iZ = (1.0f / z);
|
||||
|
||||
// bug #6656 part 2b, do not rescale
|
||||
#if 0
|
||||
@ -88,7 +88,7 @@ void ConvertDepthToRadiusOperation::executePixelSampled(float output[4], float x
|
||||
// scale crad back to original maximum and blend
|
||||
crad->rect[px] = bcrad + wts->rect[px] * (scf * crad->rect[px] - bcrad);
|
||||
#endif
|
||||
radius = 0.5f * fabsf(this->m_aperture * (this->m_dof_sp * (this->m_inverseFocalDistance - iZ) - 1.f));
|
||||
radius = 0.5f * fabsf(this->m_aperture * (this->m_dof_sp * (this->m_inverseFocalDistance - iZ) - 1.0f));
|
||||
// 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates the problem
|
||||
if (radius < 0.0f) radius = 0.0f;
|
||||
if (radius > this->m_maxRadius) {
|
||||
|
@ -79,8 +79,8 @@ void DisplaceSimpleOperation::executePixelSampled(float output[4], float x, floa
|
||||
/* clamp nodes to avoid glitches */
|
||||
u = x - p_dx + 0.5f;
|
||||
v = y - p_dy + 0.5f;
|
||||
CLAMP(u, 0.f, this->getWidth() - 1.f);
|
||||
CLAMP(v, 0.f, this->getHeight() - 1.f);
|
||||
CLAMP(u, 0.0f, this->getWidth() - 1.0f);
|
||||
CLAMP(v, 0.0f, this->getHeight() - 1.0f);
|
||||
|
||||
this->m_inputColorProgram->readSampled(output, u, v, sampler);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ void DistanceRGBMatteOperation::executePixelSampled(float output[4], float x, fl
|
||||
|
||||
/*make 100% transparent */
|
||||
if (distance < tolerance) {
|
||||
output[0] = 0.f;
|
||||
output[0] = 0.0f;
|
||||
}
|
||||
/*in the falloff region, make partially transparent */
|
||||
else if (distance < falloff + tolerance) {
|
||||
|
@ -91,7 +91,7 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect)
|
||||
this->m_sx = this->m_data.sizex * this->m_size / 2.0f;
|
||||
this->m_sy = this->m_data.sizey * this->m_size / 2.0f;
|
||||
|
||||
if ((this->m_sx == this->m_sy) && (this->m_sx > 0.f)) {
|
||||
if ((this->m_sx == this->m_sy) && (this->m_sx > 0.0f)) {
|
||||
for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
|
||||
IIR_gauss(copy, this->m_sx, c, 3);
|
||||
}
|
||||
|
@ -274,15 +274,15 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
|
||||
data2 = (fREAL *)MEM_callocN(w2 * h2 * sizeof(fREAL), "convolve_fast FHT data2");
|
||||
|
||||
// normalize convolutor
|
||||
wt[0] = wt[1] = wt[2] = 0.f;
|
||||
wt[0] = wt[1] = wt[2] = 0.0f;
|
||||
for (y = 0; y < kernelHeight; y++) {
|
||||
colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
|
||||
for (x = 0; x < kernelWidth; x++)
|
||||
add_v3_v3(wt, colp[x]);
|
||||
}
|
||||
if (wt[0] != 0.f) wt[0] = 1.f / wt[0];
|
||||
if (wt[1] != 0.f) wt[1] = 1.f / wt[1];
|
||||
if (wt[2] != 0.f) wt[2] = 1.f / wt[2];
|
||||
if (wt[0] != 0.0f) wt[0] = 1.0f / wt[0];
|
||||
if (wt[1] != 0.0f) wt[1] = 1.0f / wt[1];
|
||||
if (wt[2] != 0.0f) wt[2] = 1.0f / wt[2];
|
||||
for (y = 0; y < kernelHeight; y++) {
|
||||
colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
|
||||
for (x = 0; x < kernelWidth; x++)
|
||||
@ -375,7 +375,7 @@ void GlareFogGlowOperation::generateGlare(float *data, MemoryBuffer *inputTile,
|
||||
fRGB fcol;
|
||||
MemoryBuffer *ckrn;
|
||||
unsigned int sz = 1 << settings->size;
|
||||
const float cs_r = 1.f, cs_g = 1.f, cs_b = 1.f;
|
||||
const float cs_r = 1.0f, cs_g = 1.0f, cs_b = 1.0f;
|
||||
|
||||
// temp. src image
|
||||
// make the convolution kernel
|
||||
@ -386,14 +386,14 @@ void GlareFogGlowOperation::generateGlare(float *data, MemoryBuffer *inputTile,
|
||||
scale = 0.25f * sqrtf((float)(sz * sz));
|
||||
|
||||
for (y = 0; y < sz; ++y) {
|
||||
v = 2.f * (y / (float)sz) - 1.0f;
|
||||
v = 2.0f * (y / (float)sz) - 1.0f;
|
||||
for (x = 0; x < sz; ++x) {
|
||||
u = 2.f * (x / (float)sz) - 1.0f;
|
||||
u = 2.0f * (x / (float)sz) - 1.0f;
|
||||
r = (u * u + v * v) * scale;
|
||||
d = -sqrtf(sqrtf(sqrtf(r))) * 9.0f;
|
||||
fcol[0] = expf(d * cs_r), fcol[1] = expf(d * cs_g), fcol[2] = expf(d * cs_b);
|
||||
// linear window good enough here, visual result counts, not scientific analysis
|
||||
//w = (1.f-fabs(u))*(1.f-fabs(v));
|
||||
//w = (1.0f-fabs(u))*(1.0f-fabs(v));
|
||||
// actually, Hanning window is ok, cos^2 for some reason is slower
|
||||
w = (0.5f + 0.5f * cosf(u * (float)M_PI)) * (0.5f + 0.5f * cosf(v * (float)M_PI));
|
||||
mul_v3_fl(fcol, w);
|
||||
|
@ -40,11 +40,11 @@ static float smoothMask(float x, float y)
|
||||
void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
|
||||
{
|
||||
const int qt = 1 << settings->quality;
|
||||
const float s1 = 4.f / (float)qt, s2 = 2.f * s1;
|
||||
const float s1 = 4.0f / (float)qt, s2 = 2.0f * s1;
|
||||
int x, y, n, p, np;
|
||||
fRGB c, tc, cm[64];
|
||||
float sc, isc, u, v, sm, s, t, ofs, scalef[64];
|
||||
const float cmo = 1.f - settings->colmod;
|
||||
const float cmo = 1.0f - settings->colmod;
|
||||
|
||||
MemoryBuffer *gbuf = inputTile->duplicate();
|
||||
MemoryBuffer *tbuf1 = inputTile->duplicate();
|
||||
@ -69,10 +69,10 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
|
||||
for (x = 0; x < (settings->iter * 4); x++) {
|
||||
y = x & 3;
|
||||
cm[x][0] = cm[x][1] = cm[x][2] = 1;
|
||||
if (y == 1) fRGB_rgbmult(cm[x], 1.f, cmo, cmo);
|
||||
if (y == 2) fRGB_rgbmult(cm[x], cmo, cmo, 1.f);
|
||||
if (y == 3) fRGB_rgbmult(cm[x], cmo, 1.f, cmo);
|
||||
scalef[x] = 2.1f * (1.f - (x + ofs) / (float)(settings->iter * 4));
|
||||
if (y == 1) fRGB_rgbmult(cm[x], 1.0f, cmo, cmo);
|
||||
if (y == 2) fRGB_rgbmult(cm[x], cmo, cmo, 1.0f);
|
||||
if (y == 3) fRGB_rgbmult(cm[x], cmo, 1.0f, cmo);
|
||||
scalef[x] = 2.1f * (1.0f - (x + ofs) / (float)(settings->iter * 4));
|
||||
if (x & 1) scalef[x] = -0.99f / scalef[x];
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
|
||||
v = ((float)y + 0.5f) / (float)gbuf->getHeight();
|
||||
for (x = 0; x < gbuf->getWidth(); x++) {
|
||||
u = ((float)x + 0.5f) / (float)gbuf->getWidth();
|
||||
tc[0] = tc[1] = tc[2] = 0.f;
|
||||
tc[0] = tc[1] = tc[2] = 0.0f;
|
||||
for (p = 0; p < 4; p++) {
|
||||
np = (n << 2) + p;
|
||||
s = (u - 0.5f) * scalef[np] + 0.5f;
|
||||
|
@ -40,14 +40,14 @@ void GlareStreaksOperation::generateGlare(float *data, MemoryBuffer *inputTile,
|
||||
tdst->clear();
|
||||
memset(data, 0, size4 * sizeof(float));
|
||||
|
||||
for (a = 0.f; a < DEG2RADF(360.0f) && (!breaked); a += ang) {
|
||||
for (a = 0.0f; a < DEG2RADF(360.0f) && (!breaked); a += ang) {
|
||||
const float an = a + settings->angle_ofs;
|
||||
const float vx = cos((double)an), vy = sin((double)an);
|
||||
for (n = 0; n < settings->iter && (!breaked); ++n) {
|
||||
const float p4 = pow(4.0, (double)n);
|
||||
const float vxp = vx * p4, vyp = vy * p4;
|
||||
const float wt = pow((double)settings->fade, (double)p4);
|
||||
const float cmo = 1.f - (float)pow((double)settings->colmod, (double)n + 1); // colormodulation amount relative to current pass
|
||||
const float cmo = 1.0f - (float)pow((double)settings->colmod, (double)n + 1); // colormodulation amount relative to current pass
|
||||
float *tdstcol = tdst->getBuffer();
|
||||
for (y = 0; y < tsrc->getHeight() && (!breaked); ++y) {
|
||||
for (x = 0; x < tsrc->getWidth(); ++x, tdstcol += 4) {
|
||||
@ -55,8 +55,8 @@ void GlareStreaksOperation::generateGlare(float *data, MemoryBuffer *inputTile,
|
||||
// otherwise results in uneven brightness, only need once
|
||||
if (n == 0) tsrc->read(c1, x, y); else c1[0] = c1[1] = c1[2] = 0;
|
||||
tsrc->readBilinear(c2, x + vxp, y + vyp);
|
||||
tsrc->readBilinear(c3, x + vxp * 2.f, y + vyp * 2.f);
|
||||
tsrc->readBilinear(c4, x + vxp * 3.f, y + vyp * 3.f);
|
||||
tsrc->readBilinear(c3, x + vxp * 2.0f, y + vyp * 2.0f);
|
||||
tsrc->readBilinear(c4, x + vxp * 3.0f, y + vyp * 3.0f);
|
||||
// modulate color to look vaguely similar to a color spectrum
|
||||
c2[1] *= cmo;
|
||||
c2[2] *= cmo;
|
||||
@ -80,7 +80,7 @@ void GlareStreaksOperation::generateGlare(float *data, MemoryBuffer *inputTile,
|
||||
}
|
||||
|
||||
float *sourcebuffer = tsrc->getBuffer();
|
||||
float factor = 1.f / (float)(6 - settings->iter);
|
||||
float factor = 1.0f / (float)(6 - settings->iter);
|
||||
for (int i = 0; i < size4; i += 4) {
|
||||
madd_v3_v3fl(&data[i], &sourcebuffer[i], factor);
|
||||
data[i + 3] = 1.0f;
|
||||
|
@ -57,11 +57,11 @@ void HueSaturationValueCorrectOperation::executePixelSampled(float output[4], fl
|
||||
|
||||
/* adjust saturation, scaling returned default 0.5 up to 1 */
|
||||
f = curvemapping_evaluateF(this->m_curveMapping, 1, hsv[0]);
|
||||
hsv[1] *= (f * 2.f);
|
||||
hsv[1] *= (f * 2.0f);
|
||||
|
||||
/* adjust value, scaling returned default 0.5 up to 1 */
|
||||
f = curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]);
|
||||
hsv[2] *= (f * 2.f);
|
||||
hsv[2] *= (f * 2.0f);
|
||||
|
||||
hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */
|
||||
CLAMP(hsv[1], 0.0f, 1.0f);
|
||||
|
@ -57,10 +57,10 @@ void LuminanceMatteOperation::executePixelSampled(float output[4], float x, floa
|
||||
|
||||
/* test range */
|
||||
if (inColor[0] > high) {
|
||||
alpha = 1.f;
|
||||
alpha = 1.0f;
|
||||
}
|
||||
else if (inColor[0] < low) {
|
||||
alpha = 0.f;
|
||||
alpha = 0.0f;
|
||||
}
|
||||
else { /*blend */
|
||||
alpha = (inColor[0] - low) / (high - low);
|
||||
|
@ -63,7 +63,7 @@ void MapUVOperation::executePixelSampled(float output[4], float x, float y, Pixe
|
||||
float du = len_v2(deriv[0]);
|
||||
float dv = len_v2(deriv[1]);
|
||||
float factor = 1.0f - threshold * (du / m_inputColorProgram->getWidth() + dv / m_inputColorProgram->getHeight());
|
||||
if (factor < 0.f) alpha = 0.f;
|
||||
if (factor < 0.0f) alpha = 0.0f;
|
||||
else alpha *= factor;
|
||||
|
||||
/* "premul" */
|
||||
|
@ -462,7 +462,7 @@ void MixGlareOperation::executePixelSampled(float output[4], float x, float y, P
|
||||
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
|
||||
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
|
||||
value = inputValue[0];
|
||||
float mf = 2.f - 2.f * fabsf(value - 0.5f);
|
||||
float mf = 2.0f - 2.0f * fabsf(value - 0.5f);
|
||||
|
||||
if (inputColor1[0] < 0.0f) inputColor1[0] = 0.0f;
|
||||
if (inputColor1[1] < 0.0f) inputColor1[1] = 0.0f;
|
||||
|
@ -109,7 +109,7 @@ void *NormalizeOperation::initializeTileData(rcti *rect)
|
||||
|
||||
minmult->x = minv;
|
||||
/* The rare case of flat buffer would cause a divide by 0 */
|
||||
minmult->y = ((maxv != minv) ? 1.0f / (maxv - minv) : 0.f);
|
||||
minmult->y = ((maxv != minv) ? 1.0f / (maxv - minv) : 0.0f);
|
||||
|
||||
this->m_cachedInstance = minmult;
|
||||
}
|
||||
|
@ -52,9 +52,9 @@ void TonemapOperation::executePixel(float output[4], int x, int y, void *data)
|
||||
float dr = output[0] + this->m_data->offset;
|
||||
float dg = output[1] + this->m_data->offset;
|
||||
float db = output[2] + this->m_data->offset;
|
||||
output[0] /= ((dr == 0.f) ? 1.0f : dr);
|
||||
output[1] /= ((dg == 0.f) ? 1.0f : dg);
|
||||
output[2] /= ((db == 0.f) ? 1.0f : db);
|
||||
output[0] /= ((dr == 0.0f) ? 1.0f : dr);
|
||||
output[1] /= ((dg == 0.0f) ? 1.0f : dg);
|
||||
output[2] /= ((db == 0.0f) ? 1.0f : db);
|
||||
const float igm = avg->igm;
|
||||
if (igm != 0.0f) {
|
||||
output[0] = powf(max(output[0], 0.0f), igm);
|
||||
@ -126,7 +126,7 @@ void *TonemapOperation::initializeTileData(rcti *rect)
|
||||
float *bc = buffer;
|
||||
float avl, maxl = -1e10f, minl = 1e10f;
|
||||
const float sc = 1.0f / p;
|
||||
float Lav = 0.f;
|
||||
float Lav = 0.0f;
|
||||
float cav[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
while (p--) {
|
||||
float L = IMB_colormanagement_get_luminance(bc);
|
||||
@ -140,10 +140,10 @@ void *TonemapOperation::initializeTileData(rcti *rect)
|
||||
data->lav = Lav * 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;
|
||||
data->auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.0f;
|
||||
float al = exp((double)avl);
|
||||
data->al = (al == 0.0f) ? 0.0f : (this->m_data->key / al);
|
||||
data->igm = (this->m_data->gamma == 0.f) ? 1 : (1.f / this->m_data->gamma);
|
||||
data->igm = (this->m_data->gamma == 0.0f) ? 1 : (1.0f / this->m_data->gamma);
|
||||
this->m_cachedInstance = data;
|
||||
}
|
||||
unlockMutex();
|
||||
|
Loading…
Reference in New Issue
Block a user