2012-08-05 89 views
0
float4 PixelShaderFunction(float2 TexCoord: TEXCOORD0) : COLOR0 
{ 
float4 color1 = tex2D(inputSampler, TexCoord); 
float numb = TestFunc(5); 
float4 color3 = color1 + numb; 
return color3; 
} 

float TestFunc(float numb) 
{ 

return numb + 1; 
} 

我得到一個錯誤說錯誤x3004:未聲明的標識符 'TestFunc'HLSL功能未被識別?未申報的錯誤

回答

4

要麼宣佈TestFunc()然後在PixelShaderFunction中使用它,或者在它之前完全移動它。碘。E:

float TestFunc(float); 

float PixelShaderFunction() 
{ 
    // ... 
} 

float TestFunc(float n) 
{ 
    // ... 
} 

float TestFunc(float n) 
{ 
    // ... 
} 

float PixelShaderFunction() 
{ 
    // ... 
} 
3

嘗試PixelShaderFunction之前宣佈TestFunc,或轉發聲明它,如果它允許在HLSL:

float TestFunc(float numb);