patriciogonzalezvivo / comfyui_glslnodes

GLSL node for ComfyUI
GNU General Public License v3.0
162 stars 11 forks source link

Error running this node "!!! Exception during processing!!! GLSL Compiler failed" #6

Closed Niutonian closed 1 month ago

Niutonian commented 1 month ago

Hello, I've been trying to run your node, but I get this error

!!! Exception during processing!!! GLSL Compiler failed

fragment_shader
===============
0(14) : error C1503: undefined variable "uv"

Traceback (most recent call last):
  File "E:\COMFYUI\ComfyUI_windows_portable12_1\ComfyUI\execution.py", line 151, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\COMFYUI\ComfyUI_windows_portable12_1\ComfyUI\execution.py", line 81, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\COMFYUI\ComfyUI_windows_portable12_1\ComfyUI\execution.py", line 74, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\COMFYUI\ComfyUI_windows_portable12_1\ComfyUI\custom_nodes\comfyui_glslnodes\node.py", line 146, in main
    prog = ctx.program( vertex_shader= getDefaultVertexShader(fragment_code["version"]),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\COMFYUI\ComfyUI_windows_portable12_1\python_embeded\Lib\site-packages\moderngl\__init__.py", line 1707, in program
    res.mglo, _members, res._subroutines, res._geom, res._glo = self.mglo.program(
                                                                ^^^^^^^^^^^^^^^^^^
_moderngl.Error: GLSL Compiler failed

Screenshot 2024-07-16 212606

Screenshot 2024-07-16 212521

patriciogonzalezvivo commented 1 month ago

I push a fix for that issue recently. Please update the node.

Other wise you can change the line

color = vec4(uv, sin(u_time) * 0.5 + 0.5, 1.0);

for

color = vec4(st, sin(u_time) * 0.5 + 0.5, 1.0);
Niutonian commented 1 month ago

ok, it works now, but other codes do not, I'm sorry, I'm really new at GLSL so I have no clue what the results should look like. Do you have a website you could recomend to get started?

Niutonian commented 1 month ago

one last questiom, this code outputs a black square, do you know why?

uniform vec2    u_resolution;

varying vec4    v_position;
varying vec3    v_normal;

void main(void) {
    vec4 color = vec4(0.0, 0.0, 0.0, 1.0);
    vec2 pixel = 1.0/u_resolution;
    vec2 st = gl_FragCoord.xy * pixel;

    #if defined(BACKGROUND)

    // Draw a ciruclar gradient background
    float dist = distance(st, vec2(0.5));
    color.rgb += 1.0-dist;

    #else

    // Basic diffuse shading from directional light
    vec3 N = normalize(v_normal);
    vec3 L = vec3(1.0, 1.0, 0.0);
    vec3 Ld = normalize(L - v_position.xyz);
    color.rgb += dot(N, Ld) * 0.5 + 0.5;

    #endif

    gl_FragColor = color;
}
patriciogonzalezvivo commented 1 month ago

Hi @Niutonian That example utilize vertex shaders and have a some #defines that only works on GlslViewer that loads models. Also depending the version number gl_FragColor is deprecated.

I recomend you to start by reading The Book of Shaders The examples there should work on the editor. (probably you need to change gl_FragColor for fragColor + adding out vec4 fragColor; at the top)