2010-04-30 84 views
1

我的代碼是:問題與任何編譯HLSL效果

FileStream fs = new FileStream("ImageProcessing.fx", FileMode.Open,FileAccess.Read); 
     CompiledEffect compiledEffect = Effect.CompileEffectFromFile(fs, null, null, CompilerOptions.None, TargetPlatform.Windows); 
     fs.Close(); 
     effect = new Effect(graphics.GraphicsDevice, compiledEffect.GetEffectCode(), CompilerOptions.None, null); 

和我的FX文件:

float4x4 xViewProjection; 

struct VertexToPixel 
{ 
float4 Position  : POSITION; 
float4 Color  : COLOR0; 
}; 

struct PixelToFrame 
{ 
    float4 Color  : COLOR0; 
}; 

    VertexToPixel SimplestVertexShader(float4 inPos : POSITION, float4 inColor : COLOR0) 
{ 
    VertexToPixel Output = (VertexToPixel)0; 

    Output.Position =mul(inPos, xViewProjection); 

    Output.Color = inColor; 

    return Output; 
} 

PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) 
{ 
    PixelToFrame Output = (PixelToFrame)0;  

    Output.Color = PSIn.Color;  

    return Output; 
} 

technique Simplest 
{ 
    pass Pass 
    { 
     VertexShader = compile vs_2_0 SimplestVertexShader(); 
     PixelShader = compile ps_2_0 OurFirstPixelShader(); 
    } 
} 

它太簡單了,應該不會造成問題尚未有這樣的錯誤:

ID3DXEffectCompiler: There were no techniques 
ID3DXEffectCompiler: Compilation failed 

錯誤在哪裏? 似乎有別的問題,但我不知道在哪裏,因爲其他的例子不能編譯。 也許一些無效的字符?但是哪裏?或者輸入應該是unix格式?

回答