7
但是POW(0,2.0)給出0pow(0,2.2)在hlsl像素着色器中給出1?
似乎任何浮動指數給出1,而整數指數給我使用的DirectX 9 0
和HLSL編譯器 「D3DCompiler_43.dll」。 確認在Nvidia和Ati卡上。
我很困惑! 這是一種已知的行爲或錯誤?
爲了說明效果嘗試以下簡單的測試着色器:
// Test shader demonstrating strange pow behaviour
// when brightness becomes 0 resulting color will jump to white
float4x4 WorldViewProjXf : WorldViewProjection < string UIWidget="None";>;
float Brightness
<
string UIName = "Brightness";
float UIMin = 0;
float UIMax = 1;
> = 0;
struct VS_Input
{
float4 position : POSITION0;
};
struct VS_Output
{
float4 position : POSITION0;
};
VS_Output Vertex_Func(VS_Input in_data)
{
VS_Output outData;
outData.position = mul(in_data.position, WorldViewProjXf);
return outData;
}
float4 Fragment_Func(VS_Output in_data) : COLOR
{
return pow(Brightness, 2.2);
}
technique Main
{
pass p0
{
VertexShader = compile vs_3_0 Vertex_Func();
PixelShader = compile ps_3_0 Fragment_Func();
}
}
可否請你發佈一個鏈接到那些你講的文檔。聽起來比我能在msdn上找到的信息更好。 –
添加參考。第二個參考是「pow」指令,而不是「pow」內部函數。 –
現在我明白了,您正在討論着色器彙編器文檔。不是HLSL,但有一些幫助,因爲有一些額外的信息。它的右邊「pow(abs(Color),Exponent)」和「exp(Exponent * log(Color))」都給出了相同的結果 - 包括零錯誤,不幸的是。那麼,你的答案不完全是一個答案,但只要沒有其他答案,並且你很有幫助,你就會得到答案。 –