MDX C# Shaders

Started by
0 comments, last by remigius 17 years, 10 months ago
Hey was reading around and a bunch of people are saying to stay away from fixed function pipeline when learning directX now because it isn't going to be in directX. So I thought I would try and learn shaders. Currently all I know about directX is how to create a device and draw a triangle. MDXInfo has a lot of tutorials on HLSL shaders, but it only teaches you how to create the shader file. What I want to know is how do you load the shader file into directX in C#?
Advertisement
Our tutorials use the DirectX Effects framework for that. If you check out the 1st HLSL tutorial, you'll find the shader loading code in the Engine.cs file. On line 44 of this class (VS2003 project) you'll find the following line:

effect = Effect.FromFile(renderer.Device, "Resources/shaders/diffuse.fx", null,          null, ShaderFlags.PartialPrecision, null);

That's really all there is to loading shaders in Direct3D. This line will load the specified shader and compile it for use on your device. You can find more information on this method and it's parameters and overloads in the SDK documentation.

Hope this answers your question.
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!

This topic is closed to new replies.

Advertisement