patriciogonzalezvivo / comfyui_glslnodes

GLSL node for ComfyUI
GNU General Public License v3.0
183 stars 14 forks source link

Server down? #13

Closed nchenevey1 closed 2 months ago

nchenevey1 commented 2 months ago

Hello, Is the server down? I was unable to retrieve data from lygia.xyz which has led me to try using the nodes locally. To make this happen, I modified glsl_utils.py with the following code (modified from the python example listed in the readme). This should properly format the headers and dependencies. I'm not sure if this is the correct place to post this code, but I hope it helps anyone else facing the same issue. Edit: This code assumes the Lygia folder is in the comfyui_glslnodes directory

def resolveLygia(src: str):
    source = ""
    lines = src.split("\n")
    folder = "path/to/comfyui_glslnodes/" # Include the path to the nodes directory
    for line in lines:
        # resolve #include dependencies
        match = re.search(r'#include\s*["|<](.*.glsl)["|>]', line, re.IGNORECASE)
        if match:
            url = match.group(1)
            print("Adding dependecy", url)
            if url.startswith("lygia"):
                source += load_source(folder, url) + "\n"
            else:
                print("Non-lygia header: " + str(match.group(1)))
        else:
            source += line + "\n"

    return source

def load_source( folder: str, filename: str, dependencies = []):
    path = abspath( join(folder, filename) )

    if path in dependencies:
        return ""
    else:
        dependencies.append( path )

    source = ""

    lines = open( path ).readlines()
    for line in lines:
        if match := re.search(r'#include\s*["|<](.*.[glsl|hlsl|metal])["|>]' ,line, re.IGNORECASE):
            new_folder = join(dirname( path ), dirname( match.group(1) ))
            new_dep = basename( match.group(1) )
            source += load_source(new_folder, new_dep, dependencies) + "\n"
        else:
            source += line + "\n"
    return source
patriciogonzalezvivo commented 2 months ago

Server restored. Thank you!