Open RKGekk opened 7 years ago
if vector mRitemLayer contain more than one renderItem then rayOrigin and rayDir are overwrite with wrong values.
XMMATRIX W = XMLoadFloat4x4(&ri->World); XMMATRIX invWorld = XMMatrixInverse(&XMMatrixDeterminant(W), W); XMMATRIX toLocal = XMMatrixMultiply(invView, invWorld); //multiple times overwrite rayOrigin = XMVector3TransformCoord(rayOrigin, toLocal); rayDir = XMVector3TransformNormal(rayDir, toLocal); rayDir = XMVector3Normalize(rayDir);
fixed version: XMMATRIX W = XMLoadFloat4x4(&ri->World); XMMATRIX invWorld = XMMatrixInverse(&XMMatrixDeterminant(W), W); XMMATRIX toLocal = XMMatrixMultiply(invView, invWorld); XMVECTOR rayOriginLoc = XMVector3TransformCoord(rayOrigin, toLocal); XMVECTOR rayDirLoc = XMVector3TransformNormal(rayDir, toLocal); rayDirLoc = XMVector3Normalize(rayDirLoc);
if vector mRitemLayer contain more than one renderItem then rayOrigin and rayDir are overwrite with wrong values.
XMMATRIX W = XMLoadFloat4x4(&ri->World); XMMATRIX invWorld = XMMatrixInverse(&XMMatrixDeterminant(W), W); XMMATRIX toLocal = XMMatrixMultiply(invView, invWorld); //multiple times overwrite rayOrigin = XMVector3TransformCoord(rayOrigin, toLocal); rayDir = XMVector3TransformNormal(rayDir, toLocal); rayDir = XMVector3Normalize(rayDir);
fixed version: XMMATRIX W = XMLoadFloat4x4(&ri->World); XMMATRIX invWorld = XMMatrixInverse(&XMMatrixDeterminant(W), W); XMMATRIX toLocal = XMMatrixMultiply(invView, invWorld); XMVECTOR rayOriginLoc = XMVector3TransformCoord(rayOrigin, toLocal); XMVECTOR rayDirLoc = XMVector3TransformNormal(rayDir, toLocal); rayDirLoc = XMVector3Normalize(rayDirLoc);