XMVector3Unproject()를 사용하여 DirectX11에서 레이 - 캐스팅 카메라를 만들려고합니다. 내 이해에서, 나는 near plane의 픽셀의 (Vector3) 위치를 전달할 것이고, 별도의 호출에서는 far plane의 해당 위치를 전달할 것이다. 그렇다면이 벡터를 빼서 광선의 방향을 얻습니다. 원점은 가까운 평면상의 투영되지 않은 좌표입니다. 여기에 레이의 출처를 계산하는 내 문제는 전달합니다.XMVector3Unproject(), DirectX11에서 사용할 카메라 광선 위치를 계산하는 방법은 무엇입니까?
// assuming screenHeight and screenWidth are the number of pixels.
const uint32_t screenHeight = 768;
const uint32_t screenWidth = 1024;
struct Ray
{
XMFLOAT3 origin;
XMFLOAT3 direction;
};
Ray rays[screenWidth * screenHeight];
for (uint32_t i = 0; i < screenHeight; ++i)
{
for (uint32_t j = 0; j < screenWidth; ++j)
{
// 1. ***calculate and store the current pixel position on the near plane***
// 2. ***calculate the corresponding point on the far plane***
// 3. ***pass both positions separately into XMVector3Unproject() (2 total calls to the function)***
// 4. ***store the returned vectors' difference into rays[i * screenWidth + j].direction***
// 5. ***store the near plane pixel position's returned vector into rays[i * screenWidth + j].origin***
}
}
다행스럽게도 필자는이 문제를 제대로 이해하고있어
예. 레이의 기원이나 정정에 도움이된다면 크게 도움이 될 것입니다.