But pow (0, 2.0) gives 0
It seems that any float metric gives 1, and integer metrics give 0.
I am using DirectX 9 and the hlsl compiler "D3DCompiler_43.dll". It is confirmed that on the cards Nvidia and Ati.
I'm confused! Is this some kind of known behavior or error?
To illustrate the effect, try the following simple test shader:
// 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(); } }
Ole dittmann
source share