编译任何 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格式?
My code is:
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);
and my fx file:
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();
}
}
It so simple it shouldn't cause a problem yet there is such error:
ID3DXEffectCompiler: There were no techniques
ID3DXEffectCompiler: Compilation failed
Where is the error?
There seems to be a problem with something else but i don't know where because other examples don't compile too.
Maybe some invalid char? But where? Or enter should be in unix format?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您尝试编译的文件的编码不正确,或者您没有使用正确的换行符,则 HLSL 编译器会出现问题。例如:
the HLSL compiler has problems if the encoding on the file you're trying to compile is incorrect, and also if you're not using the right new line characters. ex: