[QUOTE=Kjetil;3738]Hello!
I’m messing around a little with xna and such. Up till now I’ve used a .fx file directly, using the directX material.
It worked fine for simpler materials, and I could assign and preview the shader while modelling. Quite handy. There I could select what uv channel the texture should use. So, quite practical, although the gui was limited.
So, I looked into scripted materials which extend the DirectX material. I had a look at the tutorial in the wiki here, and it works fine.
However, I haven’t figured out how to transfer the used UV Channel into the shader material.
Usually I setup a texture for the .fx file like this:
texture DiffuseMap : DiffuseMap
<
string UIName = “Diffuse:”;
int Texcoord = 0;
int MapChannel = 1;
>;
So, if I load the .fx file directly, I get a spinner where I can choose the UV’s. But, how do I do this for the scripted material?
Kjetil[/QUOTE]
We used scripted materials at one point, but then I made an effort to get rid of them and since then we had far less problems.
I can’t remember all the problems as its long ago, for one you could not drag and drop etc on the slots to load bitmaps. Also there may of been problems when updating the shaders that have new features - adding new constants?
I think they would of worked if our shaders didnt change, but they did frequently.
You also had to maintain the scripted materials, the script IDs and fx files alll together.
Sorry I cant offer only vague reasons, but I do remember it being a big weight lifted when we switched to not using scripted materials!
They were’nt worth it for the material looking more artist friendly.
I just remembered…
with the standard dx9 materials if you keep use the same sampler names and constants you can switch shaders which contain the same naming, just by loading the new shader from the top of the material. I think this is impossible with scripted materials, you would have to write a special scripts to convert between different shaders if you used scripted materials. Or you will loose your textures from the slots. This makes it easy for the artists to switch between shaders.
I think if shaders are missing it will default to the default.fx, so its worth putting a check in when you load a file in max it does a check for any materials in the scene that use default.fx and pop up a warning so the user doesnt save this file with lost shader info.