共用方式為


XMVector4Refract 函式 (directxmath.h)

將事件 4D 向量折疊到 4D 標準向量。

語法

XMVECTOR XM_CALLCONV XMVector4Refract(
  [in] FXMVECTOR Incident,
  [in] FXMVECTOR Normal,
  [in] float     RefractionIndex
) noexcept;

參數

[in] Incident

要參考的 4D 事件向量。

[in] Normal

4D 一般向量,以重新參考事件向量。

[in] RefractionIndex

refraction 的索引。 請參閱<備註>。

傳回值

傳回 refracted 事件向量。 如果事件向量與常態之間的 refraction 索引和角度,使得結果為總內部反映,則函式會傳回格式 < 為 0.0f、0.0f、0.0f、0.0f >的向量。

備註

下列虛擬程式代碼示範函式的作業:

XMVECTOR Result;

float t = dot(Incident, Normal);
float r = 1.0f - RefractionIndex * RefractionIndex * (1.0f - t * t);

if (r < 0.0f) // Total internal reflection
{
	Result.x = 0.0f;
	Result.y = 0.0f;
	Result.z = 0.0f;
	Result.w = 0.0f;
}
else
{
	float s = RefractionIndex * t + sqrt(r);
	Result.x = RefractionIndex * Incident.x - s * Normal.x;
	Result.y = RefractionIndex * Incident.y - s * Normal.y;
	Result.z = RefractionIndex * Incident.z - s * Normal.z;
	Result.w = RefractionIndex * Incident.w - s * Normal.w;
}

return Result;

refraction 的索引是包含事件向量之媒體的 refraction 索引與進入之媒體的 refraction 索引 (,其中媒體的 refraction 索引本身是數據清理中光線速度與中光) 速度的比例。

平臺需求

Microsoft Visual Studio 2010 或 Microsoft Visual Studio 2012 與 Windows SDK for Windows 8。 支援 Win32 傳統型應用程式、Windows 市集應用程式和 Windows Phone 8 個應用程式。

規格需求

需求
目標平台 Windows
標頭 directxmath.h (包含 DirectXMath.h)

另請參閱

DirectXMath 連結庫 4D 向量幾何函式

XMVector4RefractV