2010-04-30 66 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格式?

回答