开发者

Problem with compiling any HLSL effect

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?


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:

  • http://blog.rthand.com/post/2008/11/12/DirectX-HLSL-compiler-chokes-on-unicode-sources.aspx
  • http://www.gamedev.net/community/forums/topic.asp?topic_id=505884&whichpage=1&#3299434
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜