-
Notifications
You must be signed in to change notification settings - Fork 13
/
glsl_uniforms.py
55 lines (44 loc) · 1.92 KB
/
glsl_uniforms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from .glsl_context import Context
import comfy.utils
class GlslUniforms:
@classmethod
def INPUT_TYPES(cls):
return {
"optional": {
# TODO: add support for vertex shader and 3D models
# "vertex_shader": ("STRING"),
# "3D_model": ("3D_MODEL", { "default": None }),
"u_tex0": ("IMAGE", { "multi": True }),
"u_tex1": ("IMAGE", { "multi": True }),
"u_tex2": ("IMAGE", { "multi": True }),
"u_tex3": ("IMAGE", { "multi": True }),
"u_val0": ("*", { "multi": True }),
"u_val1": ("*", { "multi": True }),
"u_val2": ("*", { "multi": True }),
"u_val3": ("*", { "multi": True }),
}
}
CATEGORY = "GLSL"
FUNCTION = "main"
RETURN_TYPES = ("GLSL_CONTEXT",)
RETURN_NAMES = ("uniforms",)
# DESCRIPTION = """
# This node caches and optimizes inputs for GlslViewer.
# And you can connect different inputs like Images (Textures), Videos(Texture Arrays), or individual values (int, float, vec2, vec3, vec4).
# If you are working with videos or sequences of images, we recomend using glslUniforms node, so it's better cached and optimized, buy preventing changing loading all the frames everytime you edit your code.
# """
def main(self, **kwargs):
context = Context()
index = 0
total = len(kwargs.items())
pbar = comfy.utils.ProgressBar( total )
for key, value in kwargs.items():
# Update Progress Bar
if comfy.utils.PROGRESS_BAR_ENABLED:
pbar.update_absolute(index + 1, total)
if key.startswith("u_tex"):
context.loadTexture(key, value)
elif key.startswith("u_val"):
context.setUniform(key, value)
index += 1
return (context, )