From 8943dc60ecd5dd556576fc9b3c9de7b0b77a98f7 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sat, 10 May 2014 10:01:51 -0300 Subject: Bake API: selected to active needs differentials or it renders black when bump/displacement (fix T40101) --- source/blender/render/intern/source/bake_api.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source/blender/render') diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/source/bake_api.c index 6bfe356082a..258208eeec6 100644 --- a/source/blender/render/intern/source/bake_api.c +++ b/source/blender/render/intern/source/bake_api.c @@ -215,7 +215,8 @@ static void calc_barycentric_from_point( */ static bool cast_ray_highpoly( BVHTreeFromMesh *treeData, TriTessFace *triangles[], BakeHighPolyData *highpoly, - float const co_low[3], const float dir[3], const int pixel_id, const int tot_highpoly) + float const co_low[3], const float dir[3], const int pixel_id, const int tot_highpoly, + const float du_dx, const float du_dy, const float dv_dx, const float dv_dy) { int i; int primitive_id = -1; @@ -257,6 +258,13 @@ static bool cast_ray_highpoly( calc_barycentric_from_point(triangles[i], hits[i].index, hits[i].co, &primitive_id, uv); highpoly[i].pixel_array[pixel_id].primitive_id = primitive_id; copy_v2_v2(highpoly[i].pixel_array[pixel_id].uv, uv); + + /* the differentials are relative to the UV/image space, so the highpoly differentials + * are the same as the low poly differentials */ + highpoly[i].pixel_array[pixel_id].du_dx = du_dx; + highpoly[i].pixel_array[pixel_id].du_dy = du_dy; + highpoly[i].pixel_array[pixel_id].dv_dx = dv_dx; + highpoly[i].pixel_array[pixel_id].dv_dy = dv_dy; } else { highpoly[i].pixel_array[pixel_id].primitive_id = -1; @@ -421,7 +429,9 @@ void RE_bake_pixels_populate_from_objects( calc_point_from_barycentric(tris_low, primitive_id, u, v, cage_extrusion, co, dir); /* cast ray */ - if (!cast_ray_highpoly(treeData, tris_high, highpoly, co, dir, i, tot_highpoly)) { + if (!cast_ray_highpoly(treeData, tris_high, highpoly, co, dir, i, tot_highpoly, + pixel_array_from[i].du_dx, pixel_array_from[i].du_dy, + pixel_array_from[i].dv_dx, pixel_array_from[i].dv_dy)) { /* if it fails mask out the original pixel array */ pixel_array_from[i].primitive_id = -1; } -- cgit v1.2.3