我的代码是:
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
错误在哪里? 似乎有其他问题,但我不知道在哪里,因为其他示例也不编译。 也许一些无效的char?但是哪里?或者输入应该是unix格式吗?
答案 0 :(得分:3)
如果您尝试编译的文件上的编码不正确,并且您没有使用正确的新行字符,则HLSL编译器会出现问题。例如: