Extending the Direct X Shader via MaxScript.

Extending the Direct X Shader via MaxScript.

Anonymous
Not applicable
822 Views
3 Replies
Message 1 of 4

Extending the Direct X Shader via MaxScript.

Anonymous
Not applicable
Is there a way to define constants in a MaxScript extension to the direct X material that can be read in the preprocessor? For example, a sample of the shader .fx code goes like this:

#if defined(SHD_BASE)
#define PS_NEEDS_BASE_TEXCOORD
#endif

I could create a series of header files for all the possible shader permutations, but was hoping there might be a way to define a constant that could be read by the preprocessor before the fx file is compiled for rendering. For example, if I could set some sort of "hasDiffuse" constant in the extension to the DX Material that could be read by the preprocessor:

#if hasDiffuse == true
#define SHD_BASE
#endif

Or even better, if there was some way to #define SHD_BASE directly from a MaxScript extension of the DX Material.

Thanks!
0 Likes
823 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
It's not possible to define preprocessors in an FX file from MAXScript. The DirectX Shader Material is limited to the use of an effect. Shader data can be set and get but its code cannot be modified directly.

A solution is to open the FX file with MAXScrit in text mode and modify/create it as needed.
0 Likes
Message 3 of 4

Anonymous
Not applicable
Thanks for the info! I'll work with the fx files and some headers instead.

I was hoping to implement our shader pipeline directly in Max, but I guess that's just not possible. I'll have to create a hacked set of shaders instead.
0 Likes
Message 4 of 4

Anonymous
Not applicable
The C++ SDK is more powerful to do that. DirectX access is easy. I remember some presentations at GDC and Siggraph in 2005 and 2006 that covers these subjects. You can find them on the web (see GDC website or I can send you the files).
0 Likes