theTroll527

It could just be that I am a complete and total idiot but I have been looking for an easy way to draw a 3d model with shader effects (.fx file). I had orignally guessed it would be easy becuase of the Tutorial 1: Displaying a 3D model on the screen, but that uses basic effects, not an effects file. Can someone please show me a simple way of doing this because I am evidently too dumb to figure it out.

I am looking for something like the tutorial draw code...


Re: XNA Framework Drawing a 3d model with shader effects

dczraptor

If you're looking to write shader code, here are two links that might help you:

http://www.riemers.net/eng/Tutorials/XNA/Csharp/series3.php

http://www.mdxinfo.com/tutorials.php view=HLSL%20tutorials (using MDX, but you can adapt to XNA)

If you're looking to just load the effect file, just do effect = contentManager.Load<Effect>("Path\To\Effect"); and set model.Meshes[x].Effects[0] = myCustomEffect;

Or you can process it at buildtime: http://blogs.msdn.com/shawnhar/archive/2006/12/07/rendering-a-model-with-a-custom-effect.aspx






Re: XNA Framework Drawing a 3d model with shader effects

Bill Reiss

Instead of setting effect.World, View, and Projection the way you do with a BasicEffect, you will have to set the parameters in your fx file, something like this:

effect.Parameters["Position"].SetValue(positionMatrix);

where "Position" would be whatever the name that parameter has when it's declared in your fx file.

You will also have to change the foreach loop to loop through Effect objects instead of BasicEffect objects.






Re: XNA Framework Drawing a 3d model with shader effects

evilc

the reimers tutorial mentioned above is pretty awesome, as is this one...

http://www.thehazymind.com/archives/2006/11/tutorial_7_a_mo.htm