Sign in to follow this  
hjeldnes

Macros in xna + effects?

Recommended Posts

hjeldnes    122
Hello! I got a small problem with making xna working well with 3dsmax, and getting an easy pipeline from 3dsmax to game. What I would like to do is to use the same .fx shader for 3dsmax and for the game. It basically makes it all easier as I can reference the same shader in 3dsmax, and export using the shader and textures already assigned. So, it saves me work from figuring out how to export different textures from max and so on. Below is an example of how it could work, if "GAME" is true, or defined, then the shader will use COLOR0, if not it means the shader is used in 3dsmax, and TEXCOORD1 is used. This is just a simple example. So, I thought using preprocessor directives (or macros?), and use it like below. struct VertexShaderInput { float4 Position : POSITION0; float2 TexCoord : TEXCOORD0; #ifdef GAME float3 Color : COLOR0; // game is using built in color #else float3 Color : TEXCOORD1; //3dsmax is using texcoords to transfer colors #endif }; However, that did not work. It does not seem like GAME is recognized in the .fx file (it does work within the c# program, just not if used in the .fx file). So, any suggestion to how I can get this to work? I guess in the end it all boils down to me wanting to be able to export multiple textures per face from 3dsmax (diffuse, normal, lightmap, etc..). I have done this using naming conventions and assigning textures during content processor, but it's a bit limiting. And I still want to get it done without too much work. Anyway, any help here would be great! :) Thanks. Kjetil

Share this post


Link to post
Share on other sites
MJP    19789
If you use Effect.CompileEffectFromFile, you can specify an array of preprocessor definitions. This is how you'd have to define your GAME macro, since defining it in your C# code won't affect compilation of your Effect code.

If you're using the Content Pipeline to compile your Effects, you'll have to create a custom Content Processor to do this.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this