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.
This commit is contained in:
parent
2d073bbf21
commit
0d57724c64
Notes:
blender-bot
2023-02-14 11:23:57 +01:00
Referenced by issue #38077, Armature, scaling difference between octrahedal and envelope display modes. Referenced by issue #38062, Normalmap Baking- Faces with the same normals produce different RGB values
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue