diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2014-05-21 22:04:59 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2014-05-21 22:10:57 +0400 |
commit | 8d297394ba51246f2db0d503df7f4cae19ca6e92 (patch) | |
tree | 609c409de19c8228541a5fc689a6d95a528317fc /source/blender/editors/object/object_bake_api.c | |
parent | 79fe023ec6a405a5de7bf30195b7ea94938e8a99 (diff) |
Bake API: partial fix T40156 (applyRotation issues)
This fixes most of the cases, the only situation not addressed is when
the highpoly object(s) has non-uniform scale.
mul_transposed_mat3_m4_v3() should take care of non-uniform scales so
I'm a bit confused on why it doesn't work. The lowpoly object can have
any transformation, the only issue is if the highpoly object has
non-uniform scale.
Test file of the remaining issue:
https://developer.blender.org/file/info/PHID-FILE-tpw2xgddyzxtpg3e7xzs/
Reference reading:
http://www.unknownroad.com/rtfm/graphics/rt_normals.html
Diffstat (limited to 'source/blender/editors/object/object_bake_api.c')
-rw-r--r-- | source/blender/editors/object/object_bake_api.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index b344bf36504..8a946e32a0f 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -610,8 +610,9 @@ static int bake( highpoly[i].ob->restrictflag &= ~OB_RESTRICT_RENDER; /* lowpoly to highpoly transformation matrix */ - invert_m4_m4(highpoly[i].mat_lowtohigh, highpoly[i].ob->obmat); - mul_m4_m4m4(highpoly[i].mat_lowtohigh, highpoly[i].mat_lowtohigh, mat_low); + copy_m4_m4(highpoly[i].mat_high, highpoly[i].ob->obmat); + invert_m4_m4(highpoly[i].imat_high, highpoly[i].mat_high); + highpoly[i].scale = mat4_to_scale(highpoly[i].mat_high); i++; } @@ -626,7 +627,7 @@ static int bake( /* populate the pixel arrays with the corresponding face data for each high poly object */ RE_bake_pixels_populate_from_objects( me_low, pixel_array_low, highpoly, tot_highpoly, - num_pixels, cage_extrusion); + num_pixels, cage_extrusion, mat_low); /* the baking itself */ for (i = 0; i < tot_highpoly; i++) { @@ -697,7 +698,7 @@ static int bake( case R_BAKE_SPACE_TANGENT: { if (is_highpoly) { - RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_low, normal_swizzle); + RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_low, normal_swizzle, ob_low->obmat); } else { /* from multiresolution */ @@ -715,7 +716,7 @@ static int bake( me_nores = BKE_mesh_new_from_object(bmain, scene, ob_low, 1, 2, 1, 0); RE_bake_pixels_populate(me_nores, pixel_array_low, num_pixels, &bake_images); - RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_nores, normal_swizzle); + RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_nores, normal_swizzle, ob_low->obmat); BKE_libblock_free(bmain, me_nores); if (md) |