Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/bake.c
| Show First 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | static void store_bake_pixel(void *handle, int x, int y, float u, float v) | ||||
| copy_v2_fl2(pixel->uv, u, v); | copy_v2_fl2(pixel->uv, u, v); | ||||
| pixel->du_dx = bd->du_dx; | pixel->du_dx = bd->du_dx; | ||||
| pixel->du_dy = bd->du_dy; | pixel->du_dy = bd->du_dy; | ||||
| pixel->dv_dx = bd->dv_dx; | pixel->dv_dx = bd->dv_dx; | ||||
| pixel->dv_dy = bd->dv_dy; | pixel->dv_dy = bd->dv_dy; | ||||
| pixel->object_id = 0; | pixel->object_id = 0; | ||||
| pixel->seed = i; | |||||
| } | } | ||||
| void RE_bake_mask_fill(const BakePixel pixel_array[], const size_t num_pixels, char *mask) | void RE_bake_mask_fill(const BakePixel pixel_array[], const size_t num_pixels, char *mask) | ||||
| { | { | ||||
| size_t i; | size_t i; | ||||
| if (!mask) { | if (!mask) { | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | static bool cast_ray_highpoly(BVHTreeFromMesh *treeData, | ||||
| if (hit_mesh != -1) { | if (hit_mesh != -1) { | ||||
| int primitive_id_high = hits[hit_mesh].index; | int primitive_id_high = hits[hit_mesh].index; | ||||
| TriTessFace *triangle_high = &triangles[hit_mesh][primitive_id_high]; | TriTessFace *triangle_high = &triangles[hit_mesh][primitive_id_high]; | ||||
| BakePixel *pixel_low = &pixel_array_low[pixel_id]; | BakePixel *pixel_low = &pixel_array_low[pixel_id]; | ||||
| BakePixel *pixel_high = &pixel_array[pixel_id]; | BakePixel *pixel_high = &pixel_array[pixel_id]; | ||||
| pixel_high->primitive_id = primitive_id_high; | pixel_high->primitive_id = primitive_id_high; | ||||
| pixel_high->object_id = hit_mesh; | pixel_high->object_id = hit_mesh; | ||||
| pixel_high->seed = pixel_id; | |||||
| /* ray direction in high poly object space */ | /* ray direction in high poly object space */ | ||||
| float dir_high[3]; | float dir_high[3]; | ||||
| mul_v3_mat3_m4v3(dir_high, highpoly[hit_mesh].imat, dir); | mul_v3_mat3_m4v3(dir_high, highpoly[hit_mesh].imat, dir); | ||||
| normalize_v3(dir_high); | normalize_v3(dir_high); | ||||
| /* compute position differentials on low poly object */ | /* compute position differentials on low poly object */ | ||||
| float duco_low[3], dvco_low[3], dxco[3], dyco[3]; | float duco_low[3], dvco_low[3], dxco[3], dyco[3]; | ||||
| Show All 35 Lines | if (hit_mesh != -1) { | ||||
| /* verify we have valid uvs */ | /* verify we have valid uvs */ | ||||
| BLI_assert(pixel_high->uv[0] >= -1e-3f && pixel_high->uv[1] >= -1e-3f && | BLI_assert(pixel_high->uv[0] >= -1e-3f && pixel_high->uv[1] >= -1e-3f && | ||||
| pixel_high->uv[0] + pixel_high->uv[1] <= 1.0f + 1e-3f); | pixel_high->uv[0] + pixel_high->uv[1] <= 1.0f + 1e-3f); | ||||
| } | } | ||||
| else { | else { | ||||
| pixel_array[pixel_id].primitive_id = -1; | pixel_array[pixel_id].primitive_id = -1; | ||||
| pixel_array[pixel_id].object_id = -1; | pixel_array[pixel_id].object_id = -1; | ||||
| pixel_array[pixel_id].seed = 0; | |||||
| } | } | ||||
| MEM_freeN(hits); | MEM_freeN(hits); | ||||
| return hit_mesh != -1; | return hit_mesh != -1; | ||||
| } | } | ||||
| /** | /** | ||||
| * This function populates an array of verts for the triangles of a mesh | * This function populates an array of verts for the triangles of a mesh | ||||
| ▲ Show 20 Lines • Show All 626 Lines • Show Last 20 Lines | |||||