• Advertisement
Sign in to follow this  

MDX: Cant load shaders :(

This topic is 4754 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is really getting on my nerves now. I can't use Shaders in ANYWAY in my own code. I can run the SDK samples but when I try it myself i get an exception. Effect.FromFile always through an "InvalidDataException" so I thought hmmm, ok, i'll try it from a string. Effect.FromString always throughs a DirectXException. Ideas...please....HELP!!! [Edited by - acid2 on February 12, 2005 7:07:57 AM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You might try using fxc.exe (SDK\Utilities\bin\x86\fxc.exe) from the command line and see if your effect compiles properly.

Share this post


Link to post
Share on other sites
The second and third forms of Effect.FromFile have a final parameter 'compilationErrors' that is an out string. Use one of these forms and print the string to see the errors.

Share this post


Link to post
Share on other sites
Try loading your effect file in the EffectEdit tool that comes with the DirectX SDK - that will tell you if there are any errors even though it won't recognize all your annotations and semantics.

Share this post


Link to post
Share on other sites
Well, it now "compiles" the shader, so this line works:

shader = Effect.FromFile(Engine.ActiveEngine.Device, Filename, null,
"", ShaderFlags.None, null, errors);


But, the shader variable is apparently null the line after :\ Any ideas now? I'm losing hair rapidly!

Share this post


Link to post
Share on other sites
Should probably be like this.
string errors;
shader = Effect.FromFile(Engine.ActiveEngine.Device, Filename, null,"", ShaderFlags.None, null, out errors);
if(errors != ""){Console.WriteLine(errors);}

Share this post


Link to post
Share on other sites
No thats not the problem, i have a breakpoint the line after so i can easily check the contents of the errors variable. But why on earth is it returning null?

Share this post


Link to post
Share on other sites
FromFile returns null for me when there is a copmilation error. Make sure your DeviceType is Reference if you are trying to use shaders that you know your hardware does not support.

Share this post


Link to post
Share on other sites

string errors = "";
shader = Effect.FromFile(Engine.ActiveEngine.Device, Filename, null,
"", ShaderFlags.None, null, out errors);
if (errors != string.Empty && errors != null)
Console.WriteLine(errors);
shader.Technique = DefaultTechnique;


That's what I have. The console doesn't have any error messages written to it so surely Effect.FromFile shouldn't be returning null... Am I missing something really simple here, or is something going baddly wrong :
Oh, I also tryed using the reference device - still no luck.

Share this post


Link to post
Share on other sites
Try compiling your fx with 'fxc' as a previous poster suggested.

>fxc /Tfx_2_0 /Cc your.fx

Will print out a code asm listing or any errors. If fxc works fine than it the error is not in your effect, but in the manner you are loading it. I do the same thing in my code regularly and have never had any problems with FromFile. Other things it could be are an inability for the compiler to read the file (permissions, wrong path) or perhaps a bug in the version of MDX you are using (what version?).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement