Home Coding, Scripting, Shaders

in 3ds max make Shader Graph file default or load it with maxscript

polycounter lvl 12
Offline / Send Message
Tosyk polycounter lvl 12

I want to have a default directx material with specific shader graph file in my 3ds max. How to do that?

With 3ds max 2016 I was trying to load sfx file via maxscript but couldn't find any information on how to access ShaderFX Editor. Also, I was trying to make a default my sfx shader graph file without any luck? I cracked my head already trying to do this. Please help me.

Replies

  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter

    I've not done this with max but there is a rudimentary shaderfx API for maya that might give you some clues about where to start. I forget who wrote it but It was definitely linked on tech-artists.org and I believe it was also on the shader fx website.

    with that you can create a shaderfx graph - in practice you'd probably want to extend it though

    it's not hard to load an hlsl file into a dx material in max so perhaps just exporting the shaderfx and loading the result would be a good alternative - that process is documented iirc (haven't done it in 10 years)

  • Tosyk
    Options
    Offline / Send Message
    Tosyk polycounter lvl 12

    Thanks for the reply, maybe I wasn't clear, I already have shader graph (actually it's from Maya, but it doesn't matter really) file and I can use it manually without any issue. What I need is to load this shader graph `sfx` file with maxscript OR make this shader graph default for my directx material.

  • PolyHertz
    Options
    Offline / Send Message
    PolyHertz polycount lvl 666

    Afaik the easiest way is to save the sfx material to a mat file and load that (via loadTempMaterialLibrary). Alternatively you could directly access the windows/buttons via HWND, but that's super hacky (might not work right across Max versions).

    To make it the default material applied to all new model primitives in the scene upon creation, make a callback function that runs any time a "sceneNodeAdded" is triggered. Save the function + callback as a ".ms" script and place it in Maxs scripts\startup folder.

  • Tosyk
    Options
    Offline / Send Message
    Tosyk polycounter lvl 12

    Thank you, I already have tried saveing sfx to mat file, that doesn't work - when I load such material it doesn't have sfx graph applied. As for the second suggestion, I want the graph to be default with directx material only and not with any material or any created object.

  • PolyHertz
    Options
    Offline / Send Message
    PolyHertz polycount lvl 666

    I tried loading a .mat file with a simple sfx material before posting that and it loaded fine. That was with Max 2022 though so there might be issues with older versions of Max...

  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter

    i just dug out a script i made on max2012 that loads a saved .mat (directx material with a .fx file loaded) - it worked as PolyHertz says.

Sign In or Register to comment.