Fix visible seams on normal map bake due to clear colour being black:

This is a special case, tangent space normal maps should be cleared to
0.5, 0.5, 1.0. This is good practice but there's no reason why not to
automate this (for artists whose bump map fu may be a bit shallow).

Thanks to Morten Mikkelsen for reporting.
This commit is contained in:
2013-02-20 15:06:13 +00:00
parent 7175549de6
commit b9333b304c
2 changed files with 29 additions and 7 deletions

View File

@@ -648,6 +648,8 @@ static int get_next_bake_face(BakeShade *bs)
ImBuf *ibuf = NULL;
const float vec_alpha[4] = {0.0f, 0.0f, 0.0f, 0.0f};
const float vec_solid[4] = {0.0f, 0.0f, 0.0f, 1.0f};
const float nor_alpha[4] = {0.5f, 0.5f, 1.0f, 0.0f};
const float nor_solid[4] = {0.5f, 0.5f, 1.0f, 1.0f};
tface = RE_vlakren_get_tface(obr, vlr, obr->bakemtface, NULL, 0);
@@ -684,9 +686,12 @@ static int get_next_bake_face(BakeShade *bs)
if (ibuf->rect_float)
imb_freerectImBuf(ibuf);
/* clear image */
if (R.r.bake_flag & R_BAKE_CLEAR)
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
if (R.r.bake_flag & R_BAKE_CLEAR) {
if (R.r.bake_mode == RE_BAKE_NORMALS && R.r.bake_normal_space == R_BAKE_SPACE_TANGENT)
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? nor_alpha : nor_solid);
else
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
}
/* might be read by UI to set active image for display */
R.bakebuf = ima;
}