diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-05-24 16:14:32 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-05-24 16:38:15 +0300 |
commit | 7a9ad029dd1d1afe42d54c9c181de887636db7c0 (patch) | |
tree | e9281cbe8bb01365a699ffd6f4bbd09a6a91015f /source/blender/render | |
parent | 707340edd703ff1fd7c8157eb3cc811913698c8d (diff) |
Remove TexFace, per-face images
TexFace complicates the now more popular shading pipeline by having
per-face images, see: T51382 for details.
To keep the ability to select a per-material edit-image
(used with UV-mapping workflow), the material now stores an image
which will be set when changing images in edit-mode.
This is used as a bake-target when not using Cycles too.
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/extern/include/RE_multires_bake.h | 6 | ||||
-rw-r--r-- | source/blender/render/intern/source/bake.c | 7 | ||||
-rw-r--r-- | source/blender/render/intern/source/multires_bake.c | 49 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadeinput.c | 45 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadeoutput.c | 17 |
5 files changed, 46 insertions, 78 deletions
diff --git a/source/blender/render/extern/include/RE_multires_bake.h b/source/blender/render/extern/include/RE_multires_bake.h index c1c5fc4a04d..901c1c1d05d 100644 --- a/source/blender/render/extern/include/RE_multires_bake.h +++ b/source/blender/render/extern/include/RE_multires_bake.h @@ -43,6 +43,12 @@ typedef struct MultiresBakeRender { short mode; bool use_lores_mesh; /* Use low-resolution mesh when baking displacement maps */ + /* material aligned image array (for per-face bake image) */ + struct { + Image **array; + int len; + } ob_image; + int number_of_rays; /* Number of rays to be cast when doing AO baking */ float bias; /* Bias between object and start ray point when doing AO baking */ diff --git a/source/blender/render/intern/source/bake.c b/source/blender/render/intern/source/bake.c index 31e461b4536..71a595d6a8b 100644 --- a/source/blender/render/intern/source/bake.c +++ b/source/blender/render/intern/source/bake.c @@ -669,11 +669,12 @@ static int get_next_bake_face(BakeShade *bs) const float disp_solid[4] = {0.5f, 0.5f, 0.5f, 1.0f}; tface = RE_vlakren_get_tface(obr, vlr, obr->bakemtface, NULL, 0); + /* should use 'BKE_object_material_edit_image_get' but in this case simpler not to */ + ima = vlr->mat ? vlr->mat->edit_image : NULL; - if (!tface || !tface->tpage) + if (!tface || !ima) continue; - ima = tface->tpage; ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); if (ibuf == NULL) @@ -814,7 +815,7 @@ static void shade_tface(BakeShade *bs) ObjectInstanceRen *obi = bs->obi; ObjectRen *obr = obi->obr; MTFace *tface = RE_vlakren_get_tface(obr, vlr, obr->bakemtface, NULL, 0); - Image *ima = tface->tpage; + Image *ima = vlr->mat->edit_image; float vec[4][2]; int a, i1, i2, i3; diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c index 7eda0efd692..d00fea88f9e 100644 --- a/source/blender/render/intern/source/multires_bake.c +++ b/source/blender/render/intern/source/multires_bake.c @@ -44,6 +44,7 @@ #include "BKE_ccg.h" #include "BKE_global.h" #include "BKE_image.h" +#include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_multires.h" #include "BKE_modifier.h" @@ -90,6 +91,8 @@ typedef struct { void *bake_data; ImBuf *ibuf; MPassKnownData pass_data; + /* material aligned UV array */ + Image **image_array; } MResolvePixelData; typedef void (*MFlushPixel)(const MResolvePixelData *data, const int x, const int y); @@ -374,13 +377,15 @@ static void *do_multires_bake_thread(void *data_v) while ((tri_index = multires_bake_queue_next_tri(handle->queue)) >= 0) { const MLoopTri *lt = &data->mlooptri[tri_index]; - MTexPoly *mtpoly = &data->mtpoly[lt->poly]; - MLoopUV *mloopuv = data->mloopuv; + const MPoly *mp = &data->mpoly[lt->poly]; + const short mat_nr = mp->mat_nr; + const MLoopUV *mloopuv = data->mloopuv; if (multiresbake_test_break(bkr)) break; - if (mtpoly->tpage != handle->image) + Image *tri_image = mat_nr < bkr->ob_image.len ? bkr->ob_image.array[mat_nr] : NULL; + if (tri_image != handle->image) continue; data->tri_index = tri_index; @@ -1179,30 +1184,34 @@ static void apply_ao_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, void static void count_images(MultiresBakeRender *bkr) { - int a, totpoly; - DerivedMesh *dm = bkr->lores_dm; - MTexPoly *mtexpoly = CustomData_get_layer(&dm->polyData, CD_MTEXPOLY); - BLI_listbase_clear(&bkr->image); bkr->tot_image = 0; - totpoly = dm->getNumPolys(dm); - - for (a = 0; a < totpoly; a++) - mtexpoly[a].tpage->id.tag &= ~LIB_TAG_DOIT; + for (int i = 0; i < bkr->ob_image.len; i++) { + Image *ima = bkr->ob_image.array[i]; + if (ima) { + ima->id.tag &= ~LIB_TAG_DOIT; + } + } - for (a = 0; a < totpoly; a++) { - Image *ima = mtexpoly[a].tpage; - if ((ima->id.tag & LIB_TAG_DOIT) == 0) { - LinkData *data = BLI_genericNodeN(ima); - BLI_addtail(&bkr->image, data); - bkr->tot_image++; - ima->id.tag |= LIB_TAG_DOIT; + for (int i = 0; i < bkr->ob_image.len; i++) { + Image *ima = bkr->ob_image.array[i]; + if (ima) { + if ((ima->id.tag & LIB_TAG_DOIT) == 0) { + LinkData *data = BLI_genericNodeN(ima); + BLI_addtail(&bkr->image, data); + bkr->tot_image++; + ima->id.tag |= LIB_TAG_DOIT; + } } } - for (a = 0; a < totpoly; a++) - mtexpoly[a].tpage->id.tag &= ~LIB_TAG_DOIT; + for (int i = 0; i < bkr->ob_image.len; i++) { + Image *ima = bkr->ob_image.array[i]; + if (ima) { + ima->id.tag &= ~LIB_TAG_DOIT; + } + } } static void bake_images(MultiresBakeRender *bkr, MultiresBakeResult *result) diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 20602314526..597a2338fe7 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -442,7 +442,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } } - if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE))) { + if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL | MA_VERTEXCOLP))) { MCol *mcol; const float *uv; char *name; @@ -504,15 +504,6 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert suv->dyuv[0] = 0.0f; suv->dyuv[1] = 0.0f; } - - if ((mode & MA_FACETEXTURE) && i == obr->actmtface) { - if ((mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) == 0) { - shi->vcol[0] = 1.0f; - shi->vcol[1] = 1.0f; - shi->vcol[2] = 1.0f; - shi->vcol[3] = 1.0f; - } - } } if (shi->totuv == 0) { @@ -521,14 +512,6 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert suv->uv[0] = 0.0f; suv->uv[1] = spoint->strandco; suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */ - - if (mode & MA_FACETEXTURE) { - /* no tface? set at 1.0f */ - shi->vcol[0] = 1.0f; - shi->vcol[1] = 1.0f; - shi->vcol[2] = 1.0f; - shi->vcol[3] = 1.0f; - } } } @@ -570,7 +553,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } if (shi->do_manage) { - if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE)) { + if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) { srgb_to_linearrgb_v3_v3(shi->vcol, shi->vcol); } } @@ -1076,7 +1059,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) } } - if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE)) || (R.flag & R_NEED_VCOL)) { + if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) || (R.flag & R_NEED_VCOL)) { VlakRen *vlr = shi->vlr; MTFace *tface; MCol *mcol; @@ -1231,18 +1214,6 @@ void shade_input_set_shade_texco(ShadeInput *shi) suv->dyuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]); suv->dyuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]); } - - if ((mode & MA_FACETEXTURE) && i == obr->actmtface) { - if (((mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) == 0) && ((R.flag & R_NEED_VCOL) == 0)) { - shi->vcol[0] = 1.0f; - shi->vcol[1] = 1.0f; - shi->vcol[2] = 1.0f; - shi->vcol[3] = 1.0f; - } - if (tface->tpage) { - render_realtime_texture(shi, tface->tpage); - } - } } } @@ -1256,14 +1227,6 @@ void shade_input_set_shade_texco(ShadeInput *shi) suv->uv[0] = 2.0f * (u + .5f); suv->uv[1] = 2.0f * (v + .5f); suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */ - - if (mode & MA_FACETEXTURE) { - /* no tface? set at 1.0f */ - shi->vcol[0] = 1.0f; - shi->vcol[1] = 1.0f; - shi->vcol[2] = 1.0f; - shi->vcol[3] = 1.0f; - } } } @@ -1319,7 +1282,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) * else un-initialized values are used */ if (shi->do_manage) { - if ((mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE)) || (R.flag & R_NEED_VCOL)) { + if ((mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) || (R.flag & R_NEED_VCOL)) { srgb_to_linearrgb_v3_v3(shi->vcol, shi->vcol); } } diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 8dea0930b9e..c5a666d52c9 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -899,14 +899,7 @@ void shade_color(ShadeInput *shi, ShadeResult *shr) { Material *ma= shi->mat; - if (ma->mode & (MA_FACETEXTURE)) { - shi->r= shi->vcol[0]; - shi->g= shi->vcol[1]; - shi->b= shi->vcol[2]; - if (ma->mode & (MA_FACETEXTURE_ALPHA)) - shi->alpha= shi->vcol[3]; - } - else if (ma->mode & (MA_VERTEXCOLP)) { + if (ma->mode & (MA_VERTEXCOLP)) { float neg_alpha = 1.0f - shi->vcol[3]; shi->r= shi->r*neg_alpha + shi->vcol[0]*shi->vcol[3]; shi->g= shi->g*neg_alpha + shi->vcol[1]*shi->vcol[3]; @@ -1764,12 +1757,8 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) /* material color itself */ if (passflag & color_passes) { - if (ma->mode & (MA_FACETEXTURE)) { - shi->r= shi->vcol[0]; - shi->g= shi->vcol[1]; - shi->b= shi->vcol[2]; - if (ma->mode & (MA_FACETEXTURE_ALPHA)) - shi->alpha= shi->vcol[3]; + if (false) { + /* pass */ } #ifdef WITH_FREESTYLE else if (ma->vcol_alpha) { |