Notifications
Clear all

[Closed] Maxscript access to DirectX Shader properties

Hi everyone,

This is my first post on these forums, but I’ve been following a lot of threads over the whole forum already. Let me introduce myself a little bit before asking my questions (feel free to skip this part :P). I’m a C# programmer who’s looking into max for a bit. I’m still in the learning process of Maxscript, but it’s not so different from other languages i think. Anyway, my question:

I’m writing a script to export my designed level from 3ds max to be used with the 3D engine i’m using. I’m exporting all geometry as custom formats, that’s no problem, but now i’ve come to a fairly new part. I’m trying to export the settings of the directX shaders that i’m using (HLSL shaders). So lets say there’s a box in my scene, it has a directX shader material on it. How would i go about processing the data ? I mean, when it has a couple variables that you’d expect, it’s not a big deal, but when i’m creating new shaders, i still want to be able to save the settings. For example a simple float with a non default name, lets say ZaPP. How would i get the value from the material? I know i can call $.material.ZaPP, but that’s not what i want. I want to be able to get the 2nd property of the shader, and it’s name. Is this possible in Maxscript?

Thanks in advantage,

Greetings,
ZaPP

2 Replies

I’m not exactly sure what you want to do. You can see a shader’s properties with “showproperties <the material>”. I’m not sure what “I want to be able to get the 2nd property of the shader, and it’s name.” means. Maybe look at Class and Object Inspector Functions in help. I’ve done extensive work with scripting DX shaders, and the only unusual thing has been with textures, which are easy to figure out as well.

Yea i figured out the textures already, it’s working pretty good, i’m new to the whole scripting thing, but it’s even easier than normal coding because you can just evaluate seperate lines.

What I mean by the second property is this: Imagine a DX shader. The shader has a lot of variables, like a couple textures, diffuse, ambient and specular color and power etc. Sometimes i need some other variables as well, like the amount of bumpiness, the amount of parallax etc. The name of this variable will be dynamic.
This means that if i want to make a general script to export, I’ll now have to include all the possible names of those variables.
That’s not an option to me, i’d like to be able to apply a directX shader to a mesh without having to worry about the name of the variable in the HLSL code or anywhere else. I’d like to be able to export all variables (as shown in the UI) to a file without knowing the variable’s name. Is this possible? I know showproperties works, but that doesn’t give me a lits with properties, it’ll just print them in the listener right?

Thanks for the reponse

Greetings,
ZaPP

EDIT:
After a lot of fiddling around and watching the maxscript help files, i found my solution. It’s really easy, I needed:
abc = getPropNames $meshtobeexported.material
for i = 1 to abc.count do
(
prop = getProperty $meshtobeexported.material abc[i]
)