1

我的代码是:

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格式?

4

1 回答 1

3

如果您尝试编译的文件的编码不正确,并且如果您没有使用正确的换行符,则 HLSL 编译器会出现问题。前任:

于 2010-04-30T17:57:06.937 回答