Merge multiple text files into 1 text file (not solved episode 4)


    Sep 11 2017 | 8:58 pm
    Hi everyone, Been banging my head for a while on how to do this and finally admit defeat. So I'm working with glsl shader files in the .jxs format So lets say i have 5 .jxs files
    Uniforms
    Header Library
    Engine Final I want them all to be combined into one file, one after the other which is then saved to disk as a Shader_bla_bla.jxs file. I only want to edit 1 file at a time (say engine), save it and then have the whole bunch recompiled. I also need nothing to change with the structure. It has to come out exactly the way it was. And and all tips welcome.

    • Sep 12 2017 | 12:54 am
      So I've been working pretty much all day, no joy still, almost there but the last problem I hit is that my GLSL functions in multiple text files use the word float a lot (hey it's glsl ;-) SO of course I've tried turning the output of the text file into strings, symbols,like everything ... Nothing works . Max freaks out if any object gets the word float in any way what so ever...
    • Sep 12 2017 | 12:55 am
      So an example glsl function where the word float gets dropped and max says its a bad message cause its the word float without an actual float. // Sign function that doesn't return 0 float sgn(float x) { return (x<0)?-1:1; }
    • Sep 12 2017 | 12:58 am
      So in Touch designer, they have a merge object, and it totally will never care what you throw into it. It adds it all together. Throws it out in one go. All formatting intact. Everything is hunky dory. Please tell me I'm missing this object or that cycling 74 will make it one day.
    • Sep 12 2017 | 12:51 pm
      Almost Solved. By the most counter intuitive method ever. Which is why it took the better part of 18 hours to solve what should be a super simple thing. Cycling 74. Give me that merge object, give us all that merge object. No one should have to do this workaround for GLSL text or other reserved keywords. C'mon we deserve it.... I'll send you beer if you do. Promise.
      Oh, the quick solution. you have text like: set float sgn (x){
      -- this is one line of output from the text object,it adds set, god knows why, can we have an option to turn that off ?? Max freaks out cause the word float is reserved.
      plug that into: substitute set " " -- yes this adds a space, the word set is gone, float gets through. Almost beer o'clock.
    • Sep 12 2017 | 3:59 pm
      i'd strongly recommend javascript for these kinds of tasks.
      you may be interested in checking out this project i started working a while back, and then stalled out on. it's basically a shader generator (which sounds like what you're making) for building a wireframe shader (using a geometry shader), based on certain user parameters.
      i store snippets of glsl in a JSON file, and then make basic templates of each shader program to start from. i found a very basic string template replacement code and make use of that to substitute the template variables with the appropriate JSON code, based on the parameter state.
      anyways, one of these days i need to resurrect and release this, but maybe you'll find some inspiration for what you're working on: https://github.com/robtherich/jitter-packages/tree/master/gl.wireframe
    • Sep 12 2017 | 6:08 pm
      Hi Rob, thanks for that, I'll check it out. To be honest though still got the same problems with the Javascript documentation being very spotty so I kind of dropped it for now. I do have a nice system working now where i can just give a folder and the user just has to make sure they're labelled in descending order like : 01-header 02-Library etc etc.. So that all gos great and its a pretty small patch, the only thing I'm stuck on now is that if send this to the text object: write "D:/Max 7 projects/Oculus VR patches/rayMarcherStitched.jxs"
      then the file is there with the correct name and extension but empty. So yeah a shader stitcher with no Javascript is almost done.
    • Sep 12 2017 | 6:53 pm
      Just figured out that the XML parser can't work because the text object can load a file with quotation marks BUT removes them on output. This is really getting pretty sad to just add a few text files together with formatting intact.
    • Sep 14 2017 | 11:43 am
      So Rick pointed out that I have to put a \ in front of every quotation mark in the source material (the XML header in this case) . It works but I did want to keep the solution in the patch so the user only had to point to the folder with the files. Final patch coming soon.
    • Sep 14 2017 | 1:19 pm
      And the next problem is this semicolon ; It now gets removed.... So with this line vec2 res = vec2(320.,240.) ; it comes out vec2 res = vec2(320.,240.)
      Anybody got a fix ?