Hi guys,
I'm trying to snap my camera to one pixel increments. I sort of understand it except how to calculate fCascadeBound (see below), I don't know what that is.
I have an ortho projection matrix (XMMatrixOrthographicOffCenterLH) and a view matrix (XMMatrixLookAtLH).
Does anyone know how to do this ?
// The vWorldUnitsPerTexel value is calculated by taking a bound of the view frustum, and dividing by the buffer size.
FLOAT fWorldUnitsPerTexel = fCascadeBound / (float)m_CopyOfCascadeConfig.m_iBufferSize;
vWorldUnitsPerTexel = XMVectorSet(fWorldUnitsPerTexel, fWorldUnitsPerTexel, 0.0f, 0.0f);
// snap the camera to 1 pixel increments
vCameraOrthographicMin /= vWorldUnitsPerTexel;
vCameraOrthographicMin = XMVectorFloor(vCameraOrthographicMin);
vCameraOrthographicMin *= vWorldUnitsPerTexel;
vCameraOrthographicMax /= vWorldUnitsPerTexel;
vCameraOrthographicMax = XMVectorFloor(vCameraOrthographicMax);
vCameraOrthographicMax *= vWorldUnitsPerTexel;
D3DXMatrixOrthoOffCenterLH( &m_matShadowProj[ iCascadeIndex ],
XMVectorGetX( vLightCameraOrthographicMin ),
XMVectorGetX( vLightCameraOrthographicMax ),
XMVectorGetY( vLightCameraOrthographicMin ),
XMVectorGetY( vLightCameraOrthographicMax ),
fNearPlane, fFarPlane );
Thanks.