Fix T41116: Motion Blur causes random black surfaces on rigged models
Fix T41115: Motion Blur renders Objects Black - But not in Viewport Preview This actually extends previous fix to normals and makes it all much nicer now. Worth doing some intense testing, quick one worked just fine but there always could be some corner cases.
This commit is contained in:
parent
82f16f81fd
commit
eb8f85d8be
Notes:
blender-bot
2023-02-14 10:19:59 +01:00
Referenced by issue #41219, Cycles Fresnel nodes - broken gradients on objects with negative scale (final render only, not viewport) Referenced by issue #41115, Motion Blur renders Objects Black - But not in Viewport Preview Referenced by issue #41116, Motion Blur causes random black surfaces on rigged models
|
@ -127,10 +127,7 @@ ccl_device_inline float3 triangle_normal(KernelGlobals *kg, ShaderData *sd)
|
|||
float3 v2 = float4_to_float3(kernel_tex_fetch(__tri_verts, __float_as_int(tri_vindex.z)));
|
||||
|
||||
/* return normal */
|
||||
if(sd->flag & SD_NEGATIVE_SCALE_APPLIED)
|
||||
return normalize(cross(v2 - v0, v1 - v0));
|
||||
else
|
||||
return normalize(cross(v1 - v0, v2 - v0));
|
||||
return normalize(cross(v1 - v0, v2 - v0));
|
||||
}
|
||||
|
||||
/* point and normal on triangle */
|
||||
|
|
|
@ -593,7 +593,6 @@ enum ShaderDataFlag {
|
|||
SD_HOLDOUT_MASK = 524288, /* holdout for camera rays */
|
||||
SD_OBJECT_MOTION = 1048576, /* has object motion blur */
|
||||
SD_TRANSFORM_APPLIED = 2097152, /* vertices have transform applied */
|
||||
SD_NEGATIVE_SCALE_APPLIED = 4194304, /* vertices have negative scale applied */
|
||||
|
||||
SD_OBJECT_FLAGS = (SD_HOLDOUT_MASK|SD_OBJECT_MOTION|SD_TRANSFORM_APPLIED)
|
||||
};
|
||||
|
|
|
@ -341,6 +341,13 @@ void Mesh::add_vertex_normals()
|
|||
vN[i] = -vN[i];
|
||||
}
|
||||
}
|
||||
else if(flip) {
|
||||
Attribute *attr_vN = attributes.find(ATTR_STD_VERTEX_NORMAL);
|
||||
float3 *vN = attr_vN->data_float3();
|
||||
for(size_t i = 0; i < verts_size; i++) {
|
||||
vN[i] = -vN[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* motion vertex normals */
|
||||
Attribute *attr_mP = attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
|
||||
|
@ -375,6 +382,14 @@ void Mesh::add_vertex_normals()
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(has_motion_blur() && attr_mN && flip) {
|
||||
for(int step = 0; step < motion_steps - 1; step++) {
|
||||
float3 *mN = attr_mN->data_float3() + step*verts.size();
|
||||
for(size_t i = 0; i < verts_size; i++) {
|
||||
mN[i] = -mN[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::pack_normals(Scene *scene, float *tri_shader, float4 *vnormal)
|
||||
|
|
|
@ -449,8 +449,6 @@ void ObjectManager::apply_static_transforms(DeviceScene *dscene, Scene *scene, u
|
|||
}
|
||||
|
||||
object_flag[i] |= SD_TRANSFORM_APPLIED;
|
||||
if(object->mesh->transform_negative_scaled)
|
||||
object_flag[i] |= SD_NEGATIVE_SCALE_APPLIED;
|
||||
}
|
||||
else
|
||||
have_instancing = true;
|
||||
|
|
Loading…
Reference in New Issue