Fix T45606: cycles multires tangent space normal map bake issues.
This commit is contained in:
parent
f6f851d28a
commit
3143ec29d0
Notes:
blender-bot
2023-02-14 08:49:49 +01:00
Referenced by issue #45606, Cycles normal map baking issue with subdivided UVs - Margin
|
@ -647,6 +647,9 @@ static int bake(
|
|||
Mesh *me_low = NULL;
|
||||
Mesh *me_cage = NULL;
|
||||
|
||||
MultiresModifierData *mmd_low = NULL;
|
||||
int mmd_flags_low = 0;
|
||||
|
||||
float *result = NULL;
|
||||
|
||||
BakePixel *pixel_array_low = NULL;
|
||||
|
@ -762,6 +765,17 @@ static int bake(
|
|||
pixel_array_high = MEM_mallocN(sizeof(BakePixel) * num_pixels, "bake pixels high poly");
|
||||
result = MEM_callocN(sizeof(float) * depth * num_pixels, "bake return pixels");
|
||||
|
||||
/* for multires bake, use linear UV subdivision to match low res UVs */
|
||||
if (pass_type == SCE_PASS_NORMAL && normal_space == R_BAKE_SPACE_TANGENT && !is_selected_to_active)
|
||||
{
|
||||
mmd_low = (MultiresModifierData *) modifiers_findByType(ob_low, eModifierType_Multires);
|
||||
if (mmd_low)
|
||||
{
|
||||
mmd_flags_low = mmd_low->flags;
|
||||
mmd_low->flags |= eMultiresModifierFlag_PlainUv;
|
||||
}
|
||||
}
|
||||
|
||||
/* get the mesh as it arrives in the renderer */
|
||||
me_low = bake_mesh_new_from_object(bmain, scene, ob_low);
|
||||
|
||||
|
@ -1063,6 +1077,9 @@ cleanup:
|
|||
|
||||
ob_low->restrictflag = restrict_flag_low;
|
||||
|
||||
if (mmd_low)
|
||||
mmd_low->flags = mmd_flags_low;
|
||||
|
||||
if (ob_cage)
|
||||
ob_cage->restrictflag = restrict_flag_cage;
|
||||
|
||||
|
|
|
@ -792,7 +792,10 @@ void RE_bake_normal_world_to_tangent(
|
|||
offset = i * depth;
|
||||
|
||||
if (primitive_id == -1) {
|
||||
copy_v3_fl3(&result[offset], 0.5f, 0.5f, 1.0f);
|
||||
if (depth == 4)
|
||||
copy_v4_fl4(&result[offset], 0.5f, 0.5f, 1.0f, 1.0f);
|
||||
else
|
||||
copy_v3_fl3(&result[offset], 0.5f, 0.5f, 1.0f);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue