From cdcbdf8ce46d14c753d68ee8dfa533c642376805 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 28 Jan 2022 13:28:31 +0100 Subject: Remove compilation warnings TexResult. --- source/blender/render/RE_texture.h | 5 +- source/blender/render/intern/texture_common.h | 38 +-- source/blender/render/intern/texture_image.c | 283 ++++++++++----------- .../blender/render/intern/texture_pointdensity.c | 30 +-- source/blender/render/intern/texture_procedural.c | 100 ++++---- 5 files changed, 222 insertions(+), 234 deletions(-) (limited to 'source/blender/render') diff --git a/source/blender/render/RE_texture.h b/source/blender/render/RE_texture.h index d71c793f300..c6ccc547ff4 100644 --- a/source/blender/render/RE_texture.h +++ b/source/blender/render/RE_texture.h @@ -99,10 +99,11 @@ void RE_point_density_fix_linking(void); /** * Texture evaluation result. - * \note `tr tg tb ta` have to remain in this order for array access. */ typedef struct TexResult { - float tin, tr, tg, tb, ta; + float tin; + float trgba[4]; + /* Is acually a bool true->use alpha, false->set alpha to 1.0. */ int talpha; float *nor; } TexResult; diff --git a/source/blender/render/intern/texture_common.h b/source/blender/render/intern/texture_common.h index 5fc3af6153f..43487439228 100644 --- a/source/blender/render/intern/texture_common.h +++ b/source/blender/render/intern/texture_common.h @@ -40,34 +40,38 @@ extern "C" { ((void)0) #define BRICONTRGB \ - texres->tr = tex->rfac * ((texres->tr - 0.5f) * tex->contrast + tex->bright - 0.5f); \ - texres->tg = tex->gfac * ((texres->tg - 0.5f) * tex->contrast + tex->bright - 0.5f); \ - texres->tb = tex->bfac * ((texres->tb - 0.5f) * tex->contrast + tex->bright - 0.5f); \ + texres->trgba[0] = tex->rfac * \ + ((texres->trgba[0] - 0.5f) * tex->contrast + tex->bright - 0.5f); \ + texres->trgba[1] = tex->gfac * \ + ((texres->trgba[1] - 0.5f) * tex->contrast + tex->bright - 0.5f); \ + texres->trgba[2] = tex->bfac * \ + ((texres->trgba[2] - 0.5f) * tex->contrast + tex->bright - 0.5f); \ if (!(tex->flag & TEX_NO_CLAMP)) { \ - if (texres->tr < 0.0f) { \ - texres->tr = 0.0f; \ + if (texres->trgba[0] < 0.0f) { \ + texres->trgba[0] = 0.0f; \ } \ - if (texres->tg < 0.0f) { \ - texres->tg = 0.0f; \ + if (texres->trgba[1] < 0.0f) { \ + texres->trgba[1] = 0.0f; \ } \ - if (texres->tb < 0.0f) { \ - texres->tb = 0.0f; \ + if (texres->trgba[2] < 0.0f) { \ + texres->trgba[2] = 0.0f; \ } \ } \ if (tex->saturation != 1.0f) { \ float _hsv[3]; \ - rgb_to_hsv(texres->tr, texres->tg, texres->tb, _hsv, _hsv + 1, _hsv + 2); \ + rgb_to_hsv(texres->trgba[0], texres->trgba[1], texres->trgba[2], _hsv, _hsv + 1, _hsv + 2); \ _hsv[1] *= tex->saturation; \ - hsv_to_rgb(_hsv[0], _hsv[1], _hsv[2], &texres->tr, &texres->tg, &texres->tb); \ + hsv_to_rgb( \ + _hsv[0], _hsv[1], _hsv[2], &texres->trgba[0], &texres->trgba[1], &texres->trgba[2]); \ if ((tex->saturation > 1.0f) && !(tex->flag & TEX_NO_CLAMP)) { \ - if (texres->tr < 0.0f) { \ - texres->tr = 0.0f; \ + if (texres->trgba[0] < 0.0f) { \ + texres->trgba[0] = 0.0f; \ } \ - if (texres->tg < 0.0f) { \ - texres->tg = 0.0f; \ + if (texres->trgba[1] < 0.0f) { \ + texres->trgba[1] = 0.0f; \ } \ - if (texres->tb < 0.0f) { \ - texres->tb = 0.0f; \ + if (texres->trgba[2] < 0.0f) { \ + texres->trgba[2] = 0.0f; \ } \ } \ } \ diff --git a/source/blender/render/intern/texture_image.c b/source/blender/render/intern/texture_image.c index 6ded799b773..914fc22ecaf 100644 --- a/source/blender/render/intern/texture_image.c +++ b/source/blender/render/intern/texture_image.c @@ -108,7 +108,7 @@ int imagewrap(Tex *tex, int x, y, retval; int xi, yi; /* original values */ - texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.0f; + texres->tin = texres->trgba[3] = texres->trgba[0] = texres->trgba[1] = texres->trgba[2] = 0.0f; /* we need to set retval OK, otherwise texture code generates normals itself... */ retval = texres->nor ? (TEX_RGB | TEX_NOR) : TEX_RGB; @@ -269,7 +269,7 @@ int imagewrap(Tex *tex, (tex->extend == TEX_EXTEND)); } else { /* no filtering */ - ibuf_get_color(&texres->tr, ibuf, x, y); + ibuf_get_color(texres->trgba, ibuf, x, y); } if (texres->nor) { @@ -281,13 +281,13 @@ int imagewrap(Tex *tex, * the normal used in the renderer points inward. It is generated * this way in calc_vertexnormals(). Should this ever change * this negate must be removed. */ - texres->nor[0] = -2.0f * (texres->tr - 0.5f); - texres->nor[1] = 2.0f * (texres->tg - 0.5f); - texres->nor[2] = 2.0f * (texres->tb - 0.5f); + texres->nor[0] = -2.0f * (texres->trgba[0] - 0.5f); + texres->nor[1] = 2.0f * (texres->trgba[1] - 0.5f); + texres->nor[2] = 2.0f * (texres->trgba[2] - 0.5f); } else { /* bump: take three samples */ - val1 = texres->tr + texres->tg + texres->tb; + val1 = texres->trgba[0] + texres->trgba[1] + texres->trgba[2]; if (x < ibuf->x - 1) { float col[4]; @@ -314,26 +314,26 @@ int imagewrap(Tex *tex, } if (texres->talpha) { - texres->tin = texres->ta; + texres->tin = texres->trgba[3]; } else if (tex->imaflag & TEX_CALCALPHA) { - texres->ta = texres->tin = max_fff(texres->tr, texres->tg, texres->tb); + texres->trgba[3] = texres->tin = max_fff(texres->trgba[0], texres->trgba[1], texres->trgba[2]); } else { - texres->ta = texres->tin = 1.0; + texres->trgba[3] = texres->tin = 1.0; } if (tex->flag & TEX_NEGALPHA) { - texres->ta = 1.0f - texres->ta; + texres->trgba[3] = 1.0f - texres->trgba[3]; } /* de-premul, this is being pre-multiplied in shade_input_do_shade() * do not de-premul for generated alpha, it is already in straight */ - if (texres->ta != 1.0f && texres->ta > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) { - fx = 1.0f / texres->ta; - texres->tr *= fx; - texres->tg *= fx; - texres->tb *= fx; + if (texres->trgba[3] != 1.0f && texres->trgba[3] > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) { + fx = 1.0f / texres->trgba[3]; + texres->trgba[0] *= fx; + texres->trgba[1] *= fx; + texres->trgba[2] *= fx; } if (ima) { @@ -546,10 +546,10 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres) } if (starty == endy && startx == endx) { - ibuf_get_color(&texres->tr, ibuf, startx, starty); + ibuf_get_color(texres->trgba, ibuf, startx, starty); } else { - div = texres->tr = texres->tg = texres->tb = texres->ta = 0.0; + div = texres->trgba[0] = texres->trgba[1] = texres->trgba[2] = texres->trgba[3] = 0.0; for (y = starty; y <= endy; y++) { muly = 1.0; @@ -570,11 +570,7 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres) mulx = muly; ibuf_get_color(col, ibuf, startx, y); - - texres->ta += mulx * col[3]; - texres->tr += mulx * col[0]; - texres->tg += mulx * col[1]; - texres->tb += mulx * col[2]; + madd_v4_v4fl(texres->trgba, col, mulx); div += mulx; } else { @@ -588,19 +584,14 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres) } ibuf_get_color(col, ibuf, x, y); - + /* TODO(jbakker): No need to do manual optimization. Branching is slower than multiplying + * with 1. */ if (mulx == 1.0f) { - texres->ta += col[3]; - texres->tr += col[0]; - texres->tg += col[1]; - texres->tb += col[2]; + add_v4_v4(texres->trgba, col); div += 1.0f; } else { - texres->ta += mulx * col[3]; - texres->tr += mulx * col[0]; - texres->tg += mulx * col[1]; - texres->tb += mulx * col[2]; + madd_v4_v4fl(texres->trgba, col, mulx); div += mulx; } } @@ -609,13 +600,10 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres) if (div != 0.0f) { div = 1.0f / div; - texres->tb *= div; - texres->tg *= div; - texres->tr *= div; - texres->ta *= div; + mul_v4_fl(texres->trgba, div) } else { - texres->tr = texres->tg = texres->tb = texres->ta = 0.0f; + zero_v4(texres->trgba); } } } @@ -663,7 +651,7 @@ static void boxsample(ImBuf *ibuf, alphaclip = clipx_rctf(rf, 0.0, (float)(ibuf->x)); if (alphaclip <= 0.0f) { - texres->tr = texres->tb = texres->tg = texres->ta = 0.0; + texres->trgba[0] = texres->trgba[2] = texres->trgba[1] = texres->trgba[3] = 0.0; return; } } @@ -679,33 +667,33 @@ static void boxsample(ImBuf *ibuf, alphaclip *= clipy_rctf(rf, 0.0, (float)(ibuf->y)); if (alphaclip <= 0.0f) { - texres->tr = texres->tb = texres->tg = texres->ta = 0.0; + texres->trgba[0] = texres->trgba[2] = texres->trgba[1] = texres->trgba[3] = 0.0; return; } } if (count > 1) { - tot = texres->tr = texres->tb = texres->tg = texres->ta = 0.0; + tot = texres->trgba[0] = texres->trgba[2] = texres->trgba[1] = texres->trgba[3] = 0.0; while (count--) { boxsampleclip(ibuf, rf, &texr); opp = square_rctf(rf); tot += opp; - texres->tr += opp * texr.tr; - texres->tg += opp * texr.tg; - texres->tb += opp * texr.tb; + texres->trgba[0] += opp * texr.trgba[0]; + texres->trgba[1] += opp * texr.trgba[1]; + texres->trgba[2] += opp * texr.trgba[2]; if (texres->talpha) { - texres->ta += opp * texr.ta; + texres->trgba[3] += opp * texr.trgba[3]; } rf++; } if (tot != 0.0f) { - texres->tr /= tot; - texres->tg /= tot; - texres->tb /= tot; + texres->trgba[0] /= tot; + texres->trgba[1] /= tot; + texres->trgba[2] /= tot; if (texres->talpha) { - texres->ta /= tot; + texres->trgba[3] /= tot; } } } @@ -714,15 +702,15 @@ static void boxsample(ImBuf *ibuf, } if (texres->talpha == 0) { - texres->ta = 1.0; + texres->trgba[3] = 1.0; } if (alphaclip != 1.0f) { /* premul it all */ - texres->tr *= alphaclip; - texres->tg *= alphaclip; - texres->tb *= alphaclip; - texres->ta *= alphaclip; + texres->trgba[0] *= alphaclip; + texres->trgba[1] *= alphaclip; + texres->trgba[2] *= alphaclip; + texres->trgba[3] *= alphaclip; } } @@ -850,7 +838,7 @@ static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata ysam = CLAMPIS(ysam, minsam, ibuf->y * 2); xsd = 1.0f / xsam; ysd = 1.0f / ysam; - texr->tr = texr->tg = texr->tb = texr->ta = 0.0f; + texr->trgba[0] = texr->trgba[1] = texr->trgba[2] = texr->trgba[3] = 0.0f; for (ys = 0; ys < ysam; ys++) { for (xs = 0; xs < xsam; xs++) { const float su = (xs + ((ys & 1) + 0.5f) * 0.5f) * xsd - 0.5f; @@ -861,18 +849,18 @@ static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata tc, ibuf, pu * ibuf->x, pv * ibuf->y, AFD->intpol, AFD->extflag); clip |= out; cw += out ? 0.0f : 1.0f; - texr->tr += tc[0]; - texr->tg += tc[1]; - texr->tb += tc[2]; - texr->ta += texr->talpha ? tc[3] : 0.0f; + texr->trgba[0] += tc[0]; + texr->trgba[1] += tc[1]; + texr->trgba[2] += tc[2]; + texr->trgba[3] += texr->talpha ? tc[3] : 0.0f; } } xsd *= ysd; - texr->tr *= xsd; - texr->tg *= xsd; - texr->tb *= xsd; - /* clipping can be ignored if alpha used, texr->ta already includes filtered edge */ - texr->ta = texr->talpha ? texr->ta * xsd : (clip ? cw * xsd : 1.0f); + texr->trgba[0] *= xsd; + texr->trgba[1] *= xsd; + texr->trgba[2] *= xsd; + /* clipping can be ignored if alpha used, texr->trgba[3] already includes filtered edge */ + texr->trgba[3] = texr->talpha ? texr->trgba[3] * xsd : (clip ? cw * xsd : 1.0f); } typedef struct ReadEWAData { @@ -901,7 +889,7 @@ static void ewa_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t AFD->dyt, ewa_read_pixel_cb, &data, - &texr->tr); + texr->trgba); } static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD) @@ -919,7 +907,7 @@ static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata /* have to use same scaling for du/dv here as for Ux/Vx/Uy/Vy (*after* D calc.) */ du *= AFD->dusc; dv *= AFD->dvsc; - d = texr->tr = texr->tb = texr->tg = texr->ta = 0.0f; + d = texr->trgba[0] = texr->trgba[2] = texr->trgba[1] = texr->trgba[3] = 0.0f; for (n = -maxn; n <= maxn; n += 2) { float tc[4]; const float hn = n * 0.5f; @@ -934,19 +922,20 @@ static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata tc, ibuf, ibuf->x * u, ibuf->y * v, AFD->intpol, AFD->extflag); /* TXF alpha: `clip |= out;` * TXF alpha: `cw += out ? 0.0f : wt;` */ - texr->tr += tc[0] * wt; - texr->tg += tc[1] * wt; - texr->tb += tc[2] * wt; - texr->ta += texr->talpha ? tc[3] * wt : 0.0f; + texr->trgba[0] += tc[0] * wt; + texr->trgba[1] += tc[1] * wt; + texr->trgba[2] += tc[2] * wt; + texr->trgba[3] += texr->talpha ? tc[3] * wt : 0.0f; d += wt; } d = 1.0f / d; - texr->tr *= d; - texr->tg *= d; - texr->tb *= d; - /* Clipping can be ignored if alpha used, `texr->ta` already includes filtered edge */ - texr->ta = texr->talpha ? texr->ta * d : 1.0f; /* TXF alpha: `(clip ? cw*d : 1.0f);` */ + texr->trgba[0] *= d; + texr->trgba[1] *= d; + texr->trgba[2] *= d; + /* Clipping can be ignored if alpha used, `texr->trgba[3]` already includes filtered edge */ + texr->trgba[3] = texr->talpha ? texr->trgba[3] * d : + 1.0f; /* TXF alpha: `(clip ? cw*d : 1.0f);` */ } #undef EWA_MAXIDX @@ -971,10 +960,10 @@ static void alpha_clip_aniso( if (alphaclip != 1.0f) { /* premul it all */ - texres->tr *= alphaclip; - texres->tg *= alphaclip; - texres->tb *= alphaclip; - texres->ta *= alphaclip; + texres->trgba[0] *= alphaclip; + texres->trgba[1] *= alphaclip; + texres->trgba[2] *= alphaclip; + texres->trgba[3] *= alphaclip; } } } @@ -1033,7 +1022,7 @@ static int imagewraposa_aniso(Tex *tex, filterfunc = area_sample; } - texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.0f; + texres->tin = texres->trgba[3] = texres->trgba[0] = texres->trgba[1] = texres->trgba[2] = 0.0f; /* we need to set retval OK, otherwise texture code generates normals itself... */ retval = texres->nor ? (TEX_RGB | TEX_NOR) : TEX_RGB; @@ -1332,27 +1321,27 @@ static int imagewraposa_aniso(Tex *tex, if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) { /* color & normal */ filterfunc(texres, curibuf, fx, fy, &AFD); - val1 = texres->tr + texres->tg + texres->tb; + val1 = texres->trgba[0] + texres->trgba[1] + texres->trgba[2]; filterfunc(&texr, curibuf, fx + dxt[0], fy + dxt[1], &AFD); - val2 = texr.tr + texr.tg + texr.tb; + val2 = texr.trgba[0] + texr.trgba[1] + texr.trgba[2]; filterfunc(&texr, curibuf, fx + dyt[0], fy + dyt[1], &AFD); - val3 = texr.tr + texr.tg + texr.tb; + val3 = texr.trgba[0] + texr.trgba[1] + texr.trgba[2]; /* don't switch x or y! */ texres->nor[0] = val1 - val2; texres->nor[1] = val1 - val3; if (previbuf != curibuf) { /* interpolate */ filterfunc(&texr, previbuf, fx, fy, &AFD); /* rgb */ - texres->tr += levf * (texr.tr - texres->tr); - texres->tg += levf * (texr.tg - texres->tg); - texres->tb += levf * (texr.tb - texres->tb); - texres->ta += levf * (texr.ta - texres->ta); + texres->trgba[0] += levf * (texr.trgba[0] - texres->trgba[0]); + texres->trgba[1] += levf * (texr.trgba[1] - texres->trgba[1]); + texres->trgba[2] += levf * (texr.trgba[2] - texres->trgba[2]); + texres->trgba[3] += levf * (texr.trgba[3] - texres->trgba[3]); /* normal */ - val1 += levf * ((texr.tr + texr.tg + texr.tb) - val1); + val1 += levf * ((texr.trgba[0] + texr.trgba[1] + texr.trgba[2]) - val1); filterfunc(&texr, previbuf, fx + dxt[0], fy + dxt[1], &AFD); - val2 += levf * ((texr.tr + texr.tg + texr.tb) - val2); + val2 += levf * ((texr.trgba[0] + texr.trgba[1] + texr.trgba[2]) - val2); filterfunc(&texr, previbuf, fx + dyt[0], fy + dyt[1], &AFD); - val3 += levf * ((texr.tr + texr.tg + texr.tb) - val3); + val3 += levf * ((texr.trgba[0] + texr.trgba[1] + texr.trgba[2]) - val3); texres->nor[0] = val1 - val2; /* vals have been interpolated above! */ texres->nor[1] = val1 - val3; } @@ -1361,10 +1350,10 @@ static int imagewraposa_aniso(Tex *tex, filterfunc(texres, curibuf, fx, fy, &AFD); if (previbuf != curibuf) { /* interpolate */ filterfunc(&texr, previbuf, fx, fy, &AFD); - texres->tr += levf * (texr.tr - texres->tr); - texres->tg += levf * (texr.tg - texres->tg); - texres->tb += levf * (texr.tb - texres->tb); - texres->ta += levf * (texr.ta - texres->ta); + texres->trgba[0] += levf * (texr.trgba[0] - texres->trgba[0]); + texres->trgba[1] += levf * (texr.trgba[1] - texres->trgba[1]); + texres->trgba[2] += levf * (texr.trgba[2] - texres->trgba[2]); + texres->trgba[3] += levf * (texr.trgba[3] - texres->trgba[3]); } if (tex->texfilter != TXF_EWA) { @@ -1402,11 +1391,11 @@ static int imagewraposa_aniso(Tex *tex, if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) { /* color & normal */ filterfunc(texres, ibuf, fx, fy, &AFD); - val1 = texres->tr + texres->tg + texres->tb; + val1 = texres->trgba[0] + texres->trgba[1] + texres->trgba[2]; filterfunc(&texr, ibuf, fx + dxt[0], fy + dxt[1], &AFD); - val2 = texr.tr + texr.tg + texr.tb; + val2 = texr.trgba[0] + texr.trgba[1] + texr.trgba[2]; filterfunc(&texr, ibuf, fx + dyt[0], fy + dyt[1], &AFD); - val3 = texr.tr + texr.tg + texr.tb; + val3 = texr.trgba[0] + texr.trgba[1] + texr.trgba[2]; /* don't switch x or y! */ texres->nor[0] = val1 - val2; texres->nor[1] = val1 - val3; @@ -1420,13 +1409,14 @@ static int imagewraposa_aniso(Tex *tex, } if (tex->imaflag & TEX_CALCALPHA) { - texres->ta = texres->tin = texres->ta * max_fff(texres->tr, texres->tg, texres->tb); + texres->trgba[3] = texres->tin = texres->trgba[3] * + max_fff(texres->trgba[0], texres->trgba[1], texres->trgba[2]); } else { - texres->tin = texres->ta; + texres->tin = texres->trgba[3]; } if (tex->flag & TEX_NEGALPHA) { - texres->ta = 1.0f - texres->ta; + texres->trgba[3] = 1.0f - texres->trgba[3]; } if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */ @@ -1436,9 +1426,9 @@ static int imagewraposa_aniso(Tex *tex, * the normal used in the renderer points inward. It is generated * this way in calc_vertexnormals(). Should this ever change * this negate must be removed. */ - texres->nor[0] = -2.0f * (texres->tr - 0.5f); - texres->nor[1] = 2.0f * (texres->tg - 0.5f); - texres->nor[2] = 2.0f * (texres->tb - 0.5f); + texres->nor[0] = -2.0f * (texres->trgba[0] - 0.5f); + texres->nor[1] = 2.0f * (texres->trgba[1] - 0.5f); + texres->nor[2] = 2.0f * (texres->trgba[2] - 0.5f); } /* de-premul, this is being pre-multiplied in shade_input_do_shade() @@ -1449,11 +1439,11 @@ static int imagewraposa_aniso(Tex *tex, /* brecht: tried to fix this, see "TXF alpha" comments */ /* do not de-premul for generated alpha, it is already in straight */ - if (texres->ta != 1.0f && texres->ta > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) { - fx = 1.0f / texres->ta; - texres->tr *= fx; - texres->tg *= fx; - texres->tb *= fx; + if (texres->trgba[3] != 1.0f && texres->trgba[3] > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) { + fx = 1.0f / texres->trgba[3]; + texres->trgba[0] *= fx; + texres->trgba[1] *= fx; + texres->trgba[2] *= fx; } if (ima) { @@ -1490,7 +1480,7 @@ int imagewraposa(Tex *tex, return imagewraposa_aniso(tex, ima, ibuf, texvec, dxt, dyt, texres, pool, skip_load_image); } - texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.0f; + texres->tin = texres->trgba[3] = texres->trgba[0] = texres->trgba[1] = texres->trgba[2] = 0.0f; /* we need to set retval OK, otherwise texture code generates normals itself... */ retval = texres->nor ? (TEX_RGB | TEX_NOR) : TEX_RGB; @@ -1795,7 +1785,7 @@ int imagewraposa(Tex *tex, boxsample( curibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend); - val1 = texres->tr + texres->tg + texres->tb; + val1 = texres->trgba[0] + texres->trgba[1] + texres->trgba[2]; boxsample(curibuf, fx - minx + dxt[0], fy - miny + dxt[1], @@ -1804,7 +1794,7 @@ int imagewraposa(Tex *tex, &texr, imaprepeat, imapextend); - val2 = texr.tr + texr.tg + texr.tb; + val2 = texr.trgba[0] + texr.trgba[1] + texr.trgba[2]; boxsample(curibuf, fx - minx + dyt[0], fy - miny + dyt[1], @@ -1813,7 +1803,7 @@ int imagewraposa(Tex *tex, &texr, imaprepeat, imapextend); - val3 = texr.tr + texr.tg + texr.tb; + val3 = texr.trgba[0] + texr.trgba[1] + texr.trgba[2]; /* don't switch x or y! */ texres->nor[0] = (val1 - val2); @@ -1827,20 +1817,20 @@ int imagewraposa(Tex *tex, /* calc rgb */ dx = 2.0f * (pixsize - maxd) / pixsize; if (dx >= 1.0f) { - texres->ta = texr.ta; - texres->tb = texr.tb; - texres->tg = texr.tg; - texres->tr = texr.tr; + texres->trgba[3] = texr.trgba[3]; + texres->trgba[2] = texr.trgba[2]; + texres->trgba[1] = texr.trgba[1]; + texres->trgba[0] = texr.trgba[0]; } else { dy = 1.0f - dx; - texres->tb = dy * texres->tb + dx * texr.tb; - texres->tg = dy * texres->tg + dx * texr.tg; - texres->tr = dy * texres->tr + dx * texr.tr; - texres->ta = dy * texres->ta + dx * texr.ta; + texres->trgba[2] = dy * texres->trgba[2] + dx * texr.trgba[2]; + texres->trgba[1] = dy * texres->trgba[1] + dx * texr.trgba[1]; + texres->trgba[0] = dy * texres->trgba[0] + dx * texr.trgba[0]; + texres->trgba[3] = dy * texres->trgba[3] + dx * texr.trgba[3]; } - val1 = dy * val1 + dx * (texr.tr + texr.tg + texr.tb); + val1 = dy * val1 + dx * (texr.trgba[0] + texr.trgba[1] + texr.trgba[2]); boxsample(previbuf, fx - minx + dxt[0], fy - miny + dxt[1], @@ -1849,7 +1839,7 @@ int imagewraposa(Tex *tex, &texr, imaprepeat, imapextend); - val2 = dy * val2 + dx * (texr.tr + texr.tg + texr.tb); + val2 = dy * val2 + dx * (texr.trgba[0] + texr.trgba[1] + texr.trgba[2]); boxsample(previbuf, fx - minx + dyt[0], fy - miny + dyt[1], @@ -1858,17 +1848,17 @@ int imagewraposa(Tex *tex, &texr, imaprepeat, imapextend); - val3 = dy * val3 + dx * (texr.tr + texr.tg + texr.tb); + val3 = dy * val3 + dx * (texr.trgba[0] + texr.trgba[1] + texr.trgba[2]); texres->nor[0] = (val1 - val2); /* vals have been interpolated above! */ texres->nor[1] = (val1 - val3); if (dx < 1.0f) { dy = 1.0f - dx; - texres->tb = dy * texres->tb + dx * texr.tb; - texres->tg = dy * texres->tg + dx * texr.tg; - texres->tr = dy * texres->tr + dx * texr.tr; - texres->ta = dy * texres->ta + dx * texr.ta; + texres->trgba[2] = dy * texres->trgba[2] + dx * texr.trgba[2]; + texres->trgba[1] = dy * texres->trgba[1] + dx * texr.trgba[1]; + texres->trgba[0] = dy * texres->trgba[0] + dx * texr.trgba[0]; + texres->trgba[3] = dy * texres->trgba[3] + dx * texr.trgba[3]; } } texres->nor[0] *= bumpscale; @@ -1888,17 +1878,17 @@ int imagewraposa(Tex *tex, fx = 2.0f * (pixsize - maxd) / pixsize; if (fx >= 1.0f) { - texres->ta = texr.ta; - texres->tb = texr.tb; - texres->tg = texr.tg; - texres->tr = texr.tr; + texres->trgba[3] = texr.trgba[3]; + texres->trgba[2] = texr.trgba[2]; + texres->trgba[1] = texr.trgba[1]; + texres->trgba[0] = texr.trgba[0]; } else { fy = 1.0f - fx; - texres->tb = fy * texres->tb + fx * texr.tb; - texres->tg = fy * texres->tg + fx * texr.tg; - texres->tr = fy * texres->tr + fx * texr.tr; - texres->ta = fy * texres->ta + fx * texr.ta; + texres->trgba[2] = fy * texres->trgba[2] + fx * texr.trgba[2]; + texres->trgba[1] = fy * texres->trgba[1] + fx * texr.trgba[1]; + texres->trgba[0] = fy * texres->trgba[0] + fx * texr.trgba[0]; + texres->trgba[3] = fy * texres->trgba[3] + fx * texr.trgba[3]; } } } @@ -1917,7 +1907,7 @@ int imagewraposa(Tex *tex, if (texres->nor && (tex->imaflag & TEX_NORMALMAP) == 0) { boxsample(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend); - val1 = texres->tr + texres->tg + texres->tb; + val1 = texres->trgba[0] + texres->trgba[1] + texres->trgba[2]; boxsample(ibuf, fx - minx + dxt[0], fy - miny + dxt[1], @@ -1926,7 +1916,7 @@ int imagewraposa(Tex *tex, &texr, imaprepeat, imapextend); - val2 = texr.tr + texr.tg + texr.tb; + val2 = texr.trgba[0] + texr.trgba[1] + texr.trgba[2]; boxsample(ibuf, fx - minx + dyt[0], fy - miny + dyt[1], @@ -1935,7 +1925,7 @@ int imagewraposa(Tex *tex, &texr, imaprepeat, imapextend); - val3 = texr.tr + texr.tg + texr.tb; + val3 = texr.trgba[0] + texr.trgba[1] + texr.trgba[2]; /* don't switch x or y! */ texres->nor[0] = (val1 - val2); @@ -1947,14 +1937,15 @@ int imagewraposa(Tex *tex, } if (tex->imaflag & TEX_CALCALPHA) { - texres->ta = texres->tin = texres->ta * max_fff(texres->tr, texres->tg, texres->tb); + texres->trgba[3] = texres->tin = texres->trgba[3] * + max_fff(texres->trgba[0], texres->trgba[1], texres->trgba[2]); } else { - texres->tin = texres->ta; + texres->tin = texres->trgba[3]; } if (tex->flag & TEX_NEGALPHA) { - texres->ta = 1.0f - texres->ta; + texres->trgba[3] = 1.0f - texres->trgba[3]; } if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { @@ -1963,15 +1954,15 @@ int imagewraposa(Tex *tex, * It needs to be done because in Blender the normal used in the renderer points inward. * It is generated this way in #calc_vertexnormals(). * Should this ever change this negate must be removed. */ - texres->nor[0] = -2.0f * (texres->tr - 0.5f); - texres->nor[1] = 2.0f * (texres->tg - 0.5f); - texres->nor[2] = 2.0f * (texres->tb - 0.5f); + texres->nor[0] = -2.0f * (texres->trgba[0] - 0.5f); + texres->nor[1] = 2.0f * (texres->trgba[1] - 0.5f); + texres->nor[2] = 2.0f * (texres->trgba[2] - 0.5f); } /* de-premul, this is being pre-multiplied in shade_input_do_shade() */ /* do not de-premul for generated alpha, it is already in straight */ - if (texres->ta != 1.0f && texres->ta > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) { - mul_v3_fl(&texres->tr, 1.0f / texres->ta); + if (texres->trgba[3] != 1.0f && texres->trgba[3] > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) { + mul_v3_fl(texres->trgba, 1.0f / texres->trgba[3]); } if (ima) { @@ -1996,7 +1987,7 @@ void image_sample( texres.talpha = true; /* boxsample expects to be initialized */ boxsample(ibuf, fx, fy, fx + dx, fy + dy, &texres, 0, 1); - copy_v4_v4(result, &texres.tr); + copy_v4_v4(result, texres.trgba); ima->flag |= IMA_USED_FOR_RENDER; @@ -2020,5 +2011,5 @@ void ibuf_sample(ImBuf *ibuf, float fx, float fy, float dx, float dy, float resu ewa_eval(&texres, ibuf, fx, fy, &AFD); - copy_v4_v4(result, &texres.tr); + copy_v4_v4(result, texres.trgba); } diff --git a/source/blender/render/intern/texture_pointdensity.c b/source/blender/render/intern/texture_pointdensity.c index 683260f86cb..9abaeb3739f 100644 --- a/source/blender/render/intern/texture_pointdensity.c +++ b/source/blender/render/intern/texture_pointdensity.c @@ -687,7 +687,7 @@ static int pointdensity(PointDensity *pd, static void pointdensity_color( PointDensity *pd, TexResult *texres, float age, const float vec[3], const float col[3]) { - texres->tr = texres->tg = texres->tb = texres->ta = 1.0f; + copy_v4_fl(texres->trgba, 1.0f); if (pd->source == TEX_PD_PSYS) { float rgba[4]; @@ -697,9 +697,9 @@ static void pointdensity_color( if (pd->coba) { if (BKE_colorband_evaluate(pd->coba, age, rgba)) { texres->talpha = true; - copy_v3_v3(&texres->tr, rgba); + copy_v3_v3(texres->trgba, rgba); texres->tin *= rgba[3]; - texres->ta = texres->tin; + texres->trgba[3] = texres->tin; } } break; @@ -709,17 +709,17 @@ static void pointdensity_color( if (pd->coba) { if (BKE_colorband_evaluate(pd->coba, speed, rgba)) { texres->talpha = true; - copy_v3_v3(&texres->tr, rgba); + copy_v3_v3(texres->trgba, rgba); texres->tin *= rgba[3]; - texres->ta = texres->tin; + texres->trgba[3] = texres->tin; } } break; } case TEX_PD_COLOR_PARTVEL: texres->talpha = true; - mul_v3_v3fl(&texres->tr, vec, pd->speed_scale); - texres->ta = texres->tin; + mul_v3_v3fl(texres->trgba, vec, pd->speed_scale); + texres->trgba[3] = texres->tin; break; case TEX_PD_COLOR_CONSTANT: default: @@ -732,24 +732,24 @@ static void pointdensity_color( switch (pd->ob_color_source) { case TEX_PD_COLOR_VERTCOL: texres->talpha = true; - copy_v3_v3(&texres->tr, col); - texres->ta = texres->tin; + copy_v3_v3(texres->trgba, col); + texres->trgba[3] = texres->tin; break; case TEX_PD_COLOR_VERTWEIGHT: texres->talpha = true; if (pd->coba && BKE_colorband_evaluate(pd->coba, col[0], rgba)) { - copy_v3_v3(&texres->tr, rgba); + copy_v3_v3(texres->trgba, rgba); texres->tin *= rgba[3]; } else { - copy_v3_v3(&texres->tr, col); + copy_v3_v3(texres->trgba, col); } - texres->ta = texres->tin; + texres->trgba[3] = texres->tin; break; case TEX_PD_COLOR_VERTNOR: texres->talpha = true; - copy_v3_v3(&texres->tr, col); - texres->ta = texres->tin; + copy_v3_v3(texres->trgba, col); + texres->trgba[3] = texres->tin; break; case TEX_PD_COLOR_CONSTANT: default: @@ -915,7 +915,7 @@ static void point_density_sample_func(void *__restrict data_v, pointdensity(pd, texvec, &texres, vec, &age, col); pointdensity_color(pd, &texres, age, vec, col); - copy_v3_v3(&values[index * 4 + 0], &texres.tr); + copy_v3_v3(&values[index * 4 + 0], texres.trgba); values[index * 4 + 3] = texres.tin; } } diff --git a/source/blender/render/intern/texture_procedural.c b/source/blender/render/intern/texture_procedural.c index c894d8d9f48..ee45810f445 100644 --- a/source/blender/render/intern/texture_procedural.c +++ b/source/blender/render/intern/texture_procedural.c @@ -212,23 +212,23 @@ static int clouds(const Tex *tex, const float texvec[3], TexResult *texres) if (tex->stype == TEX_COLOR) { /* in this case, int. value should really be computed from color, * and bumpnormal from that, would be too slow, looks ok as is */ - texres->tr = texres->tin; - texres->tg = BLI_noise_generic_turbulence(tex->noisesize, - texvec[1], - texvec[0], - texvec[2], - tex->noisedepth, - (tex->noisetype != TEX_NOISESOFT), - tex->noisebasis); - texres->tb = BLI_noise_generic_turbulence(tex->noisesize, - texvec[1], - texvec[2], - texvec[0], - tex->noisedepth, - (tex->noisetype != TEX_NOISESOFT), - tex->noisebasis); + texres->trgba[0] = texres->tin; + texres->trgba[1] = BLI_noise_generic_turbulence(tex->noisesize, + texvec[1], + texvec[0], + texvec[2], + tex->noisedepth, + (tex->noisetype != TEX_NOISESOFT), + tex->noisebasis); + texres->trgba[2] = BLI_noise_generic_turbulence(tex->noisesize, + texvec[1], + texvec[2], + texvec[0], + tex->noisedepth, + (tex->noisetype != TEX_NOISESOFT), + tex->noisebasis); BRICONTRGB; - texres->ta = 1.0; + texres->trgba[3] = 1.0; return (rv | TEX_RGB); } @@ -453,14 +453,14 @@ static int magic(const Tex *tex, const float texvec[3], TexResult *texres) y /= turb; z /= turb; } - texres->tr = 0.5f - x; - texres->tg = 0.5f - y; - texres->tb = 0.5f - z; + texres->trgba[0] = 0.5f - x; + texres->trgba[1] = 0.5f - y; + texres->trgba[2] = 0.5f - z; - texres->tin = (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb); + texres->tin = (1.0f / 3.0f) * (texres->trgba[0] + texres->trgba[1] + texres->trgba[2]); BRICONTRGB; - texres->ta = 1.0f; + texres->trgba[3] = 1.0f; return TEX_RGB; } @@ -767,21 +767,21 @@ static int voronoiTex(const Tex *tex, const float texvec[3], TexResult *texres) if (tex->vn_coltype) { float ca[3]; /* cell color */ BLI_noise_cell_v3(pa[0], pa[1], pa[2], ca); - texres->tr = aw1 * ca[0]; - texres->tg = aw1 * ca[1]; - texres->tb = aw1 * ca[2]; + texres->trgba[0] = aw1 * ca[0]; + texres->trgba[1] = aw1 * ca[1]; + texres->trgba[2] = aw1 * ca[2]; BLI_noise_cell_v3(pa[3], pa[4], pa[5], ca); - texres->tr += aw2 * ca[0]; - texres->tg += aw2 * ca[1]; - texres->tb += aw2 * ca[2]; + texres->trgba[0] += aw2 * ca[0]; + texres->trgba[1] += aw2 * ca[1]; + texres->trgba[2] += aw2 * ca[2]; BLI_noise_cell_v3(pa[6], pa[7], pa[8], ca); - texres->tr += aw3 * ca[0]; - texres->tg += aw3 * ca[1]; - texres->tb += aw3 * ca[2]; + texres->trgba[0] += aw3 * ca[0]; + texres->trgba[1] += aw3 * ca[1]; + texres->trgba[2] += aw3 * ca[2]; BLI_noise_cell_v3(pa[9], pa[10], pa[11], ca); - texres->tr += aw4 * ca[0]; - texres->tg += aw4 * ca[1]; - texres->tb += aw4 * ca[2]; + texres->trgba[0] += aw4 * ca[0]; + texres->trgba[1] += aw4 * ca[1]; + texres->trgba[2] += aw4 * ca[2]; if (tex->vn_coltype >= 2) { float t1 = (da[1] - da[0]) * 10; if (t1 > 1) { @@ -793,14 +793,14 @@ static int voronoiTex(const Tex *tex, const float texvec[3], TexResult *texres) else { t1 *= sc; } - texres->tr *= t1; - texres->tg *= t1; - texres->tb *= t1; + texres->trgba[0] *= t1; + texres->trgba[1] *= t1; + texres->trgba[2] *= t1; } else { - texres->tr *= sc; - texres->tg *= sc; - texres->tb *= sc; + texres->trgba[0] *= sc; + texres->trgba[1] *= sc; + texres->trgba[2] *= sc; } } @@ -821,7 +821,7 @@ static int voronoiTex(const Tex *tex, const float texvec[3], TexResult *texres) if (tex->vn_coltype) { BRICONTRGB; - texres->ta = 1.0; + texres->trgba[3] = 1.0; return (rv | TEX_RGB); } @@ -1270,10 +1270,7 @@ static int multitex(Tex *tex, float col[4]; if (BKE_colorband_evaluate(tex->coba, texres->tin, col)) { texres->talpha = true; - texres->tr = col[0]; - texres->tg = col[1]; - texres->tb = col[2]; - texres->ta = col[3]; + copy_v4_v4(texres->trgba, col); retval |= TEX_RGB; } } @@ -1330,7 +1327,7 @@ static int multitex_nodes_intern(Tex *tex, /* don't linearize float buffers, assumed to be linear */ if (ibuf != NULL && ibuf->rect_float == NULL && (rgbnor & TEX_RGB) && scene_color_manage) { - IMB_colormanagement_colorspace_to_scene_linear_v3(&texres->tr, ibuf->rect_colorspace); + IMB_colormanagement_colorspace_to_scene_linear_v3(texres->trgba, ibuf->rect_colorspace); } BKE_image_pool_release_ibuf(tex->ima, ibuf, pool); @@ -1375,7 +1372,7 @@ static int multitex_nodes_intern(Tex *tex, /* don't linearize float buffers, assumed to be linear */ if (ibuf != NULL && ibuf->rect_float == NULL && (rgbnor & TEX_RGB) && scene_color_manage) { - IMB_colormanagement_colorspace_to_scene_linear_v3(&texres->tr, ibuf->rect_colorspace); + IMB_colormanagement_colorspace_to_scene_linear_v3(texres->trgba, ibuf->rect_colorspace); } BKE_image_pool_release_ibuf(tex->ima, ibuf, pool); @@ -1768,19 +1765,14 @@ bool RE_texture_evaluate(const MTex *mtex, true); if (rgb) { - texr.tin = IMB_colormanagement_get_luminance(&texr.tr); + texr.tin = IMB_colormanagement_get_luminance(texr.trgba); } else { - texr.tr = mtex->r; - texr.tg = mtex->g; - texr.tb = mtex->b; + copy_v3_fl3(texr.trgba, mtex->r, mtex->g, mtex->b); } *r_intensity = texr.tin; - r_rgba[0] = texr.tr; - r_rgba[1] = texr.tg; - r_rgba[2] = texr.tb; - r_rgba[3] = texr.ta; + copy_v4_v4(r_rgba, texr.trgba); return (rgb != 0); } -- cgit v1.2.3