From 9622dace3e23a8eddaa0c443030120072a4a6482 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 20 Jun 2022 17:10:27 +0200 Subject: Cleanup: removed unused Blender Internal bump/normal mapping texture code The TexResult.nor output does not appear to be used anywhere. --- source/blender/render/intern/texture_image.c | 308 +++------------- source/blender/render/intern/texture_procedural.c | 414 +--------------------- 2 files changed, 54 insertions(+), 668 deletions(-) (limited to 'source/blender/render/intern') diff --git a/source/blender/render/intern/texture_image.c b/source/blender/render/intern/texture_image.c index 3b1eb293a3a..7da9e7c3d58 100644 --- a/source/blender/render/intern/texture_image.c +++ b/source/blender/render/intern/texture_image.c @@ -88,14 +88,13 @@ int imagewrap(Tex *tex, struct ImagePool *pool, const bool skip_load_image) { - float fx, fy, val1, val2, val3; + float fx, fy; int x, y, retval; int xi, yi; /* original values */ 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; + retval = TEX_RGB; /* quick tests */ if (ima == NULL) { @@ -256,47 +255,6 @@ int imagewrap(Tex *tex, ibuf_get_color(texres->trgba, ibuf, x, y); } - if (texres->nor) { - if (tex->imaflag & TEX_NORMALMAP) { - /* Normal from color: - * The invert of the red channel is to make - * the normal map compliant with the outside world. - * 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->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->trgba[0] + texres->trgba[1] + texres->trgba[2]; - - if (x < ibuf->x - 1) { - float col[4]; - ibuf_get_color(col, ibuf, x + 1, y); - val2 = (col[0] + col[1] + col[2]); - } - else { - val2 = val1; - } - - if (y < ibuf->y - 1) { - float col[4]; - ibuf_get_color(col, ibuf, x, y + 1); - val3 = (col[0] + col[1] + col[2]); - } - else { - val3 = val1; - } - - /* do not mix up x and y here! */ - texres->nor[0] = (val1 - val2); - texres->nor[1] = (val1 - val3); - } - } - if (texres->talpha) { texres->tin = texres->trgba[3]; } @@ -989,7 +947,7 @@ static int imagewraposa_aniso(Tex *tex, { TexResult texr; float fx, fy, minx, maxx, miny, maxy; - float maxd, val1, val2, val3; + float maxd; int curmap, retval, intpol, extflag = 0; afdata_t AFD; @@ -1008,8 +966,7 @@ static int imagewraposa_aniso(Tex *tex, 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; + retval = TEX_RGB; /* quick tests */ if (ibuf == NULL && ima == NULL) { @@ -1040,7 +997,7 @@ static int imagewraposa_aniso(Tex *tex, if (ima) { if ((tex->imaflag & TEX_USEALPHA) && (ima->alpha_mode != IMA_ALPHA_IGNORE)) { if ((tex->imaflag & TEX_CALCALPHA) == 0) { - texres->talpha = 1; + texres->talpha = true; } } } @@ -1301,48 +1258,17 @@ static int imagewraposa_aniso(Tex *tex, } /* filter functions take care of interpolation themselves, no need to modify dxt/dyt here */ - - if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) { - /* color & normal */ - filterfunc(texres, curibuf, fx, fy, &AFD); - val1 = texres->trgba[0] + texres->trgba[1] + texres->trgba[2]; - filterfunc(&texr, curibuf, fx + dxt[0], fy + dxt[1], &AFD); - val2 = texr.trgba[0] + texr.trgba[1] + texr.trgba[2]; - filterfunc(&texr, curibuf, fx + dyt[0], fy + dyt[1], &AFD); - 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->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.trgba[0] + texr.trgba[1] + texr.trgba[2]) - val1); - filterfunc(&texr, previbuf, fx + dxt[0], fy + dxt[1], &AFD); - 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.trgba[0] + texr.trgba[1] + texr.trgba[2]) - val3); - texres->nor[0] = val1 - val2; /* vals have been interpolated above! */ - texres->nor[1] = val1 - val3; - } + filterfunc(texres, curibuf, fx, fy, &AFD); + if (previbuf != curibuf) { /* interpolate */ + filterfunc(&texr, previbuf, fx, fy, &AFD); + 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]); } - else { /* color */ - filterfunc(texres, curibuf, fx, fy, &AFD); - if (previbuf != curibuf) { /* interpolate */ - filterfunc(&texr, previbuf, fx, fy, &AFD); - 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) { - alpha_clip_aniso(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, extflag, texres); - } + if (tex->texfilter != TXF_EWA) { + alpha_clip_aniso(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, extflag, texres); } } else { /* no mipmap */ @@ -1372,23 +1298,9 @@ static int imagewraposa_aniso(Tex *tex, AFD.dusc = 1.0f / ff; AFD.dvsc = ff / (float)ibuf->y; } - if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) { - /* color & normal */ - filterfunc(texres, ibuf, fx, fy, &AFD); - val1 = texres->trgba[0] + texres->trgba[1] + texres->trgba[2]; - filterfunc(&texr, ibuf, fx + dxt[0], fy + dxt[1], &AFD); - val2 = texr.trgba[0] + texr.trgba[1] + texr.trgba[2]; - filterfunc(&texr, ibuf, fx + dyt[0], fy + dyt[1], &AFD); - 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; - } - else { - filterfunc(texres, ibuf, fx, fy, &AFD); - if (tex->texfilter != TXF_EWA) { - alpha_clip_aniso(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, extflag, texres); - } + filterfunc(texres, ibuf, fx, fy, &AFD); + if (tex->texfilter != TXF_EWA) { + alpha_clip_aniso(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, extflag, texres); } } @@ -1403,18 +1315,6 @@ static int imagewraposa_aniso(Tex *tex, texres->trgba[3] = 1.0f - texres->trgba[3]; } - if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */ - /* The invert of the red channel is to make - * the normal map compliant with the outside world. - * 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->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() * TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode, * so for now commented out also disabled in imagewraposa() @@ -1451,7 +1351,7 @@ int imagewraposa(Tex *tex, { TexResult texr; float fx, fy, minx, maxx, miny, maxy, dx, dy, dxt[2], dyt[2]; - float maxd, pixsize, val1, val2, val3; + float maxd, pixsize; int curmap, retval, imaprepeat, imapextend; /* TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa() @@ -1466,8 +1366,7 @@ int imagewraposa(Tex *tex, 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; + retval = TEX_RGB; /* quick tests */ if (ibuf == NULL && ima == NULL) { @@ -1762,118 +1661,30 @@ int imagewraposa(Tex *tex, } } - if (texres->nor && (tex->imaflag & TEX_NORMALMAP) == 0) { - /* a bit extra filter */ - // minx*= 1.35f; - // miny*= 1.35f; - - boxsample( - curibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend); - val1 = texres->trgba[0] + texres->trgba[1] + texres->trgba[2]; - boxsample(curibuf, - fx - minx + dxt[0], - fy - miny + dxt[1], - fx + minx + dxt[0], - fy + miny + dxt[1], - &texr, - imaprepeat, - imapextend); - val2 = texr.trgba[0] + texr.trgba[1] + texr.trgba[2]; - boxsample(curibuf, - fx - minx + dyt[0], - fy - miny + dyt[1], - fx + minx + dyt[0], - fy + miny + dyt[1], - &texr, - imaprepeat, - imapextend); - 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 */ - - boxsample( - previbuf, fx - minx, fy - miny, fx + minx, fy + miny, &texr, imaprepeat, imapextend); - - /* calc rgb */ - dx = 2.0f * (pixsize - maxd) / pixsize; - if (dx >= 1.0f) { - 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->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.trgba[0] + texr.trgba[1] + texr.trgba[2]); - boxsample(previbuf, - fx - minx + dxt[0], - fy - miny + dxt[1], - fx + minx + dxt[0], - fy + miny + dxt[1], - &texr, - imaprepeat, - imapextend); - val2 = dy * val2 + dx * (texr.trgba[0] + texr.trgba[1] + texr.trgba[2]); - boxsample(previbuf, - fx - minx + dyt[0], - fy - miny + dyt[1], - fx + minx + dyt[0], - fy + miny + dyt[1], - &texr, - imaprepeat, - imapextend); - 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->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; - texres->nor[1] *= bumpscale; - } - else { - maxx = fx + minx; - minx = fx - minx; - maxy = fy + miny; - miny = fy - miny; + maxx = fx + minx; + minx = fx - minx; + maxy = fy + miny; + miny = fy - miny; - boxsample(curibuf, minx, miny, maxx, maxy, texres, imaprepeat, imapextend); + boxsample(curibuf, minx, miny, maxx, maxy, texres, imaprepeat, imapextend); - if (previbuf != curibuf) { /* interpolate */ - boxsample(previbuf, minx, miny, maxx, maxy, &texr, imaprepeat, imapextend); + if (previbuf != curibuf) { /* interpolate */ + boxsample(previbuf, minx, miny, maxx, maxy, &texr, imaprepeat, imapextend); - fx = 2.0f * (pixsize - maxd) / pixsize; + fx = 2.0f * (pixsize - maxd) / pixsize; - if (fx >= 1.0f) { - 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->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]; - } + if (fx >= 1.0f) { + 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->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]; } } } @@ -1889,35 +1700,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->trgba[0] + texres->trgba[1] + texres->trgba[2]; - boxsample(ibuf, - fx - minx + dxt[0], - fy - miny + dxt[1], - fx + minx + dxt[0], - fy + miny + dxt[1], - &texr, - imaprepeat, - imapextend); - val2 = texr.trgba[0] + texr.trgba[1] + texr.trgba[2]; - boxsample(ibuf, - fx - minx + dyt[0], - fy - miny + dyt[1], - fx + minx + dyt[0], - fy + miny + dyt[1], - &texr, - imaprepeat, - imapextend); - 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); - } - else { - boxsample(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend); - } + boxsample(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend); } if (tex->imaflag & TEX_CALCALPHA) { @@ -1932,17 +1715,6 @@ int imagewraposa(Tex *tex, texres->trgba[3] = 1.0f - texres->trgba[3]; } - if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { - /* Normal from color: - * The invert of the red channel is to make the normal map compliant with the outside world. - * 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->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->trgba[3] != 1.0f && texres->trgba[3] > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) { diff --git a/source/blender/render/intern/texture_procedural.c b/source/blender/render/intern/texture_procedural.c index ce58993b7cf..37605236738 100644 --- a/source/blender/render/intern/texture_procedural.c +++ b/source/blender/render/intern/texture_procedural.c @@ -61,34 +61,6 @@ void RE_texture_rng_exit(void) /* ------------------------------------------------------------------------- */ -/* This allows color-banded textures to control normals as well. */ -static void tex_normal_derivate(const Tex *tex, TexResult *texres) -{ - if (tex->flag & TEX_COLORBAND) { - float col[4]; - if (BKE_colorband_evaluate(tex->coba, texres->tin, col)) { - float fac0, fac1, fac2, fac3; - - fac0 = (col[0] + col[1] + col[2]); - BKE_colorband_evaluate(tex->coba, texres->nor[0], col); - fac1 = (col[0] + col[1] + col[2]); - BKE_colorband_evaluate(tex->coba, texres->nor[1], col); - fac2 = (col[0] + col[1] + col[2]); - BKE_colorband_evaluate(tex->coba, texres->nor[2], col); - fac3 = (col[0] + col[1] + col[2]); - - texres->nor[0] = (fac0 - fac1) / 3.0f; - texres->nor[1] = (fac0 - fac2) / 3.0f; - texres->nor[2] = (fac0 - fac3) / 3.0f; - - return; - } - } - texres->nor[0] = texres->tin - texres->nor[0]; - texres->nor[1] = texres->tin - texres->nor[1]; - texres->nor[2] = texres->tin - texres->nor[2]; -} - static int blend(const Tex *tex, const float texvec[3], TexResult *texres) { float x, y, t; @@ -165,37 +137,7 @@ static int clouds(const Tex *tex, const float texvec[3], TexResult *texres) (tex->noisetype != TEX_NOISESOFT), tex->noisebasis); - if (texres->nor != NULL) { - /* calculate bumpnormal */ - texres->nor[0] = BLI_noise_generic_turbulence(tex->noisesize, - texvec[0] + tex->nabla, - texvec[1], - texvec[2], - tex->noisedepth, - (tex->noisetype != TEX_NOISESOFT), - tex->noisebasis); - texres->nor[1] = BLI_noise_generic_turbulence(tex->noisesize, - texvec[0], - texvec[1] + tex->nabla, - texvec[2], - tex->noisedepth, - (tex->noisetype != TEX_NOISESOFT), - tex->noisebasis); - texres->nor[2] = BLI_noise_generic_turbulence(tex->noisesize, - texvec[0], - texvec[1], - texvec[2] + tex->nabla, - tex->noisedepth, - (tex->noisetype != TEX_NOISESOFT), - tex->noisebasis); - - tex_normal_derivate(tex, texres); - rv |= TEX_NOR; - } - 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->trgba[0] = texres->tin; texres->trgba[1] = BLI_noise_generic_turbulence(tex->noisesize, texvec[1], @@ -298,15 +240,6 @@ static int wood(const Tex *tex, const float texvec[3], TexResult *texres) int rv = TEX_INT; texres->tin = wood_int(tex, texvec[0], texvec[1], texvec[2]); - if (texres->nor != NULL) { - /* calculate bumpnormal */ - texres->nor[0] = wood_int(tex, texvec[0] + tex->nabla, texvec[1], texvec[2]); - texres->nor[1] = wood_int(tex, texvec[0], texvec[1] + tex->nabla, texvec[2]); - texres->nor[2] = wood_int(tex, texvec[0], texvec[1], texvec[2] + tex->nabla); - - tex_normal_derivate(tex, texres); - rv |= TEX_NOR; - } BRICONT; @@ -358,17 +291,6 @@ static int marble(const Tex *tex, const float texvec[3], TexResult *texres) texres->tin = marble_int(tex, texvec[0], texvec[1], texvec[2]); - if (texres->nor != NULL) { - /* calculate bumpnormal */ - texres->nor[0] = marble_int(tex, texvec[0] + tex->nabla, texvec[1], texvec[2]); - texres->nor[1] = marble_int(tex, texvec[0], texvec[1] + tex->nabla, texvec[2]); - texres->nor[2] = marble_int(tex, texvec[0], texvec[1], texvec[2] + tex->nabla); - - tex_normal_derivate(tex, texres); - - rv |= TEX_NOR; - } - BRICONT; return rv; @@ -454,7 +376,7 @@ static int magic(const Tex *tex, const float texvec[3], TexResult *texres) /* newnoise: stucci also modified to use different noisebasis */ static int stucci(const Tex *tex, const float texvec[3], TexResult *texres) { - float nor[3], b2, ofs; + float b2, ofs; int retval = TEX_INT; b2 = BLI_noise_generic_noise(tex->noisesize, @@ -469,40 +391,13 @@ static int stucci(const Tex *tex, const float texvec[3], TexResult *texres) if (tex->stype) { ofs *= (b2 * b2); } - nor[0] = BLI_noise_generic_noise(tex->noisesize, - texvec[0] + ofs, - texvec[1], - texvec[2], - (tex->noisetype != TEX_NOISESOFT), - tex->noisebasis); - nor[1] = BLI_noise_generic_noise(tex->noisesize, - texvec[0], - texvec[1] + ofs, - texvec[2], - (tex->noisetype != TEX_NOISESOFT), - tex->noisebasis); - nor[2] = BLI_noise_generic_noise(tex->noisesize, - texvec[0], - texvec[1], - texvec[2] + ofs, - (tex->noisetype != TEX_NOISESOFT), - tex->noisebasis); - - texres->tin = nor[2]; - - if (texres->nor) { - - copy_v3_v3(texres->nor, nor); - tex_normal_derivate(tex, texres); - - if (tex->stype == TEX_WALLOUT) { - texres->nor[0] = -texres->nor[0]; - texres->nor[1] = -texres->nor[1]; - texres->nor[2] = -texres->nor[2]; - } - retval |= TEX_NOR; - } + texres->tin = BLI_noise_generic_noise(tex->noisesize, + texvec[0], + texvec[1], + texvec[2] + ofs, + (tex->noisetype != TEX_NOISESOFT), + tex->noisebasis); if (tex->stype == TEX_WALLOUT) { texres->tin = 1.0f - texres->tin; @@ -538,36 +433,6 @@ static int mg_mFractalOrfBmTex(const Tex *tex, const float texvec[3], TexResult tex->mg_octaves, tex->noisebasis); - if (texres->nor != NULL) { - float ofs = tex->nabla / tex->noisesize; /* also scaling of texvec */ - - /* calculate bumpnormal */ - texres->nor[0] = tex->ns_outscale * mgravefunc(texvec[0] + ofs, - texvec[1], - texvec[2], - tex->mg_H, - tex->mg_lacunarity, - tex->mg_octaves, - tex->noisebasis); - texres->nor[1] = tex->ns_outscale * mgravefunc(texvec[0], - texvec[1] + ofs, - texvec[2], - tex->mg_H, - tex->mg_lacunarity, - tex->mg_octaves, - tex->noisebasis); - texres->nor[2] = tex->ns_outscale * mgravefunc(texvec[0], - texvec[1], - texvec[2] + ofs, - tex->mg_H, - tex->mg_lacunarity, - tex->mg_octaves, - tex->noisebasis); - - tex_normal_derivate(tex, texres); - rv |= TEX_NOR; - } - BRICONT; return rv; @@ -595,42 +460,6 @@ static int mg_ridgedOrHybridMFTex(const Tex *tex, const float texvec[3], TexResu tex->mg_gain, tex->noisebasis); - if (texres->nor != NULL) { - float ofs = tex->nabla / tex->noisesize; /* also scaling of texvec */ - - /* calculate bumpnormal */ - texres->nor[0] = tex->ns_outscale * mgravefunc(texvec[0] + ofs, - texvec[1], - texvec[2], - tex->mg_H, - tex->mg_lacunarity, - tex->mg_octaves, - tex->mg_offset, - tex->mg_gain, - tex->noisebasis); - texres->nor[1] = tex->ns_outscale * mgravefunc(texvec[0], - texvec[1] + ofs, - texvec[2], - tex->mg_H, - tex->mg_lacunarity, - tex->mg_octaves, - tex->mg_offset, - tex->mg_gain, - tex->noisebasis); - texres->nor[2] = tex->ns_outscale * mgravefunc(texvec[0], - texvec[1], - texvec[2] + ofs, - tex->mg_H, - tex->mg_lacunarity, - tex->mg_octaves, - tex->mg_offset, - tex->mg_gain, - tex->noisebasis); - - tex_normal_derivate(tex, texres); - rv |= TEX_NOR; - } - BRICONT; return rv; @@ -649,39 +478,6 @@ static int mg_HTerrainTex(const Tex *tex, const float texvec[3], TexResult *texr tex->mg_offset, tex->noisebasis); - if (texres->nor != NULL) { - float ofs = tex->nabla / tex->noisesize; /* also scaling of texvec */ - - /* calculate bumpnormal */ - texres->nor[0] = tex->ns_outscale * BLI_noise_mg_hetero_terrain(texvec[0] + ofs, - texvec[1], - texvec[2], - tex->mg_H, - tex->mg_lacunarity, - tex->mg_octaves, - tex->mg_offset, - tex->noisebasis); - texres->nor[1] = tex->ns_outscale * BLI_noise_mg_hetero_terrain(texvec[0], - texvec[1] + ofs, - texvec[2], - tex->mg_H, - tex->mg_lacunarity, - tex->mg_octaves, - tex->mg_offset, - tex->noisebasis); - texres->nor[2] = tex->ns_outscale * BLI_noise_mg_hetero_terrain(texvec[0], - texvec[1], - texvec[2] + ofs, - tex->mg_H, - tex->mg_lacunarity, - tex->mg_octaves, - tex->mg_offset, - tex->noisebasis); - - tex_normal_derivate(tex, texres); - rv |= TEX_NOR; - } - BRICONT; return rv; @@ -694,33 +490,6 @@ static int mg_distNoiseTex(const Tex *tex, const float texvec[3], TexResult *tex texres->tin = BLI_noise_mg_variable_lacunarity( texvec[0], texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2); - if (texres->nor != NULL) { - float ofs = tex->nabla / tex->noisesize; /* also scaling of texvec */ - - /* calculate bumpnormal */ - texres->nor[0] = BLI_noise_mg_variable_lacunarity(texvec[0] + ofs, - texvec[1], - texvec[2], - tex->dist_amount, - tex->noisebasis, - tex->noisebasis2); - texres->nor[1] = BLI_noise_mg_variable_lacunarity(texvec[0], - texvec[1] + ofs, - texvec[2], - tex->dist_amount, - tex->noisebasis, - tex->noisebasis2); - texres->nor[2] = BLI_noise_mg_variable_lacunarity(texvec[0], - texvec[1], - texvec[2] + ofs, - tex->dist_amount, - tex->noisebasis, - tex->noisebasis2); - - tex_normal_derivate(tex, texres); - rv |= TEX_NOR; - } - BRICONT; return rv; @@ -788,21 +557,6 @@ static int voronoiTex(const Tex *tex, const float texvec[3], TexResult *texres) } } - if (texres->nor != NULL) { - float ofs = tex->nabla / tex->noisesize; /* also scaling of texvec */ - - /* calculate bumpnormal */ - BLI_noise_voronoi(texvec[0] + ofs, texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm); - texres->nor[0] = sc * fabsf(dot_v4v4(&tex->vn_w1, da)); - BLI_noise_voronoi(texvec[0], texvec[1] + ofs, texvec[2], da, pa, tex->vn_mexp, tex->vn_distm); - texres->nor[1] = sc * fabsf(dot_v4v4(&tex->vn_w1, da)); - BLI_noise_voronoi(texvec[0], texvec[1], texvec[2] + ofs, da, pa, tex->vn_mexp, tex->vn_distm); - texres->nor[2] = sc * fabsf(dot_v4v4(&tex->vn_w1, da)); - - tex_normal_derivate(tex, texres); - rv |= TEX_NOR; - } - if (tex->vn_coltype) { BRICONTRGB; texres->trgba[3] = 1.0; @@ -1148,7 +902,7 @@ static int multitex(Tex *tex, const bool use_nodes) { float tmpvec[3]; - int retval = 0; /* return value, int:0, col:1, nor:2, everything:3 */ + int retval = 0; /* return value, TEX_INT or TEX_RGB. */ texres->talpha = false; /* is set when image texture returns alpha (considered premul) */ @@ -1283,14 +1037,14 @@ static int multitex_nodes_intern(Tex *tex, } if (tex->type == TEX_IMAGE) { - int rgbnor; + int retval; if (mtex) { float texvec_l[3]; copy_v3_v3(texvec_l, texvec); /* we have mtex, use it for 2d mapping images only */ do_2d_mapping(mtex, texvec_l, NULL, dxt, dyt); - rgbnor = multitex(tex, + retval = multitex(tex, texvec_l, dxt, dyt, @@ -1307,7 +1061,7 @@ static int multitex_nodes_intern(Tex *tex, ImBuf *ibuf = BKE_image_pool_acquire_ibuf(tex->ima, &tex->iuser, pool); /* don't linearize float buffers, assumed to be linear */ - if (ibuf != NULL && ibuf->rect_float == NULL && (rgbnor & TEX_RGB) && scene_color_manage) { + if (ibuf != NULL && ibuf->rect_float == NULL && (retval & TEX_RGB) && scene_color_manage) { IMB_colormanagement_colorspace_to_scene_linear_v3(texres->trgba, ibuf->rect_colorspace); } @@ -1335,7 +1089,7 @@ static int multitex_nodes_intern(Tex *tex, } do_2d_mapping(&localmtex, texvec_l, NULL, dxt_l, dyt_l); - rgbnor = multitex(tex, + retval = multitex(tex, texvec_l, dxt_l, dyt_l, @@ -1352,7 +1106,7 @@ static int multitex_nodes_intern(Tex *tex, ImBuf *ibuf = BKE_image_pool_acquire_ibuf(tex->ima, &tex->iuser, pool); /* don't linearize float buffers, assumed to be linear */ - if (ibuf != NULL && ibuf->rect_float == NULL && (rgbnor & TEX_RGB) && scene_color_manage) { + if (ibuf != NULL && ibuf->rect_float == NULL && (retval & TEX_RGB) && scene_color_manage) { IMB_colormanagement_colorspace_to_scene_linear_v3(texres->trgba, ibuf->rect_colorspace); } @@ -1360,7 +1114,7 @@ static int multitex_nodes_intern(Tex *tex, } } - return rgbnor; + return retval; } return multitex(tex, @@ -1456,145 +1210,6 @@ int multitex_ext_safe(Tex *tex, /* ------------------------------------------------------------------------- */ -void texture_rgb_blend( - float in[3], const float tex[3], const float out[3], float fact, float facg, int blendtype) -{ - float facm; - - switch (blendtype) { - case MTEX_BLEND: - fact *= facg; - facm = 1.0f - fact; - - in[0] = (fact * tex[0] + facm * out[0]); - in[1] = (fact * tex[1] + facm * out[1]); - in[2] = (fact * tex[2] + facm * out[2]); - break; - - case MTEX_MUL: - fact *= facg; - facm = 1.0f - fact; - in[0] = (facm + fact * tex[0]) * out[0]; - in[1] = (facm + fact * tex[1]) * out[1]; - in[2] = (facm + fact * tex[2]) * out[2]; - break; - - case MTEX_SCREEN: - fact *= facg; - facm = 1.0f - fact; - in[0] = 1.0f - (facm + fact * (1.0f - tex[0])) * (1.0f - out[0]); - in[1] = 1.0f - (facm + fact * (1.0f - tex[1])) * (1.0f - out[1]); - in[2] = 1.0f - (facm + fact * (1.0f - tex[2])) * (1.0f - out[2]); - break; - - case MTEX_OVERLAY: - fact *= facg; - facm = 1.0f - fact; - - if (out[0] < 0.5f) { - in[0] = out[0] * (facm + 2.0f * fact * tex[0]); - } - else { - in[0] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[0])) * (1.0f - out[0]); - } - if (out[1] < 0.5f) { - in[1] = out[1] * (facm + 2.0f * fact * tex[1]); - } - else { - in[1] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[1])) * (1.0f - out[1]); - } - if (out[2] < 0.5f) { - in[2] = out[2] * (facm + 2.0f * fact * tex[2]); - } - else { - in[2] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[2])) * (1.0f - out[2]); - } - break; - - case MTEX_SUB: - fact = -fact; - ATTR_FALLTHROUGH; - case MTEX_ADD: - fact *= facg; - in[0] = (fact * tex[0] + out[0]); - in[1] = (fact * tex[1] + out[1]); - in[2] = (fact * tex[2] + out[2]); - break; - - case MTEX_DIV: - fact *= facg; - facm = 1.0f - fact; - - if (tex[0] != 0.0f) { - in[0] = facm * out[0] + fact * out[0] / tex[0]; - } - if (tex[1] != 0.0f) { - in[1] = facm * out[1] + fact * out[1] / tex[1]; - } - if (tex[2] != 0.0f) { - in[2] = facm * out[2] + fact * out[2] / tex[2]; - } - - break; - - case MTEX_DIFF: - fact *= facg; - facm = 1.0f - fact; - in[0] = facm * out[0] + fact * fabsf(tex[0] - out[0]); - in[1] = facm * out[1] + fact * fabsf(tex[1] - out[1]); - in[2] = facm * out[2] + fact * fabsf(tex[2] - out[2]); - break; - - case MTEX_DARK: - fact *= facg; - facm = 1.0f - fact; - - in[0] = min_ff(out[0], tex[0]) * fact + out[0] * facm; - in[1] = min_ff(out[1], tex[1]) * fact + out[1] * facm; - in[2] = min_ff(out[2], tex[2]) * fact + out[2] * facm; - break; - - case MTEX_LIGHT: - fact *= facg; - - in[0] = max_ff(fact * tex[0], out[0]); - in[1] = max_ff(fact * tex[1], out[1]); - in[2] = max_ff(fact * tex[2], out[2]); - break; - - case MTEX_BLEND_HUE: - fact *= facg; - copy_v3_v3(in, out); - ramp_blend(MA_RAMP_HUE, in, fact, tex); - break; - case MTEX_BLEND_SAT: - fact *= facg; - copy_v3_v3(in, out); - ramp_blend(MA_RAMP_SAT, in, fact, tex); - break; - case MTEX_BLEND_VAL: - fact *= facg; - copy_v3_v3(in, out); - ramp_blend(MA_RAMP_VAL, in, fact, tex); - break; - case MTEX_BLEND_COLOR: - fact *= facg; - copy_v3_v3(in, out); - ramp_blend(MA_RAMP_COLOR, in, fact, tex); - break; - case MTEX_SOFT_LIGHT: - fact *= facg; - copy_v3_v3(in, out); - ramp_blend(MA_RAMP_SOFT, in, fact, tex); - break; - case MTEX_LIN_LIGHT: - fact *= facg; - copy_v3_v3(in, out); - ramp_blend(MA_RAMP_LINEAR, in, fact, tex); - break; - } -} - float texture_value_blend(float tex, float out, float fact, float facg, int blendtype) { float in = 0.0, facm, col, scf; @@ -1703,7 +1318,6 @@ bool RE_texture_evaluate(const MTex *mtex, if (tex == NULL) { return 0; } - texr.nor = NULL; /* placement */ if (mtex->projx) { -- cgit v1.2.3