depthboundstest11/src/DepthBoundsTest11.cpp
void SetDepthBoundsFromLightRadius(UINT i, XMVECTOR *pViewVec, XMMATRIX *pViewProjection)
{
	XMVECTOR center = XMVectorSet(g_pLightArray[i].vWorldSpacePosition.x, g_pLightArray[i].vWorldSpacePosition.y, g_pLightArray[i].vWorldSpacePosition.z, 1.0);
	XMVECTOR pos, radiusVec;
	XMVECTOR tfmNear, tfmFar;

	// scale the view vector by the radius
	radiusVec = *pViewVec * g_pLightArray[i].fRange;

	// calculate the near z
	pos = center + radiusVec;
	pos = XMVectorSet(XMVectorGetX(pos), XMVectorGetY(pos), XMVectorGetZ(pos), 1.0f);

	// project the near coordinate into screen space
	tfmNear = XMVector4Transform(pos, *pViewProjection);
	float nearBound = XMVectorGetZ(tfmNear) / XMVectorGetW(tfmNear);

	// calculate the far z
	pos = center - radiusVec;
	pos = XMVectorSet(XMVectorGetX(pos), XMVectorGetY(pos), XMVectorGetZ(pos), 1.0f);

	// project the far coordinate into screen space
	tfmFar =  XMVector4Transform(pos, *pViewProjection);
	float farBound =  XMVectorGetZ(tfmFar) / XMVectorGetW(tfmFar);

	// clip values outside the frustum
	nearBound = CLIP(nearBound);
	farBound = CLIP(farBound);

	// set the depth bounds based on the near and far z of the light
	agsDriverExtensionsDX11_SetDepthBounds( g_pAGSContext, true, nearBound, farBound );
}
//--------------------------------------------------------------------------------------
// SetDepthBoundsFromLightRadius 
//
// Calculates the depth bounds in screen space using the world space center and radius
// of the light. It then sets the hardware depth bounds test to this range which causes
// pixels outside the range to be culled.
//
//--------------------------------------------------------------------------------------

SetDepthBoundsFromLightRadius
Calculates the depth bounds in screen space using the world space center and radius
of the light. It then sets the hardware depth bounds test to this range which causes
pixels outside the range to be culled.
SetDepthBoundsFromLightRadius Calculates the depth bounds in screen space using the world space center and radius of the light . It then sets the hardware depth bounds test to this range which causes pixels outside the range to be culled .
void SetDepthBoundsFromLightRadius(UINT i, XMVECTOR *pViewVec, XMMATRIX *pViewProjection)
{
	XMVECTOR center = XMVectorSet(g_pLightArray[i].vWorldSpacePosition.x, g_pLightArray[i].vWorldSpacePosition.y, g_pLightArray[i].vWorldSpacePosition.z, 1.0);
	XMVECTOR pos, radiusVec;
	XMVECTOR tfmNear, tfmFar;
	radiusVec = *pViewVec * g_pLightArray[i].fRange;
	pos = center + radiusVec;
	pos = XMVectorSet(XMVectorGetX(pos), XMVectorGetY(pos), XMVectorGetZ(pos), 1.0f);
	tfmNear = XMVector4Transform(pos, *pViewProjection);
	float nearBound = XMVectorGetZ(tfmNear) / XMVectorGetW(tfmNear);
	pos = center - radiusVec;
	pos = XMVectorSet(XMVectorGetX(pos), XMVectorGetY(pos), XMVectorGetZ(pos), 1.0f);
	tfmFar =  XMVector4Transform(pos, *pViewProjection);
	float farBound =  XMVectorGetZ(tfmFar) / XMVectorGetW(tfmFar);
	nearBound = CLIP(nearBound);
	farBound = CLIP(farBound);
	agsDriverExtensionsDX11_SetDepthBounds( g_pAGSContext, true, nearBound, farBound );
}
void SetDepthBoundsFromLightRadius ( UINT i , XMVECTOR * pViewVec , XMMATRIX * pViewProjection ) { XMVECTOR center = XMVectorSet ( g_pLightArray [ i ] . vWorldSpacePosition . x , g_pLightArray [ i ] . vWorldSpacePosition . y , g_pLightArray [ i ] . vWorldSpacePosition . z , 1.0 ) ; XMVECTOR pos , radiusVec ; XMVECTOR tfmNear , tfmFar ; radiusVec = * pViewVec * g_pLightArray [ i ] . fRange ; pos = center + radiusVec ; pos = XMVectorSet ( XMVectorGetX ( pos ) , XMVectorGetY ( pos ) , XMVectorGetZ ( pos ) , 1.0f ) ; tfmNear = XMVector4Transform ( pos , * pViewProjection ) ; float nearBound = XMVectorGetZ ( tfmNear ) / XMVectorGetW ( tfmNear ) ; pos = center - radiusVec ; pos = XMVectorSet ( XMVectorGetX ( pos ) , XMVectorGetY ( pos ) , XMVectorGetZ ( pos ) , 1.0f ) ; tfmFar = XMVector4Transform ( pos , * pViewProjection ) ; float farBound = XMVectorGetZ ( tfmFar ) / XMVectorGetW ( tfmFar ) ; nearBound = CLIP ( nearBound ) ; farBound = CLIP ( farBound ) ; agsDriverExtensionsDX11_SetDepthBounds ( g_pAGSContext , true , nearBound , farBound ) ; }
SetDepthBoundsFromLightRadius
Calculates the depth bounds in screen space using the world space center and radius
of the light.
SetDepthBoundsFromLightRadius Calculates the depth bounds in screen space using the world space center and radius of the light .
// scale the view vector by the radius
 // calculate the near z
 // project the near coordinate into screen space
 // calculate the far z
 // project the far coordinate into screen space
 // clip values outside the frustum
 // set the depth bounds based on the near and far z of the light
