diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-01-09 02:36:11 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-01-09 02:36:11 +0400 |
commit | 0d57724c644c6a45cf14778c79b5138438d01cd6 (patch) | |
tree | 4540ccf3c84747cfa7416f0ef47f2e466d85573a /source/blender/render | |
parent | 2d073bbf216feece9b23a53919efba282f9e376b (diff) |
Fix T38062: normal map baking gave randomly values 127 or 128 in flat areas.
Due to float precision issues it was basically random which of the two was used,
now it's slightly biased towards 128, which is the convention for flat colors.
The small difference between 127 and 128 could give problems with sharp glossy
shaders where it would be visible as seams.
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/intern/source/bake.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/render/intern/source/bake.c b/source/blender/render/intern/source/bake.c index cf724dbcfea..977c30ff20a 100644 --- a/source/blender/render/intern/source/bake.c +++ b/source/blender/render/intern/source/bake.c @@ -223,10 +223,14 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua * 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. */ - shr.combined[0] = (-nor[0]) / 2.0f + 0.5f; - shr.combined[1] = nor[1] / 2.0f + 0.5f; - shr.combined[2] = nor[2] / 2.0f + 0.5f; + * this negate must be removed. + * + * there is also a small 1e-5f bias for precision issues. otherwise + * we randomly get 127 or 128 for neutral colors. we choose 128 + * because it is the convention flat color. * */ + shr.combined[0] = (-nor[0]) / 2.0f + 0.5f + 1e-5f; + shr.combined[1] = nor[1] / 2.0f + 0.5f + 1e-5f; + shr.combined[2] = nor[2] / 2.0f + 0.5f + 1e-5f; } else if (bs->type == RE_BAKE_TEXTURE) { copy_v3_v3(shr.combined, &shi->r); |