Cycles: Watertight fix for SSS intersection
Same as previous commit, just was missing in there.
This commit is contained in:
@@ -142,8 +142,8 @@ ccl_device_inline bool triangle_intersect(KernelGlobals *kg,
|
|||||||
float U = Cx * By - Cy * Bx;
|
float U = Cx * By - Cy * Bx;
|
||||||
float V = Ax * Cy - Ay * Cx;
|
float V = Ax * Cy - Ay * Cx;
|
||||||
float W = Bx * Ay - By * Ax;
|
float W = Bx * Ay - By * Ax;
|
||||||
if ((U < 0.0f || V < 0.0f || W < 0.0f) &&
|
if((U < 0.0f || V < 0.0f || W < 0.0f) &&
|
||||||
(U > 0.0f || V > 0.0f || W > 0.0f))
|
(U > 0.0f || V > 0.0f || W > 0.0f))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -242,13 +242,12 @@ ccl_device_inline void triangle_intersect_subsurface(
|
|||||||
|
|
||||||
/* Calculate scaled barycentric coordinates. */
|
/* Calculate scaled barycentric coordinates. */
|
||||||
float U = Cx * By - Cy * Bx;
|
float U = Cx * By - Cy * Bx;
|
||||||
int sign_mask = (__float_as_int(U) & 0x80000000);
|
|
||||||
float V = Ax * Cy - Ay * Cx;
|
float V = Ax * Cy - Ay * Cx;
|
||||||
if(sign_mask != (__float_as_int(V) & 0x80000000)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
float W = Bx * Ay - By * Ax;
|
float W = Bx * Ay - By * Ax;
|
||||||
if(sign_mask != (__float_as_int(W) & 0x80000000)) {
|
|
||||||
|
if((U < 0.0f || V < 0.0f || W < 0.0f) &&
|
||||||
|
(U > 0.0f || V > 0.0f || W > 0.0f))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,10 +260,11 @@ ccl_device_inline void triangle_intersect_subsurface(
|
|||||||
/* Calculate scaled z−coordinates of vertices and use them to calculate
|
/* Calculate scaled z−coordinates of vertices and use them to calculate
|
||||||
* the hit distance.
|
* the hit distance.
|
||||||
*/
|
*/
|
||||||
|
const int sign_det = (__float_as_int(det) & 0x80000000);
|
||||||
const float T = (U * A_kz + V * B_kz + W * C_kz) * Sz;
|
const float T = (U * A_kz + V * B_kz + W * C_kz) * Sz;
|
||||||
const float sign_T = xor_signmask(T, sign_mask);
|
const float sign_T = xor_signmask(T, sign_det);
|
||||||
if((sign_T < 0.0f) ||
|
if((sign_T < 0.0f) ||
|
||||||
(sign_T > tmax * xor_signmask(det, sign_mask)))
|
(sign_T > tmax * xor_signmask(det, sign_det)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user