Home Coding, Scripting, Shaders

[Solved][MAXSCRIPT] How to load .sfx?

polycounter lvl 16
Offline / Send Message
dimwalker polycounter lvl 16

Trying to load shaderfx .sfx file using maxscript, but max loads some sort of default instead. I can import my file manually from shaderfx editor so the .sfx file itself is not the problem it seems.

Doesn't work even when I read the file into variable and assign it to .shaderfxgraph. Heck, I copied the whole thing into listener(inside quotes) and assigned from there, still nothing.

Trying this

$.material = DirectX_9_Shader()
$.material.useshaderfx = 1
$.material.effectfile = "D:\sfx.sfx"

Then checking with showproperties $.material. I have two textures exposed in sfx so it's easy to tell if it worked or not.

What am I doing wrong here?

Replies

  • Klunk
    Offline / Send Message
    Klunk ngon master

    have you tried


    $.mat.effectFilename = "D:\sfx.sfx"

  • dimwalker
    Offline / Send Message
    dimwalker polycounter lvl 16

    Yes. It is getting same value when I assign .effectfile and I tried to manually set it to same value. I suspect it to be just a display name. Can set it to any string with no warnings or errors.

  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter

    don't you need to escape the path string ?


    I thought I had a script lying around for this but sadly can't find it

  • dimwalker
    Offline / Send Message
    dimwalker polycounter lvl 16

    You mean double-slashing everything? I had a problem with "D:xxx\txxx" producing a tab and placed file here since it's simplest path that should not give me any problems. How should path string look properly escaped?

    As an experiment I tried to load non-existing "D:\sfx222.sfx222" - max throws no errors and visually it works the same as with "D:\sfx.sfx" (material turns from grey to black) so maybe max just can't find the file and plays it cool hoping I won't notice.

  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter

    My Maxscript is super rusty but I believe these things are valid for paths


    "d:\\something"

    @"d:\something"

    "d:/something"

    I'm a forward slash person as a rule


    escaping in general works like this - hence the tab in your example above

    \t = tab

    \n = newline

    \\ = \


    in terms of it not working - are you getting anything in the listener about it failing? I remember this being a pain in the arse with shaderfx but honestly can't remember what I did to work around it.

  • dimwalker
    Offline / Send Message
    dimwalker polycounter lvl 16

    Escaping it didn't work 8(

    Listener only outputs path I fed it, no matter if it is existing file or just random letters.

    $.material.effectfile = "D:/sfx.sfx"
    "D:/sfx.sfx"
    

    What I've noticed is shaderfx editor "breaks" after that.

    For example, I just made new DX material and did $.material.effectfile = "D:/sfx.sfx" , my plane epoly became black. I open shaderfx editor and import sfx manually. Graph loads and looks fine, but has no effect, nodes I add or remove won't change anything visually and used exposed textures don't show up with showproperties $.material

    But if I assign new DirectX_9_Shader material and instead of setting .effectfile would copy shader's content to listener and use that to set .shaderfxgraph it behaves differently. Plane color doesn't change to black or any other. Textures still don't show up in properties, but if I open shaderfx editor (shows default graph) and mess around with nodes I can see changes in viewport.

  • dimwalker
    Offline / Send Message
    dimwalker polycounter lvl 16

    Colleague found a solution.

    In shaderfx editor you need to use "hwshader / save to disk" to save graph as .fx file which can be loaded by setting .effectfile

Sign In or Register to comment.